Skip to content

Commit

Permalink
Merge branch 'r-lib:main' into fix/2705-img-src
Browse files Browse the repository at this point in the history
  • Loading branch information
HenningLorenzen-ext-bayer authored Aug 1, 2024
2 parents cc095ae + 6f01c92 commit 9bb2514
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 4 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# 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

## Major changes
Expand Down
27 changes: 26 additions & 1 deletion R/clean.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#'
#' @param quiet If `TRUE`, suppresses a message.
#' @inheritParams build_site
#' @rdname clean
#' @export
clean_site <- function(pkg = ".", quiet = FALSE) {

Expand All @@ -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()
Expand All @@ -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")]
}
}
2 changes: 1 addition & 1 deletion R/usage.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
5 changes: 5 additions & 0 deletions man/clean_site.Rd → man/clean.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/testthat/test-usage.R
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down

0 comments on commit 9bb2514

Please sign in to comment.