Skip to content

When Roxygen comment block ends with a tag, the stylerignore directives are ignored #1067

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

Closed
IndrajeetPatil opened this issue Nov 23, 2022 · 4 comments · Fixed by #1089
Closed

Comments

@IndrajeetPatil
Copy link
Collaborator

This was difficult to track down, but I finally have a minimal reprex to show the issue.


When the Roxygen comment ends with a tag (any tag), the stylerignore directives are ignored.

For example, here the Roxygen comment block is surrounded by the stylerignore directives, and yet the code in examples is styled.

styler::style_text(
  "# styler: off
#' @examples 
#' x=1
#' @export
# styler: on"
)
#> # styler: off
#> #' @examples
#> #' x <- 1
#> #' @export
#> # styler: on

And I think that this has something to do with the tag at the end, because if you relocate it to any other position in the comment block, we get the expected behaviour.

styler::style_text(
  "# styler: off
#' @export
#' @examples 
#' x=1
# styler: on"
)
#> # styler: off
#> #' @export
#> #' @examples 
#> #' x=1
#> # styler: on

Created on 2022-11-23 with reprex v2.0.2

@lorenzwalthert
Copy link
Collaborator

Thanks for the reprex. I agree, this is not what we are after.

IndrajeetPatil added a commit to easystats/datawizard that referenced this issue Dec 22, 2022
I know that this is not what we want, but the styler annotations are creating problematic formatting.

I have created issues to track this.

- r-lib/styler#1067
- r-lib/styler#1072

We can revisit this once they are resolved.
@lorenzwalthert
Copy link
Collaborator

lorenzwalthert commented Dec 27, 2022

To me, it seems rather that roxygen code sequences are not recognized as such if they don't end with an @ tag after the example section, code or a blank line.

styler::style_text(
  "
#' @export
#' @examples 
#' x=1
"
)
#> #' @export
#> #' @examples
#> #' x=1

Created on 2022-12-27 with reprex v2.0.2

If we fixed that, I don't think current behavior would do what you wanted. I am not even sure roxygen code comments are stylerignored in any way.

@IndrajeetPatil
Copy link
Collaborator Author

I am not even sure roxygen code comments are stylerignored in any way.

I think they are: #1085 (comment)

@lorenzwalthert
Copy link
Collaborator

Should the issue be reopened or did #1089 fully solve the issue?

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

Successfully merging a pull request may close this issue.

2 participants