mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
refs #2336: Add `imported_members option to sphinx-autogen` command to document imported members.
This commit is contained in:
@@ -13,6 +13,8 @@ Features added
|
||||
--------------
|
||||
|
||||
* #3136: Add ``:name:`` option to the directives in ``sphinx.ext.graphviz``
|
||||
* #2336: Add ``imported_members`` option to ``sphinx-autogen`` command to document
|
||||
imported members.
|
||||
|
||||
Bugs fixed
|
||||
----------
|
||||
|
||||
@@ -70,6 +70,9 @@ def main(argv=sys.argv):
|
||||
p.add_option("-t", "--templates", action="store", type="string",
|
||||
dest="templates", default=None,
|
||||
help="Custom template directory (default: %default)")
|
||||
p.add_option("-i", "--imported-members", action="store_true",
|
||||
dest="imported_members", default=False,
|
||||
help="Document imported members (default: %default)")
|
||||
options, args = p.parse_args(argv[1:])
|
||||
|
||||
if len(args) < 1:
|
||||
@@ -77,7 +80,8 @@ def main(argv=sys.argv):
|
||||
|
||||
generate_autosummary_docs(args, options.output_dir,
|
||||
"." + options.suffix,
|
||||
template_dir=options.templates)
|
||||
template_dir=options.templates,
|
||||
imported_members=options.imported_members)
|
||||
|
||||
|
||||
def _simple_info(msg):
|
||||
@@ -94,8 +98,9 @@ def _simple_warn(msg):
|
||||
|
||||
def generate_autosummary_docs(sources, output_dir=None, suffix='.rst',
|
||||
warn=_simple_warn, info=_simple_info,
|
||||
base_path=None, builder=None, template_dir=None):
|
||||
# type: (List[unicode], unicode, unicode, Callable, Callable, unicode, Builder, unicode) -> None # NOQA
|
||||
base_path=None, builder=None, template_dir=None,
|
||||
imported_members=False):
|
||||
# type: (List[unicode], unicode, unicode, Callable, Callable, unicode, Builder, unicode, bool) -> None # NOQA
|
||||
|
||||
showed_sources = list(sorted(sources))
|
||||
if len(showed_sources) > 20:
|
||||
@@ -186,17 +191,17 @@ def generate_autosummary_docs(sources, output_dir=None, suffix='.rst',
|
||||
if doc.objtype == 'module':
|
||||
ns['members'] = dir(obj)
|
||||
ns['functions'], ns['all_functions'] = \
|
||||
get_members(obj, 'function')
|
||||
get_members(obj, 'function', imported=imported_members)
|
||||
ns['classes'], ns['all_classes'] = \
|
||||
get_members(obj, 'class')
|
||||
get_members(obj, 'class', imported=imported_members)
|
||||
ns['exceptions'], ns['all_exceptions'] = \
|
||||
get_members(obj, 'exception')
|
||||
get_members(obj, 'exception', imported=imported_members)
|
||||
elif doc.objtype == 'class':
|
||||
ns['members'] = dir(obj)
|
||||
ns['methods'], ns['all_methods'] = \
|
||||
get_members(obj, 'method', ['__init__'])
|
||||
get_members(obj, 'method', ['__init__'], imported=imported_members)
|
||||
ns['attributes'], ns['all_attributes'] = \
|
||||
get_members(obj, 'attribute')
|
||||
get_members(obj, 'attribute', imported=imported_members)
|
||||
|
||||
parts = name.split('.')
|
||||
if doc.objtype in ('method', 'attribute'):
|
||||
|
||||
Reference in New Issue
Block a user