mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
BUG: autosummary to list all class members
This commit is contained in:
parent
931148eadb
commit
098add17f6
@ -159,7 +159,7 @@ def generate_autosummary_docs(sources, output_dir=None, suffix='.rst',
|
||||
except TemplateNotFound:
|
||||
template = template_env.get_template('autosummary/base.rst')
|
||||
|
||||
def get_members(obj, typ, include_public=[], imported=False):
|
||||
def get_members(obj, typ, include_public=[], imported=True):
|
||||
# type: (Any, unicode, List[unicode], bool) -> Tuple[List[unicode], List[unicode]] # NOQA
|
||||
items = [] # type: List[unicode]
|
||||
for name in dir(obj):
|
||||
@ -169,9 +169,7 @@ def generate_autosummary_docs(sources, output_dir=None, suffix='.rst',
|
||||
continue
|
||||
documenter = get_documenter(value, obj)
|
||||
if documenter.objtype == typ:
|
||||
if typ == 'method':
|
||||
items.append(name)
|
||||
elif imported or getattr(value, '__module__', None) == obj.__name__:
|
||||
if imported or getattr(value, '__module__', None) == obj.__name__:
|
||||
# skip imported members if expected
|
||||
items.append(name)
|
||||
public = [x for x in items
|
||||
@ -191,9 +189,9 @@ def generate_autosummary_docs(sources, output_dir=None, suffix='.rst',
|
||||
elif doc.objtype == 'class':
|
||||
ns['members'] = dir(obj)
|
||||
ns['methods'], ns['all_methods'] = \
|
||||
get_members(obj, 'method', ['__init__'], imported=imported_members)
|
||||
get_members(obj, 'method', ['__init__'])
|
||||
ns['attributes'], ns['all_attributes'] = \
|
||||
get_members(obj, 'attribute', imported=imported_members)
|
||||
get_members(obj, 'attribute')
|
||||
|
||||
parts = name.split('.')
|
||||
if doc.objtype in ('method', 'attribute'):
|
||||
|
@ -7,3 +7,7 @@ class Foo:
|
||||
|
||||
def bar(self):
|
||||
pass
|
||||
|
||||
@property
|
||||
def baz(self):
|
||||
pass
|
||||
|
@ -145,6 +145,10 @@ def test_autosummary_generate(app, status, warning):
|
||||
' ~Foo.__init__\n'
|
||||
' ~Foo.bar\n'
|
||||
' \n' in Foo)
|
||||
assert (' .. autosummary::\n'
|
||||
' \n'
|
||||
' ~Foo.baz\n'
|
||||
' \n' in Foo)
|
||||
|
||||
|
||||
def test_import_by_name():
|
||||
|
Loading…
Reference in New Issue
Block a user