sphinx
sphinx copied to clipboard
Add support for singledispatchmethod class methods in MethodDocumenter
Fix #11278. Fix #11531.
Details:
- Add
:classmethod:directive option for@classmethodcombined with@singledispatchmethod. - Add tests.
~~There is some decision making to doc for this feature concerning the compatibility for Python versions up to 3.9 (excluded), so I want to get some feedback before merging.~~
~~Prior to Python 3.9~~
Legacy comment
If a method is decorated with @singledispatchmethod and @classmethod, the MethodDocumenter miserably fails to extract the correct signature or docstring. However, in order to properly extract the signature or the docstring, this would require a lot of changes in the sphinx.util.inspect or sphinx.ext.autodoc module which may break other things.
Therefore, I think it would be better to say "autodocumenting a singledispatched classmethod works assuming that Sphinx is running Python 3.9 or later".
Since we are dropping 3.8 support, I'll clean this PR when I've got time.
I wanted to rename some branch but it closed the PR. So I'll stick with an old name.
I've had this PR for a long time and nothing has ever changed, so let's merge this one now.