diff --git a/R/build-home-authors.R b/R/build-home-authors.R
index 79fbdf72e..beb5dfb98 100644
--- a/R/build-home-authors.R
+++ b/R/build-home-authors.R
@@ -56,12 +56,12 @@ data_home_sidebar_authors <- function(pkg = ".") {
bullets <- c(
markdown_text_inline(
pkg$meta$authors$sidebar$before,
- pkgdown_field(pkg, c("authors", "sidebar", "before"))
+ pkgdown_field(c("authors", "sidebar", "before"))
),
authors,
markdown_text_inline(
pkg$meta$authors$sidebar$after,
- pkgdown_field(pkg, c("authors", "sidebar", "after"))
+ pkgdown_field(c("authors", "sidebar", "after"))
)
)
@@ -96,7 +96,7 @@ author_name <- function(x, authors, pkg) {
if (!is.null(author$html)) {
name <- markdown_text_inline(
author$html,
- pkgdown_field(pkg, c("authors", name, "html"))
+ pkgdown_field(c("authors", name, "html"))
)
}
@@ -186,8 +186,8 @@ role_lookup <- function(abbr) {
out <- unname(roles[abbr])
if (any(is.na(out))) {
- missing <- paste0("'", abbr[is.na(out)], "'", collapse = ", ")
- cli::cli_alert_warning("Unknown MARC role abbreviation{?s}: {missing}")
+ missing <- abbr[is.na(out)]
+ cli::cli_warn("Unknown MARC role abbreviation{?s}: {.field {missing}}")
out[is.na(out)] <- abbr[is.na(out)]
}
out
diff --git a/R/build-home-index.R b/R/build-home-index.R
index d98249a30..f9d14daf8 100644
--- a/R/build-home-index.R
+++ b/R/build-home-index.R
@@ -64,9 +64,12 @@ data_home_sidebar <- function(pkg = ".") {
if (length(html_path)) {
if (!file.exists(html_path)) {
- cli::cli_abort(
- "Can't find file {.file {html_path}} specified by {pkgdown_field(pkg, c('home', 'sidebar', 'html'))}"
- )
+ rel_html_path <- fs::path_rel(html_path, pkg$src_path)
+ rel_config_path <- pkgdown_config_relpath(pkg)
+ cli::cli_abort(c(
+ "Can't locate {.file {rel_html_path}}",
+ "x" = "{.field {pkgdown_field(c('home', 'sidebar', 'html'))}} in {.file {rel_config_path}} is misconfigured"
+ ))
}
return(read_file(html_path))
}
diff --git a/R/build-redirects.R b/R/build-redirects.R
index 9e7307af4..30d1f843b 100644
--- a/R/build-redirects.R
+++ b/R/build-redirects.R
@@ -26,7 +26,7 @@ build_redirects <- function(pkg = ".",
build_redirect <- function(entry, index, pkg) {
if (!is.character(entry) || length(entry) != 2) {
cli::cli_abort(
- "Entry {.emph index} in {pkgdown_field(pkg, 'redirects')} must be a character vector of length 2.",
+ "Entry {.emph {index}} in {.field {pkgdown_field('redirects')}} must be a character vector of length 2.",
)
}
diff --git a/R/build-reference-index.R b/R/build-reference-index.R
index d8e4df7e5..fc2173ed9 100644
--- a/R/build-reference-index.R
+++ b/R/build-reference-index.R
@@ -69,17 +69,10 @@ check_all_characters <- function(contents, index, pkg) {
any_null <- any(null)
if (any_null) {
- abort(
- c(
- sprintf(
- "Item %s in section %s in %s is empty.",
- toString(which(null)),
- index,
- pkgdown_field(pkg, "reference")
- ),
- i = "Either delete the empty line or add a function name."
- )
- )
+ cli::cli_abort(c(
+ "Item {.field {which(null)}} in section {index} in {.field {pkgdown_field('reference')}} is empty.",
+ i = "Either delete the empty line or add a function name in {.file {pkgdown_config_relpath(pkg)}}."
+ ))
}
not_char <- !purrr::map_lgl(contents, is.character)
@@ -89,17 +82,10 @@ check_all_characters <- function(contents, index, pkg) {
return(invisible())
}
- abort(
- c(
- sprintf(
- "Item %s in section %s in %s must be a character.",
- toString(which(not_char)),
- index,
- pkgdown_field(pkg, "reference")
- ),
- i = "You might need to add '' around e.g. - 'N' or - 'off'."
- )
- )
+ cli::cli_abort(c(
+ "Item {.field {which(not_char)}} in section {index} in {.field {pkgdown_field('reference')}} must be a character.",
+ i = "You might need to add '' around e.g. - 'N' or - 'off' in {.file {pkgdown_config_relpath(pkg)}}."
+ ))
}
diff --git a/R/package.R b/R/package.R
index 0f06e3401..b80dc3cd3 100644
--- a/R/package.R
+++ b/R/package.R
@@ -103,10 +103,10 @@ check_bootstrap_version <- function(version, pkg = list()) {
cli::cli_warn("{.var bootstrap: 4} no longer supported, using {.var bootstrap: 5} instead")
5
} else {
- field <- pkgdown_field(pkg, c("template", "bootstrap"))
+ field <- pkgdown_field(c("template", "bootstrap"))
cli::cli_abort(c(
"Boostrap version must be 3 or 5.",
- "x" = "You specified a value of {.var {version}} in {.var {field}}"
+ "x" = "You specified a value of {.var {version}} in {.field {field}}."
))
}
}
diff --git a/R/rd-example.R b/R/rd-example.R
index d3f1e8566..25180bd45 100644
--- a/R/rd-example.R
+++ b/R/rd-example.R
@@ -65,7 +65,7 @@ process_conditional_examples <- function(rd) {
if (!is_false) {
new_cond <- paste0("if (FALSE) { # ", cond_expr_str)
cli::cli_warn(
- "@examplesIf condition {.var cond_expr_str} FALSE"
+ "@examplesIf condition {.var cond_expr_str} is FALSE"
)
} else {
new_cond <- "if (FALSE) {"
diff --git a/R/rd-html.R b/R/rd-html.R
index 03a404c67..397fef055 100644
--- a/R/rd-html.R
+++ b/R/rd-html.R
@@ -130,7 +130,7 @@ as_html.tag_deqn <- function(x, ...) {
as_html.tag_url <- function(x, ...) {
if (length(x) != 1) {
if (length(x) == 0) {
- msg <- "Check for empty \\url{} tags."
+ msg <- "Check for empty \\url{{}} tags."
} else {
msg <- "This may be caused by a \\url tag that spans a line break."
}
@@ -229,7 +229,7 @@ as_html.tag_Sexpr <- function(x, ...) {
text = as.character(res),
rd = flatten_text(rd_text(as.character(res))),
hide = "",
- cli::cli_abort("\\Sexpr{result=", results, "} not yet supported", call. = FALSE)
+ cli::cli_abort("\\Sexpr{result=", results, "} not yet supported")
)
}
@@ -565,7 +565,7 @@ parse_opts <- function(string) {
}
stop_bad_tag <- function(tag, msg = NULL) {
- bad_tag <- paste0("\\\\", tag, "{}")
+ bad_tag <- paste0("\\", tag, "{}")
msg_abort <- 'Failed to parse tag {.var {bad_tag}}.'
if (!is.null(msg)) {
msg_abort <- c(msg_abort, "x" = msg)
diff --git a/R/sitrep.R b/R/sitrep.R
index ebdcc9f71..f88d9f039 100644
--- a/R/sitrep.R
+++ b/R/sitrep.R
@@ -17,13 +17,13 @@ pkgdown_sitrep <- function(pkg = ".") {
warns <- c()
if (is.null(pkg$meta[["url"]])) {
- warns <- c(warns, "x" = "{pkgdown_field(pkg, 'url')} is not configured. See vignette {.vignette pkgdown::metatdata}.")
+ warns <- c(warns, "x" = "{pkgdown_field('url')} is not configured in {.file {pkgdown_config_relpath(pkg)}}. See vignette {.vignette pkgdown::metatdata}.")
}
desc_urls <- pkg$desc$get_urls()
- desc_urls <- sub("/$", "", urls)
- if (!pkg$meta[["url"]] %in% desc_urls) {
- warns <- c(warns, "x" = "DESCRIPTION {.field URL} is empty.")
+ desc_urls <- sub("/$", "", desc_urls)
+ if (length(desc_urls) == 0 || !pkg$meta[["url"]] %in% desc_urls) {
+ warns <- c(warns, "x" = "{.file DESCRIPTION} {.field URL} is empty.")
}
if (length(warns) == 0) {
diff --git a/R/theme.R b/R/theme.R
index a4232cfc9..6d90e4d73 100644
--- a/R/theme.R
+++ b/R/theme.R
@@ -105,9 +105,9 @@ check_bootswatch_theme <- function(bootswatch_theme, bs_version, pkg) {
sprintf(
"Can't find Bootswatch theme '%s' (%s) for Bootstrap version '%s' (%s).",
bootswatch_theme,
- pkgdown_field(pkg, c("template", "bootswatch")),
+ pkgdown_field(c("template", "bootswatch")),
bs_version,
- pkgdown_field(pkg, c("template", "bootstrap"))
+ pkgdown_field(c("template", "bootstrap"))
)
)
}
diff --git a/R/topics-external.R b/R/topics-external.R
index 312f0afa9..e0d6620a9 100644
--- a/R/topics-external.R
+++ b/R/topics-external.R
@@ -30,7 +30,7 @@ get_rd_from_help <- function(package, alias) {
help <- utils::help((alias), (package))
if (length(help) == 0) {
fun <- paste0(package, "::", alias)
- cli::cli_abort("Could not find documentation for {.fn fun}.")
+ cli::cli_abort("Could not find documentation for {.fn {fun}}.")
return()
}
diff --git a/R/utils-yaml.R b/R/utils-yaml.R
index c5799abaf..04b6e5596 100644
--- a/R/utils-yaml.R
+++ b/R/utils-yaml.R
@@ -4,10 +4,10 @@ check_yaml_has <- function(missing, where, pkg) {
}
missing_components <- lapply(missing, function(x) c(where, x))
- missing_fields <- pkgdown_fields(pkg, missing_components)
+ missing_fields <- purrr::map_chr(missing_components, pkgdown_field)
cli::cli_abort(
- "Can't find components: {missing_fields}."
+ "Can't find {.field {missing_fields}} component{?s} in {.file {pkgdown_config_relpath(pkg)}}."
)
}
@@ -19,27 +19,13 @@ yaml_character <- function(pkg, where) {
} else if (is.character(x)) {
x
} else {
- fld <- pkgdown_field(pkg, where)
+ fld <- pkgdown_field(where)
cli::cli_abort("{fld} must be a character vector")
}
}
-pkgdown_field <- function(pkg, field) {
- pkgdown_fields(pkg, list(field))
-}
-
-pkgdown_fields <- function(pkg, fields, join = ", ") {
- fields <- purrr::map_chr(fields, ~ paste0(cli::style_bold(.x), collapse = "."))
- fields_str <- paste0(fields, collapse = join)
-
- config_path <- pkgdown_config_path(pkg$src_path)
-
- if (is.null(config_path)) {
- fields_str
- } else {
- config <- src_path(pkgdown_config_relpath(pkg))
- paste0('`', fields_str, "` in ", config)
- }
+pkgdown_field <- function(fields) {
+ purrr::map_chr(list(fields), ~ paste0(.x, collapse = "."))
}
# print helper ------------------------------------------------------------
diff --git a/tests/testthat/_snaps/build-articles.md b/tests/testthat/_snaps/build-articles.md
index c3626334b..0488d2eb7 100644
--- a/tests/testthat/_snaps/build-articles.md
+++ b/tests/testthat/_snaps/build-articles.md
@@ -1,16 +1,116 @@
-# warns about missing images
+# links to man/figures are automatically relocated
+
+ Code
+ copy_figures(pkg)
+
+---
+
+ Code
+ build_articles(pkg, lazy = FALSE)
+
+# warns about missing images [plain]
Code
build_articles(pkg)
- Message
-
- -- Building articles --
-
- i Writing articles/index.html
- i Reading vignettes/html-vignette.Rmd
- i Writing articles/html-vignette.html
Condition
Warning:
Missing images in 'vignettes/html-vignette.Rmd': 'foo.png'
i pkgdown can only use images in 'man/figures' and 'vignettes'
+# warns about missing images [ansi]
+
+ Code
+ build_articles(pkg)
+ Condition
+ [1m[33mWarning[39m:[22m
+ [1m[22mMissing images in [34mvignettes/html-vignette.Rmd[39m: [34mfoo.png[39m
+ [36mi[39m pkgdown can only use images in [34mman/figures[39m and [34mvignettes[39m
+
+# warns about missing images [unicode]
+
+ Code
+ build_articles(pkg)
+ Condition
+ Warning:
+ Missing images in 'vignettes/html-vignette.Rmd': 'foo.png'
+ ℹ pkgdown can only use images in 'man/figures' and 'vignettes'
+
+# warns about missing images [fancy]
+
+ Code
+ build_articles(pkg)
+ Condition
+ [1m[33mWarning[39m:[22m
+ [1m[22mMissing images in [34mvignettes/html-vignette.Rmd[39m: [34mfoo.png[39m
+ [36mℹ[39m pkgdown can only use images in [34mman/figures[39m and [34mvignettes[39m
+
+# articles don't include header-attrs.js script
+
+ Code
+ path <- build_article("standard", pkg)
+
+# can build article that uses html_vignette
+
+ Code
+ expect_error(build_article("html-vignette", pkg), NA)
+
+# can override html_document() options
+
+ Code
+ path <- build_article("html-document", pkg)
+
+# html widgets get needed css/js
+
+ Code
+ path <- build_article("widget", pkg)
+
+# can override options with _output.yml
+
+ Code
+ path <- build_article("html-document", pkg)
+
+# can set width
+
+ Code
+ path <- build_article("width", pkg)
+
+# finds external resources referenced by R code in the article html
+
+ Code
+ path <- build_article("resources", pkg)
+
+# BS5 article laid out correctly with and without TOC
+
+ Code
+ init_site(pkg)
+
+---
+
+ Code
+ toc_true_path <- build_article("standard", pkg)
+
+---
+
+ Code
+ toc_false_path <- build_article("toc-false", pkg)
+
+# articles in vignettes/articles/ are unnested into articles/
+
+ Code
+ path <- build_article("articles/nested", pkg)
+
+---
+
+ Code
+ build_redirects(pkg)
+
+# pkgdown deps are included only once in articles
+
+ Code
+ init_site(pkg)
+
+---
+
+ Code
+ path <- build_article("html-deps", pkg)
+
diff --git a/tests/testthat/_snaps/build-favicons.md b/tests/testthat/_snaps/build-favicons.md
index 8d68d02b0..21f970cf1 100644
--- a/tests/testthat/_snaps/build-favicons.md
+++ b/tests/testthat/_snaps/build-favicons.md
@@ -2,8 +2,7 @@
Code
build_favicons(pkg)
- Output
- -- Building favicons -----------------------------------------------------------
Message
- Favicons already exist in `pkgdown/`. Set `overwrite = TRUE` to re-create.
+ Favicons already exist in 'pkgdown'
+ i Set `overwrite = TRUE` to re-create.
diff --git a/tests/testthat/_snaps/build-favicons.new.md b/tests/testthat/_snaps/build-favicons.new.md
deleted file mode 100644
index c1426593b..000000000
--- a/tests/testthat/_snaps/build-favicons.new.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# existing logo generates message
-
- Code
- build_favicons(pkg)
- Message
- -- Building favicons -----------------------------------------------------------
- Favicons already exist in 'pkgdown'
- i Set `overwrite = TRUE` to re-create.
-
diff --git a/tests/testthat/_snaps/build-github.md b/tests/testthat/_snaps/build-github.md
new file mode 100644
index 000000000..461afc69a
--- /dev/null
+++ b/tests/testthat/_snaps/build-github.md
@@ -0,0 +1,5 @@
+# a CNAME record is built if a url exists in metadata
+
+ Code
+ build_github_pages(pkg)
+
diff --git a/tests/testthat/_snaps/build-home-authors.md b/tests/testthat/_snaps/build-home-authors.md
index 46755f61b..c6429c32c 100644
--- a/tests/testthat/_snaps/build-home-authors.md
+++ b/tests/testthat/_snaps/build-home-authors.md
@@ -16,13 +16,43 @@
-# role has multiple fallbacks
+# role has multiple fallbacks [plain]
Code
role_lookup("unknown")
Condition
Warning:
- Unknown MARC role abbreviation 'unknown'
+ Unknown MARC role abbreviation: unknown
+ Output
+ [1] "unknown"
+
+# role has multiple fallbacks [ansi]
+
+ Code
+ role_lookup("unknown")
+ Condition
+ [1m[33mWarning[39m:[22m
+ [1m[22mUnknown MARC role abbreviation: [32munknown[39m
+ Output
+ [1] "unknown"
+
+# role has multiple fallbacks [unicode]
+
+ Code
+ role_lookup("unknown")
+ Condition
+ Warning:
+ Unknown MARC role abbreviation: unknown
+ Output
+ [1] "unknown"
+
+# role has multiple fallbacks [fancy]
+
+ Code
+ role_lookup("unknown")
+ Condition
+ [1m[33mWarning[39m:[22m
+ [1m[22mUnknown MARC role abbreviation: [32munknown[39m
Output
[1] "unknown"
diff --git a/tests/testthat/_snaps/build-home-authors.new.md b/tests/testthat/_snaps/build-home-authors.new.md
deleted file mode 100644
index 5de8ba248..000000000
--- a/tests/testthat/_snaps/build-home-authors.new.md
+++ /dev/null
@@ -1,27 +0,0 @@
-# data_home_sidebar_authors() works with text
-
- Code
- cat(data_home_sidebar_authors(pkg))
- Output
-
-
Developers
-
- - yay
- - Hadley Wickham
- Author, maintainer
- - RStudio
- Copyright holder, funder
- - cool
- - More about authors...
-
-
-
-# role has multiple fallbacks
-
- Code
- role_lookup("unknown")
- Message
- ! Unknown MARC role abbreviation: 'unknown'
- Output
- [1] "unknown"
-
diff --git a/tests/testthat/_snaps/build-home-citation.md b/tests/testthat/_snaps/build-home-citation.md
index 220471332..7910dda4e 100644
--- a/tests/testthat/_snaps/build-home-citation.md
+++ b/tests/testthat/_snaps/build-home-citation.md
@@ -1,3 +1,8 @@
+# source link is added to citation page
+
+ Code
+ build_home(pkg)
+
# multiple citations all have HTML and BibTeX formats
[[1]]
diff --git a/tests/testthat/_snaps/build-home-index.md b/tests/testthat/_snaps/build-home-index.md
index 4e33fc563..37e018779 100644
--- a/tests/testthat/_snaps/build-home-index.md
+++ b/tests/testthat/_snaps/build-home-index.md
@@ -1,3 +1,8 @@
+# version formatting in preserved
+
+ Code
+ init_site(pkg)
+
# data_home_sidebar() works by default
Code
@@ -48,7 +53,8 @@
# data_home_sidebar() errors well when no HTML file
- Can't find file 'file.html' specified by home.sidebar.html in '_pkgdown.yml'.
+ Can't locate 'file.html'
+ x home.sidebar.html in '_pkgdown.yml' is misconfigured
# data_home_sidebar() can get a custom markdown formatted component
@@ -70,23 +76,23 @@
# data_home_sidebar() outputs informative error messages
- Can't find component home.sidebar.components.fancy in '_pkgdown.yml'.
+ Can't find home.sidebar.components.fancy component in '_pkgdown.yml'.
---
- Can't find components home.sidebar.components.fancy, home.sidebar.components.cool in '_pkgdown.yml'.
+ Can't find home.sidebar.components.fancy and home.sidebar.components.cool components in '_pkgdown.yml'.
---
i In index: 1.
i With name: fancy.
Caused by error in `check_yaml_has()`:
- ! Can't find component home.sidebar.components.fancy.title in '_pkgdown.yml'.
+ ! Can't find home.sidebar.components.fancy.title component in '_pkgdown.yml'.
---
i In index: 1.
i With name: fancy.
Caused by error in `check_yaml_has()`:
- ! Can't find components home.sidebar.components.fancy.title, home.sidebar.components.fancy.text in '_pkgdown.yml'.
+ ! Can't find home.sidebar.components.fancy.title and home.sidebar.components.fancy.text components in '_pkgdown.yml'.
diff --git a/tests/testthat/_snaps/build-home-index.new.md b/tests/testthat/_snaps/build-home-index.new.md
deleted file mode 100644
index 875903a65..000000000
--- a/tests/testthat/_snaps/build-home-index.new.md
+++ /dev/null
@@ -1,92 +0,0 @@
-# data_home_sidebar() works by default
-
- Code
- cat(data_home_sidebar(pkg))
- Output
-
-
-
-
-
-
-
Developers
-
- - Hadley Wickham
- Author, maintainer
- - RStudio
- Copyright holder, funder
-
-
-
-
-
----
-
-
-
-# data_home_sidebar() errors well when no HTML file
-
- Can't find file 'html_path' specified by home.sidebar.html in _pkgdown.yml
-
-# data_home_sidebar() can get a custom markdown formatted component
-
-
-
Fancy section
-
- How cool is pkgdown?!
-
-
-
-# data_home_sidebar() can add a README
-
-
-
-# data_home_sidebar() outputs informative error messages
-
- Can't find component home.sidebar.components.fancy in _pkgdown.yml.
-
----
-
- Can't find component home.sidebar.components.fancy, home.sidebar.components.cool in _pkgdown.yml.
-
----
-
- i In index: 1.
- i With name: fancy.
- Caused by error in `check_yaml_has()`:
- ! Can't find component home.sidebar.components.fancy.title in _pkgdown.yml.
-
----
-
- i In index: 1.
- i With name: fancy.
- Caused by error in `check_yaml_has()`:
- ! Can't find component home.sidebar.components.fancy.title, home.sidebar.components.fancy.text in _pkgdown.yml.
-
diff --git a/tests/testthat/_snaps/build-home.md b/tests/testthat/_snaps/build-home.md
index 022d951c2..e95c93c19 100644
--- a/tests/testthat/_snaps/build-home.md
+++ b/tests/testthat/_snaps/build-home.md
@@ -1,14 +1,56 @@
-# warns about missing images
+# intermediate files cleaned up automatically
+
+ Code
+ build_home(pkg)
+
+---
+
+ Code
+ build_home(pkg)
+
+# warns about missing images [plain]
Code
build_home(pkg)
- Output
- -- Building home ---------------------------------------------------------------
- Writing 'authors.html'
Condition
Warning:
Missing images in 'README.md': 'foo.png'
i pkgdown can only use images in 'man/figures' and 'vignettes'
- Output
- Writing '404.html'
+
+# warns about missing images [ansi]
+
+ Code
+ build_home(pkg)
+ Condition
+ [1m[33mWarning[39m:[22m
+ [1m[22mMissing images in [34mREADME.md[39m: [34mfoo.png[39m
+ [36mi[39m pkgdown can only use images in [34mman/figures[39m and [34mvignettes[39m
+
+# warns about missing images [unicode]
+
+ Code
+ build_home(pkg)
+ Condition
+ Warning:
+ Missing images in 'README.md': 'foo.png'
+ ℹ pkgdown can only use images in 'man/figures' and 'vignettes'
+
+# warns about missing images [fancy]
+
+ Code
+ build_home(pkg)
+ Condition
+ [1m[33mWarning[39m:[22m
+ [1m[22mMissing images in [34mREADME.md[39m: [34mfoo.png[39m
+ [36mℹ[39m pkgdown can only use images in [34mman/figures[39m and [34mvignettes[39m
+
+# can build site even if no Authors@R present
+
+ Code
+ build_home(pkg)
+
+# .github files are copied and linked
+
+ Code
+ build_home(pkg)
diff --git a/tests/testthat/_snaps/build-home.new.md b/tests/testthat/_snaps/build-home.new.md
deleted file mode 100644
index 028a3674e..000000000
--- a/tests/testthat/_snaps/build-home.new.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# warns about missing images
-
- Code
- build_home(pkg)
- Message
- -- Building home ---------------------------------------------------------------
- Output
- Writing {path}
- Condition
- Warning:
- Missing images in `src_path`: ''foo.png''
- i pkgdown can only use images in 'man/figures' and 'vignettes'
- Output
- Writing {path}
-
diff --git a/tests/testthat/_snaps/build-logo.md b/tests/testthat/_snaps/build-logo.md
index 6064320d3..86a7316f9 100644
--- a/tests/testthat/_snaps/build-logo.md
+++ b/tests/testthat/_snaps/build-logo.md
@@ -1,7 +1,20 @@
-# can handle logo in subdir
+# can handle logo in subdir [plain]
+
+ Code
+ copy_logo(pkg)
+
+# can handle logo in subdir [ansi]
+
+ Code
+ copy_logo(pkg)
+
+# can handle logo in subdir [unicode]
+
+ Code
+ copy_logo(pkg)
+
+# can handle logo in subdir [fancy]
Code
copy_logo(pkg)
- Output
- Copying 'man/figures/logo.svg' to 'logo.svg'
diff --git a/tests/testthat/_snaps/build-news.md b/tests/testthat/_snaps/build-news.md
index 7317c2bec..504a4b369 100644
--- a/tests/testthat/_snaps/build-news.md
+++ b/tests/testthat/_snaps/build-news.md
@@ -14,15 +14,77 @@
1 1.0.0.9000 dev testpackage-1009000
2 1.0.0 1.0 testpackage-100
-# multi-page news are rendered
+# multi-page news are rendered [plain]
- # A tibble: 4 x 3
- version page anchor
-
- 1 2.0 2.0 testpackage-20
- 2 1.1 1.1 testpackage-11
- 3 1.0.1 1.0 testpackage-101
- 4 1.0.0 1.0 testpackage-100
+ Code
+ data_news(pkg)[c("version", "page", "anchor")]
+ Output
+ # A tibble: 4 x 3
+ version page anchor
+
+ 1 2.0 2.0 testpackage-20
+ 2 1.1 1.1 testpackage-11
+ 3 1.0.1 1.0 testpackage-101
+ 4 1.0.0 1.0 testpackage-100
+
+---
+
+ Code
+ build_news(pkg)
+
+# multi-page news are rendered [ansi]
+
+ Code
+ data_news(pkg)[c("version", "page", "anchor")]
+ Output
+ [90m# A tibble: 4 x 3[39m
+ version page anchor
+ [3m[90m[39m[23m [3m[90m[39m[23m [3m[90m[39m[23m
+ [90m1[39m 2.0 2.0 testpackage-20
+ [90m2[39m 1.1 1.1 testpackage-11
+ [90m3[39m 1.0.1 1.0 testpackage-101
+ [90m4[39m 1.0.0 1.0 testpackage-100
+
+---
+
+ Code
+ build_news(pkg)
+
+# multi-page news are rendered [unicode]
+
+ Code
+ data_news(pkg)[c("version", "page", "anchor")]
+ Output
+ # A tibble: 4 × 3
+ version page anchor
+
+ 1 2.0 2.0 testpackage-20
+ 2 1.1 1.1 testpackage-11
+ 3 1.0.1 1.0 testpackage-101
+ 4 1.0.0 1.0 testpackage-100
+
+---
+
+ Code
+ build_news(pkg)
+
+# multi-page news are rendered [fancy]
+
+ Code
+ data_news(pkg)[c("version", "page", "anchor")]
+ Output
+ [90m# A tibble: 4 × 3[39m
+ version page anchor
+ [3m[90m[39m[23m [3m[90m[39m[23m [3m[90m[39m[23m
+ [90m1[39m 2.0 2.0 testpackage-20
+ [90m2[39m 1.1 1.1 testpackage-11
+ [90m3[39m 1.0.1 1.0 testpackage-101
+ [90m4[39m 1.0.0 1.0 testpackage-100
+
+---
+
+ Code
+ build_news(pkg)
# news headings get class and release date
@@ -43,13 +105,13 @@
Invalid NEWS.md: inconsistent use of section headings.
i Top-level headings must be either all or all .
- i See ?build_news for more details.
+ i See `?pkgdown::build_news()` for more details.
# clear error for bad hierarchy - h3
Invalid NEWS.md: inconsistent use of section headings.
i Top-level headings must be either all or all .
- i See ?build_news for more details.
+ i See `?pkgdown::build_news()` for more details.
# news can contain footnotes
diff --git a/tests/testthat/_snaps/build-reference-index.md b/tests/testthat/_snaps/build-reference-index.md
index d595dc877..aed65b432 100644
--- a/tests/testthat/_snaps/build-reference-index.md
+++ b/tests/testthat/_snaps/build-reference-index.md
@@ -59,31 +59,148 @@
i In index: 1.
Caused by error in `check_all_characters()`:
- ! Item 2 in section 1 in reference in '_pkgdown.yml' is empty.
- i Either delete the empty line or add a function name.
+ ! Item 2 in section 1 in reference is empty.
+ i Either delete the empty line or add a function name in '_pkgdown.yml'.
-# errors well when a content entry is not a character
+# errors well when a content entry is not a character [plain]
- i In index: 1.
- Caused by error in `check_all_characters()`:
- ! Item 2 in section 1 in reference in '_pkgdown.yml' must be a character.
- i You might need to add '' around e.g. - 'N' or - 'off'.
+ Code
+ build_reference_index(pkg)
+ Condition
+ Error in `map2()`:
+ i In index: 1.
+ Caused by error in `check_all_characters()`:
+ ! Item 2 in section 1 in reference must be a character.
+ i You might need to add '' around e.g. - 'N' or - 'off' in '_pkgdown.yml'.
-# errors well when a content entry refers to a not installed package
+# errors well when a content entry is not a character [ansi]
- i In index: 1.
- Caused by error in `purrr::map2()`:
- i In index: 1.
- Caused by error in `.f()`:
- ! The package "notapackage" is required as it's used in the reference index.
+ Code
+ build_reference_index(pkg)
+ Condition
+ [1m[33mError[39m in `map2()`:[22m
+ [1m[22m[36mi[39m In index: 1.
+ [1mCaused by error in `check_all_characters()`:[22m
+ [1m[22m[33m![39m Item [32m2[39m in section 1 in [32mreference[39m must be a character.
+ [36mi[39m You might need to add '' around e.g. - 'N' or - 'off' in [34m_pkgdown.yml[39m.
-# errors well when a content entry refers to a non existing function
+# errors well when a content entry is not a character [unicode]
- i In index: 1.
- Caused by error in `purrr::map2()`:
- i In index: 1.
- Caused by error in `.f()`:
- ! Could not find documentation for rlang::lala
+ Code
+ build_reference_index(pkg)
+ Condition
+ Error in `map2()`:
+ ℹ In index: 1.
+ Caused by error in `check_all_characters()`:
+ ! Item 2 in section 1 in reference must be a character.
+ ℹ You might need to add '' around e.g. - 'N' or - 'off' in '_pkgdown.yml'.
+
+# errors well when a content entry is not a character [fancy]
+
+ Code
+ build_reference_index(pkg)
+ Condition
+ [1m[33mError[39m in `map2()`:[22m
+ [1m[22m[36mℹ[39m In index: 1.
+ [1mCaused by error in `check_all_characters()`:[22m
+ [1m[22m[33m![39m Item [32m2[39m in section 1 in [32mreference[39m must be a character.
+ [36mℹ[39m You might need to add '' around e.g. - 'N' or - 'off' in [34m_pkgdown.yml[39m.
+
+# errors well when a content entry refers to a not installed package [plain]
+
+ Code
+ build_reference_index(pkg)
+ Condition
+ Error in `map2()`:
+ i In index: 1.
+ Caused by error in `purrr::map2()`:
+ i In index: 1.
+ Caused by error in `.f()`:
+ ! The package "notapackage" is required as it's used in the reference index.
+
+# errors well when a content entry refers to a not installed package [ansi]
+
+ Code
+ build_reference_index(pkg)
+ Condition
+ [1m[33mError[39m in `map2()`:[22m
+ [1m[22m[36mi[39m In index: 1.
+ [1mCaused by error in `purrr::map2()`:[22m
+ [1m[22m[36mi[39m In index: 1.
+ [1mCaused by error in `.f()`:[22m
+ [1m[22m[33m![39m The package "notapackage" is required as it's used in the reference index.
+
+# errors well when a content entry refers to a not installed package [unicode]
+
+ Code
+ build_reference_index(pkg)
+ Condition
+ Error in `map2()`:
+ ℹ In index: 1.
+ Caused by error in `purrr::map2()`:
+ ℹ In index: 1.
+ Caused by error in `.f()`:
+ ! The package "notapackage" is required as it's used in the reference index.
+
+# errors well when a content entry refers to a not installed package [fancy]
+
+ Code
+ build_reference_index(pkg)
+ Condition
+ [1m[33mError[39m in `map2()`:[22m
+ [1m[22m[36mℹ[39m In index: 1.
+ [1mCaused by error in `purrr::map2()`:[22m
+ [1m[22m[36mℹ[39m In index: 1.
+ [1mCaused by error in `.f()`:[22m
+ [1m[22m[33m![39m The package "notapackage" is required as it's used in the reference index.
+
+# errors well when a content entry refers to a non existing function [plain]
+
+ Code
+ build_reference_index(pkg)
+ Condition
+ Error in `map2()`:
+ i In index: 1.
+ Caused by error in `purrr::map2()`:
+ i In index: 1.
+ Caused by error in `.f()`:
+ ! Could not find documentation for `rlang::lala()`.
+
+# errors well when a content entry refers to a non existing function [ansi]
+
+ Code
+ build_reference_index(pkg)
+ Condition
+ [1m[33mError[39m in `map2()`:[22m
+ [1m[22m[36mi[39m In index: 1.
+ [1mCaused by error in `purrr::map2()`:[22m
+ [1m[22m[36mi[39m In index: 1.
+ [1mCaused by error in `.f()`:[22m
+ [1m[22m[33m![39m Could not find documentation for `rlang::lala()`.
+
+# errors well when a content entry refers to a non existing function [unicode]
+
+ Code
+ build_reference_index(pkg)
+ Condition
+ Error in `map2()`:
+ ℹ In index: 1.
+ Caused by error in `purrr::map2()`:
+ ℹ In index: 1.
+ Caused by error in `.f()`:
+ ! Could not find documentation for `rlang::lala()`.
+
+# errors well when a content entry refers to a non existing function [fancy]
+
+ Code
+ build_reference_index(pkg)
+ Condition
+ [1m[33mError[39m in `map2()`:[22m
+ [1m[22m[36mℹ[39m In index: 1.
+ [1mCaused by error in `purrr::map2()`:[22m
+ [1m[22m[36mℹ[39m In index: 1.
+ [1mCaused by error in `.f()`:[22m
+ [1m[22m[33m![39m Could not find documentation for `rlang::lala()`.
# can use a topic from another package
diff --git a/tests/testthat/_snaps/build-reference.md b/tests/testthat/_snaps/build-reference.md
index 2190def0e..eff444709 100644
--- a/tests/testthat/_snaps/build-reference.md
+++ b/tests/testthat/_snaps/build-reference.md
@@ -1,11 +1,7 @@
-# parse failures include file name
+# parse failures include file name [plain]
Code
build_reference(pkg)
- Output
- -- Building function reference -------------------------------------------------
- Writing 'reference/index.html'
- Reading 'man/f.Rd'
Condition
Error in `purrr::map()`:
i In index: 1.
@@ -16,6 +12,187 @@
Caused by error in `purrr::map()`:
i In index: 4.
Caused by error in `stop_bad_tag()`:
- ! Failed to parse \url{}.
- i Check for empty \url{} tags.
+ ! Failed to parse tag `\url{}`.
+ x Check for empty \url{} tags.
+
+# parse failures include file name [ansi]
+
+ Code
+ build_reference(pkg)
+ Condition
+ [1m[33mError[39m in `purrr::map()`:[22m
+ [1m[22m[36mi[39m In index: 1.
+ [36mi[39m With name: f.Rd.
+ [1mCaused by error in `.f()`:[22m
+ [33m![39m Failed to parse Rd in f.Rd
+ In index: 4.
+ [1mCaused by error in `purrr::map()`:[22m
+ [1m[22m[36mi[39m In index: 4.
+ [1mCaused by error in `stop_bad_tag()`:[22m
+ [1m[22m[33m![39m Failed to parse tag `\url{}`.
+ [31mx[39m Check for empty \url{} tags.
+
+# parse failures include file name [unicode]
+
+ Code
+ build_reference(pkg)
+ Condition
+ Error in `purrr::map()`:
+ ℹ In index: 1.
+ ℹ With name: f.Rd.
+ Caused by error in `.f()`:
+ ! Failed to parse Rd in f.Rd
+ In index: 4.
+ Caused by error in `purrr::map()`:
+ ℹ In index: 4.
+ Caused by error in `stop_bad_tag()`:
+ ! Failed to parse tag `\url{}`.
+ ✖ Check for empty \url{} tags.
+
+# parse failures include file name [fancy]
+
+ Code
+ build_reference(pkg)
+ Condition
+ [1m[33mError[39m in `purrr::map()`:[22m
+ [1m[22m[36mℹ[39m In index: 1.
+ [36mℹ[39m With name: f.Rd.
+ [1mCaused by error in `.f()`:[22m
+ [33m![39m Failed to parse Rd in f.Rd
+ In index: 4.
+ [1mCaused by error in `purrr::map()`:[22m
+ [1m[22m[36mℹ[39m In index: 4.
+ [1mCaused by error in `stop_bad_tag()`:[22m
+ [1m[22m[33m![39m Failed to parse tag `\url{}`.
+ [31m✖[39m Check for empty \url{} tags.
+
+# test usage ok on rendered page [plain]
+
+ Code
+ build_reference(pkg, topics = "c")
+
+---
+
+ Code
+ init_site(pkg)
+
+---
+
+ Code
+ build_reference(pkg, topics = "c")
+
+# test usage ok on rendered page [ansi]
+
+ Code
+ build_reference(pkg, topics = "c")
+
+---
+
+ Code
+ init_site(pkg)
+
+---
+
+ Code
+ build_reference(pkg, topics = "c")
+
+# test usage ok on rendered page [unicode]
+
+ Code
+ build_reference(pkg, topics = "c")
+
+---
+
+ Code
+ init_site(pkg)
+
+---
+
+ Code
+ build_reference(pkg, topics = "c")
+
+# test usage ok on rendered page [fancy]
+
+ Code
+ build_reference(pkg, topics = "c")
+
+---
+
+ Code
+ init_site(pkg)
+
+---
+
+ Code
+ build_reference(pkg, topics = "c")
+
+# .Rd without usage doesn't get Usage section [plain]
+
+ Code
+ build_reference(pkg, topics = "e")
+
+---
+
+ Code
+ init_site(pkg)
+
+---
+
+ Code
+ build_reference(pkg, topics = "e")
+
+# .Rd without usage doesn't get Usage section [ansi]
+
+ Code
+ build_reference(pkg, topics = "e")
+
+---
+
+ Code
+ init_site(pkg)
+
+---
+
+ Code
+ build_reference(pkg, topics = "e")
+
+# .Rd without usage doesn't get Usage section [unicode]
+
+ Code
+ build_reference(pkg, topics = "e")
+
+---
+
+ Code
+ init_site(pkg)
+
+---
+
+ Code
+ build_reference(pkg, topics = "e")
+
+# .Rd without usage doesn't get Usage section [fancy]
+
+ Code
+ build_reference(pkg, topics = "e")
+
+---
+
+ Code
+ init_site(pkg)
+
+---
+
+ Code
+ build_reference(pkg, topics = "e")
+
+# pkgdown html dependencies are suppressed from examples in references
+
+ Code
+ init_site(pkg)
+
+---
+
+ Code
+ build_reference(pkg, topics = "a")
diff --git a/tests/testthat/_snaps/build-search-docs.md b/tests/testthat/_snaps/build-search-docs.md
new file mode 100644
index 000000000..d56d25c96
--- /dev/null
+++ b/tests/testthat/_snaps/build-search-docs.md
@@ -0,0 +1,45 @@
+# docsearch.json and sitemap.xml are valid
+
+ Code
+ build_site(pkg, new_process = FALSE)
+
+# build_search() builds the expected search`.json with an URL
+
+ Code
+ init_site(pkg)
+
+---
+
+ Code
+ build_news(pkg)
+
+---
+
+ Code
+ build_home(pkg)
+
+---
+
+ Code
+ build_sitemap(pkg)
+
+# build_search() builds the expected search.json with no URL
+
+ Code
+ init_site(pkg)
+
+---
+
+ Code
+ build_news(pkg)
+
+---
+
+ Code
+ build_home(pkg)
+
+---
+
+ Code
+ build_sitemap(pkg)
+
diff --git a/tests/testthat/_snaps/check.md b/tests/testthat/_snaps/check.md
index 0580cafd1..e75f065e3 100644
--- a/tests/testthat/_snaps/check.md
+++ b/tests/testthat/_snaps/check.md
@@ -1,4 +1,4 @@
-# fails if reference index incomplete
+# fails if reference index incomplete [plain]
Code
check_pkgdown(pkg)
@@ -8,18 +8,85 @@
x Missing topics: ?
i Either add to _pkgdown.yml or use @keywords internal
-# fails if article index incomplete
+# fails if reference index incomplete [ansi]
+
+ Code
+ check_pkgdown(pkg)
+ Condition
+ [1m[33mError[39m in `check_missing_topics()`:[22m
+ [33m![39m All topics must be included in reference index
+ [31mx[39m Missing topics: ?
+ [34mi[39m Either add to _pkgdown.yml or use @keywords internal
+
+# fails if reference index incomplete [unicode]
+
+ Code
+ check_pkgdown(pkg)
+ Condition
+ Error in `check_missing_topics()`:
+ ! All topics must be included in reference index
+ ✖ Missing topics: ?
+ ℹ Either add to _pkgdown.yml or use @keywords internal
+
+# fails if reference index incomplete [fancy]
+
+ Code
+ check_pkgdown(pkg)
+ Condition
+ [1m[33mError[39m in `check_missing_topics()`:[22m
+ [33m![39m All topics must be included in reference index
+ [31m✖[39m Missing topics: ?
+ [34mℹ[39m Either add to _pkgdown.yml or use @keywords internal
+
+# fails if article index incomplete [plain]
Code
check_pkgdown(pkg)
Condition
Error in `data_articles_index()`:
- ! Vignettes missing from index: articles/nested, width
+ ! Vignettes missing from index: articles/nested and width
+
+# fails if article index incomplete [ansi]
+
+ Code
+ check_pkgdown(pkg)
+ Condition
+ [1m[33mError[39m in `data_articles_index()`:[22m
+ [1m[22m[33m![39m Vignettes missing from index: articles/nested and width
+
+# fails if article index incomplete [unicode]
+
+ Code
+ check_pkgdown(pkg)
+ Condition
+ Error in `data_articles_index()`:
+ ! Vignettes missing from index: articles/nested and width
+
+# fails if article index incomplete [fancy]
+
+ Code
+ check_pkgdown(pkg)
+ Condition
+ [1m[33mError[39m in `data_articles_index()`:[22m
+ [1m[22m[33m![39m Vignettes missing from index: articles/nested and width
+
+# informs if everything is ok [plain]
+
+ Code
+ check_pkgdown(pkg)
+
+# informs if everything is ok [ansi]
+
+ Code
+ check_pkgdown(pkg)
+
+# informs if everything is ok [unicode]
+
+ Code
+ check_pkgdown(pkg)
-# informs if everything is ok
+# informs if everything is ok [fancy]
Code
check_pkgdown(pkg)
- Message
- No problems found
diff --git a/tests/testthat/_snaps/check.new.md b/tests/testthat/_snaps/check.new.md
deleted file mode 100644
index 410b2ac2b..000000000
--- a/tests/testthat/_snaps/check.new.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# fails if reference index incomplete
-
- Code
- check_pkgdown(pkg)
- Condition
- Error in `check_missing_topics()`:
- ! All topics must be included in reference index
- x Missing topics: ?
- i Either add to _pkgdown.yml or use @keywords internal
-
-# fails if article index incomplete
-
- Code
- check_pkgdown(pkg)
- Condition
- Error in `data_articles_index()`:
- ! Vignettes missing from index: articles/nested and width
-
-# informs if everything is ok
-
- Code
- check_pkgdown(pkg)
- Message
- No problems found
-
diff --git a/tests/testthat/_snaps/figure.md b/tests/testthat/_snaps/figure.md
new file mode 100644
index 000000000..c6487fc6e
--- /dev/null
+++ b/tests/testthat/_snaps/figure.md
@@ -0,0 +1,40 @@
+# can override defaults in _pkgdown.yml [plain]
+
+ Code
+ build_reference(pkg, devel = FALSE)
+
+---
+
+ Code
+ build_articles(pkg)
+
+# can override defaults in _pkgdown.yml [ansi]
+
+ Code
+ build_reference(pkg, devel = FALSE)
+
+---
+
+ Code
+ build_articles(pkg)
+
+# can override defaults in _pkgdown.yml [unicode]
+
+ Code
+ build_reference(pkg, devel = FALSE)
+
+---
+
+ Code
+ build_articles(pkg)
+
+# can override defaults in _pkgdown.yml [fancy]
+
+ Code
+ build_reference(pkg, devel = FALSE)
+
+---
+
+ Code
+ build_articles(pkg)
+
diff --git a/tests/testthat/_snaps/init.md b/tests/testthat/_snaps/init.md
index 31a5e2518..efdf10d1a 100644
--- a/tests/testthat/_snaps/init.md
+++ b/tests/testthat/_snaps/init.md
@@ -1,12 +1,140 @@
-# site meta doesn't break unexpectedly
-
- pandoc: '{version}'
- pkgdown: '{version}'
- pkgdown_sha: '{sha}'
- articles: {}
- last_built: 2020-01-01T00:00Z
- urls:
- reference: http://test.org/reference
- article: http://test.org/articles
-
+# extra.css and extra.js copied and linked [plain]
+
+ Code
+ init_site(pkg)
+
+---
+
+ Code
+ build_home(pkg)
+
+# extra.css and extra.js copied and linked [ansi]
+
+ Code
+ init_site(pkg)
+
+---
+
+ Code
+ build_home(pkg)
+
+# extra.css and extra.js copied and linked [unicode]
+
+ Code
+ init_site(pkg)
+
+---
+
+ Code
+ build_home(pkg)
+
+# extra.css and extra.js copied and linked [fancy]
+
+ Code
+ init_site(pkg)
+
+---
+
+ Code
+ build_home(pkg)
+
+# single extra.css correctly copied [plain]
+
+ Code
+ init_site(pkg)
+
+# single extra.css correctly copied [ansi]
+
+ Code
+ init_site(pkg)
+
+# single extra.css correctly copied [unicode]
+
+ Code
+ init_site(pkg)
+
+# single extra.css correctly copied [fancy]
+
+ Code
+ init_site(pkg)
+
+# asset subdirectories are copied [plain]
+
+ Code
+ init_site(pkg)
+
+# asset subdirectories are copied [ansi]
+
+ Code
+ init_site(pkg)
+
+# asset subdirectories are copied [unicode]
+
+ Code
+ init_site(pkg)
+
+# asset subdirectories are copied [fancy]
+
+ Code
+ init_site(pkg)
+
+# site meta doesn't break unexpectedly [plain]
+
+ Code
+ yaml
+ Output
+ pandoc: '{version}'
+ pkgdown: '{version}'
+ pkgdown_sha: '{sha}'
+ articles: {}
+ last_built: 2020-01-01T00:00Z
+ urls:
+ reference: http://test.org/reference
+ article: http://test.org/articles
+
+
+# site meta doesn't break unexpectedly [ansi]
+
+ Code
+ yaml
+ Output
+ pandoc: '{version}'
+ pkgdown: '{version}'
+ pkgdown_sha: '{sha}'
+ articles: {}
+ last_built: 2020-01-01T00:00Z
+ urls:
+ reference: http://test.org/reference
+ article: http://test.org/articles
+
+
+# site meta doesn't break unexpectedly [unicode]
+
+ Code
+ yaml
+ Output
+ pandoc: '{version}'
+ pkgdown: '{version}'
+ pkgdown_sha: '{sha}'
+ articles: {}
+ last_built: 2020-01-01T00:00Z
+ urls:
+ reference: http://test.org/reference
+ article: http://test.org/articles
+
+
+# site meta doesn't break unexpectedly [fancy]
+
+ Code
+ yaml
+ Output
+ pandoc: '{version}'
+ pkgdown: '{version}'
+ pkgdown_sha: '{sha}'
+ articles: {}
+ last_built: 2020-01-01T00:00Z
+ urls:
+ reference: http://test.org/reference
+ article: http://test.org/articles
+
diff --git a/tests/testthat/_snaps/markdown.md b/tests/testthat/_snaps/markdown.md
index 15d37dbfd..74d9b40c7 100644
--- a/tests/testthat/_snaps/markdown.md
+++ b/tests/testthat/_snaps/markdown.md
@@ -1,7 +1,4 @@
# markdown_text_inline() works with inline markdown
- Can't use a block element in , need an inline element:
- x
-
- y
+ Can't use a block element in ``, need an inline element: `x y`
diff --git a/tests/testthat/_snaps/package.md b/tests/testthat/_snaps/package.md
index a069241e7..1db0aa566 100644
--- a/tests/testthat/_snaps/package.md
+++ b/tests/testthat/_snaps/package.md
@@ -5,5 +5,5 @@
Condition
Error in `check_bootstrap_version()`:
! Boostrap version must be 3 or 5.
- x You specified a value of 1 in template.bootstrap.
+ x You specified a value of `1` in template.bootstrap.
diff --git a/tests/testthat/_snaps/rd-example.md b/tests/testthat/_snaps/rd-example.md
new file mode 100644
index 000000000..f88f1ccf5
--- /dev/null
+++ b/tests/testthat/_snaps/rd-example.md
@@ -0,0 +1,32 @@
+# @examplesIf [plain]
+
+ Code
+ expect_equal(strtrim(rd2ex(rd3), 40), strtrim(exp3, 40))
+ Condition
+ Warning:
+ @examplesIf condition `cond_expr_str` is FALSE
+
+# @examplesIf [ansi]
+
+ Code
+ expect_equal(strtrim(rd2ex(rd3), 40), strtrim(exp3, 40))
+ Condition
+ [1m[33mWarning[39m:[22m
+ [1m[22m@examplesIf condition `cond_expr_str` is FALSE
+
+# @examplesIf [unicode]
+
+ Code
+ expect_equal(strtrim(rd2ex(rd3), 40), strtrim(exp3, 40))
+ Condition
+ Warning:
+ @examplesIf condition `cond_expr_str` is FALSE
+
+# @examplesIf [fancy]
+
+ Code
+ expect_equal(strtrim(rd2ex(rd3), 40), strtrim(exp3, 40))
+ Condition
+ [1m[33mWarning[39m:[22m
+ [1m[22m@examplesIf condition `cond_expr_str` is FALSE
+
diff --git a/tests/testthat/_snaps/rd-html.md b/tests/testthat/_snaps/rd-html.md
index bd153d0cb..b9fcbac86 100644
--- a/tests/testthat/_snaps/rd-html.md
+++ b/tests/testthat/_snaps/rd-html.md
@@ -1,7 +1,7 @@
-# subsection generates h3
+# subsection generates h3 [plain]
Code
- cat_line(rd2html("\\subsection{A}{B}"))
+ cli::cat_line(rd2html("\\subsection{A}{B}"))
Output
A
@@ -11,7 +11,7 @@
---
Code
- cat_line(rd2html("\\subsection{A}{\n p1\n\n p2\n }"))
+ cli::cat_line(rd2html("\\subsection{A}{\n p1\n\n p2\n }"))
Output
A
@@ -19,10 +19,112 @@
p2
-# nested subsection generates h4
+# subsection generates h3 [ansi]
Code
- cat_line(rd2html("\\subsection{H3}{\\subsection{H4}{}}"))
+ cli::cat_line(rd2html("\\subsection{A}{B}"))
+ Output
+
+
+---
+
+ Code
+ cli::cat_line(rd2html("\\subsection{A}{\n p1\n\n p2\n }"))
+ Output
+
+
+# subsection generates h3 [unicode]
+
+ Code
+ cli::cat_line(rd2html("\\subsection{A}{B}"))
+ Output
+
+
+---
+
+ Code
+ cli::cat_line(rd2html("\\subsection{A}{\n p1\n\n p2\n }"))
+ Output
+
+
+# subsection generates h3 [fancy]
+
+ Code
+ cli::cat_line(rd2html("\\subsection{A}{B}"))
+ Output
+
+
+---
+
+ Code
+ cli::cat_line(rd2html("\\subsection{A}{\n p1\n\n p2\n }"))
+ Output
+
+
+# nested subsection generates h4 [plain]
+
+ Code
+ cli::cat_line(rd2html("\\subsection{H3}{\\subsection{H4}{}}"))
+ Output
+
+
+# nested subsection generates h4 [ansi]
+
+ Code
+ cli::cat_line(rd2html("\\subsection{H3}{\\subsection{H4}{}}"))
+ Output
+
+
+# nested subsection generates h4 [unicode]
+
+ Code
+ cli::cat_line(rd2html("\\subsection{H3}{\\subsection{H4}{}}"))
+ Output
+
+
+# nested subsection generates h4 [fancy]
+
+ Code
+ cli::cat_line(rd2html("\\subsection{H3}{\\subsection{H4}{}}"))
Output
H3
@@ -32,7 +134,47 @@
-# bad specs throw errors
+# Sexprs with multiple args are parsed [plain]
+
+ Code
+ rd2html("\\Sexpr[results=verbatim]{1}")
+ Condition
+ Error in `purrr::map_chr()`:
+ i In index: 1.
+ Caused by error in `glue()`:
+ ! Expecting '}'
+
+# Sexprs with multiple args are parsed [ansi]
+
+ Code
+ rd2html("\\Sexpr[results=verbatim]{1}")
+ Condition
+ [1m[33mError[39m in `purrr::map_chr()`:[22m
+ [1m[22m[36mi[39m In index: 1.
+ [1mCaused by error in `glue()`:[22m
+ [33m![39m Expecting '}'
+
+# Sexprs with multiple args are parsed [unicode]
+
+ Code
+ rd2html("\\Sexpr[results=verbatim]{1}")
+ Condition
+ Error in `purrr::map_chr()`:
+ ℹ In index: 1.
+ Caused by error in `glue()`:
+ ! Expecting '}'
+
+# Sexprs with multiple args are parsed [fancy]
+
+ Code
+ rd2html("\\Sexpr[results=verbatim]{1}")
+ Condition
+ [1m[33mError[39m in `purrr::map_chr()`:[22m
+ [1m[22m[36mℹ[39m In index: 1.
+ [1mCaused by error in `glue()`:[22m
+ [33m![39m Expecting '}'
+
+# bad specs throw errors [plain]
Code
rd2html("\\url{}")
@@ -40,31 +182,133 @@
Error in `purrr::map_chr()`:
i In index: 1.
Caused by error in `stop_bad_tag()`:
- ! Failed to parse \url{}.
- i Check for empty \url{} tags.
+ ! Failed to parse tag `\url{}`.
+ x Check for empty \url{} tags.
Code
rd2html("\\url{a\nb}")
Condition
Error in `purrr::map_chr()`:
i In index: 1.
Caused by error in `stop_bad_tag()`:
- ! Failed to parse \url{}.
- i This may be caused by a \url tag that spans a line break.
+ ! Failed to parse tag `\url{}`.
+ x This may be caused by a \url tag that spans a line break.
Code
rd2html("\\email{}")
Condition
Error in `purrr::map_chr()`:
i In index: 1.
Caused by error in `stop_bad_tag()`:
- ! Failed to parse \email{}.
- i empty {}
+ ! Failed to parse tag `\email{}`.
+ x empty
Code
rd2html("\\linkS4class{}")
Condition
Error in `purrr::map_chr()`:
i In index: 1.
Caused by error in `stop_bad_tag()`:
- ! Failed to parse \linkS4class{}.
+ ! Failed to parse tag `\linkS4class{}`.
+
+# bad specs throw errors [ansi]
+
+ Code
+ rd2html("\\url{}")
+ Condition
+ [1m[33mError[39m in `purrr::map_chr()`:[22m
+ [1m[22m[36mi[39m In index: 1.
+ [1mCaused by error in `stop_bad_tag()`:[22m
+ [1m[22m[33m![39m Failed to parse tag `\url{}`.
+ [31mx[39m Check for empty \url{} tags.
+ Code
+ rd2html("\\url{a\nb}")
+ Condition
+ [1m[33mError[39m in `purrr::map_chr()`:[22m
+ [1m[22m[36mi[39m In index: 1.
+ [1mCaused by error in `stop_bad_tag()`:[22m
+ [1m[22m[33m![39m Failed to parse tag `\url{}`.
+ [31mx[39m This may be caused by a \url tag that spans a line break.
+ Code
+ rd2html("\\email{}")
+ Condition
+ [1m[33mError[39m in `purrr::map_chr()`:[22m
+ [1m[22m[36mi[39m In index: 1.
+ [1mCaused by error in `stop_bad_tag()`:[22m
+ [1m[22m[33m![39m Failed to parse tag `\email{}`.
+ [31mx[39m empty
+ Code
+ rd2html("\\linkS4class{}")
+ Condition
+ [1m[33mError[39m in `purrr::map_chr()`:[22m
+ [1m[22m[36mi[39m In index: 1.
+ [1mCaused by error in `stop_bad_tag()`:[22m
+ [1m[22m[33m![39m Failed to parse tag `\linkS4class{}`.
+
+# bad specs throw errors [unicode]
+
+ Code
+ rd2html("\\url{}")
+ Condition
+ Error in `purrr::map_chr()`:
+ ℹ In index: 1.
+ Caused by error in `stop_bad_tag()`:
+ ! Failed to parse tag `\url{}`.
+ ✖ Check for empty \url{} tags.
+ Code
+ rd2html("\\url{a\nb}")
+ Condition
+ Error in `purrr::map_chr()`:
+ ℹ In index: 1.
+ Caused by error in `stop_bad_tag()`:
+ ! Failed to parse tag `\url{}`.
+ ✖ This may be caused by a \url tag that spans a line break.
+ Code
+ rd2html("\\email{}")
+ Condition
+ Error in `purrr::map_chr()`:
+ ℹ In index: 1.
+ Caused by error in `stop_bad_tag()`:
+ ! Failed to parse tag `\email{}`.
+ ✖ empty
+ Code
+ rd2html("\\linkS4class{}")
+ Condition
+ Error in `purrr::map_chr()`:
+ ℹ In index: 1.
+ Caused by error in `stop_bad_tag()`:
+ ! Failed to parse tag `\linkS4class{}`.
+
+# bad specs throw errors [fancy]
+
+ Code
+ rd2html("\\url{}")
+ Condition
+ [1m[33mError[39m in `purrr::map_chr()`:[22m
+ [1m[22m[36mℹ[39m In index: 1.
+ [1mCaused by error in `stop_bad_tag()`:[22m
+ [1m[22m[33m![39m Failed to parse tag `\url{}`.
+ [31m✖[39m Check for empty \url{} tags.
+ Code
+ rd2html("\\url{a\nb}")
+ Condition
+ [1m[33mError[39m in `purrr::map_chr()`:[22m
+ [1m[22m[36mℹ[39m In index: 1.
+ [1mCaused by error in `stop_bad_tag()`:[22m
+ [1m[22m[33m![39m Failed to parse tag `\url{}`.
+ [31m✖[39m This may be caused by a \url tag that spans a line break.
+ Code
+ rd2html("\\email{}")
+ Condition
+ [1m[33mError[39m in `purrr::map_chr()`:[22m
+ [1m[22m[36mℹ[39m In index: 1.
+ [1mCaused by error in `stop_bad_tag()`:[22m
+ [1m[22m[33m![39m Failed to parse tag `\email{}`.
+ [31m✖[39m empty
+ Code
+ rd2html("\\linkS4class{}")
+ Condition
+ [1m[33mError[39m in `purrr::map_chr()`:[22m
+ [1m[22m[36mℹ[39m In index: 1.
+ [1mCaused by error in `stop_bad_tag()`:[22m
+ [1m[22m[33m![39m Failed to parse tag `\linkS4class{}`.
# \describe items can contain multiple paragraphs
diff --git a/tests/testthat/_snaps/render.md b/tests/testthat/_snaps/render.md
index 9886a9c8e..7fb106e7d 100644
--- a/tests/testthat/_snaps/render.md
+++ b/tests/testthat/_snaps/render.md
@@ -51,3 +51,23 @@
right: Site built with pkgdown {version}.
+# can include text in header, before body, and after body [plain]
+
+ Code
+ init_site(pkg)
+
+# can include text in header, before body, and after body [ansi]
+
+ Code
+ init_site(pkg)
+
+# can include text in header, before body, and after body [unicode]
+
+ Code
+ init_site(pkg)
+
+# can include text in header, before body, and after body [fancy]
+
+ Code
+ init_site(pkg)
+
diff --git a/tests/testthat/_snaps/rmarkdown.md b/tests/testthat/_snaps/rmarkdown.md
index dfcebf315..5631a8c68 100644
--- a/tests/testthat/_snaps/rmarkdown.md
+++ b/tests/testthat/_snaps/rmarkdown.md
@@ -1,23 +1,108 @@
-# render_rmarkdown yields useful error
+# render_rmarkdown copies image files in subdirectories [plain]
+
+ Code
+ render_rmarkdown(pkg, "assets/vignette-with-img.Rmd", "test.html")
+
+# render_rmarkdown copies image files in subdirectories [ansi]
+
+ Code
+ render_rmarkdown(pkg, "assets/vignette-with-img.Rmd", "test.html")
+
+# render_rmarkdown copies image files in subdirectories [unicode]
+
+ Code
+ render_rmarkdown(pkg, "assets/vignette-with-img.Rmd", "test.html")
+
+# render_rmarkdown copies image files in subdirectories [fancy]
+
+ Code
+ render_rmarkdown(pkg, "assets/vignette-with-img.Rmd", "test.html")
+
+# render_rmarkdown yields useful error [plain]
Code
render_rmarkdown(pkg, "assets/pandoc-fail.Rmd", "test.html", output_format = rmarkdown::html_document(
pandoc_args = "--fail-if-warnings"))
Output
- Reading 'assets/pandoc-fail.Rmd'
- -- RMarkdown error -------------------------------------------------------------
[WARNING] Could not fetch resource path-to-image.png
Failing because there were warnings.
- --------------------------------------------------------------------------------
Condition
- Error in `render_rmarkdown()`:
- ! Failed to render RMarkdown
- Caused by error:
- ! in callr subprocess.
- Caused by error:
- ! pandoc document conversion failed with error 3
-
-# render_rmarkdown styles ANSI escapes
+ Error in `value[[3L]]()`:
+ ! Failed to render RMarkdown document
+
+# render_rmarkdown yields useful error [ansi]
+
+ Code
+ render_rmarkdown(pkg, "assets/pandoc-fail.Rmd", "test.html", output_format = rmarkdown::html_document(
+ pandoc_args = "--fail-if-warnings"))
+ Output
+ [WARNING] Could not fetch resource path-to-image.png
+ Failing because there were warnings.
+ Condition
+ [1m[33mError[39m in `value[[3L]]()`:[22m
+ [1m[22m[33m![39m Failed to render RMarkdown document
+
+# render_rmarkdown yields useful error [unicode]
+
+ Code
+ render_rmarkdown(pkg, "assets/pandoc-fail.Rmd", "test.html", output_format = rmarkdown::html_document(
+ pandoc_args = "--fail-if-warnings"))
+ Output
+ [WARNING] Could not fetch resource path-to-image.png
+ Failing because there were warnings.
+ Condition
+ Error in `value[[3L]]()`:
+ ! Failed to render RMarkdown document
+
+# render_rmarkdown yields useful error [fancy]
+
+ Code
+ render_rmarkdown(pkg, "assets/pandoc-fail.Rmd", "test.html", output_format = rmarkdown::html_document(
+ pandoc_args = "--fail-if-warnings"))
+ Output
+ [WARNING] Could not fetch resource path-to-image.png
+ Failing because there were warnings.
+ Condition
+ [1m[33mError[39m in `value[[3L]]()`:[22m
+ [1m[22m[33m![39m Failed to render RMarkdown document
+
+# render_rmarkdown styles ANSI escapes [plain]
+
+ Code
+ path <- render_rmarkdown(pkg, input = "assets/vignette-with-crayon.Rmd",
+ output = "test.html")
+
+---
+
+ #> X
+
+# render_rmarkdown styles ANSI escapes [ansi]
+
+ Code
+ path <- render_rmarkdown(pkg, input = "assets/vignette-with-crayon.Rmd",
+ output = "test.html")
+
+---
+
+ #> X
+
+# render_rmarkdown styles ANSI escapes [unicode]
+
+ Code
+ path <- render_rmarkdown(pkg, input = "assets/vignette-with-crayon.Rmd",
+ output = "test.html")
+
+---
+
+ #> X
+
+# render_rmarkdown styles ANSI escapes [fancy]
+
+ Code
+ path <- render_rmarkdown(pkg, input = "assets/vignette-with-crayon.Rmd",
+ output = "test.html")
+
+---
#> X
diff --git a/tests/testthat/_snaps/sitrep.md b/tests/testthat/_snaps/sitrep.md
index 330db5d0c..37cf72ac4 100644
--- a/tests/testthat/_snaps/sitrep.md
+++ b/tests/testthat/_snaps/sitrep.md
@@ -1,12 +1,96 @@
-# pkgdown_sitrep works
+# pkgdown_sitrep works [plain]
- * url in '_pkgdown.yml' not configured.
+ Code
+ pkgdown_sitrep(pkg)
+ Condition
+ Warning:
+ pkgdown situation report: configuration error
+ x url is not configured in '_pkgdown.yml'. See vignette `vignette(pkgdown::metatdata)`.
+ x 'DESCRIPTION' URL is empty.
---
- * URL missing from the DESCRIPTION URL field.
+ Code
+ pkgdown_sitrep(pkg)
+ Condition
+ Warning:
+ pkgdown situation report: configuration error
+ x 'DESCRIPTION' URL is empty.
---
- All good :-)
+ Code
+ pkgdown_sitrep(pkg)
+
+# pkgdown_sitrep works [ansi]
+
+ Code
+ pkgdown_sitrep(pkg)
+ Condition
+ [1m[33mWarning[39m:[22m
+ [1m[22mpkgdown situation report: [3m[31mconfiguration error[39m[23m
+ [31mx[39m url is not configured in [34m_pkgdown.yml[39m. See vignette `vignette(pkgdown::metatdata)`.
+ [31mx[39m [34mDESCRIPTION[39m [32mURL[39m is empty.
+
+---
+
+ Code
+ pkgdown_sitrep(pkg)
+ Condition
+ [1m[33mWarning[39m:[22m
+ [1m[22mpkgdown situation report: [3m[31mconfiguration error[39m[23m
+ [31mx[39m [34mDESCRIPTION[39m [32mURL[39m is empty.
+
+---
+
+ Code
+ pkgdown_sitrep(pkg)
+
+# pkgdown_sitrep works [unicode]
+
+ Code
+ pkgdown_sitrep(pkg)
+ Condition
+ Warning:
+ pkgdown situation report: configuration error
+ ✖ url is not configured in '_pkgdown.yml'. See vignette `vignette(pkgdown::metatdata)`.
+ ✖ 'DESCRIPTION' URL is empty.
+
+---
+
+ Code
+ pkgdown_sitrep(pkg)
+ Condition
+ Warning:
+ pkgdown situation report: configuration error
+ ✖ 'DESCRIPTION' URL is empty.
+
+---
+
+ Code
+ pkgdown_sitrep(pkg)
+
+# pkgdown_sitrep works [fancy]
+
+ Code
+ pkgdown_sitrep(pkg)
+ Condition
+ [1m[33mWarning[39m:[22m
+ [1m[22mpkgdown situation report: [3m[31mconfiguration error[39m[23m
+ [31m✖[39m url is not configured in [34m_pkgdown.yml[39m. See vignette `vignette(pkgdown::metatdata)`.
+ [31m✖[39m [34mDESCRIPTION[39m [32mURL[39m is empty.
+
+---
+
+ Code
+ pkgdown_sitrep(pkg)
+ Condition
+ [1m[33mWarning[39m:[22m
+ [1m[22mpkgdown situation report: [3m[31mconfiguration error[39m[23m
+ [31m✖[39m [34mDESCRIPTION[39m [32mURL[39m is empty.
+
+---
+
+ Code
+ pkgdown_sitrep(pkg)
diff --git a/tests/testthat/_snaps/topics-external.md b/tests/testthat/_snaps/topics-external.md
index 6a2e8ed02..4584ff7d2 100644
--- a/tests/testthat/_snaps/topics-external.md
+++ b/tests/testthat/_snaps/topics-external.md
@@ -29,5 +29,5 @@
Error in `purrr::map2()`:
i In index: 1.
Caused by error in `.f()`:
- ! Could not find documentation for base::doesntexist
+ ! Could not find documentation for `base::doesntexist()`.
diff --git a/tests/testthat/_snaps/topics.md b/tests/testthat/_snaps/topics.md
index 0a2c20ad1..db935a207 100644
--- a/tests/testthat/_snaps/topics.md
+++ b/tests/testthat/_snaps/topics.md
@@ -5,43 +5,41 @@
Condition
Error in `purrr::map()`:
i In index: 1.
- Caused by error:
+ Caused by error in `topic_must()`:
! In '_pkgdown.yml', topic must be valid R code
- x Not 'x + '
+ x Not `x + `
Code
t <- select_topics("y", topics)
Condition
Error in `purrr::map()`:
i In index: 1.
- Caused by error:
+ Caused by error in `topic_must()`:
! In '_pkgdown.yml', topic must be a known topic name or alias
- x Not 'y'
+ x Not `y`
Code
t <- select_topics("paste(1)", topics)
Condition
Error in `purrr::map()`:
i In index: 1.
- Caused by error:
+ Caused by error in `topic_must()`:
! In '_pkgdown.yml', topic must be a known selector function
- x Not 'paste(1)'
- Caused by error in `paste()`:
- ! could not find function "paste"
+ x Not `paste(1)`
Code
t <- select_topics("starts_with", topics)
Condition
Error in `purrr::map()`:
i In index: 1.
- Caused by error:
+ Caused by error in `topic_must()`:
! In '_pkgdown.yml', topic must be a known topic name or alias
- x Not 'starts_with'
+ x Not `starts_with`
Code
t <- select_topics("1", topics)
Condition
Error in `purrr::map()`:
i In index: 1.
- Caused by error:
+ Caused by error in `topic_must()`:
! In '_pkgdown.yml', topic must be a string or function call
- x Not '1'
+ x Not `1`
Code
t <- select_topics("starts_with('y')", topics, check = TRUE)
Condition
@@ -55,24 +53,24 @@
Condition
Error in `purrr::map()`:
i In index: 1.
- Caused by error:
+ Caused by error in `topic_must()`:
! In '_pkgdown.yml', topic must be a known topic name or alias
- x Not 'a4'
+ x Not `a4`
Code
select_topics("c::a", topics)
Condition
Error in `purrr::map()`:
i In index: 1.
- Caused by error:
+ Caused by error in `topic_must()`:
! In '_pkgdown.yml', topic must be a known topic name or alias
- x Not 'c::a'
+ x Not `c::a`
# an unmatched selection generates a warning
Code
select_topics(c("a", "starts_with('unmatched')"), topics, check = TRUE)
Condition
- Error:
+ Error in `topic_must()`:
! In '_pkgdown.yml', topic must match a function or concept
- x Not 'starts_with(\'unmatched\')'
+ x Not `starts_with('unmatched')`
diff --git a/tests/testthat/_snaps/utils-yaml.md b/tests/testthat/_snaps/utils-yaml.md
index 7573cb83f..80129eeb7 100644
--- a/tests/testthat/_snaps/utils-yaml.md
+++ b/tests/testthat/_snaps/utils-yaml.md
@@ -1,13 +1,49 @@
-# pkgdown_field(s) produces useful description
+# pkgdown_field(s) produces useful description [plain]
Code
- pkgdown_field(pkg, c("a", "b"))
+ pkgdown_field(c("a", "b"))
Output
- [1] "a.b in '_pkgdown.yml'"
+ [1] "a.b"
+
+---
+
+ Code
+ check_yaml_has("x", where = "a", pkg = pkg)
+ Condition
+ Error in `check_yaml_has()`:
+ ! Can't find a.x component in '_pkgdown.yml'.
+ Code
+ check_yaml_has(c("x", "y"), where = "a", pkg = pkg)
+ Condition
+ Error in `check_yaml_has()`:
+ ! Can't find a.x and a.y components in '_pkgdown.yml'.
+
+# pkgdown_field(s) produces useful description [ansi]
+
Code
- pkgdown_fields(pkg, list(c("a", "b"), "c"))
+ pkgdown_field(c("a", "b"))
Output
- [1] "a.b, c in '_pkgdown.yml'"
+ [1] "a.b"
+
+---
+
+ Code
+ check_yaml_has("x", where = "a", pkg = pkg)
+ Condition
+ [1m[33mError[39m in `check_yaml_has()`:[22m
+ [1m[22m[33m![39m Can't find [32ma.x[39m component in [34m_pkgdown.yml[39m.
+ Code
+ check_yaml_has(c("x", "y"), where = "a", pkg = pkg)
+ Condition
+ [1m[33mError[39m in `check_yaml_has()`:[22m
+ [1m[22m[33m![39m Can't find [32ma.x[39m and [32ma.y[39m components in [34m_pkgdown.yml[39m.
+
+# pkgdown_field(s) produces useful description [unicode]
+
+ Code
+ pkgdown_field(c("a", "b"))
+ Output
+ [1] "a.b"
---
@@ -15,10 +51,30 @@
check_yaml_has("x", where = "a", pkg = pkg)
Condition
Error in `check_yaml_has()`:
- ! Can't find component a.x in '_pkgdown.yml'.
+ ! Can't find a.x component in '_pkgdown.yml'.
Code
check_yaml_has(c("x", "y"), where = "a", pkg = pkg)
Condition
Error in `check_yaml_has()`:
- ! Can't find components a.x, a.y in '_pkgdown.yml'.
+ ! Can't find a.x and a.y components in '_pkgdown.yml'.
+
+# pkgdown_field(s) produces useful description [fancy]
+
+ Code
+ pkgdown_field(c("a", "b"))
+ Output
+ [1] "a.b"
+
+---
+
+ Code
+ check_yaml_has("x", where = "a", pkg = pkg)
+ Condition
+ [1m[33mError[39m in `check_yaml_has()`:[22m
+ [1m[22m[33m![39m Can't find [32ma.x[39m component in [34m_pkgdown.yml[39m.
+ Code
+ check_yaml_has(c("x", "y"), where = "a", pkg = pkg)
+ Condition
+ [1m[33mError[39m in `check_yaml_has()`:[22m
+ [1m[22m[33m![39m Can't find [32ma.x[39m and [32ma.y[39m components in [34m_pkgdown.yml[39m.
diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R
new file mode 100644
index 000000000..75010f6ee
--- /dev/null
+++ b/tests/testthat/setup.R
@@ -0,0 +1,3 @@
+# suppress cli messages in interactive testthat output
+# https://github.com/r-lib/cli/issues/434
+options(cli.default_handler = function(...) { })
diff --git a/tests/testthat/test-build-articles.R b/tests/testthat/test-build-articles.R
index 250af53d3..3701091ce 100644
--- a/tests/testthat/test-build-articles.R
+++ b/tests/testthat/test-build-articles.R
@@ -10,8 +10,8 @@ test_that("links to man/figures are automatically relocated", {
skip_on_cran()
pkg <- local_pkgdown_site(test_path("assets/man-figures"))
- expect_output(copy_figures(pkg))
- expect_output(build_articles(pkg, lazy = FALSE))
+ expect_snapshot(copy_figures(pkg))
+ expect_snapshot(build_articles(pkg, lazy = FALSE))
html <- xml2::read_html(path(pkg$dst_path, "articles", "kitten.html"))
src <- xpath_attr(html, "//img", "src")
@@ -26,7 +26,7 @@ test_that("links to man/figures are automatically relocated", {
expect_false(dir_exists(path(pkg$dst_path, "man")))
})
-test_that("warns about missing images", {
+cli::test_that_cli("warns about missing images", {
pkg <- local_pkgdown_site(test_path("assets/bad-images"))
expect_snapshot(build_articles(pkg))
})
@@ -35,7 +35,7 @@ test_that("articles don't include header-attrs.js script", {
pkg <- as_pkgdown(test_path("assets/articles"))
withr::defer(clean_site(pkg))
- expect_output(path <- build_article("standard", pkg))
+ expect_snapshot(path <- build_article("standard", pkg))
html <- xml2::read_html(path)
js <- xpath_attr(html, ".//body//script", "src")
@@ -48,12 +48,12 @@ test_that("can build article that uses html_vignette", {
pkg <- local_pkgdown_site(test_path("assets/articles"))
# theme is not set since html_vignette doesn't support it
- expect_output(expect_error(build_article("html-vignette", pkg), NA))
+ expect_snapshot(expect_error(build_article("html-vignette", pkg), NA))
})
test_that("can override html_document() options", {
pkg <- local_pkgdown_site(test_path("assets/articles"))
- expect_output(path <- build_article("html-document", pkg))
+ expect_snapshot(path <- build_article("html-document", pkg))
# Check that number_sections is respected
html <- xml2::read_html(path)
@@ -69,7 +69,7 @@ test_that("can override html_document() options", {
test_that("html widgets get needed css/js", {
pkg <- local_pkgdown_site(test_path("assets/articles"))
- expect_output(path <- build_article("widget", pkg))
+ expect_snapshot(path <- build_article("widget", pkg))
html <- xml2::read_html(path)
css <- xpath_attr(html, ".//body//link", "href")
@@ -81,7 +81,7 @@ test_that("html widgets get needed css/js", {
test_that("can override options with _output.yml", {
pkg <- local_pkgdown_site(test_path("assets/articles"))
- expect_output(path <- build_article("html-document", pkg))
+ expect_snapshot(path <- build_article("html-document", pkg))
# Check that number_sections is respected
html <- xml2::read_html(path)
@@ -94,7 +94,7 @@ test_that("can set width", {
width: 50
")
- expect_output(path <- build_article("width", pkg))
+ expect_snapshot(path <- build_article("width", pkg))
html <- xml2::read_html(path)
expect_equal(xpath_text(html, ".//pre")[[2]], "## [1] 50")
})
@@ -104,7 +104,7 @@ test_that("finds external resources referenced by R code in the article html", {
skip_on_cran()
pkg <- local_pkgdown_site(test_path("assets", "articles-resources"))
- expect_output(path <- build_article("resources", pkg))
+ expect_snapshot(path <- build_article("resources", pkg))
# ensure that we the HTML references `` directly
expect_equal(
@@ -124,9 +124,9 @@ test_that("BS5 article laid out correctly with and without TOC", {
bootstrap: 5
")
- expect_output(init_site(pkg))
- expect_output(toc_true_path <- build_article("standard", pkg))
- expect_output(toc_false_path <- build_article("toc-false", pkg))
+ expect_snapshot(init_site(pkg))
+ expect_snapshot(toc_true_path <- build_article("standard", pkg))
+ expect_snapshot(toc_false_path <- build_article("toc-false", pkg))
toc_true <- xml2::read_html(toc_true_path)
toc_false <- xml2::read_html(toc_false_path)
@@ -145,7 +145,7 @@ test_that("articles in vignettes/articles/ are unnested into articles/", {
skip_on_cran()
pkg <- local_pkgdown_site(test_path("assets/articles"))
- expect_output(path <- build_article("articles/nested", pkg))
+ expect_snapshot(path <- build_article("articles/nested", pkg))
expect_equal(
normalizePath(path),
@@ -154,7 +154,7 @@ test_that("articles in vignettes/articles/ are unnested into articles/", {
# Check automatic redirect from articles/articles/foo.html -> articles/foo.html
pkg$meta$url <- "https://example.com"
- expect_output(build_redirects(pkg))
+ expect_snapshot(build_redirects(pkg))
# Check that the redirect file exists in /articles/articles/
redirect_path <- path(pkg$dst_path, "articles", "articles", "nested.html")
@@ -175,8 +175,8 @@ test_that("pkgdown deps are included only once in articles", {
bootstrap: 5
")
- expect_output(init_site(pkg))
- expect_output(path <- build_article("html-deps", pkg))
+ expect_snapshot(init_site(pkg))
+ expect_snapshot(path <- build_article("html-deps", pkg))
html <- xml2::read_html(path)
diff --git a/tests/testthat/test-build-favicons.R b/tests/testthat/test-build-favicons.R
index 4990401fd..dbc1cea90 100644
--- a/tests/testthat/test-build-favicons.R
+++ b/tests/testthat/test-build-favicons.R
@@ -2,7 +2,7 @@ test_that("missing logo generates message", {
pkg <- local_pkgdown_site(test_path("assets/site-empty"))
expect_error(
- expect_output(build_favicons(pkg)),
+ expect_snapshot(build_favicons(pkg)),
"Can't find package logo"
)
})
diff --git a/tests/testthat/test-build-github.R b/tests/testthat/test-build-github.R
index 23dd0e5dc..bbb90ddd1 100644
--- a/tests/testthat/test-build-github.R
+++ b/tests/testthat/test-build-github.R
@@ -2,7 +2,7 @@ test_that("a CNAME record is built if a url exists in metadata", {
pkg <- local_pkgdown_site(test_path("assets/cname"))
dir_create(path(pkg$dst_path, "docs"))
- expect_output(build_github_pages(pkg))
+ expect_snapshot(build_github_pages(pkg))
expect_equal(read_lines(path(pkg$dst_path, "CNAME")), "testpackage.r-lib.org")
})
diff --git a/tests/testthat/test-build-home-authors.R b/tests/testthat/test-build-home-authors.R
index 0eb6cd332..a6c2445b8 100644
--- a/tests/testthat/test-build-home-authors.R
+++ b/tests/testthat/test-build-home-authors.R
@@ -55,7 +55,7 @@ test_that("data_home_sidebar_authors() works with text", {
expect_snapshot(cat(data_home_sidebar_authors(pkg)))
})
-test_that("role has multiple fallbacks", {
+cli::test_that_cli("role has multiple fallbacks", {
expect_equal(role_lookup("cre"), "maintainer")
expect_equal(role_lookup("res"), "researcher")
expect_snapshot(role_lookup("unknown"))
diff --git a/tests/testthat/test-build-home-citation.R b/tests/testthat/test-build-home-citation.R
index d3ae147e9..cf369c151 100644
--- a/tests/testthat/test-build-home-citation.R
+++ b/tests/testthat/test-build-home-citation.R
@@ -23,7 +23,7 @@ test_that("create_meta can read DESCRIPTION with an Encoding", {
test_that("source link is added to citation page", {
pkg <- local_pkgdown_site(test_path("assets/site-citation/encoding-UTF-8"))
- expect_output(build_home(pkg))
+ expect_snapshot(build_home(pkg))
lines <- read_lines(path(pkg$dst_path, "authors.html"))
expect_true(any(grepl("inst/CITATION
", lines)))
diff --git a/tests/testthat/test-build-home-index.R b/tests/testthat/test-build-home-index.R
index 141547a69..b2e1b6e9c 100644
--- a/tests/testthat/test-build-home-index.R
+++ b/tests/testthat/test-build-home-index.R
@@ -12,7 +12,7 @@ test_that("version formatting in preserved", {
pkg <- local_pkgdown_site(test_path("assets/version-formatting"))
expect_equal(pkg$version, "1.0.0-9000")
- expect_output(init_site(pkg))
+ expect_snapshot(init_site(pkg))
build_home_index(pkg, quiet = TRUE)
index <- read_lines(path(pkg$dst_path, "index.html"))
expect_true(any(grepl("1.0.0-9000", index, fixed = TRUE)))
diff --git a/tests/testthat/test-build-home.R b/tests/testthat/test-build-home.R
index 4299e6e61..4bf483e2c 100644
--- a/tests/testthat/test-build-home.R
+++ b/tests/testthat/test-build-home.R
@@ -4,7 +4,7 @@ test_that("intermediate files cleaned up automatically", {
skip_if_no_pandoc()
pkg <- local_pkgdown_site(test_path("assets/home-index-rmd"))
- expect_output(build_home(pkg))
+ expect_snapshot(build_home(pkg))
expect_setequal(dir(pkg$src_path), c("DESCRIPTION", "index.Rmd"))
})
@@ -13,7 +13,7 @@ test_that("intermediate files cleaned up automatically", {
skip_if_no_pandoc()
pkg <- local_pkgdown_site(test_path("assets/home-readme-rmd"))
- expect_output(build_home(pkg))
+ expect_snapshot(build_home(pkg))
expect_setequal(
dir(pkg$src_path),
@@ -21,7 +21,7 @@ test_that("intermediate files cleaned up automatically", {
)
})
-test_that("warns about missing images", {
+cli::test_that_cli("warns about missing images", {
pkg <- local_pkgdown_site(test_path("assets/bad-images"))
expect_snapshot(build_home(pkg))
})
@@ -30,7 +30,7 @@ test_that("can build site even if no Authors@R present", {
skip_if_no_pandoc()
pkg <- local_pkgdown_site(test_path("assets/home-old-skool"))
- expect_output(build_home(pkg))
+ expect_snapshot(build_home(pkg))
})
# .github files -----------------------------------------------------------
@@ -42,7 +42,7 @@ test_that(".github files are copied and linked", {
skip_if_not(dir_exists(test_path("assets/site-dot-github/.github")))
pkg <- local_pkgdown_site(test_path("assets/site-dot-github"))
- expect_output(build_home(pkg))
+ expect_snapshot(build_home(pkg))
lines <- read_lines(path(pkg$dst_path, "index.html"))
expect_true(any(grepl('href="CODE_OF_CONDUCT.html"', lines)))
diff --git a/tests/testthat/test-build-logo.R b/tests/testthat/test-build-logo.R
index b0d027bdc..8737b0b11 100644
--- a/tests/testthat/test-build-logo.R
+++ b/tests/testthat/test-build-logo.R
@@ -1,4 +1,4 @@
-test_that("can handle logo in subdir", {
+cli::test_that_cli("can handle logo in subdir", {
src <- withr::local_tempdir()
dst <- withr::local_tempdir()
diff --git a/tests/testthat/test-build-news.R b/tests/testthat/test-build-news.R
index 64fe95269..15921fa45 100644
--- a/tests/testthat/test-build-news.R
+++ b/tests/testthat/test-build-news.R
@@ -24,7 +24,7 @@ test_that("data_news works as expected for h1 & h2", {
})
-test_that("multi-page news are rendered", {
+cli::test_that_cli("multi-page news are rendered", {
skip_if_no_pandoc()
pkg <- local_pkgdown_site(meta = "
@@ -45,8 +45,8 @@ test_that("multi-page news are rendered", {
"* second thing"
))
- expect_snapshot_output(data_news(pkg)[c("version", "page", "anchor")])
- expect_output(build_news(pkg))
+ expect_snapshot(data_news(pkg)[c("version", "page", "anchor")])
+ expect_snapshot(build_news(pkg))
# test that index links are correct
lines <- read_lines(path(pkg$dst_path, "news", "index.html"))
diff --git a/tests/testthat/test-build-reference-index.R b/tests/testthat/test-build-reference-index.R
index 562a02c88..5806e28e1 100644
--- a/tests/testthat/test-build-reference-index.R
+++ b/tests/testthat/test-build-reference-index.R
@@ -72,27 +72,27 @@ test_that("errors well when a content entry is empty", {
expect_snapshot_error(build_reference_index(pkg))
})
-test_that("errors well when a content entry is not a character", {
+cli::test_that_cli("errors well when a content entry is not a character", {
meta <- yaml::yaml.load( "reference:\n- title: bla\n contents:\n - aname\n - N")
pkg <- as_pkgdown(test_path("assets/reference"), override = meta)
- expect_snapshot_error(build_reference_index(pkg))
+ expect_snapshot(build_reference_index(pkg), error = TRUE)
})
-test_that("errors well when a content entry refers to a not installed package", {
+cli::test_that_cli("errors well when a content entry refers to a not installed package", {
skip_if_not_installed("cli", "3.1.0")
meta <- yaml::yaml.load( "reference:\n- title: bla\n contents:\n - notapackage::lala")
pkg <- as_pkgdown(test_path("assets/reference"), override = meta)
- expect_snapshot_error(build_reference_index(pkg))
+ expect_snapshot(build_reference_index(pkg), error = TRUE)
})
-test_that("errors well when a content entry refers to a non existing function", {
+cli::test_that_cli("errors well when a content entry refers to a non existing function", {
meta <- yaml::yaml.load( "reference:\n- title: bla\n contents:\n - rlang::lala")
pkg <- as_pkgdown(test_path("assets/reference"), override = meta)
- expect_snapshot_error(build_reference_index(pkg))
+ expect_snapshot(build_reference_index(pkg), error = TRUE)
})
test_that("can exclude topics", {
diff --git a/tests/testthat/test-build-reference.R b/tests/testthat/test-build-reference.R
index 029065c4f..de81ebe25 100644
--- a/tests/testthat/test-build-reference.R
+++ b/tests/testthat/test-build-reference.R
@@ -1,4 +1,4 @@
-test_that("parse failures include file name", {
+cli::test_that_cli("parse failures include file name", {
skip_if_not(getRversion() >= "4.0.0")
pkg <- local_pkgdown_site("assets/reference-fail")
expect_snapshot(build_reference(pkg), error = TRUE)
@@ -30,9 +30,9 @@ test_that("examples_env sets width", {
})
-test_that("test usage ok on rendered page", {
+cli::test_that_cli("test usage ok on rendered page", {
pkg <- local_pkgdown_site(test_path("assets/reference"))
- expect_output(build_reference(pkg, topics = "c"))
+ expect_snapshot(build_reference(pkg, topics = "c"))
html <- xml2::read_html(file.path(pkg$dst_path, "reference", "c.html"))
expect_equal(xpath_text(html, "//div[@id='ref-usage']", trim = TRUE), "c()")
clean_site(pkg)
@@ -41,16 +41,16 @@ test_that("test usage ok on rendered page", {
template:
bootstrap: 5
")
- expect_output(init_site(pkg))
- expect_output(build_reference(pkg, topics = "c"))
+ expect_snapshot(init_site(pkg))
+ expect_snapshot(build_reference(pkg, topics = "c"))
html <- xml2::read_html(file.path(pkg$dst_path, "reference", "c.html"))
# tweak_anchors() moves id into
expect_equal(xpath_text(html, "//div[h2[@id='ref-usage']]/div", trim = TRUE), "c()")
})
-test_that(".Rd without usage doesn't get Usage section", {
+cli::test_that_cli(".Rd without usage doesn't get Usage section", {
pkg <- local_pkgdown_site(test_path("assets/reference"))
- expect_output(build_reference(pkg, topics = "e"))
+ expect_snapshot(build_reference(pkg, topics = "e"))
html <- xml2::read_html(file.path(pkg$dst_path, "reference", "e.html"))
expect_equal(xpath_length(html, "//div[@id='ref-usage']"), 0)
clean_site(pkg)
@@ -59,8 +59,8 @@ test_that(".Rd without usage doesn't get Usage section", {
template:
bootstrap: 5
")
- expect_output(init_site(pkg))
- expect_output(build_reference(pkg, topics = "e"))
+ expect_snapshot(init_site(pkg))
+ expect_snapshot(build_reference(pkg, topics = "e"))
html <- xml2::read_html(file.path(pkg$dst_path, "reference", "e.html"))
# tweak_anchors() moves id into
expect_equal(xpath_length(html, "//div[h2[@id='ref-usage']]"), 0)
@@ -68,8 +68,8 @@ test_that(".Rd without usage doesn't get Usage section", {
test_that("pkgdown html dependencies are suppressed from examples in references", {
pkg <- local_pkgdown_site(test_path("assets/reference-html-dep"))
- expect_output(init_site(pkg))
- expect_output(build_reference(pkg, topics = "a"))
+ expect_snapshot(init_site(pkg))
+ expect_snapshot(build_reference(pkg, topics = "a"))
html <- xml2::read_html(file.path(pkg$dst_path, "reference", "a.html"))
# jquery is only loaded once, even though it's included by an example
diff --git a/tests/testthat/test-build-search-docs.R b/tests/testthat/test-build-search-docs.R
index f39b4f1f6..4fa477cda 100644
--- a/tests/testthat/test-build-search-docs.R
+++ b/tests/testthat/test-build-search-docs.R
@@ -1,7 +1,7 @@
test_that("docsearch.json and sitemap.xml are valid", {
pkg <- local_pkgdown_site(test_path("assets/search-site"))
- expect_output(build_site(pkg, new_process = FALSE))
+ expect_snapshot(build_site(pkg, new_process = FALSE))
json <- path(pkg$dst_path, "docsearch.json")
expect_true(jsonlite::validate(read_lines(json)))
@@ -21,10 +21,10 @@ test_that("build_search() builds the expected search`.json with an URL", {
mode: devel
')
- expect_output(init_site(pkg))
- expect_output(build_news(pkg))
- expect_output(build_home(pkg))
- expect_output(build_sitemap(pkg))
+ expect_snapshot(init_site(pkg))
+ expect_snapshot(build_news(pkg))
+ expect_snapshot(build_home(pkg))
+ expect_snapshot(build_sitemap(pkg))
json_path <- withr::local_tempfile()
jsonlite::write_json(build_search_index(pkg), json_path, pretty = TRUE)
@@ -41,10 +41,10 @@ test_that("build_search() builds the expected search.json with no URL", {
mode: devel
')
- expect_output(init_site(pkg))
- expect_output(build_news(pkg))
- expect_output(build_home(pkg))
- expect_output(build_sitemap(pkg))
+ expect_snapshot(init_site(pkg))
+ expect_snapshot(build_news(pkg))
+ expect_snapshot(build_home(pkg))
+ expect_snapshot(build_sitemap(pkg))
json_path <- withr::local_tempfile()
jsonlite::write_json(build_search_index(pkg), json_path, pretty = TRUE)
diff --git a/tests/testthat/test-check.R b/tests/testthat/test-check.R
index 8dcfc6cfb..796ddf33e 100644
--- a/tests/testthat/test-check.R
+++ b/tests/testthat/test-check.R
@@ -1,4 +1,4 @@
-test_that("fails if reference index incomplete", {
+cli::test_that_cli("fails if reference index incomplete", {
pkg <- local_pkgdown_site(test_path("assets/reference"), meta = "
reference:
- title: Title
@@ -8,7 +8,7 @@ test_that("fails if reference index incomplete", {
})
-test_that("fails if article index incomplete", {
+cli::test_that_cli("fails if article index incomplete", {
pkg <- local_pkgdown_site(test_path("assets/articles"), meta = "
articles:
- title: Title
@@ -17,7 +17,7 @@ test_that("fails if article index incomplete", {
expect_snapshot(check_pkgdown(pkg), error = TRUE)
})
-test_that("informs if everything is ok", {
+cli::test_that_cli("informs if everything is ok", {
pkg <- local_pkgdown_site(test_path("assets/reference"))
expect_snapshot(check_pkgdown(pkg))
})
diff --git a/tests/testthat/test-figure.R b/tests/testthat/test-figure.R
index 5be80c383..0ac81796b 100644
--- a/tests/testthat/test-figure.R
+++ b/tests/testthat/test-figure.R
@@ -1,4 +1,4 @@
-test_that("can override defaults in _pkgdown.yml", {
+cli::test_that_cli("can override defaults in _pkgdown.yml", {
skip_if_no_pandoc()
withr::local_temp_libpaths()
@@ -6,11 +6,11 @@ test_that("can override defaults in _pkgdown.yml", {
callr::rcmd("INSTALL", pkg$src_path, show = FALSE, fail_on_status = TRUE)
- expect_output(build_reference(pkg, devel = FALSE))
+ expect_snapshot(build_reference(pkg, devel = FALSE))
img <- path_file(dir_ls(path(pkg$dst_path, "reference"), glob = "*.jpg"))
expect_setequal(img, c("figure-1.jpg", "figure-2.jpg"))
- expect_output(build_articles(pkg))
+ expect_snapshot(build_articles(pkg))
img <- path_file(dir_ls(path(pkg$dst_path, "articles"), glob = "*.jpg", recurse = TRUE))
expect_equal(img, "unnamed-chunk-1-1.jpg")
})
diff --git a/tests/testthat/test-init.R b/tests/testthat/test-init.R
index 9f4a9cc91..c1595c6e0 100644
--- a/tests/testthat/test-init.R
+++ b/tests/testthat/test-init.R
@@ -1,13 +1,13 @@
-test_that("extra.css and extra.js copied and linked", {
+cli::test_that_cli("extra.css and extra.js copied and linked", {
pkg <- local_pkgdown_site(test_path("assets/init-extra-2"))
- expect_output(init_site(pkg))
+ expect_snapshot(init_site(pkg))
expect_true(file_exists(path(pkg$dst_path, "extra.css")))
expect_true(file_exists(path(pkg$dst_path, "extra.js")))
skip_if_no_pandoc()
# Now check they actually get used .
- expect_output(build_home(pkg))
+ expect_snapshot(build_home(pkg))
html <- xml2::read_html(path(pkg$dst_path, "index.html"))
paths <- xpath_attr(html, ".//link", "href")
@@ -15,22 +15,22 @@ test_that("extra.css and extra.js copied and linked", {
expect_true("extra.css" %in% paths)
})
-test_that("single extra.css correctly copied", {
+cli::test_that_cli("single extra.css correctly copied", {
pkg <- local_pkgdown_site(test_path("assets/init-extra-1"))
- expect_output(init_site(pkg))
+ expect_snapshot(init_site(pkg))
expect_true(file_exists(path(pkg$dst_path, "extra.css")))
})
-test_that("asset subdirectories are copied", {
+cli::test_that_cli("asset subdirectories are copied", {
pkg <- local_pkgdown_site(test_path("assets/init-asset-subdirs"))
- expect_output(init_site(pkg))
+ expect_snapshot(init_site(pkg))
expect_true(file_exists(path(pkg$dst_path, "subdir1", "file1.txt")))
expect_true(file_exists(path(pkg$dst_path, "subdir1", "subdir2", "file2.txt")))
})
-test_that("site meta doesn't break unexpectedly", {
+cli::test_that_cli("site meta doesn't break unexpectedly", {
pkgdown <- as_pkgdown(test_path("assets/reference"))
# null out components that will vary
@@ -40,5 +40,5 @@ test_that("site meta doesn't break unexpectedly", {
yaml$pandoc <- "{version}"
yaml$last_built <- timestamp(as.POSIXct("2020-01-01", tz = "UTC"))
- expect_snapshot_output(yaml)
+ expect_snapshot(yaml)
})
diff --git a/tests/testthat/test-rd-example.R b/tests/testthat/test-rd-example.R
index c53cd7511..229d900e6 100644
--- a/tests/testthat/test-rd-example.R
+++ b/tests/testthat/test-rd-example.R
@@ -51,7 +51,7 @@ test_that("extracts conditions from if", {
expect_equal(rd2ex("\\ifelse{latex}{1 + 2}{3 + 4}"), "3 + 4")
})
-test_that("@examplesIf", {
+cli::test_that_cli("@examplesIf", {
rd <- paste0(
"\\dontshow{if (1 == 0) (if (getRversion() >= \"3.4\") withAutoprint else force)(\\{ # examplesIf}\n",
"answer <- 43\n",
@@ -88,8 +88,7 @@ test_that("@examplesIf", {
"answer <- 43",
"}"
)
- expect_no_error(expect_warning(
- expect_equal(strtrim(rd2ex(rd3), 40), strtrim(exp3, 40)),
- "is FALSE"
- ))
+ expect_snapshot(
+ expect_equal(strtrim(rd2ex(rd3), 40), strtrim(exp3, 40))
+ )
})
diff --git a/tests/testthat/test-rd-html.R b/tests/testthat/test-rd-html.R
index 98a240729..f98d7acf3 100644
--- a/tests/testthat/test-rd-html.R
+++ b/tests/testthat/test-rd-html.R
@@ -24,11 +24,12 @@ test_that("simple wrappers work as expected", {
expect_equal(rd2html("\\strong{\\emph{x}}"), "x")
})
-test_that("subsection generates h3", {
- expect_snapshot(cat_line(rd2html("\\subsection{A}{B}")))
+cli::test_that_cli("subsection generates h3", {
+ expect_snapshot(cli::cat_line(rd2html("\\subsection{A}{B}")))
})
-test_that("subsection generates h3", {
- expect_snapshot(cat_line(rd2html("\\subsection{A}{
+
+cli::test_that_cli("subsection generates h3", {
+ expect_snapshot(cli::cat_line(rd2html("\\subsection{A}{
p1
p2
@@ -44,8 +45,8 @@ test_that("subsection generates generated anchor", {
expect_equal(xpath_attr(html, ".//a", "href"), "#a")
})
-test_that("nested subsection generates h4", {
- expect_snapshot(cat_line(rd2html("\\subsection{H3}{\\subsection{H4}{}}")))
+cli::test_that_cli("nested subsection generates h4", {
+ expect_snapshot(cli::cat_line(rd2html("\\subsection{H3}{\\subsection{H4}{}}")))
})
test_that("if generates html", {
@@ -170,9 +171,9 @@ test_that("Sexprs with multiple args are parsed", {
expect_equal(rd2html("\\Sexpr[results=hide,stage=build]{1}"), character())
})
-test_that("Sexprs with multiple args are parsed", {
+cli::test_that_cli("Sexprs with multiple args are parsed", {
local_context_eval()
- expect_error(rd2html("\\Sexpr[results=verbatim]{1}"), "not yet supported")
+ expect_snapshot(rd2html("\\Sexpr[results=verbatim]{1}"), error = TRUE)
})
test_that("Sexprs in file share environment", {
@@ -277,7 +278,7 @@ test_that("link to non-existing functions return label", {
expect_equal(rd2html("\\linkS4class{TEST}"), "TEST")
})
-test_that("bad specs throw errors", {
+cli::test_that_cli("bad specs throw errors", {
expect_snapshot(error = TRUE, {
rd2html("\\url{}")
rd2html("\\url{a\nb}")
diff --git a/tests/testthat/test-render.R b/tests/testthat/test-render.R
index 77e5316b2..13aceb748 100644
--- a/tests/testthat/test-render.R
+++ b/tests/testthat/test-render.R
@@ -12,7 +12,7 @@ test_that("capture data_template()", {
expect_snapshot_output(data)
})
-test_that("can include text in header, before body, and after body", {
+cli::test_that_cli("can include text in header, before body, and after body", {
pkg <- local_pkgdown_site(test_path("assets/site-empty"), '
template:
includes:
@@ -34,7 +34,7 @@ test_that("can include text in header, before body, and after body", {
)
pkg$bs_version <- 5
- expect_output(init_site(pkg))
+ expect_snapshot(init_site(pkg))
html <- render_page_html(pkg, "title-body")
expect_equal(
xpath_text(html, ".//test"),
diff --git a/tests/testthat/test-rmarkdown.R b/tests/testthat/test-rmarkdown.R
index c0ffe732d..4bee49382 100644
--- a/tests/testthat/test-rmarkdown.R
+++ b/tests/testthat/test-rmarkdown.R
@@ -1,9 +1,9 @@
-test_that("render_rmarkdown copies image files in subdirectories", {
+cli::test_that_cli("render_rmarkdown copies image files in subdirectories", {
skip_if_no_pandoc()
tmp <- dir_create(file_temp())
pkg <- list(src_path = test_path("."), dst_path = tmp, bs_version = 3)
- expect_output(
+ expect_snapshot(
render_rmarkdown(pkg, "assets/vignette-with-img.Rmd", "test.html")
)
expect_equal(
@@ -12,7 +12,7 @@ test_that("render_rmarkdown copies image files in subdirectories", {
)
})
-test_that("render_rmarkdown yields useful error", {
+cli::test_that_cli("render_rmarkdown yields useful error", {
skip_on_cran() # fragile due to pandoc dependency
skip_if_no_pandoc("2.18")
@@ -25,12 +25,12 @@ test_that("render_rmarkdown yields useful error", {
})
})
-test_that("render_rmarkdown styles ANSI escapes", {
+cli::test_that_cli("render_rmarkdown styles ANSI escapes", {
skip_if_no_pandoc()
tmp <- dir_create(file_temp())
pkg <- list(src_path = test_path("."), dst_path = tmp, bs_version = 5)
- expect_output({
+ expect_snapshot({
path <- render_rmarkdown(pkg,
input = "assets/vignette-with-crayon.Rmd",
output = "test.html"
diff --git a/tests/testthat/test-sitrep.R b/tests/testthat/test-sitrep.R
index bae4e8d7f..a488ae565 100644
--- a/tests/testthat/test-sitrep.R
+++ b/tests/testthat/test-sitrep.R
@@ -1,11 +1,11 @@
-test_that("pkgdown_sitrep works", {
+cli::test_that_cli("pkgdown_sitrep works", {
# URL not in the pkgdown config
pkg <- test_path("assets/figure")
- expect_snapshot_output(pkgdown_sitrep(pkg))
+ expect_snapshot(pkgdown_sitrep(pkg))
# URL only in the pkgdown config
pkg <- test_path("assets/cname")
- expect_snapshot_output(pkgdown_sitrep(pkg))
+ expect_snapshot(pkgdown_sitrep(pkg))
# URL everywhere
pkg <- test_path("assets/open-graph")
- expect_snapshot_output(pkgdown_sitrep(pkg))
+ expect_snapshot(pkgdown_sitrep(pkg))
})
diff --git a/tests/testthat/test-utils-yaml.R b/tests/testthat/test-utils-yaml.R
index ebf8d2d7a..23646d227 100644
--- a/tests/testthat/test-utils-yaml.R
+++ b/tests/testthat/test-utils-yaml.R
@@ -1,16 +1,10 @@
-test_that("pkgdown_field(s) produces useful description", {
+cli::test_that_cli("pkgdown_field(s) produces useful description", {
pkg <- local_pkgdown_site()
file_touch(file.path(pkg$src_path, "_pkgdown.yml"))
expect_snapshot({
- pkgdown_field(pkg, c("a", "b"))
- pkgdown_fields(pkg, list(c("a", "b"), "c"))
+ pkgdown_field(c("a", "b"))
})
-})
-
-test_that("pkgdown_field(s) produces useful description", {
- pkg <- local_pkgdown_site()
- file_touch(file.path(pkg$src_path, "_pkgdown.yml"))
expect_snapshot(error = TRUE, {
check_yaml_has("x", where = "a", pkg = pkg)