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

Merged
merged 2 commits into from
Jan 28, 2025

Conversation

jfmontanaro
Copy link
Contributor

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
@JaagupAverin
Copy link
Contributor

+1 on getting this rebased and merged soon :)

@mikayla-maki
Copy link
Contributor

I think the questions here are similar to the ones in: #21454

@zed-industries-bot

This comment was marked as off-topic.

@osiewicz
Copy link
Contributor

osiewicz commented Jan 8, 2025

Let's just roll with the current capture groups; we can always refine them later if needed.

@osiewicz osiewicz merged commit bb59e7f into zed-industries:main Jan 28, 2025
13 checks passed
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.

5 participants