Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine syntax highlighting for Python docstrings #20898

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jfmontanaro
Copy link

Following up on #20763, this PR adds support for module- and class-level docstrings, adds "additional docstrings" as described in PEP 257, and fixes function-level docstrings so that only the first string literal in a function gets treated as a docstring.

One question that occurs to me is: Would it be good to capture attribute and additional docstrings differently from regular docstrings? E.g. @string.doc.attribute, @string.doc.additional? PEP 257 mentions that unlike regular docstrings, these docstrings are ignored by the interpreter (regular docstrings get added as the __doc__ property of the object they document), so I can see someone potentially wanting to style them a little differently.

Release notes:

  • Added Python syntax highlighting for class- and module-level docstrings, additional docstrings, and improved recognition of function-level docstrings.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Nov 20, 2024
* Add highlighting for module- and class-level docstrings
* Add highlighting for additional docstrings as described in PEP 257
* Remove highlighting for non-docstring string literals in functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant