Closes #1148: autodoc: Add autodecorator directive for decorators

This commit is contained in:
Takeshi KOMIYA
2019-02-15 02:14:38 +09:00
parent cd542fb2af
commit 686486498c
5 changed files with 61 additions and 1 deletions
@@ -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
+23
View File
@@ -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')