mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix: autodoc class __init__ override not removed from docstring. Closes #1138
This commit is contained in:
@@ -301,6 +301,39 @@ def test_get_doc():
|
||||
assert getdocl('class', D) == ['Class docstring', '', 'Init docstring',
|
||||
'', 'Other', ' lines']
|
||||
|
||||
#__init__ have signature at first line of docstring
|
||||
class E:
|
||||
"""Class docstring"""
|
||||
def __init__(self, *args, **kw):
|
||||
"""
|
||||
__init__(a1, a2, kw1=True, kw2=False)
|
||||
|
||||
Init docstring
|
||||
"""
|
||||
|
||||
# signature line in the docstring will be kept when
|
||||
# autodoc_docstring_signature == False
|
||||
directive.env.config.autodoc_docstring_signature = False
|
||||
directive.env.config.autoclass_content = 'class'
|
||||
assert getdocl('class', E) == ['Class docstring']
|
||||
directive.env.config.autoclass_content = 'init'
|
||||
assert getdocl('class', E) == ['__init__(a1, a2, kw1=True, kw2=False)',
|
||||
'', 'Init docstring']
|
||||
directive.env.config.autoclass_content = 'both'
|
||||
assert getdocl('class', E) == ['Class docstring', '',
|
||||
'__init__(a1, a2, kw1=True, kw2=False)',
|
||||
'', 'Init docstring']
|
||||
|
||||
# signature line in the docstring will be removed when
|
||||
# autodoc_docstring_signature == True
|
||||
directive.env.config.autodoc_docstring_signature = True #default
|
||||
directive.env.config.autoclass_content = 'class'
|
||||
assert getdocl('class', E) == ['Class docstring']
|
||||
directive.env.config.autoclass_content = 'init'
|
||||
assert getdocl('class', E) == ['Init docstring']
|
||||
directive.env.config.autoclass_content = 'both'
|
||||
assert getdocl('class', E) == ['Class docstring', '', 'Init docstring']
|
||||
|
||||
|
||||
@with_setup(setup_test)
|
||||
def test_docstring_processing():
|
||||
|
||||
Reference in New Issue
Block a user