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

check() now checks pkgdown #2561

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Imports:
remotes (>= 2.4.2),
rlang (>= 1.0.4),
roxygen2 (>= 7.2.1),
rprojroot (>= 2.0.4),
rversions (>= 2.1.1),
sessioninfo (>= 1.2.2),
stats,
Expand Down Expand Up @@ -62,8 +63,6 @@ Suggests:
spelling (>= 2.2)
VignetteBuilder:
knitr
Remotes:
r-lib/testthat
Config/Needs/website: tidyverse/tidytemplate
Config/testthat/edition: 3
Encoding: UTF-8
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# devtools (development version)

* `check()` now runs `pkgdown::check_pkgdown()` optionally (@olivroy, #2449)

* `test_coverage()` now works if the package has not been installed.

* `test_coverage_active_file()` now reports if any tests failed and does
Expand Down
24 changes: 24 additions & 0 deletions R/check.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#' roxygen2 version matches the version declared in the `DESCRIPTION`
#' file. Use `TRUE` or `FALSE` to override the default.
#' @param build_args Additional arguments passed to `R CMD build`
#' @param pkgdown Should run [pkgdown::check_pkgdown()]?
#' @param ... Additional arguments passed on to [pkgbuild::build()].
#' @param vignettes If `FALSE`, do not build or check vignettes, equivalent to
#' using `args = '--ignore-vignettes' and `build_args = '--no-build-vignettes'.
Expand All @@ -61,6 +62,7 @@ check <- function(pkg = ".",
run_dont_test = FALSE,
args = "--timings",
env_vars = c(NOT_CRAN = "true"),
pkgdown = NULL,
quiet = FALSE,
check_dir = NULL,
cleanup = deprecated(),
Expand Down Expand Up @@ -90,6 +92,17 @@ check <- function(pkg = ".",
cli::cat_line()
}
}
pkgdown <- pkgdown %||% has_pkgdown(pkg$path)

if (pkgdown) {
if (!quiet) {
cat_rule("Checking pkgdown", col = "cyan", line = 2)
}
pkgdown::check_pkgdown(pkg = pkg$path)
if (!quiet) {
cli::cat_line()
}
}

if (!quiet) {
cat_rule("Building", col = "cyan", line = 2)
Expand Down Expand Up @@ -151,6 +164,17 @@ can_document <- function(pkg) {
}
}

has_pkgdown <- function(path) {
tryCatch(
!is.null(
rprojroot::find_root_file(
criterion = rprojroot::is_pkgdown_project,
path = path)
),
error = function(e) FALSE
)
}

#' @export
#' @rdname check
#' @param path Path to built package.
Expand Down
3 changes: 3 additions & 0 deletions man/check.Rd

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

Loading