diff --git a/sphinx/ext/autosummary/generate.py b/sphinx/ext/autosummary/generate.py index f02c50692..fce51924a 100644 --- a/sphinx/ext/autosummary/generate.py +++ b/sphinx/ext/autosummary/generate.py @@ -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'): diff --git a/tests/roots/test-ext-autosummary/autosummary_dummy_module.py b/tests/roots/test-ext-autosummary/autosummary_dummy_module.py index aa4aaa9f2..c76e73302 100644 --- a/tests/roots/test-ext-autosummary/autosummary_dummy_module.py +++ b/tests/roots/test-ext-autosummary/autosummary_dummy_module.py @@ -7,3 +7,7 @@ class Foo: def bar(self): pass + + @property + def baz(self): + pass diff --git a/tests/test_ext_autosummary.py b/tests/test_ext_autosummary.py index b59f0cbc8..5c7e7f844 100644 --- a/tests/test_ext_autosummary.py +++ b/tests/test_ext_autosummary.py @@ -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():