Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to force site cleaning #2827

Merged
merged 2 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading