python: Highlight attribute docstrings (#20763)
Adds more docstring highlights missing from #20486. [PEP257](https://peps.python.org/pep-0257/) defines attribute docstrings as > String literals occurring immediately after a simple assignment at the top level of a module, class, or __init__ method are called “attribute docstrings”. This PR adds `@string.doc` for such cases. Before:  After:  Release Notes: - Added Python syntax highlighting for attribute docstrings. --------- Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
This commit is contained in:
parent
f5cbfa718e
commit
7853e32f80
1 changed files with 19 additions and 0 deletions
|
@ -98,6 +98,25 @@
|
||||||
(parameters)?
|
(parameters)?
|
||||||
body: (block (expression_statement (string) @string.doc)))
|
body: (block (expression_statement (string) @string.doc)))
|
||||||
|
|
||||||
|
(module
|
||||||
|
(expression_statement (assignment))
|
||||||
|
. (expression_statement (string) @string.doc))
|
||||||
|
|
||||||
|
(class_definition
|
||||||
|
body: (block
|
||||||
|
(expression_statement (assignment))
|
||||||
|
. (expression_statement (string) @string.doc)))
|
||||||
|
|
||||||
|
(class_definition
|
||||||
|
body: (block
|
||||||
|
(function_definition
|
||||||
|
name: (identifier) @function.method.constructor
|
||||||
|
(#eq? @function.method.constructor "__init__")
|
||||||
|
body: (block
|
||||||
|
(expression_statement (assignment))
|
||||||
|
. (expression_statement (string) @string.doc)))))
|
||||||
|
|
||||||
|
|
||||||
[
|
[
|
||||||
"-"
|
"-"
|
||||||
"-="
|
"-="
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue