Skip to content

Commit dfa28be

Browse files
Provide a way to force site cleaning (#2827)
Closes #2699
1 parent 6e1613c commit dfa28be

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# pkgdown (development version)
22

3+
* New `clean_site(force = TRUE)` for cleaning of `docs/` regardless of whether it was built by pkgdown (#2827).
34
* 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()`.
45
* 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).
56

R/clean.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
#' Delete all files in `docs/` (except for `CNAME`).
44
#'
55
#' @param quiet If `TRUE`, suppresses a message.
6+
#' @param force If `TRUE`, delete contents of `docs` even if it is not a pkgdown site.
67
#' @inheritParams build_site
78
#' @rdname clean
89
#' @export
9-
clean_site <- function(pkg = ".", quiet = FALSE) {
10+
clean_site <- function(pkg = ".", quiet = FALSE, force = FALSE) {
1011

1112
pkg <- as_pkgdown(pkg)
1213

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

1920
top_level <- dest_files(pkg)
20-
if (length(top_level) > 0) {
21+
if (length(top_level) > 0 && !force) {
2122
check_dest_is_pkgdown(pkg)
2223
}
2324

@@ -60,7 +61,7 @@ check_dest_is_pkgdown <- function(pkg) {
6061
cli::cli_abort(c(
6162
"{.file {pkg$dst_path}} is non-empty and not built by pkgdown",
6263
"!" = "Make sure it contains no important information \\
63-
and use {.run pkgdown::clean_site()} to delete its contents."
64+
and use {.run pkgdown::clean_site(force = TRUE)} to delete its contents."
6465
)
6566
)
6667
}

man/clean.Rd

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

0 commit comments

Comments
 (0)