def main(argv=sys.argv):
# type: (List[str]) -> int
"""Parse and check the command line arguments."""
parser = optparse.OptionParser(
usage="""\
usage: %prog [options] -o <output_path> <module_path> [exclude_pattern, ...]
Look recursively in <module_path> for Python modules and packages and create
one reST file with automodule directives per package in the <output_path>.
The <exclude_pattern>s can be file and/or directory patterns that will be
excluded from generation.
Note: By default this script will not overwrite already created files.""")
parser.add_option('-o', '--output-dir', action='store', dest='destdir',
help='Directory to place all output', default='api')
parser.add_option('-s', '--source-dir', action='store', dest='srcdir',
help='Documentation source directory', default=BASEDIR)
parser.add_option('-n', '--docname', action='store', dest='docname',
help='Index document name', default='api')
parser.add_option('-l', '--follow-links', action='store_true',
dest='followlinks', default=False,
help='Follow symbolic links. Powerful when combined '
'with collective.recipe.omelette.')
parser.add_option('-P', '--private', action='store_true',
dest='includeprivate',
help='Include "_private" modules')
parser.add_option('--implicit-namespaces', action='store_true',
dest='implicit_namespaces',
help='Interpret module paths according to PEP-0420 '
'implicit namespaces specification')
parser.add_option('--version', action='store_true', dest='show_version',
help='Show version information and exit')
parser.add_option('--clean', action='store_true', dest='cleanup',
help='Clean up generated files and exit')
group = parser.add_option_group('Extension options')
for ext in EXTENSIONS:
group.add_option('--ext-' + ext, action='store_true',
dest='ext_' + ext, default=False,
help='enable %s extension' % ext)
(opts, args) = parser.parse_args(argv[1:])
# Make this more explicitly the current directory.
if not opts.srcdir:
opts.srcdir = '.'
if opts.show_version:
print('Sphinx (sphinx-apidoc) %s' % __display_version__)
return 0
if opts.cleanup:
print("Removing generated API docs from '{}'...".format(opts.srcdir))
return cleanup_api_docs(opts)
if not args:
parser.error('A package path is required.')
opts.rootpath, opts.excludes = args[0], args[1:]
return generate_api_docs(opts)
评论列表
文章目录