Skip to content

Commit

Permalink
Provide a way to force site cleaning (#2827)
Browse files Browse the repository at this point in the history
Closes #2699
  • Loading branch information
jayhesselberth authored Dec 1, 2024
1 parent 6e1613c commit dfa28be
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# pkgdown (development version)

* New `clean_site(force = TRUE)` for cleaning of `docs/` regardless of whether it was built by pkgdown (#2827).
* Links to favicons in page headers were updated to reflect changes to https://realfavicongenerator.net/ (#2804). Favicons should be re-generated by manually removing the `pkgdown/favicon` directory and then running `pkgdown::build_favicons()`.
* The language of the site is set from the first `Language:` in the `DESCRIPTION` if it is available and no other language is specified (@jonthegeek, #2808).

Expand Down
7 changes: 4 additions & 3 deletions R/clean.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
#' Delete all files in `docs/` (except for `CNAME`).
#'
#' @param quiet If `TRUE`, suppresses a message.
#' @param force If `TRUE`, delete contents of `docs` even if it is not a pkgdown site.
#' @inheritParams build_site
#' @rdname clean
#' @export
clean_site <- function(pkg = ".", quiet = FALSE) {
clean_site <- function(pkg = ".", quiet = FALSE, force = FALSE) {

pkg <- as_pkgdown(pkg)

Expand All @@ -17,7 +18,7 @@ clean_site <- function(pkg = ".", quiet = FALSE) {
if (!dir_exists(pkg$dst_path)) return(invisible())

top_level <- dest_files(pkg)
if (length(top_level) > 0) {
if (length(top_level) > 0 && !force) {
check_dest_is_pkgdown(pkg)
}

Expand Down Expand Up @@ -60,7 +61,7 @@ check_dest_is_pkgdown <- function(pkg) {
cli::cli_abort(c(
"{.file {pkg$dst_path}} is non-empty and not built by pkgdown",
"!" = "Make sure it contains no important information \\
and use {.run pkgdown::clean_site()} to delete its contents."
and use {.run pkgdown::clean_site(force = TRUE)} to delete its contents."
)
)
}
Expand Down
4 changes: 3 additions & 1 deletion man/clean.Rd

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

0 comments on commit dfa28be

Please sign in to comment.