diff --git a/R/build-articles.R b/R/build-articles.R index ceb406d93..d434233ad 100644 --- a/R/build-articles.R +++ b/R/build-articles.R @@ -371,7 +371,8 @@ data_articles_index <- function(pkg = ".") { if (length(missing) > 0) { cli::cli_abort( - "{length(missing)} vignette{?s} missing from index: {.file {missing}}.", + "{length(missing)} vignette{?s} missing from index in \\ + {pkgdown_config_href({pkg$src_path})}: {.val {missing}}.", call = caller_env() ) } diff --git a/R/build-favicons.R b/R/build-favicons.R index 066f4dfb7..ed137c686 100644 --- a/R/build-favicons.R +++ b/R/build-favicons.R @@ -32,7 +32,7 @@ build_favicons <- function(pkg = ".", overwrite = FALSE) { if (has_favicons(pkg) && !overwrite) { cli::cli_inform(c( "Favicons already exist in {.path pkgdown}", - "i" = "Set {.var overwrite = TRUE} to re-create." + "i" = "Set {.code overwrite = TRUE} to re-create." )) return(invisible()) } @@ -78,10 +78,7 @@ build_favicons <- function(pkg = ".", overwrite = FALSE) { result <- content$favicon_generation_result if (!identical(result$result$status, "success")) { - cli::cli_abort(c( - "API request failed.", - "i" = "{.href [Please submit a bug report](https://github.com/r-lib/pkgdown/issues)}" - )) + cli::cli_abort("API request failed.", .internal = TRUE) } tmp <- tempfile() diff --git a/R/build-reference-index.R b/R/build-reference-index.R index 1e0c3dfce..0abdd661a 100644 --- a/R/build-reference-index.R +++ b/R/build-reference-index.R @@ -1,4 +1,4 @@ -data_reference_index <- function(pkg = ".") { +data_reference_index <- function(pkg = ".", error_call = caller_env()) { pkg <- as_pkgdown(pkg) meta <- pkg$meta[["reference"]] %||% default_reference_index(pkg) @@ -13,7 +13,7 @@ data_reference_index <- function(pkg = ".") { has_icons <- purrr::some(rows, ~ .x$row_has_icons %||% FALSE) - check_missing_topics(rows, pkg) + check_missing_topics(rows, pkg, error_call = error_call) rows <- Filter(function(x) !x$is_internal, rows) print_yaml(list( @@ -125,7 +125,7 @@ default_reference_index <- function(pkg = ".") { )) } -check_missing_topics <- function(rows, pkg) { +check_missing_topics <- function(rows, pkg, error_call = caller_env()) { # Cross-reference complete list of topics vs. topics found in index page all_topics <- rows %>% purrr::map("names") %>% unlist(use.names = FALSE) in_index <- pkg$topics$name %in% all_topics @@ -133,11 +133,11 @@ check_missing_topics <- function(rows, pkg) { missing <- !in_index & !pkg$topics$internal if (any(missing)) { - topics <- paste0(pkg$topics$name[missing], collapse = ", ") - abort(c( + cli::cli_abort(c( "All topics must be included in reference index", - `x` = paste0("Missing topics: ", topics), - i = "Either add to _pkgdown.yml or use @keywords internal" - )) + "x" = "Missing topics: {pkg$topics$name[missing]}", + i = "Either add to {pkgdown_config_href({pkg$src_path})} or use @keywords internal" + ), + call = error_call) } } diff --git a/R/build.R b/R/build.R index f455f9b31..14afb5cf5 100644 --- a/R/build.R +++ b/R/build.R @@ -408,7 +408,7 @@ build_site_external <- function(pkg = ".", timeout = getOption('pkgdown.timeout', Inf) ) - cli::cli_rule(paste0("Finished building pkgdown site for package ", cli::col_blue(pkg$package))) + cli::cli_rule("Finished building pkgdown site for package {.pkg {pkg$package}}") preview_site(pkg, preview = preview) invisible() @@ -426,7 +426,7 @@ build_site_local <- function(pkg = ".", pkg <- section_init(pkg, depth = 0, override = override) - cli::cli_rule(paste0("Building pkgdown site for package ", cli::col_blue(pkg$package))) + cli::cli_rule("Building pkgdown site for package {.pkg {pkg$package}}") cli::cli_inform("Reading from: {src_path(path_abs(pkg$src_path))}") cli::cli_inform("Writing to: {dst_path(path_abs(pkg$dst_path))}") @@ -453,6 +453,6 @@ build_site_local <- function(pkg = ".", build_search(pkg, override = override) } - cli::cli_rule(paste0("Finished building pkgdown site for package ", cli::col_blue(pkg$package))) + cli::cli_rule("Finished building pkgdown site for package {.pkg {pkg$package}}") preview_site(pkg, preview = preview) } diff --git a/R/check.R b/R/check.R index 49a1154df..1858ab454 100644 --- a/R/check.R +++ b/R/check.R @@ -12,6 +12,7 @@ check_pkgdown <- function(pkg = ".") { data_articles_index(pkg) data_reference_index(pkg) - cli::cli_alert_success("No problems found in {.file {pkgdown_config_relpath(pkg)}}") + cli::cli_inform(c( + "v" = "No problems found in {pkgdown_config_href({pkg$src_path})}" + )) } - diff --git a/R/package.R b/R/package.R index 415baf2ef..dfaa04659 100644 --- a/R/package.R +++ b/R/package.R @@ -129,6 +129,12 @@ pkgdown_config_path <- function(path) { ) ) } +pkgdown_config_href <- function(path) { + cli::style_hyperlink( + text = "_pkgdown.yml", + url = paste0("file://", pkgdown_config_path(path)) + ) +} read_meta <- function(path) { path <- pkgdown_config_path(path) diff --git a/tests/testthat/_snaps/build-reference-index.md b/tests/testthat/_snaps/build-reference-index.md index 13a43f0e2..892130a08 100644 --- a/tests/testthat/_snaps/build-reference-index.md +++ b/tests/testthat/_snaps/build-reference-index.md @@ -50,9 +50,9 @@ Code data_reference_index(pkg) Condition - Error in `check_missing_topics()`: + Error: ! All topics must be included in reference index - x Missing topics: c, e, ? + x Missing topics: c, e, and ? i Either add to _pkgdown.yml or use @keywords internal # errors well when a content entry is empty diff --git a/tests/testthat/_snaps/check.md b/tests/testthat/_snaps/check.md index d90010d88..f1e4bb125 100644 --- a/tests/testthat/_snaps/check.md +++ b/tests/testthat/_snaps/check.md @@ -3,7 +3,7 @@ Code check_pkgdown(pkg) Condition - Error in `check_missing_topics()`: + Error in `check_pkgdown()`: ! All topics must be included in reference index x Missing topics: ? i Either add to _pkgdown.yml or use @keywords internal @@ -14,10 +14,12 @@ check_pkgdown(pkg) Condition Error in `check_pkgdown()`: - ! 2 vignettes missing from index: 'articles/nested' and 'width'. + ! 2 vignettes missing from index in _pkgdown.yml: "articles/nested" and "width". # informs if everything is ok Code check_pkgdown(pkg) + Message + v No problems found in _pkgdown.yml