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

@examples section messes up highlighting in roxygen2 blocks further down the page #1360

Open
Tracked by #2011
hadley opened this issue Sep 21, 2023 · 6 comments
Open
Tracked by #2011
Labels
bug Something isn't working lang: r

Comments

@hadley
Copy link

hadley commented Sep 21, 2023

Positron Version:

Steps to reproduce the issue:

Screenshot 2023-09-21 at 16 26 17

cf https://github.com/r-lib/devtools/blob/main/R/package.R#L88

What did you expect to happen?

Looks like something further up the page leaves the parser in the wrong state.

Were there any error messages in the output or Developer Tools console?

@kevinushey
Copy link
Contributor

Looks like this is caused by the #' @examples block above. A smaller reprex:

#' @examples
#' print(1 + 1)
NULL

#' Uh oh
Screenshot 2023-09-22 at 1 04 18 PM

Note that the text within the Roxygen documentation is being highlighted as though it were R code still.

Screenshot 2023-09-22 at 1 05 03 PM

@kevinushey
Copy link
Contributor

Here's the offending code:

"begin": "(^\\s*#+')\\s*(@examples)\\s*$",
"beginCaptures": {
"1": { "name": "comment.line" },
"2": { "name": "{{ roxygen-tag }}" }
},
"end": "(^\\s*#+')\\s*(@\\w*)",
"endCaptures": {
"1": { "name": "comment.line" },
"2": { "name": "{{ roxygen-tag }}" }
},

We need to improve how the "end" of an roxygen example code chunk ends.

@mine-cetinkaya-rundel
Copy link

Another instance of wrong highlighting in comments, not in roxygen comments but for comments followed by 4+ dashes:

Screenshot 2023-09-25 at 9 47 11 PM

@kevinushey
Copy link
Contributor

That was intentional; the goal there is to help comment-style section titles stand out. Do you prefer the "plain" comment styling?

@mine-cetinkaya-rundel
Copy link

@kevinushey Having them stand out could be nice, but the color matching the default/code color doesn't make them stand out to me. I'd prefer either plain comment styling or using a different color (like a lighter green or something here) to have them stand out. Turning that text to black seems like it's not being interpreted as a comment.

@jennybc jennybc added this to the Release Candidate milestone Feb 23, 2024
@jennybc jennybc changed the title Comment gets wrong syntax highlighting Roxygen comment gets wrong syntax highlighting Feb 23, 2024
@wesm wesm added lang: r bug Something isn't working labels Feb 29, 2024
@DavisVaughan
Copy link
Contributor

Just hit this again for the docs of between() in dplyr

Screen.Recording.2024-08-27.at.11.25.18.AM.mov

@DavisVaughan DavisVaughan changed the title Roxygen comment gets wrong syntax highlighting @examples section messes up highlighting in roxygen2 blocks further down the page Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lang: r
Projects
None yet
Development

No branches or pull requests

6 participants