Skip to content

Commit

Permalink
check_missing_topics() error on CI (#1395)
Browse files Browse the repository at this point in the history
Fixes #1378
  • Loading branch information
ThierryO committed Sep 21, 2020
1 parent bc3c3ea commit e1e46f2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# pkgdown (development version)

* Missing topics makes the build fail when the environment variable `CI` is set
to `"true"` (@ThierryO, #1378).

* The default navbar no longer includes a home icon - this took up precious
horizontal space and wasn't very useful since there is already a link to the
home page immediately to its left (#1383).
Expand Down
10 changes: 9 additions & 1 deletion R/build-reference-index.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ check_missing_topics <- function(rows, pkg) {

missing <- !in_index & !pkg$topics$internal
if (any(missing)) {
warn(c("Topics missing from index: ", unname(pkg$topics$name[missing])))
if (on_ci()) {
stop(c("Topics missing from index: ", unname(pkg$topics$name[missing])))
} else {
warn(c("Topics missing from index: ", unname(pkg$topics$name[missing])))
}
}
}

on_ci <- function() {
isTRUE(as.logical(Sys.getenv("CI")))
}
3 changes: 3 additions & 0 deletions R/build-reference.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
#'
#' pkgdown will check that all non-internal topics are included on
#' the reference index page, and will generate a warning if you have missed any.
#' When the code is run in a continuous integration environment (i.e. when the
#' CI envar is "true"), this is an error so that the build will fail if you
#' forget to include topics in the index.
#'
#' ## Icons
#' You can optionally supply an icon for each help topic. To do so, you'll need
Expand Down
3 changes: 3 additions & 0 deletions man/build_reference.Rd

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

3 changes: 3 additions & 0 deletions tests/testthat/test-build-reference-index.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ test_that("warns if missing topics", {
)
meta <- list(reference = ref)
pkg <- as_pkgdown(test_path("assets/reference"), override = meta)
withr::local_envvar(new = c(CI = "false"))
expect_warning(data_reference_index(pkg), "Topics missing")
withr::local_envvar(new = c(CI = "true"))
expect_error(data_reference_index(pkg), "Topics missing")
})

test_that("default reference includes all functions", {
Expand Down

0 comments on commit e1e46f2

Please sign in to comment.