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

Warning exists when reprex(... style = FALSE) #461

Open
beauchamplab opened this issue Feb 2, 2024 · 3 comments
Open

Warning exists when reprex(... style = FALSE) #461

beauchamplab opened this issue Feb 2, 2024 · 3 comments

Comments

@beauchamplab
Copy link

With style=FALSE, users would like to render without styler. I wonder if "Install the styler package" should still show up?

reprex::reprex({ print("") }, style = FALSE)
#> ✖ Install the styler package in order to use `style = TRUE`.
#> ℹ Non-interactive session, setting `html_preview = FALSE`.
#> ℹ Rendering reprex...

Created on 2024-02-02 with reprex v2.1.0

@jennybc
Copy link
Member

jennybc commented Feb 2, 2024

Yeah this appears to be a thinko in this helper. It doesn't seem to consult whether style is TRUE or FALSE 🙈

reprex/R/reprex_impl.R

Lines 129 to 137 in e1f65e9

style_requires_styler <- function(style) {
if (!requireNamespace("styler", quietly = TRUE)) {
reprex_danger("
Install the {.pkg styler} package in order to use
{.code style = TRUE}.")
style <- FALSE
}
invisible(style)
}

@beauchamplab
Copy link
Author

Our users asked us if they should install styler since they got this "warning". Maybe:

style_requires_styler <- function(style) { 
   if (style && !requireNamespace("styler", quietly = TRUE)) { 
     reprex_danger(" 
       Install the {.pkg styler} package in order to use 
       {.code style = TRUE}.") 
     style <- FALSE 
   } 
   invisible(style) 
 } 

?

@jennybc
Copy link
Member

jennybc commented Feb 5, 2024

Yes LGTM. Would you like to make a PR?

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

No branches or pull requests

2 participants