Skip to content

Commit

Permalink
check() now checks pkgdown
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Feb 20, 2024
1 parent c3fa3df commit 387efa9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
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(pkg) {
tryCatch(
!is.null(
rprojroot::find_root_file(
criterion = rprojroot::is_pkgdown_project,
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.

0 comments on commit 387efa9

Please sign in to comment.