diff --git a/setup.py b/setup.py index aa4d2c216..13e70690e 100644 --- a/setup.py +++ b/setup.py @@ -178,7 +178,7 @@ setup( 'console_scripts': [ 'sphinx-build = sphinx:main', 'sphinx-quickstart = sphinx.quickstart:main', - 'sphinx-autogen = sphinx.scripts.autosummary_generate:main', + 'sphinx-autogen = sphinx.ext.autosummary.generate:main', ], 'distutils.commands': [ 'build_sphinx = sphinx.setup_command:BuildDoc', diff --git a/sphinx/ext/autosummary/LICENSE.txt b/sphinx/ext/autosummary/LICENSE.txt index 035a2095b..da27afd4c 100644 --- a/sphinx/ext/autosummary/LICENSE.txt +++ b/sphinx/ext/autosummary/LICENSE.txt @@ -2,7 +2,8 @@ - __init__.py - docscrape.py - doscrape-sphinx.py - - ../scripts/autosummary_generate.py + - generate.py + - templates/module.html have the following license: diff --git a/sphinx/scripts/autosummary_generate.py b/sphinx/ext/autosummary/generate.py old mode 100755 new mode 100644 similarity index 91% rename from sphinx/scripts/autosummary_generate.py rename to sphinx/ext/autosummary/generate.py index acab57d36..ce9e4c2d8 --- a/sphinx/scripts/autosummary_generate.py +++ b/sphinx/ext/autosummary/generate.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -r""" +""" autosummary_generate.py OPTIONS FILES Generate automatic RST source files for items referred to in @@ -11,30 +10,29 @@ extracts the docstring of the referred item. Example Makefile rule:: generate: - ./ext/autosummary_generate.py -o source/generated source/*.rst + sphinx-autogen source/*.rst source/generated """ import glob, re, inspect, os, optparse from sphinx.ext.autosummary import import_by_name from jinja import Environment, PackageLoader -env = Environment(loader=PackageLoader('numpyext', 'templates')) +env = Environment(loader=PackageLoader('sphinx.ext.autosummary', 'templates')) def main(): p = optparse.OptionParser(__doc__.strip()) - p.add_option("-o", "--output-dir", action="store", type="string", - dest="output_dir", default=None, - help=("Write all output files to the given directory (instead " - "of writing them as specified in the autosummary:: " - "directives)")) options, args = p.parse_args() - - if len(args) == 0: + + if len(args) <2: p.error("wrong number of arguments") + print 'generating docs from:', args[:-1] + generate_autosummary_docs(args[:-1], args[-1]) + +def generate_autosummary_docs(source_dir, output_dir): # read names = {} - for name, loc in get_documented(args).items(): + for name, loc in get_documented(source_dir).items(): for (filename, sec_title, keyword, toctree) in loc: if toctree is not None: path = os.path.join(os.path.dirname(filename), toctree) @@ -42,8 +40,7 @@ def main(): # write for name, path in sorted(names.items()): - if options.output_dir is not None: - path = options.output_dir + path = output_dir if not os.path.isdir(path): os.makedirs(path) diff --git a/sphinx/templates/autosummary-module.html b/sphinx/ext/autosummary/templates/module.html similarity index 100% rename from sphinx/templates/autosummary-module.html rename to sphinx/ext/autosummary/templates/module.html diff --git a/sphinx/scripts/__init__.py b/sphinx/scripts/__init__.py deleted file mode 100644 index e69de29bb..000000000