reprex icon indicating copy to clipboard operation
reprex copied to clipboard

Warning exists when `reprex(... style = FALSE)`

Open beauchamplab opened this issue 1 year ago • 3 comments

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

beauchamplab avatar Feb 02 '24 22:02 beauchamplab

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

https://github.com/tidyverse/reprex/blob/e1f65e9949ed30d1ee4f1e984736b408d8e001ee/R/reprex_impl.R#L129-L137

jennybc avatar Feb 02 '24 23:02 jennybc

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) 
 } 

?

beauchamplab avatar Feb 03 '24 01:02 beauchamplab

Yes LGTM. Would you like to make a PR?

jennybc avatar Feb 05 '24 17:02 jennybc