Skip to content

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

Closed

Description

@IndrajeetPatil

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

Activity

  1. lorenzwalthert commented on Nov 23, 2022

    @lorenzwalthert
    Collaborator

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

  2. added a commit that references this issue on Dec 22, 2022
  3. lorenzwalthert commented on Dec 27, 2022

    @lorenzwalthert
    Collaborator

    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.

  4. IndrajeetPatil commented on Dec 27, 2022

    @IndrajeetPatil
    CollaboratorAuthor

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

    I think they are: #1085 (comment)

  5. lorenzwalthert commented on Dec 28, 2022

    @lorenzwalthert
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions