mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Close #4257: autodoc: Add autodoc_class_signature
Add `autodoc_class_signature` to separate the class entry and the definition of `__init__()` method.
This commit is contained in:
@@ -140,6 +140,57 @@ def test_autoclass_content_init(app):
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_class_signature_mixed(app):
|
||||
app.config.autodoc_class_signature = 'mixed'
|
||||
options = {"members": None,
|
||||
"undoc-members": None}
|
||||
actual = do_autodoc(app, 'class', 'target.classes.Bar', options)
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:class:: Bar(x, y)',
|
||||
' :module: target.classes',
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_class_signature_separated_init(app):
|
||||
app.config.autodoc_class_signature = 'separated'
|
||||
options = {"members": None,
|
||||
"undoc-members": None}
|
||||
actual = do_autodoc(app, 'class', 'target.classes.Bar', options)
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:class:: Bar',
|
||||
' :module: target.classes',
|
||||
'',
|
||||
'',
|
||||
' .. py:method:: Bar.__init__(x, y)',
|
||||
' :module: target.classes',
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_class_signature_separated_new(app):
|
||||
app.config.autodoc_class_signature = 'separated'
|
||||
options = {"members": None,
|
||||
"undoc-members": None}
|
||||
actual = do_autodoc(app, 'class', 'target.classes.Baz', options)
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:class:: Baz',
|
||||
' :module: target.classes',
|
||||
'',
|
||||
'',
|
||||
' .. py:method:: Baz.__new__(cls, x, y)',
|
||||
' :module: target.classes',
|
||||
' :staticmethod:',
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoclass_content_both(app):
|
||||
app.config.autoclass_content = 'both'
|
||||
|
||||
Reference in New Issue
Block a user