Skip to content

Commit

Permalink
Merged origin/main into analytics-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Apr 17, 2024
2 parents 7b16b6c + a319c9c commit a3fd911
Show file tree
Hide file tree
Showing 23 changed files with 1,076 additions and 138 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
- {os: macos-latest, r: 'release'}

- {os: windows-latest, r: 'release'}
# Use 3.6 to trigger usage of RTools35
- {os: windows-latest, r: '3.6'}
# use 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: '4.1'}

Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Imports:
memoise,
purrr (>= 1.0.0),
ragg,
rlang (>= 1.0.0),
rlang (>= 1.1.0),
rmarkdown (>= 1.1.9007),
tibble,
whisker,
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# pkgdown (development version)

* The skip link now becomes visible when focussed (#2138). Thanks to @glin for the styles!
* `build_reference_index()` gives more informative errors if your `contents` field is malformed (#2323).
* The left and right footers no longer contain an extra empty paragraph tag and the footer gains additional padding-top to keep the whitespace constant (#2381).
* `build_article_index()` and `build_reference_index()` use an improved BS5 template that correctly wraps each section description in a `<div>`, rather than a `<p>`. This eliminates an empty pargraph tag that preceded each section description (#2352).
* `build_news()` now warns if it doesn't find any version headings, suggesting that that `NEWS.md` is structured incorrectly (#2213).
Expand Down
4 changes: 2 additions & 2 deletions R/build-home-index.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ data_home_sidebar <- function(pkg = ".", call = caller_env()) {

sidebar_components <- utils::modifyList(
sidebar_components,
purrr::map2(
unwrap_purrr_error(purrr::map2(
components,
names(components),
data_home_component,
pkg = pkg,
call = call
) %>%
)) %>%
set_names(names(components))
)

Expand Down
62 changes: 36 additions & 26 deletions R/build-reference-index.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ data_reference_index <- function(pkg = ".", error_call = caller_env()) {
return(list())
}

rows <- meta %>%
purrr::imap(data_reference_index_rows, pkg = pkg) %>%
purrr::compact() %>%
unlist(recursive = FALSE)
unwrap_purrr_error(
rows <- meta %>%
purrr::imap(data_reference_index_rows, pkg = pkg) %>%
purrr::compact() %>%
unlist(recursive = FALSE)
)

has_icons <- purrr::some(rows, ~ .x$row_has_icons %||% FALSE)

Expand Down Expand Up @@ -47,7 +49,8 @@ data_reference_index_rows <- function(section, index, pkg) {


if (has_name(section, "contents")) {
check_all_characters(section$contents, index, pkg)
id <- section$title %||% section$subtitle %||% index
check_contents(section$contents, id, pkg)
topics <- section_topics(section$contents, pkg$topics, pkg$src_path)

names <- topics$name
Expand All @@ -64,35 +67,42 @@ data_reference_index_rows <- function(section, index, pkg) {
purrr::compact(rows)
}

check_all_characters <- function(contents, index, pkg) {
null <- purrr::map_lgl(contents, is.null)
any_null <- any(null)
check_contents <- function(contents, id, pkg) {
malformed <- "This typically indicates that your {pkgdown_config_href(pkg$src_path)} is malformed."
call <- quote(build_reference_index())

if (any_null) {
msg_fld <- pkgdown_field(pkg, "reference", cfg = TRUE, fmt = TRUE)
if (length(contents) == 0) {
cli::cli_abort(
c(
"Item {.field {which(null)}} in section {index} is empty.",
x = paste0("Delete the empty line or add function name to ", msg_fld, ".")
), call = caller_env()
"Section {.val {id}}: {.field contents} is empty.",
i = malformed
),
call = call
)
}

not_char <- !purrr::map_lgl(contents, is.character)
any_not_char <- any(not_char)

if (!any_not_char) {
return(invisible())
is_null <- purrr::map_lgl(contents, is.null)
if (any(is_null)) {
cli::cli_abort(
c(
"Section {.val {id}}: contents {.field {which(is_null)}} is empty.",
i = malformed
),
call = call
)
}

msg_fld <- pkgdown_field(pkg, "reference", cfg = TRUE, fmt = TRUE)
cli::cli_abort(
c(
"Item {.field {which(not_char)}} in section {index} must be a character.",
x = paste0("You might need to add '' around e.g. - 'N' or - 'off' to ", msg_fld, ".")
), call = caller_env()
)

is_char <- purrr::map_lgl(contents, is.character)
if (!all(is_char)) {
cli::cli_abort(
c(
"Section {.val {id}}: {.field {which(!is_char)}} must be a character.",
i = "You might need to add '' around special values like 'N' or 'off'",
i = malformed
),
call = call
)
}
}

find_icons <- function(x, path) {
Expand Down
12 changes: 8 additions & 4 deletions R/build-reference.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ build_reference <- function(pkg = ".",
topics <- purrr::transpose(pkg$topics)
}

purrr::map(
unwrap_purrr_error(purrr::map(
topics,
build_reference_topic,
pkg = pkg,
lazy = lazy,
examples_env = examples_env,
run_dont_run = run_dont_run
)
))

preview_site(pkg, "reference", preview = preview)
}
Expand Down Expand Up @@ -268,7 +268,7 @@ build_reference_topic <- function(topic,
pkg,
lazy = TRUE,
examples_env = globalenv(),
run_dont_run = FALSE ) {
run_dont_run = FALSE) {

in_path <- path(pkg$src_path, "man", topic$file_in)
out_path <- path(pkg$dst_path, "reference", topic$file_out)
Expand All @@ -286,7 +286,11 @@ build_reference_topic <- function(topic,
run_dont_run = run_dont_run
),
error = function(err) {
cli::cli_abort("Failed to parse Rd in {.file {topic$file_in}}", parent = err)
cli::cli_abort(
"Failed to parse Rd in {.file {topic$file_in}}",
parent = err,
call = quote(build_reference())
)
}
)

Expand Down
Loading

0 comments on commit a3fd911

Please sign in to comment.