Skip to content

Commit

Permalink
Merge branch 'main' into incl-assets
Browse files Browse the repository at this point in the history
  • Loading branch information
salim-b committed Mar 12, 2024
2 parents f5e01f0 + 3c4d8f1 commit 75ceecc
Show file tree
Hide file tree
Showing 140 changed files with 1,426 additions and 866 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
tags: ['*']
pull_request:
branches: [master, main]
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: pkgdown

jobs:
pkgdown:
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork == false
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
isPush: ${{ github.event_name == 'push' }}

isPush: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-tinytex@v2

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
shell: Rscript {0}

Expand Down
13 changes: 8 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ Package: pkgdown
Title: Make Static HTML Documentation for a Package
Version: 2.0.7.9000
Authors@R: c(
person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre"),
person("Hadley", "Wickham", , "hadley@posit.co", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-4757-117X")),
person("Jay", "Hesselberth", role = "aut",
comment = c(ORCID = "0000-0002-6299-179X")),
person("Maëlle", "Salmon", role = "aut",
comment = c(ORCID = "0000-0002-2815-0399")),
person("RStudio", role = c("cph", "fnd"))
person("Posit Software, PBC", role = c("cph", "fnd"))
)
Description: Generate an attractive and useful website from a source
package. 'pkgdown' converts your documentation, vignettes, 'README',
Expand All @@ -18,11 +18,11 @@ License: MIT + file LICENSE
URL: https://pkgdown.r-lib.org, https://github.com/r-lib/pkgdown
BugReports: https://github.com/r-lib/pkgdown/issues
Depends:
R (>= 3.1.0)
R (>= 3.6)
Imports:
bslib (>= 0.3.1),
callr (>= 3.7.3),
cli,
cli (>= 3.6.1),
desc (>= 1.4.0),
digest,
downlit (>= 0.4.0),
Expand All @@ -45,6 +45,7 @@ Suggests:
covr,
diffviewer,
evaluate,
gert,
htmltools,
htmlwidgets,
knitr,
Expand All @@ -54,6 +55,7 @@ Suggests:
rsconnect,
rstudioapi,
rticles,
rvest,
sass,
testthat (>= 3.1.3),
tools
Expand All @@ -62,7 +64,8 @@ VignetteBuilder:
Config/Needs/website: usethis, servr
Config/potools/style: explicit
Config/testthat/edition: 3
Config/testthat/parallel: true
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.2.9000
RoxygenNote: 7.3.1
SystemRequirements: pandoc
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
YEAR: 2014--2018
COPYRIGHT HOLDER: RStudio
YEAR: 2023
COPYRIGHT HOLDER: pkgdown authors
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License

Copyright (c) 2014-2018 RStudio
Copyright (c) 2023 pkgdown authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ export(autolink_html)
export(build_article)
export(build_articles)
export(build_articles_index)
export(build_favicon)
export(build_favicons)
export(build_home)
export(build_home_index)
Expand Down
15 changes: 15 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
# pkgdown (development version)

* `\cr` is now translated to `<br>` not `<br />` (#2400).
* Fix parsing of github profiles and issues into links when present at the beginning of list items (@pearsonca, #2122)
* Correct parse usage for S3 methods with non-syntactic class names (#2384).
* Deprecated `build_favicon()` was removed (`build_favicons()` remains).
* Use [cli](https://github.com/r-lib/cli) to provide interactive feedback.
* Preserve Markdown code blocks with class rmd from roxygen2 docs (@salim-b, #2298).
* Avoid unwanted linebreaks from parsing `DESCRIPTION` (@salim-b, #2247).
* Remove redundant entries in the documentation index when multiple explicit `@usage` tags are provided (@klmr, #2302)
* The article index now sorts vignettes and non-vignette articles alphabetically by their filename (literally, their `basename()`), by default (@jennybc, #2253).
* Add Catalan translation (@jmaspons, #2333)
* Set RNG seed before building articles by default. Use `build_articles(seed = NULL)` for the old (unreproducible) behaviour. (@salim-b, #2354).
* Set RNG seed for htmlwidgets IDs. This reduces noise in final HTML output,
both for articles and examples in the reference that contain htmlwidgets
(@salim-b, #2294, #2354).
* Set RNG seed for htmlwidgets IDs. This reduces noise in pkgdown reference HTML output when examples generate htmlwidgets (@salim-b, #2294).
* Fix BS5 navbar template to get `navbar.type: dark` to work with bslib 0.6+ / Bootstrap 5.3+ (@tanho63, #2388)
* Allow detection of quarto `.qmd` articles and let them be processed using the [`quarto`](https://cran.r-project.org/web/packages/quarto/index.html) vignette builder (@rcannood, #2404).
* Fix setting `seed` in `build_reference()`. The seed was reset too early, before. (@salim-b, #2355)
* Translates citation sections (@eliocamp, #2410).
* Topic names that conflict with selector functions can now be listed as references in `_pkgdown.yml` (@dmurdoch, #2397).
* All external assets (JS, CSS, fonts) are now directly included in the site
instead of being fetched from external CDNs if the [Bootstrap 5 template is
used](https://pkgdown.r-lib.org/index.html#pkgdown-200-and-bootstrap-5).
Expand Down
44 changes: 27 additions & 17 deletions R/build-articles.R
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,15 @@
#' pandoc. This is useful when debugging.
#' @param lazy If `TRUE`, will only re-build article if input file has been
#' modified more recently than the output file.
#' @param seed Seed used to initialize random number generation in order to
#' make article output reproducible. An integer scalar or `NULL` for no seed.
#' @param preview If `TRUE`, or `is.na(preview) && interactive()`, will preview
#' freshly generated section in browser.
#' @export
build_articles <- function(pkg = ".",
quiet = TRUE,
lazy = TRUE,
seed = 1014L,
override = list(),
preview = NA) {
pkg <- section_init(pkg, depth = 1L, override = override)
Expand All @@ -177,14 +180,16 @@ build_articles <- function(pkg = ".",
return(invisible())
}

rule("Building articles")
cli::cli_rule("Building articles")

build_articles_index(pkg)
purrr::walk(
pkg$vignettes$name, build_article,
pkg$vignettes$name,
build_article,
pkg = pkg,
quiet = quiet,
lazy = lazy
lazy = lazy,
seed = seed,
quiet = quiet
)

preview_site(pkg, "articles", preview = preview)
Expand All @@ -196,18 +201,22 @@ build_articles <- function(pkg = ".",
#' relative to `vignettes/` without extension, or `index` or `README`.
#' @param data Additional data to pass on to template.
build_article <- function(name,
pkg = ".",
data = list(),
lazy = FALSE,
quiet = TRUE) {
pkg = ".",
data = list(),
lazy = FALSE,
seed = 1014L,
quiet = TRUE) {

pkg <- as_pkgdown(pkg)

# Look up in pkg vignette data - this allows convenient automatic
# specification of depth, output destination, and other parameters that
# allow code sharing with building of the index.
vig <- match(name, pkg$vignettes$name)
if (is.na(vig)) {
stop("Can't find article called ", src_path(name), call. = FALSE)
cli::cli_abort(
"Can't find article {.file {name}}"
)
}

input <- pkg$vignettes$file_in[vig]
Expand Down Expand Up @@ -283,6 +292,7 @@ build_article <- function(name,
output = output_file,
output_format = format,
output_options = options,
seed = seed,
quiet = quiet
)
}
Expand Down Expand Up @@ -368,12 +378,10 @@ data_articles_index <- function(pkg = ".") {
missing <- setdiff(pkg$vignettes$name, c(listed, pkg$package))

if (length(missing) > 0) {
abort(
paste0(
"Vignettes missing from index: ",
paste(missing, collapse = ", ")
),
call. = FALSE
cli::cli_abort(
"{length(missing)} vignette{?s} missing from index in \\
{pkgdown_config_href({pkg$src_path})}: {.val {missing}}.",
call = caller_env()
)
}

Expand All @@ -385,7 +393,10 @@ data_articles_index <- function(pkg = ".") {

data_articles_index_section <- function(section, pkg) {
if (!set_contains(names(section), c("title", "contents"))) {
abort("Section must have components `title`, `contents`")
cli::cli_abort(
"Section must have components {.field title}, {.field contents}",
call = caller_env()
)
}

# Match topics against any aliases
Expand Down Expand Up @@ -424,7 +435,6 @@ default_articles_index <- function(pkg = ".") {
return(NULL)
}


print_yaml(list(
list(
title = tr_("All vignettes"),
Expand Down
37 changes: 13 additions & 24 deletions R/build-favicons.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,25 @@ build_favicons <- function(pkg = ".", overwrite = FALSE) {
rlang::check_installed("openssl")
pkg <- as_pkgdown(pkg)

rule("Building favicons")
cli::cli_rule("Building favicons")

logo_path <- find_logo(pkg$src_path)

if (is.null(logo_path)) {
stop("Can't find package logo PNG or SVG to build favicons.", call. = FALSE)
cli::cli_abort(
"Can't find package logo PNG or SVG to build favicons."
)
}

if (has_favicons(pkg) && !overwrite) {
message("Favicons already exist in `pkgdown/`. Set `overwrite = TRUE` to re-create.")
cli::cli_inform(c(
"Favicons already exist in {.path pkgdown}",
"i" = "Set {.code overwrite = TRUE} to re-create."
))
return(invisible())
}

message("Building favicons with realfavicongenerator.net...")
cli::cli_inform("Building favicons with {.url https://realfavicongenerator.net} ...")

logo <- readBin(logo_path, what = "raw", n = fs::file_info(logo_path)$size)

Expand Down Expand Up @@ -66,18 +71,14 @@ build_favicons <- function(pkg = ".", overwrite = FALSE) {
quiet = TRUE
)
if (httr::http_error(resp)) {
stop("API request failed.", call. = FALSE)
cli::cli_abort("API request failed.", call = caller_env())
}

content <- httr::content(resp)
result <- content$favicon_generation_result

if (!identical(result$result$status, "success")) {
stop(
"API request failed. ", "
Please submit bug report to <https://github.com/r-lib/pkgdown/issues>",
call. = FALSE
)
cli::cli_abort("API request failed.", .internal = TRUE)
}

tmp <- tempfile()
Expand All @@ -93,27 +94,15 @@ build_favicons <- function(pkg = ".", overwrite = FALSE) {
utils::unzip(tmp, exdir = path(pkg$src_path, "pkgdown", "favicon"))
},
warning = function(e) {
abort("Your logo file couldn't be processed and may be corrupt.", parent = e)
cli::cli_abort("Your logo file couldn't be processed and may be corrupt.", parent = e)
},
error = function(e) {
abort("Your logo file couldn't be processed and may be corrupt.", parent = e)
cli::cli_abort("Your logo file couldn't be processed and may be corrupt.", parent = e)
})

invisible()
}

#' Deprecated as of pkgdown 1.4.0
#' @rdname build_favicons
#' @inheritParams build_favicons
#' @export
build_favicon <- function(pkg, overwrite) {
message(
"`build_favicon()` is deprecated as of pkgdown 1.4.0. ",
"Please use `build_favicons()` instead."
)
build_favicons(pkg, overwrite)
}

copy_favicons <- function(pkg = ".") {
pkg <- as_pkgdown(pkg)

Expand Down
4 changes: 2 additions & 2 deletions R/build-github.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ build_site_github_pages <- function(pkg = ".",
pkg <- as_pkgdown(pkg, override = list(destination = dest_dir))

if (clean) {
rule("Cleaning files from old site", line = 1)
cli::cli_rule("Cleaning files from old site")
clean_site(pkg)
}

Expand All @@ -36,7 +36,7 @@ build_site_github_pages <- function(pkg = ".",
}

build_github_pages <- function(pkg = ".") {
rule("Extra files for GitHub pages")
cli::cli_rule("Extra files for GitHub pages")
pkg <- as_pkgdown(pkg)

# Add .nojekyll since site is static HTML
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 @@ -186,8 +186,8 @@ role_lookup <- function(abbr) {

out <- unname(roles[abbr])
if (any(is.na(out))) {
missing <- paste0("'", abbr[is.na(out)], "'", collapse = ", ")
warn(paste0("Unknown MARC role abbreviation ", 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
Expand Down
3 changes: 2 additions & 1 deletion R/build-home-citation.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ data_home_sidebar_citation <- function(pkg = ".") {
pkg <- as_pkgdown(pkg)

sidebar_section(
heading = "Citation",
heading = tr_("Citation"),
bullets = a(sprintf(tr_("Citing %s"), pkg$package), "authors.html#citation")
)
}
Expand Down Expand Up @@ -91,6 +91,7 @@ build_citation_authors <- function(pkg = ".") {

data <- list(
pagetitle = tr_("Authors and Citation"),
citationtitle = tr_("Citation"),
citations = data_citations(pkg),
authors = unname(data_authors(pkg)$all),
source = source
Expand Down
Loading

0 comments on commit 75ceecc

Please sign in to comment.