sphinx-doc / sphinx-doc/sphinx
[FEATURE] "Bases: [...]" added by ClassDocumenter.add_directive_header must not be part of the directive header.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
When asked, the ClassDocumenter.add_directive_header adds a line Bases: [...] containing the parent classes. However, custom implementations are no longer allowed to put additional directive options since they will be considered part of the docstring and not part of the directive options block.
Additionally, since ClassDocumenter.add_directive_header does something before calling super().add_directive_header(), then a custom implementation must either reimplement the whole method or make it so that
fails and manually adds the bases at the very end. Both solutions are highly dependent on the implementation of ClassDocumenter.add_directive_header, but we should prevent this. I therefore suggest adding a separate hook in the ClassDocumenter that is entirely responsible for adding the "Bases: ..." after the directive header has been processed. For me, "Bases: [...]" must not be part of the directive header (at least, according to the docutils specifications).
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
Start in sphinx/ext/autodoc/init.py, especially ClassDocumenter.add_directive_header and the linked lines around 1656–1696. Trace how the directive header is assembled and how the Bases line is added; done means the Bases line is emitted after directive options are processed without requiring custom implementations to reimplement the method.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100