#280: Autodoc can now document instance attributes assigned in `__init__` methods.

This commit is contained in:
Georg Brandl
2010-01-03 13:59:30 +01:00
parent 268911eb47
commit 09147448d4
4 changed files with 92 additions and 15 deletions

View File

@@ -382,7 +382,10 @@ def test_generate():
('attribute', 'test_autodoc.Class.descr'),
('attribute', 'test_autodoc.Class.attr'),
('attribute', 'test_autodoc.Class.docattr'),
('attribute', 'test_autodoc.Class.udocattr')])
('attribute', 'test_autodoc.Class.udocattr'),
('attribute', 'test_autodoc.Class.inst_attr_comment'),
('attribute', 'test_autodoc.Class.inst_attr_string')
])
options.members = ALL
assert_processes(should, 'class', 'Class')
options.undoc_members = True
@@ -403,7 +406,7 @@ def test_generate():
assert_result_contains(' :platform: Platform', 'module', 'test_autodoc')
# test if __all__ is respected for modules
options.members = ALL
assert_result_contains('.. class:: Class', 'module', 'test_autodoc')
assert_result_contains('.. class:: Class(arg)', 'module', 'test_autodoc')
try:
assert_result_contains('.. exception:: CustomEx',
'module', 'test_autodoc')
@@ -499,6 +502,13 @@ class Class(Base):
udocattr = 'quux'
u"""should be documented as well - süß"""
def __init__(self, arg):
#: a documented instance attribute
self.inst_attr_comment = None
self.inst_attr_string = None
"""a documented instance attribute"""
class CustomDict(dict):
"""Docstring."""