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

Use cli messaging for cache #1127

Merged
merged 3 commits into from
Jun 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions R/set-assert-args.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ assert_transformers <- function(transformers) {
action <- if (utils::packageVersion("styler") >= version_cutoff) {
"are not supported anymore"
} else {
"depreciated and will be removed in a future version of styler."
"deprecated and will be removed in a future version of styler."
}
message <- paste(
"Style guides without a name and a version field are",
action, "\nIf you are a user: Open an issue on",
"https://github.com/r-lib/styler and provide a reproducible example",
"of this error. \nIf you are a developer:",
"When you create a style guide with `styler::create_style_guide()`, the",
"When you create a style guide with {.fn styler::create_style_guide}, the",
"argument `style_guide_name` and `style_guide_version` should be",
"non-NULL. See help(\"create_style_guide\") for how to set them."
"non-NULL. See {.help styler::create_style_guide} for how to set them."
)

if (utils::packageVersion("styler") >= version_cutoff) {
rlang::abort(message)
cli::cli_abort(message)
} else {
rlang::warn(message)
cli::cli_warn(message)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions R/stylerignore.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ add_stylerignore <- function(pd_flat) {
pd_flat$indicator_off <- cumsum_start + cumsum_stop
is_invalid <- cumsum_start - cumsum_stop < 0L | cumsum_start - cumsum_stop > 1L
if (any(is_invalid)) {
warn(paste0(
cli::cli_warn(paste0(
"Invalid stylerignore sequences found, potentially ignoring some of the ",
"markers set.\nSee `help(\"stylerignore\", \"styler\")`."
"markers set.\nSee {.help styler::stylerignore}."
))
}

Expand Down
4 changes: 2 additions & 2 deletions R/vertical.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ print.vertical <- function(x, ...,
if (is_installed("prettycode")) {
x <- prettycode::highlight(x, style = style)
} else {
warn(paste(
cli::cli_warn(paste(
"Could not use `colored = TRUE`, as the package prettycode is not",
"installed. Please install it if you want to see colored output",
"or see `?print.vertical` for more information."
"or see {.help styler::print.vertical} for more information."
))
}
}
Expand Down
6 changes: 3 additions & 3 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ ask_to_switch_to_non_default_cache_root <- function(ask = interactive()) {


ask_to_switch_to_non_default_cache_root_impl <- function() {
rlang::inform(paste0(
"{styler} cache is cleared after 6 days. ",
"See `?styler::caching` to configure differently or silence this message."
cli::cli_inform(paste0(
"{{styler}} cache is cleared after 6 days. ",
"See {.help styler::caching} to configure differently or silence this message."
))
}

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-exception_handling.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ test_that("warning is given when transformers does not contain a version", {
}
expect_fun(
assert_transformers(sg),
"name and a version field are depreciated and will be removed in a future version of styler"
"name and a version field are deprecated and will be removed in a future version of styler"
)
})
2 changes: 1 addition & 1 deletion tests/testthat/test-public_api-3.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ test_that("Can display warning on unset styler cache", {
withr::local_seed(7)
expect_message(
ask_to_switch_to_non_default_cache_root(ask = TRUE),
"See `?styler::caching`",
regexp = "styler::caching",
fixed = TRUE
)
})
Expand Down
5 changes: 2 additions & 3 deletions vignettes/remove_rules.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ If you want to change the behavior of styler to match your desired style, there
are multiple ways:

- Use the tidyverse style guide, but not with the default options. Starting
point for this approach is the [help
file](https://styler.r-lib.org/reference/tidyverse_style.html) for the
point for this approach is the `help("tidyverse_style")` for the
function `tidyverse_style()`, which returns the transformer functions that
prettify your code. Most of these options are explained in
`vignette("styler")`.
Expand Down Expand Up @@ -164,7 +163,7 @@ styler.

- Then pinpoint the probable rule type (e.g. line breaks if you want less new
lines).
- In a local styler clone, add e.g. a `return(pd` at the top of the body to
- In a local styler clone, add e.g. a `return(pd)` at the top of the body to
deactivate the rule quickly, or add a `print(pd)` or `browser()` call in
the functions of that type (e.g. the different functions of
`R/rules-line-breaks.R`), `load_all()`, run your example, see if that
Expand Down