refactor: autodoc: class processors on autofunction is no longer needed

This commit is contained in:
Takeshi KOMIYA
2020-05-06 19:41:30 +09:00
parent 6ce265dc81
commit 24fe05f14f
5 changed files with 42 additions and 25 deletions

View File

@@ -0,0 +1,12 @@
class Foo:
pass
class Bar:
def __init__(self, x, y):
pass
class Baz:
def __new__(cls, x, y):
pass

View File

@@ -1164,6 +1164,33 @@ def test_descriptor_class(app):
]
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autofunction_for_classes(app):
actual = do_autodoc(app, 'function', 'target.classes.Foo')
assert list(actual) == [
'',
'.. py:function:: Foo()',
' :module: target.classes',
'',
]
actual = do_autodoc(app, 'function', 'target.classes.Bar')
assert list(actual) == [
'',
'.. py:function:: Bar(x, y)',
' :module: target.classes',
'',
]
actual = do_autodoc(app, 'function', 'target.classes.Baz')
assert list(actual) == [
'',
'.. py:function:: Baz(x, y)',
' :module: target.classes',
'',
]
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autofunction_for_callable(app):
actual = do_autodoc(app, 'function', 'target.callable.function')

View File

@@ -30,10 +30,10 @@ def test_signature():
inspect.signature('')
# builitin classes
with pytest.raises(TypeError):
with pytest.raises(ValueError):
inspect.signature(int)
with pytest.raises(TypeError):
with pytest.raises(ValueError):
inspect.signature(str)
# normal function