diff --git a/DESCRIPTION b/DESCRIPTION index 7db0adf59..861121a98 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -33,6 +33,7 @@ Imports: remotes (>= 2.5.0), rlang (>= 1.1.6), roxygen2 (>= 7.3.3), + rprojroot, rversions (>= 2.1.2), sessioninfo (>= 1.2.3), stats, diff --git a/NEWS.md b/NEWS.md index 8810e8904..f81408c4c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # devtools (development version) +* `check()` now runs `pkgdown::check_pkgdown()` optionally (@olivroy, #2449) + # devtools 2.4.6 * Functions that use httr now explicitly check that it is installed diff --git a/R/check.R b/R/check.R index 11489ffb1..3c6f1c7d6 100644 --- a/R/check.R +++ b/R/check.R @@ -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'`. @@ -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(), @@ -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) @@ -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. diff --git a/man/check.Rd b/man/check.Rd index 1acf0c256..75a0dab80 100644 --- a/man/check.Rd +++ b/man/check.Rd @@ -18,6 +18,7 @@ check( run_dont_test = FALSE, args = "--timings", env_vars = c(NOT_CRAN = "true"), + pkgdown = NULL, quiet = FALSE, check_dir = NULL, cleanup = deprecated(), @@ -83,6 +84,8 @@ Windows.)} \item{env_vars}{Environment variables set during \verb{R CMD check}} +\item{pkgdown}{Should run \code{\link[pkgdown:check_pkgdown]{pkgdown::check_pkgdown()}}?} + \item{quiet}{if \code{TRUE} suppresses output from this function.} \item{check_dir}{Path to a directory where the check is performed.