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

Documentation comments for both Python and Rust #11993

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions runtime/queries/python/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@

(integer) @constant.numeric.integer
(float) @constant.numeric.float
(expression_statement (string) @content
(#match? @content "^\"\"\"")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@the-mikedavis wow, I guess we don't need grammar changes to detect this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like python exposes a (string_start) node under (string) which contains these markers anyways, but it is handy that we wouldn't necessarily need the python grammar to do that in order to match this. (@probablySophie you can use :tree-sitter-subtree when selecting a syntax node to see how the nodes are laid out - this is usually more helpful than :tree-sitter-scopes which only shows the node names.)

I think we should follow nvim-treesitter's queries for this instead though since they're more specific and don't need #match? or #eq? at all: https://github.com/nvim-treesitter/nvim-treesitter/blob/dfd3207ed43a0c572c13acc02bf9d7dc270f4030/queries/python/highlights.scm#L201-L222

) @comment.block.documentation
(comment) @comment
(string) @string
(escape_sequence) @constant.character.escape
Expand Down
2 changes: 2 additions & 0 deletions runtime/queries/rust/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
(string_literal)
(raw_string_literal)
] @string
(line_comment (doc_comment)) @comment.documentation
(block_comment (doc_comment)) @comment.block.documentation
[
(line_comment)
(block_comment)
Expand Down