Skip to content

Commit

Permalink
Merge branch 'main' into parts
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy authored May 21, 2024
2 parents e40d7b0 + 39ea964 commit 9d85e61
Show file tree
Hide file tree
Showing 56 changed files with 291 additions and 266 deletions.
4 changes: 1 addition & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Imports:
purrr (>= 1.0.0),
ragg,
rlang (>= 1.1.0),
rmarkdown (>= 2.26.2),
rmarkdown (>= 2.27),
tibble,
whisker,
withr (>= 2.4.3),
Expand Down Expand Up @@ -72,5 +72,3 @@ Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
SystemRequirements: pandoc
Remotes:
rstudio/rmarkdown
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# pkgdown (development version)

* Custom navbars that specify `icon` but not `aria-label` will now generate a message reminding you to provide one for to improve accessibility (#2533).
* `init_site()` will no longer automatically build favicons on CI systems (e.g. GHA). This is an expensive operation that uses an external service so it should only be run locally (#2553).
* `build_home_index()` now reports when rendering the home page (#2544).
* Bootstrap 3 has been deprecated. It was superseded in December 2021, and now we're starting to more directly encourage folks to move away from it.
* Improve HTML5 compliance (#2369):
* No longer support IE9 or earlier
Expand Down
6 changes: 2 additions & 4 deletions R/build-articles.R
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,8 @@ build_article <- function(name,

front <- rmarkdown::yaml_front_matter(input_path)
# Take opengraph from article's yaml front matter
front_opengraph <- check_open_graph(front$opengraph %||% list())
data$opengraph <- utils::modifyList(
data$opengraph %||% list(), front_opengraph
)
front_opengraph <- check_open_graph(front$opengraph, input)
data$opengraph <- modify_list(data$opengraph, front_opengraph)

# Allow users to opt-in to their own template
ext <- purrr::pluck(front, "pkgdown", "extension", .default = "html")
Expand Down
4 changes: 2 additions & 2 deletions R/build-favicons.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ build_favicons <- function(pkg = ".", overwrite = FALSE) {
cli::cli_abort("API request failed.", .internal = TRUE)
}

tmp <- withr::local_tempdir()
tmp <- withr::local_tempfile()
result <- httr::RETRY(
"GET",
result$favicon$package_url,
httr::write_disk(tmp),
httr::write_disk(tmp, overwrite = TRUE),
quiet = TRUE
)

Expand Down
4 changes: 2 additions & 2 deletions R/build-home-authors.R
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ citation_auto <- function(pkg) {
)
}

# helpers -----------------------------------------------------------------
# helpers -------------------------------------------------------------------------

# Not strictly necessary, but produces a simpler data structure testing
remove_orcid <- function(x) {
Expand All @@ -301,4 +301,4 @@ remove_orcid <- function(x) {
names(out) <- NULL
}
out
}
}
9 changes: 9 additions & 0 deletions R/build-home-index.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ build_home_index <- function(pkg = ".", quiet = TRUE) {
data <- data_home(pkg)

if (is.null(src_path)) {
cli::cli_inform("Reading {.file DESCRIPTION}")
data$index <- linkify(pkg$desc$get_field("Description", ""))
} else {
cli::cli_inform("Reading {src_path(path_rel(src_path, pkg$src_path))}")
local_options_link(pkg, depth = 0L)
data$index <- markdown_body(src_path)
}

cur_digest <- file_digest(dst_path)
render_page(pkg, "home", data, "index.html", quiet = quiet)

strip_header <- isTRUE(pkg$meta$home$strip_header)
Expand All @@ -28,6 +32,11 @@ build_home_index <- function(pkg = ".", quiet = TRUE) {
logo = logo_path(pkg, depth = 0)
)

new_digest <- file_digest(dst_path)
if (cur_digest != new_digest) {
writing_file(path_rel(dst_path, pkg$dst_path), "index.html")
}

invisible()
}

Expand Down
4 changes: 2 additions & 2 deletions R/build-news.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ data_news <- function(pkg = list()) {
sections <- sections[!is.na(versions)]

if (length(sections) == 0) {
cli::cli_warn(c(
cli::cli_warn(c(
"No version headings found in {src_path('NEWS.md')}",
i = "See {.help pkgdown::build_news} for expected structure."
))
}

versions <- versions[!is.na(versions)]

show_dates <- purrr::pluck(pkg, "meta", "news", "cran_dates", .default = !is_testing())
Expand Down
20 changes: 10 additions & 10 deletions R/build-redirects.R
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#' Build redirects
#'
#'
#' @description
#' If you change the structure of your documentation (by renaming vignettes or
#' If you change the structure of your documentation (by renaming vignettes or
#' help topics) you can setup redirects from the old content to the new content.
#' One or several now-absent pages can be redirected to a new page (or to a new
#' section of a new page). This works by creating a html page that performs a
#' "meta refresh", which isn't the best way of doing a redirect but works
#' One or several now-absent pages can be redirected to a new page (or to a new
#' section of a new page). This works by creating a html page that performs a
#' "meta refresh", which isn't the best way of doing a redirect but works
#' everywhere that you might deploy your site.
#'
#' The syntax is the following, with old paths on the left, and new paths or
#'
#' The syntax is the following, with old paths on the left, and new paths or
#' URLs on the right.
#'
#'
#' ```yaml
#' redirects:
#' - ["articles/old-vignette-name.html", "articles/new-vignette-name.html"]
#' - ["articles/another-old-vignette-name.html", "articles/new-vignette-name.html"]
#' - ["articles/yet-another-old-vignette-name.html", "https://pkgdown.r-lib.org/dev"]
#' ```
#'
#' If for some reason you choose to redirect an existing page make sure to
#'
#' If for some reason you choose to redirect an existing page make sure to
#' exclude it from the search index, see `?build_search`.
#'
#' @inheritParams as_pkgdown
Expand Down
2 changes: 1 addition & 1 deletion R/build-reference-index.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ check_missing_topics <- function(rows, pkg, error_call = caller_env()) {

if (any(missing)) {
config_abort(
pkg,
pkg,
c(
"{sum(missing)} topic{?s} missing from index: {.val {pkg$topics$name[missing]}}.",
i = "Either use {.code @keywords internal} to drop from index, or"
Expand Down
4 changes: 2 additions & 2 deletions R/build-reference.R
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ build_reference <- function(pkg = ".",
lazy = lazy,
examples_env = examples_env,
run_dont_run = run_dont_run
))
))

preview_site(pkg, "reference", preview = preview)
}
Expand Down Expand Up @@ -295,7 +295,7 @@ build_reference_topic <- function(topic,
),
error = function(err) {
cli::cli_abort(
"Failed to parse Rd in {.file {topic$file_in}}",
"Failed to parse Rd in {.file {topic$file_in}}",
parent = err,
call = quote(build_reference())
)
Expand Down
10 changes: 5 additions & 5 deletions R/check.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#' Check `_pkgdown.yml`
#'
#' @description
#' This pair of functions checks that your `_pkgdown.yml` is valid without
#' This pair of functions checks that your `_pkgdown.yml` is valid without
#' building the whole site. `check_pkgdown()` errors at the first problem;
#' `pkgdown_sitrep()` reports the status of all checks.
#'
#'
#' Currently they check that:
#'
#' * There's a `url` in the pkgdown configuration, which is also recorded
Expand Down Expand Up @@ -65,7 +65,7 @@ error_to_sitrep <- function(title, code) {
check_urls <- function(pkg = ".", call = caller_env()) {
pkg <- as_pkgdown(pkg)
details <- c(i = "See details in {.vignette pkgdown::metadata}.")

if (identical(pkg$meta, list())) {
cli::cli_abort(
c("No {.path _pkgdown.yml} found.", details),
Expand All @@ -83,12 +83,12 @@ check_urls <- function(pkg = ".", call = caller_env()) {
} else {
desc_urls <- pkg$desc$get_urls()
desc_urls <- sub("/$", "", desc_urls)

if (!pkg$meta[["url"]] %in% desc_urls) {
cli::cli_abort(
c("{.file DESCRIPTION} {.field URL} lacks package url ({url}).", details),
call = call
)
}
}
}
}
108 changes: 0 additions & 108 deletions R/compat-friendly-type.R

This file was deleted.

2 changes: 1 addition & 1 deletion R/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,6 @@ config_abort <- function(pkg,

config_path <- function(pkg) {
# Not all projects necessary have a _pkgdown.yml (#2542)
config <- pkgdown_config_path(pkg$src_path) %||% "_pkgdown.yml"
config <- pkgdown_config_path(pkg) %||% "_pkgdown.yml"
cli::style_hyperlink(path_file(config), paste0("file://", config))
}
10 changes: 5 additions & 5 deletions R/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ init_site <- function(pkg = ".") {
build_bslib(pkg)
}

if (has_logo(pkg) && !has_favicons(pkg)) {
# Building favicons is expensive, so we hopefully only do it once.
# Building favicons is expensive, so we hopefully only do it once, locally
if (has_logo(pkg) && !has_favicons(pkg) && !on_ci()) {
build_favicons(pkg)
}
copy_favicons(pkg)
Expand All @@ -59,8 +59,8 @@ copy_assets <- function(pkg = ".") {
# pkgdown assets
if (!identical(template$default_assets, FALSE)) {
copy_asset_dir(
pkg,
path_pkgdown(paste0("BS", pkg$bs_version, "/", "assets")),
pkg,
path_pkgdown(paste0("BS", pkg$bs_version, "/", "assets")),
src_root = path_pkgdown(),
src_label = "<pkgdown>/"
)
Expand All @@ -69,7 +69,7 @@ copy_assets <- function(pkg = ".") {
# package assets
if (!is.null(template$package)) {
copy_asset_dir(
pkg,
pkg,
path_package_pkgdown("assets", template$package, pkg$bs_version),
src_root = system_file(package = template$package),
src_label = paste0("<", template$package, ">/")
Expand Down
Loading

0 comments on commit 9d85e61

Please sign in to comment.