sphinx-doc / sphinx-doc/sphinx
Missing documentation of python class with decorators.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
When generating documentation for class with decorators, Sphinx recognizes the wrapped class as the wrapper function returned by the top decorator instead of the actual class being wrapped by decorators.
How to Reproduce
index.rst
.. automodule:: test_sphinx
:members:
:show-inheritance:
:undoc-members:
test_sphinx.py
def Singleton(class_):
"""A singleton decorator"""
instances = {}
def getinstance(*args, **kwargs):
if class_ not in instances:
instances[class_] = class_(*args, **kwargs)
return instances[class_]
return getinstance
@Singleton
class Foo:
"""An example class."""
def bar(self):
"""An example function."""
pass
Environment Information
Platform: Ubuntu 22.04;
Python version: 3.10.13 (GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-44).GCC: (GNU) 7.3.1 20180303 (Red Hat 7.3.1-5).)
Python implementation: CPython
Sphinx version: 5.3.0
Sphinx extensions
No response
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the index.rst directive and the decorated Foo class in test_sphinx.py under Python 3.10 and Sphinx 5.3.0. Compare the generated documentation with the wrapped class and its bar method, then identify the relevant autodoc behavior and add coverage for the expected class documentation. Done means the decorated class is documented as Foo rather than as the decorator's wrapper function.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100