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

Invalid "use pkgdown::clean_site()" advice #2699

Closed
Bisaloo opened this issue Jul 6, 2024 · 4 comments · Fixed by #2827
Closed

Invalid "use pkgdown::clean_site()" advice #2699

Bisaloo opened this issue Jul 6, 2024 · 4 comments · Fixed by #2827
Labels
bug an unexpected problem or unintended behavior

Comments

@Bisaloo
Copy link
Contributor

Bisaloo commented Jul 6, 2024

When docs/ is not empty and not created by pkgdown, an error message will be returned:

pkgdown/R/clean.R

Lines 30 to 41 in c7c4865

check_dest_is_pkgdown <- function(pkg) {
if (file_exists(path(pkg$dst_path, "pkgdown.yml"))) {
return()
}
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."
)
)
}

But when running pkgdown::clean_site(), the same message is returned because clean_site() itself calls check_dest_is_pkgdown():

pkgdown/R/clean.R

Lines 19 to 21 in c7c4865

if (length(top_level) > 0) {
check_dest_is_pkgdown(pkg)
}

I can create a reprex package for this issue if helpful.

@Bisaloo Bisaloo changed the title Incorrect "use pkgdown::clean_site()" advice Invalid "use pkgdown::clean_site()" advice Jul 6, 2024
@hadley
Copy link
Member

hadley commented Jul 6, 2024

Hmmm, I think it's the advice that's wrong here — clean_site() is specifically for cleaning up sites (as the name suggests 😄) not deleting directories that aren't sites.

@hadley hadley added bug an unexpected problem or unintended behavior tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day labels Jul 8, 2024
@jayhesselberth
Copy link
Collaborator

@Bisaloo what advice do you think pkgdown should provide in this case?

@jayhesselberth
Copy link
Collaborator

Actually, in testing this, the advice is to "make sure it contains no important information and use pkgdown::clean_site() to
delete its contents." So this would imply that clean_site() should delete anything in the directory, regardless of whether it was built by pkgdown or not.

@jayhesselberth
Copy link
Collaborator

We could just add clean_site(force = TRUE) to skip the check that the directory was built by pkgdown.

jayhesselberth added a commit that referenced this issue Nov 29, 2024
@jayhesselberth jayhesselberth removed the tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day label Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants