Skip to content

Commit 4ed3431

Browse files
authored
Merge pull request #10 from Chilipp/instance_attr
Resolve bug in autosummary table for instance attributes
2 parents 23c30e4 + 95eaecf commit 4ed3431

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

autodocsumm/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,8 @@ def get_items_from_documenters(self, documenters):
617617
documenter.real_modname = documenter.get_real_modname()
618618
real_name = documenter.fullname
619619
display_name = documenter.object_name
620+
if display_name is None: # for instance attributes
621+
display_name = documenter.objpath[-1]
620622
if check_module and not documenter.check_module():
621623
continue
622624

tests/sphinx_supp/dummy.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ def __call__(self, a, b):
4242
class TestClass(object):
4343
"""Class test for autosummary"""
4444

45+
def __init__(self):
46+
#: This is an instance attribute
47+
self.instance_attribute = 1
48+
4549
def test_method(self):
4650
"""Test if the method is included"""
4751
pass

tests/test_autodocsumm.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ def test_module_with_title(self, app, status, warning):
7979
def test_class(self, app, status, warning):
8080
app.build()
8181
html = get_html(app, '/test_class.html')
82+
83+
self.assertIn('<span class="pre">instance_attribute</span>', html)
84+
8285
self.assertIn('<span class="pre">test_method</span>', html)
8386
self.assertIn('<span class="pre">test_attr</span>', html)
8487

0 commit comments

Comments
 (0)