Skip to content

Commit d71e2cc

Browse files
Merge pull request #1127 from olivroy/patch-1
Use cli messaging for cache
2 parents e8836fd + 015874f commit d71e2cc

File tree

7 files changed

+16
-17
lines changed

7 files changed

+16
-17
lines changed

R/set-assert-args.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@ assert_transformers <- function(transformers) {
2828
action <- if (utils::packageVersion("styler") >= version_cutoff) {
2929
"are not supported anymore"
3030
} else {
31-
"depreciated and will be removed in a future version of styler."
31+
"deprecated and will be removed in a future version of styler."
3232
}
3333
message <- paste(
3434
"Style guides without a name and a version field are",
3535
action, "\nIf you are a user: Open an issue on",
3636
"https://github.com/r-lib/styler and provide a reproducible example",
3737
"of this error. \nIf you are a developer:",
38-
"When you create a style guide with `styler::create_style_guide()`, the",
38+
"When you create a style guide with {.fn styler::create_style_guide}, the",
3939
"argument `style_guide_name` and `style_guide_version` should be",
40-
"non-NULL. See help(\"create_style_guide\") for how to set them."
40+
"non-NULL. See {.help styler::create_style_guide} for how to set them."
4141
)
4242

4343
if (utils::packageVersion("styler") >= version_cutoff) {
44-
rlang::abort(message)
44+
cli::cli_abort(message)
4545
} else {
46-
rlang::warn(message)
46+
cli::cli_warn(message)
4747
}
4848
}
4949
}

R/stylerignore.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ add_stylerignore <- function(pd_flat) {
7676
pd_flat$indicator_off <- cumsum_start + cumsum_stop
7777
is_invalid <- cumsum_start - cumsum_stop < 0L | cumsum_start - cumsum_stop > 1L
7878
if (any(is_invalid)) {
79-
warn(paste0(
79+
cli::cli_warn(paste0(
8080
"Invalid stylerignore sequences found, potentially ignoring some of the ",
81-
"markers set.\nSee `help(\"stylerignore\", \"styler\")`."
81+
"markers set.\nSee {.help styler::stylerignore}."
8282
))
8383
}
8484

R/vertical.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ print.vertical <- function(x, ...,
2424
if (is_installed("prettycode")) {
2525
x <- prettycode::highlight(x, style = style)
2626
} else {
27-
warn(paste(
27+
cli::cli_warn(paste(
2828
"Could not use `colored = TRUE`, as the package prettycode is not",
2929
"installed. Please install it if you want to see colored output",
30-
"or see `?print.vertical` for more information."
30+
"or see {.help styler::print.vertical} for more information."
3131
))
3232
}
3333
}

R/zzz.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ ask_to_switch_to_non_default_cache_root <- function(ask = interactive()) {
6464

6565

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

tests/testthat/test-exception_handling.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ test_that("warning is given when transformers does not contain a version", {
3232
}
3333
expect_fun(
3434
assert_transformers(sg),
35-
"name and a version field are depreciated and will be removed in a future version of styler"
35+
"name and a version field are deprecated and will be removed in a future version of styler"
3636
)
3737
})

tests/testthat/test-public_api-3.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ test_that("Can display warning on unset styler cache", {
153153
withr::local_seed(7)
154154
expect_message(
155155
ask_to_switch_to_non_default_cache_root(ask = TRUE),
156-
"See `?styler::caching`",
156+
regexp = "styler::caching",
157157
fixed = TRUE
158158
)
159159
})

vignettes/remove_rules.Rmd

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ If you want to change the behavior of styler to match your desired style, there
2525
are multiple ways:
2626

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

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

0 commit comments

Comments
 (0)