From 89c9e51b7a9c9082cc48fc73ec4b9743c07fb388 Mon Sep 17 00:00:00 2001 From: Jay Hesselberth Date: Sat, 13 Jul 2024 14:20:59 -0600 Subject: [PATCH 1/4] Depend on R version >= 4.0.0 (#2717) Fixes #2714 --- DESCRIPTION | 2 +- NEWS.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 474198131..72d671059 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -21,7 +21,7 @@ License: MIT + file LICENSE URL: https://pkgdown.r-lib.org/, https://github.com/r-lib/pkgdown BugReports: https://github.com/r-lib/pkgdown/issues Depends: - R (>= 3.6) + R (>= 4.0.0) Imports: bslib (>= 0.5.1), callr (>= 3.7.3), diff --git a/NEWS.md b/NEWS.md index dc25587c3..01a508bd7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # pkgdown (development version) +* pkgdown now depends on R >= 4.0.0 (#2714) + # pkgdown 2.1.0 ## Major changes From 9779d2890d39c68d47f43a6514c565e394ce4c71 Mon Sep 17 00:00:00 2001 From: Jay Hesselberth Date: Sun, 14 Jul 2024 11:45:48 -0600 Subject: [PATCH 2/4] Implement `clean_cache()` (#2719) Closes #2718 --- NAMESPACE | 1 + NEWS.md | 1 + R/clean.R | 27 ++++++++++++++++++++++++++- man/{clean_site.Rd => clean.Rd} | 5 +++++ 4 files changed, 33 insertions(+), 1 deletion(-) rename man/{clean_site.Rd => clean.Rd} (76%) diff --git a/NAMESPACE b/NAMESPACE index b5c4203db..6e2bdfb2f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -125,6 +125,7 @@ export(build_site) export(build_site_github_pages) export(build_tutorials) export(check_pkgdown) +export(clean_cache) export(clean_site) export(data_template) export(deploy_site_github) diff --git a/NEWS.md b/NEWS.md index 01a508bd7..6bd90a976 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # pkgdown (development version) +* New `clean_cache()` function removes the contents of the cache directory (#2718). * pkgdown now depends on R >= 4.0.0 (#2714) # pkgdown 2.1.0 diff --git a/R/clean.R b/R/clean.R index 8f781e54e..b8472fb34 100644 --- a/R/clean.R +++ b/R/clean.R @@ -4,6 +4,7 @@ #' #' @param quiet If `TRUE`, suppresses a message. #' @inheritParams build_site +#' @rdname clean #' @export clean_site <- function(pkg = ".", quiet = FALSE) { @@ -27,6 +28,30 @@ clean_site <- function(pkg = ".", quiet = FALSE) { invisible(TRUE) } +#' Clean cache +#' +#' Delete all files in the pkgdown cache directory. +#' +#' @rdname clean +#' @export +clean_cache <- function(pkg = ".", quiet = FALSE) { + + pkg <- as_pkgdown(pkg) + cache_path <- tools::R_user_dir("pkgdown", "cache") + + if (dir_exists(cache_path)) { + if (!quiet) { + cli::cli_inform( + "Cleaning {.pkg {pkg$package}} cache files from {.path {cache_path}}" + ) + } + + dir_delete(cache_path) + } + + invisible(TRUE) +} + check_dest_is_pkgdown <- function(pkg) { if (file_exists(path(pkg$dst_path, "pkgdown.yml"))) { return() @@ -45,6 +70,6 @@ dest_files <- function(pkg) { character() } else { top_level <- dir_ls(pkg$dst_path) - top_level[!path_file(top_level) %in% c("CNAME", "dev")] + top_level[!path_file(top_level) %in% c("CNAME", "dev")] } } diff --git a/man/clean_site.Rd b/man/clean.Rd similarity index 76% rename from man/clean_site.Rd rename to man/clean.Rd index d8e73f3cf..b6d8b0710 100644 --- a/man/clean_site.Rd +++ b/man/clean.Rd @@ -2,9 +2,12 @@ % Please edit documentation in R/clean.R \name{clean_site} \alias{clean_site} +\alias{clean_cache} \title{Clean site} \usage{ clean_site(pkg = ".", quiet = FALSE) + +clean_cache(pkg = ".", quiet = FALSE) } \arguments{ \item{pkg}{Path to package.} @@ -13,4 +16,6 @@ clean_site(pkg = ".", quiet = FALSE) } \description{ Delete all files in \verb{docs/} (except for \code{CNAME}). + +Delete all files in the pkgdown cache directory. } From 2841c0f994fda7f7c7da94034bd24e3882fc7a37 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Tue, 16 Jul 2024 07:49:06 -0500 Subject: [PATCH 3/4] Bump httr2 dep (#2725) --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 72d671059..6a0a62f8a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,7 +31,7 @@ Imports: downlit (>= 0.4.4), fontawesome, fs (>= 1.4.0), - httr2 (>= 1.0.0), + httr2 (>= 1.0.2), jsonlite, openssl, purrr (>= 1.0.0), From 6f01c9267a1cee263216cec38eea10017d751dd8 Mon Sep 17 00:00:00 2001 From: Leonardo Collado-Torres Date: Tue, 23 Jul 2024 08:55:44 -0400 Subject: [PATCH 4/4] Parse symbolic usage Closes #2727 --- R/usage.R | 2 +- tests/testthat/test-usage.R | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/R/usage.R b/R/usage.R index 1c4631fa0..6ecc78e71 100644 --- a/R/usage.R +++ b/R/usage.R @@ -19,7 +19,7 @@ as_data.tag_usage <- function(x, ...) { lines <- strsplit(text, "\n", fixed = TRUE)[[1]] parsed <- lapply(lines, function(x) tryCatch(parse(text = x)[[1]], error = function(e) NULL)) needs_tweak <- function(x) { - is_call(x) && !is_call(x, "=") && !is_syntactic(x[[1]]) + is_call(x) && !is_call(x, "=") && (is_symbol(x[[1]]) && !is_syntactic(x[[1]])) } to_tweak <- vapply(parsed, needs_tweak, logical(1)) lines[to_tweak] <- vapply(parsed[to_tweak], deparse1, character(1)) diff --git a/tests/testthat/test-usage.R b/tests/testthat/test-usage.R index 776f7df50..97a00b83a 100644 --- a/tests/testthat/test-usage.R +++ b/tests/testthat/test-usage.R @@ -186,6 +186,10 @@ test_that("can parse dots", { expect_equal(usage$name, "f") }) +test_that("usage2text can parse symbols (#2727)", { + expect_no_error(usage2text("viridisLite::viridis(21)")) +}) + # short_name -------------------------------------------------------------- test_that("infix functions left as", {