Skip to content

Expose doc comment contents #212

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

Merged
merged 1 commit into from
Apr 5, 2024

Conversation

the-mikedavis
Copy link
Contributor

@the-mikedavis the-mikedavis commented Feb 17, 2024

#195 parsed doc comments but it exposed the nodes for the doc comment markers (!//) rather than the content of the comments. The comment content is useful for injecting markdown into the comments:

; injections.scm
([(line_comment !doc) (block_comment !doc)] @injection.content
 (#set! injection.language "comment"))

((doc_comment) @injection.content
 (#set! injection.language "markdown")
 (#set! injection.combined))

I've also changed the line doc comment slightly to fix an issue with the marker node (it unnecessarily consumed the character after the ///) and to include the line's line-ending, which is useful to tree-sitter-markdown.

cc @ProfDoof I've only made the change to line comments, I may need some help to make block comments have the same structure

Block comment changes are included as well.

@amaanq
Copy link
Member

amaanq commented Feb 17, 2024

Do you want to alias it as a literal instead for consistency? (might be easier for queries too?)

@the-mikedavis
Copy link
Contributor Author

Do you mean the marker or the comment's contents? I'm not very familiar with this grammar but it looks like the existing literal rules are used for values like ints/floats/etc. With these changes the queries we would add for Helix are pretty simple (- just what I listed above)

@the-mikedavis the-mikedavis marked this pull request as draft February 21, 2024 21:57
@the-mikedavis the-mikedavis force-pushed the md-fix-line-doc-comments branch 2 times, most recently from 5b3d7a8 to 35f4a5b Compare February 22, 2024 16:01
@the-mikedavis the-mikedavis marked this pull request as ready for review February 22, 2024 16:01
@the-mikedavis the-mikedavis changed the title Expose line doc comment contents Expose doc comment contents Feb 22, 2024
@amaanq
Copy link
Member

amaanq commented Feb 24, 2024

I meant the markers, sorry for not being clear. I do like your content changes though

Though you'll need to rebase since there was an edge case I fixed w.r.t. empty line doc comments eating up contents on the following line

@amaanq
Copy link
Member

amaanq commented Feb 24, 2024

Also regenerate with 0.21.0 😁 (and redo the test updates with -u, that no longer updates all test header delimiters to be 80 chars long)

@the-mikedavis the-mikedavis force-pushed the md-fix-line-doc-comments branch 2 times, most recently from 2a7a942 to 03ad90a Compare February 26, 2024 16:24
@amaanq amaanq force-pushed the md-fix-line-doc-comments branch from 03ad90a to c524e8f Compare April 5, 2024 13:39
@amaanq amaanq merged commit 927a1b5 into tree-sitter:master Apr 5, 2024
5 checks passed
@amaanq
Copy link
Member

amaanq commented Apr 5, 2024

Really sorry for taking forever on this

@the-mikedavis the-mikedavis deleted the md-fix-line-doc-comments branch April 5, 2024 13:57
@the-mikedavis
Copy link
Contributor Author

No worries, I've been testing this locally in the meantime.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants