sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

Add support for singledispatchmethod class methods in MethodDocumenter

Open picnixz opened this issue 2 years ago • 2 comments

Fix #11278. Fix #11531.

Details:

  • Add :classmethod: directive option for @classmethod combined 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".

picnixz avatar Apr 03 '23 11:04 picnixz

Since we are dropping 3.8 support, I'll clean this PR when I've got time.

picnixz avatar Jul 27 '23 13:07 picnixz

I wanted to rename some branch but it closed the PR. So I'll stick with an old name.

picnixz avatar Aug 03 '23 09:08 picnixz

I've had this PR for a long time and nothing has ever changed, so let's merge this one now.

picnixz avatar Mar 14 '24 11:03 picnixz