Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed singledispatch documentation #10285

Merged
merged 5 commits into from Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions sphinx/ext/autodoc/__init__.py
Expand Up @@ -1399,8 +1399,8 @@ def dummy():
except (AttributeError, TypeError):
# failed to update signature (ex. built-in or extension types)
return None
else:
return None

return func


class DecoratorDocumenter(FunctionDocumenter):
Expand Down Expand Up @@ -2281,8 +2281,8 @@ def dummy():
except (AttributeError, TypeError):
# failed to update signature (ex. built-in or extension types)
return None
else:
return None

return func

def get_doc(self, ignore: int = None) -> Optional[List[List[str]]]:
if self._new_docstrings is not None:
Expand Down
8 changes: 8 additions & 0 deletions tests/roots/test-ext-autodoc/target/singledispatch.py
Expand Up @@ -26,3 +26,11 @@ def _func_int(arg, kwarg=None):
def _func_str(arg, kwarg=None):
"""A function for str."""
pass


@func.register
def _func_dict(arg: dict, kwarg=None):
"""A function for dict."""
# This function tests for specifying type through annotations
pass

6 changes: 6 additions & 0 deletions tests/roots/test-ext-autodoc/target/singledispatchmethod.py
Expand Up @@ -19,3 +19,9 @@ def _meth_int(self, arg, kwarg=None):
def _meth_str(self, arg, kwarg=None):
"""A method for str."""
pass

@meth.register
def _meth_dict(self, arg: dict, kwarg=None):
"""A method for dict."""
# This function tests for specifying type through annotations
pass
3 changes: 3 additions & 0 deletions tests/test_ext_autodoc.py
Expand Up @@ -2073,6 +2073,7 @@ def test_singledispatch(app):
' func(arg: float, kwarg=None)',
' func(arg: int, kwarg=None)',
' func(arg: str, kwarg=None)',
' func(arg: dict, kwarg=None)',
' :module: target.singledispatch',
'',
' A function for general use.',
Expand Down Expand Up @@ -2101,6 +2102,7 @@ def test_singledispatchmethod(app):
' Foo.meth(arg: float, kwarg=None)',
' Foo.meth(arg: int, kwarg=None)',
' Foo.meth(arg: str, kwarg=None)',
' Foo.meth(arg: dict, kwarg=None)',
' :module: target.singledispatchmethod',
'',
' A method for general use.',
Expand All @@ -2120,6 +2122,7 @@ def test_singledispatchmethod_automethod(app):
' Foo.meth(arg: float, kwarg=None)',
' Foo.meth(arg: int, kwarg=None)',
' Foo.meth(arg: str, kwarg=None)',
' Foo.meth(arg: dict, kwarg=None)',
' :module: target.singledispatchmethod',
'',
' A method for general use.',
Expand Down