mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
Closes #1148: autodoc: Add autodecorator directive for decorators
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
def deco1(func):
|
||||
"""docstring for deco1"""
|
||||
def wrapper():
|
||||
return func()
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
def deco2(condition, message):
|
||||
"""docstring for deco2"""
|
||||
def decorator(func):
|
||||
def wrapper():
|
||||
return func()
|
||||
|
||||
return wrapper
|
||||
return decorator
|
||||
@@ -602,6 +602,29 @@ def test_generate():
|
||||
'Class.meth', more_content=add_content)
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_decorator(app):
|
||||
actual = do_autodoc(app, 'decorator', 'target.decorator.deco1')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:decorator:: deco1',
|
||||
' :module: target.decorator',
|
||||
'',
|
||||
' docstring for deco1',
|
||||
' '
|
||||
]
|
||||
|
||||
actual = do_autodoc(app, 'decorator', 'target.decorator.deco2')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:decorator:: deco2(condition, message)',
|
||||
' :module: target.decorator',
|
||||
'',
|
||||
' docstring for deco2',
|
||||
' '
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_exception(app):
|
||||
actual = do_autodoc(app, 'exception', 'target.CustomEx')
|
||||
|
||||
Reference in New Issue
Block a user