diff --git a/CHANGES b/CHANGES index 9c60620eb06..948ea84979e 100644 --- a/CHANGES +++ b/CHANGES @@ -31,6 +31,7 @@ Bugs fixed * #7301: capital characters are not allowed for node_id * #7301: epub: duplicated node_ids are generated * #6564: html: a width of table was ignored on HTML builder +* #7355: autodoc: a signature of cython-function is not recognized well Testing -------- diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index 7b6b3e4aae5..041ebc20b56 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -1019,6 +1019,7 @@ def format_args(self, **kwargs: Any) -> str: if (not inspect.isfunction(self.object) and not inspect.ismethod(self.object) and not inspect.isbuiltin(self.object) and + not inspect.is_cython_function_or_method(self.object) and not inspect.isclass(self.object) and hasattr(self.object, '__call__')): self.env.app.emit('autodoc-before-process-signature', diff --git a/tests/roots/test-ext-autodoc/target/cython.pyx b/tests/roots/test-ext-autodoc/target/cython.pyx index 1457db3c9cf..31ef33c2986 100644 --- a/tests/roots/test-ext-autodoc/target/cython.pyx +++ b/tests/roots/test-ext-autodoc/target/cython.pyx @@ -1,6 +1,6 @@ # cython: binding=True -def foo(*args, **kwargs): +def foo(x: int, *args, y: str, **kwargs): """Docstring.""" diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index 741c4bb60b4..fc56a7f7237 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -1641,7 +1641,7 @@ def test_cython(): ' Docstring.', '', '', - '.. py:function:: foo(*args, **kwargs)', + '.. py:function:: foo(x: int, *args, y: str, **kwargs)', ' :module: target.cython', '', ' Docstring.',