mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #6083 from tk0miya/6047_autofunction_warns_for_methods
Fix #6047: autodoc: ``autofunction`` emits a warning for method objects
This commit is contained in:
commit
836d65f04c
1
CHANGES
1
CHANGES
@ -20,6 +20,7 @@ Bugs fixed
|
|||||||
* #6026: LaTeX: A cross reference to definition list does not work
|
* #6026: LaTeX: A cross reference to definition list does not work
|
||||||
* #6046: LaTeX: ``TypeError`` is raised when invalid latex_elements given
|
* #6046: LaTeX: ``TypeError`` is raised when invalid latex_elements given
|
||||||
* #6019: imgconverter: Including multipage PDF fails
|
* #6019: imgconverter: Including multipage PDF fails
|
||||||
|
* #6047: autodoc: ``autofunction`` emits a warning for method objects
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -1056,6 +1056,7 @@ class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # typ
|
|||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
if (not isfunction(self.object) and
|
if (not isfunction(self.object) and
|
||||||
|
not inspect.ismethod(self.object) and
|
||||||
not isbuiltin(self.object) and
|
not isbuiltin(self.object) and
|
||||||
not inspect.isclass(self.object) and
|
not inspect.isclass(self.object) and
|
||||||
hasattr(self.object, '__call__')):
|
hasattr(self.object, '__call__')):
|
||||||
|
@ -4,5 +4,10 @@ class Callable():
|
|||||||
def __call__(self, arg1, arg2, **kwargs):
|
def __call__(self, arg1, arg2, **kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def method(self, arg1, arg2):
|
||||||
|
"""docstring of Callable.method()."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
function = Callable()
|
function = Callable()
|
||||||
|
method = function.method
|
||||||
|
@ -1359,6 +1359,19 @@ def test_autofunction_for_callable(app):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
|
def test_autofunction_for_method(app):
|
||||||
|
actual = do_autodoc(app, 'function', 'target.callable.method')
|
||||||
|
assert list(actual) == [
|
||||||
|
'',
|
||||||
|
'.. py:function:: method(arg1, arg2)',
|
||||||
|
' :module: target.callable',
|
||||||
|
'',
|
||||||
|
' docstring of Callable.method().',
|
||||||
|
' '
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx('html', testroot='root')
|
@pytest.mark.sphinx('html', testroot='root')
|
||||||
def test_mocked_module_imports(app):
|
def test_mocked_module_imports(app):
|
||||||
options = {"members": 'TestAutodoc,decoratedFunction'}
|
options = {"members": 'TestAutodoc,decoratedFunction'}
|
||||||
|
Loading…
Reference in New Issue
Block a user