Repository navigation
Render only class docstrings; test constructors have none - #2221
Open
bernardhaddad wants to merge 1 commit into
Open
bernardhaddad wants to merge 1 commit into
bernardhaddad wants to merge 1 commit into
Conversation
Contributes to PyCalendar#1620. Set autoclass_content to "class", so the API reference shows the class docstring only. The pages for AdrFields, NFields and Alarm.Triggers lose the "Create new instance of ..." text that Python generates for a NamedTuple's __new__. Add test_no_init_docstrings.py: it walks every icalendar module and fails if a class's own __init__ or __new__ has a docstring. Constructors that Python generates (NamedTuple) are skipped, because their code is not in the class's module. Update the style guide to describe the new setup. AI use: Claude Opus 5.5 in Claude Code. Prompt (summary): find an open beginner issue in icalendar and prepare a pull request for it. Claude checked that no __init__ or __new__ docstrings remain in src/, wrote the test and checked that it fails when a docstring is added to vText.__new__, changed the Sphinx setting, updated the style guide, built the docs before and after the change to compare warnings and rendered pages, and ran the test suite and ruff. Output: this commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bernardhaddad
requested review from
niccokunzmann and
stevepiercy
as code owners
December 5, 2026 11:09
stevepiercy
requested changes
Dec 5, 2026
stevepiercy
left a comment
Member
There was a problem hiding this comment.
Thank you for your contribution. Just a minor tweak to the docs, and I'll approve.
I didn't realize we had completed migration of all docstrings from all the class's __init__ and __new__ methods, which the tests confirm. Nice work!
| Sphinx will automatically append the ``__init__`` or ``__new__`` docstrings to the class's docstring, which may render the documentation in a confusing manner to the reader. | ||
|
|
||
| If you find docstrings in a class's ``__init__`` or ``__new__`` methods, then please create a pull request that moves and merges their content into the class's docstring, leaving their docstrings empty. | ||
| Sphinx renders only the class's docstring, so it won't show a docstring written for ``__init__`` or ``__new__``. |
Member
There was a problem hiding this comment.
Suggested change
| Sphinx renders only the class's docstring, so it won't show a docstring written for ``__init__`` or ``__new__``. | |
| Sphinx is configured to render only the class's docstring. | |
| It won't render a docstring written for ``__init__`` or ``__new__``. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue
__init__or__new__docstrings into their class's docstring #1620Description
The API reference showed "Create new instance of ..." text that Python generates for NamedTuple constructors. Sphinx now renders only the class docstring, a new test fails if any
__init__or__new__gets its own docstring, and the style guide says so.The vague
binary.pydocstring item from the issue is not part of this PR.Checklist
Additional information
This description was drafted with Claude Code, like the change itself (disclosed in the commit message and change log entry). I reviewed it and I'm happy to make any changes you ask for.