python: Highlight docstrings for classes and modules (#20486)
Release Notes: - Add `string.doc` python syntax highlighting to class and module-level docstrings. Previously, only docstrings inside python functions were labeled as `string.doc`, but docstrings can exist at the class or module level too. This adds the more specific string type for each of those. *Before*: <img width="288" alt="image" src="https://github.com/user-attachments/assets/5a6c4c9d-709c-40e2-8316-31c95084a1a9"> *After*: <img width="294" alt="image" src="https://github.com/user-attachments/assets/8212bfa2-2288-4623-aa63-f748a2295ada">
This commit is contained in:
parent
3dcb94c204
commit
20bffaf93f
1 changed files with 10 additions and 1 deletions
|
@ -96,7 +96,16 @@
|
|||
"def"
|
||||
name: (_)
|
||||
(parameters)?
|
||||
body: (block (expression_statement (string) @string.doc)))
|
||||
body: (block . (expression_statement (string) @string.doc)))
|
||||
|
||||
(class_definition
|
||||
body: (block
|
||||
. (comment) @comment*
|
||||
. (expression_statement (string) @string.doc)))
|
||||
|
||||
(module
|
||||
. (comment) @comment*
|
||||
. (expression_statement (string) @string.doc))
|
||||
|
||||
(module
|
||||
(expression_statement (assignment))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue