Skip to content

Commit 1f3e72e

Browse files
turn verbose warning into slick messsage and move info to docs
1 parent 8859cc3 commit 1f3e72e

File tree

6 files changed

+58
-25
lines changed

6 files changed

+58
-25
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Roxygen: list(markdown = TRUE, roclets = c( "rd", "namespace", "collate",
5353
if (rlang::is_installed("pkgapi")) "pkgapi::api_roclet" else {
5454
warning("Please install r-lib/pkgapi to make sure the file API is kept
5555
up to date"); NULL}))
56-
RoxygenNote: 7.2.1
56+
RoxygenNote: 7.2.2
5757
Config/testthat/edition: 3
5858
Config/testthat/parallel: true
5959
Collate:

R/ui-caching.R

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,25 @@ cache_clear <- function(cache_name = NULL, ask = TRUE) {
2323
#' Remember the past to be quicker in the future
2424
#'
2525
#' Caching makes styler faster on repeated styling and is shared across all APIs
26-
#' (e.g. `style_text()` and Addin).
27-
#' That means if you style code that already complies to a
28-
#' style guide and you have previously styled that code, it will be quicker.
26+
#' (e.g. `style_text()` and Addin). That means if you style code that already
27+
#' complies to a style guide and you have previously styled that code, it will
28+
#' be quicker.
29+
#'
30+
#' @section Configuring the cache:
31+
#'
32+
#' To comply with the CRAN policy, \{styler\} will by default clean up cache files
33+
#' that are older than 6 days. This implies that you loose the benefit of the cache
34+
#' for the files not styled in the last 6 days. You can set the R option
35+
#' `styler.cache_root` explicitly, (e.g. in your `.Rprofile` with
36+
#' [usethis::edit_r_profile()]) to
37+
#'
38+
#' * confirm the default and silence the message with
39+
#' `options(styler.cache_root = "styler")`.
40+
#'
41+
#' * opt for an indefinitely long-living cache by setting the option to something
42+
#' else (we recommend `options(styler.cache_root = "styler-perm")`, which is
43+
#' also used by pre-commit).
44+
#'
2945
#' @section Manage the cache:
3046
#' See [cache_info()],[cache_activate()] or [cache_clear()] for utilities to
3147
#' manage the cache. You can deactivate it altogether with [cache_deactivate()].
@@ -47,6 +63,11 @@ cache_clear <- function(cache_name = NULL, ask = TRUE) {
4763
#' which is why it takes zero space on disk (the cache is a directory with
4864
#' empty files which have the hash of output code as name).
4965
#'
66+
#' The cache literally takes zero space on your disk, only the inode, and you
67+
#' can always manually clean up with [cache_clear()] or just go to the
68+
#' directory where the cache lives (find it with [cache_info()]) and manually
69+
#' delete files.
70+
#'
5071
#' @section Using a cache for styler in CI/CD:
5172
#' If you want to set up caching in a CI/CD pipeline, we suggest to set the
5273
#' `{R.cache}` root path to a directory for which you have the cache enabled.

R/zzz.R

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,11 @@ ask_to_switch_to_non_default_cache_root <- function(ask = interactive()) {
3131
}
3232
}
3333

34+
3435
ask_to_switch_to_non_default_cache_root_impl <- function() {
35-
rlang::warn(paste0(
36-
"The R option `styler.cache_root` is not set, which means the cache ",
37-
"will get cleaned up after 6 days (and repeated styling will be slower).",
38-
" To keep cache files longer, set ",
39-
"the option to location within the {R.cache} cache where you want to ",
40-
"store the cache, e.g. `\"styler-perm\"`.\n\n",
41-
"options(styler.cache_root = \"styler-perm\")\n\n",
42-
"in your .Rprofile. Note that the cache literally ",
43-
"takes zero space on your disk, only the inode, and you can always ",
44-
"manually clean up with `styler::cache_clear()`, and if you update the ",
45-
"{styler} package, the cache is removed in any case. To ignore this ",
46-
"message in the future, set the default explictly to \"styler\" with\n\n",
47-
"options(styler.cache_root = \"styler\")\n\nin your `.Rprofile`. This ",
48-
"message will only be displayed once in a while.\n"
36+
rlang::inform(paste0(
37+
"{styler} cache is cleared after 6 days. ",
38+
"See `?styler::caching` to configure differently or silence this message."
4939
))
5040
}
5141

man/caching.Rd

Lines changed: 25 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/combine_children.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-public_api.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,9 @@ test_that("Can properly determine style_after_saving", {
512512
test_that("Can display warning on unset styler cache", {
513513
withr::local_options(styler.cache_root = NULL)
514514
withr::local_seed(7)
515-
expect_warning(
515+
expect_message(
516516
ask_to_switch_to_non_default_cache_root(ask = TRUE),
517-
'options(styler.cache_root = "styler-perm")',
517+
"See `?styler::caching`",
518518
fixed = TRUE
519519
)
520520
})

0 commit comments

Comments
 (0)