mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#280: Autodoc can now document instance attributes assigned in `__init__` methods.
This commit is contained in:
@@ -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."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user