Skip to content

Commit

Permalink
Merge branch 'main' into addin
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley authored Apr 30, 2024
2 parents c89f901 + df6e6ea commit 8e313ae
Show file tree
Hide file tree
Showing 133 changed files with 1,614 additions and 4,137 deletions.
6 changes: 5 additions & 1 deletion 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 (>= 1.1.9007),
rmarkdown (>= 2.26.2),
tibble,
whisker,
withr (>= 2.4.3),
Expand All @@ -45,10 +45,12 @@ Suggests:
diffviewer,
evaluate,
gert,
gt,
htmltools,
htmlwidgets,
knitr,
lifecycle,
magick,
methods,
openssl,
pkgload (>= 1.0.2),
Expand All @@ -70,3 +72,5 @@ Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
SystemRequirements: pandoc
Remotes:
rstudio/rmarkdown
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ S3method(as_html,tag_url)
S3method(as_html,tag_var)
S3method(as_html,tag_verb)
S3method(pkgdown_print,default)
S3method(pkgdown_print,gt_tbl)
S3method(pkgdown_print,htmlwidget)
S3method(print,pkgdown_xml)
S3method(print,print_yaml)
Expand Down Expand Up @@ -116,6 +117,7 @@ export(build_favicons)
export(build_home)
export(build_home_index)
export(build_news)
export(build_redirects)
export(build_reference)
export(build_reference_index)
export(build_search)
Expand Down
19 changes: 19 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
# pkgdown (development version)

* The addin now runs `build_site()` instead of `build_site_external()`, which generally should be more reliable (#2252).
* Anchors are displayed when they're the target of a link.
* `build_reference()` adds anchors to arguments making it possible to link directly to an argument, if desired. A subtle visual treatment makes it easy to see which argument is targeted (#2228).
* `build_redirects()` is now exported to make it easier to document (#2500).
* `build_reference()` now automatically renders any tables created by gt (#2326).
* `build_articles()` now drops a section called "internal". This allows you to have articles that either aren't indexed at all or are included manually elsewhere in the navbar (#2205).
* `as.pkgdown()` will no longer prompt you to install a missing template package from CRAN, since these are almost always found in GitHub (#2076).
* `init_site()` once again describes one copy per line, and now uses a better prefix when copying assets from pkgdown itself (#2445).
* Very wide words are now automatically broken across lines and hyphenated (when possible) when they'd otherwise create a horizontal scrollbar on mobile (#1888).
* The `repo.source.url` field no longer requires a trailing slash (#2017).
* Anywhere you can use `_pkgdown.yml`, you can now use `_pkgdown.yaml` (#2244).
* pkgdown no longer overrides the default selection colours. This improves accessibility for users who have set their own colours in their browser settings (#2139, @glin).
* `build_article()` now escapes html characters in the title (#2286).
* `build_article()` no longer generates the wrong source link when you build your site outside of the root directory (#2172).
* `build_reference()` matches usage for S3 and S4 methods to the style used by R 4.0.0 and later (#2187).
* `<source>` tags now have their `srcref` attributes tweaked in the same way that the `src` attributes of `<img>` tags are (#2402).
* New translation for "Search site", the label applied to the search box for screenreaders. This was previously incorrectly labelled as "Toggle navigation" (#2320).
* You can now choose where the search box is placed with the "search" navbar component. This has been documented for a very long time, but as far as I can tell, never worked (#2320). If you have made your own template with a custom `navbar`, you will need to remove the `<form>` with `role="search"` to avoid getting two search boxes.
* The mobile version of pkgdown sites no longer has a scrollburglar (a small amount of horizontal scroll) (#2179, @netique).
* The `template.bslib` item now also accepts a `bootswatch` key (@gadenbuie, #2483).

# pkgdown 2.0.9

Expand Down
40 changes: 27 additions & 13 deletions R/build-articles.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' package, not the current source version. This makes iteration quicker when
#' you are primarily working on the text of an article.
#'
#' @section Index and navbar:
#' # Index and navbar
#' You can control the articles index and navbar with a `articles` field in
#' your `_pkgdown.yml`. If you use it, pkgdown will check that all articles
#' are included, and will error if you have missed any.
Expand Down Expand Up @@ -77,7 +77,7 @@
#' the navbar, it will link directly to the articles index instead of
#' providing a drop-down.
#'
#' @section Get started:
#' # Get started
#' Note that a vignette with the same name as the package (e.g.,
#' `vignettes/pkgdown.Rmd` or `vignettes/articles/pkgdown.Rmd`) automatically
#' becomes a top-level "Get started" link, and will not appear in the articles
Expand All @@ -86,7 +86,14 @@
#' (If your package name includes a `.`, e.g. `pack.down`, use a `-` in the
#' vignette name, e.g. `pack-down.Rmd`.)
#'
#' @section External files:
#' ## Missing topics
#'
#' pkgdown will warn if there are (non-internal) articles that aren't listed
#' in the articles index. You can suppress such warnings by listing the
#' affected articles in a section with `title: internal` (case sensitive);
#' this section will not be displayed on the index page.
#'
#' # External files
#' pkgdown differs from base R in its handling of external files. When building
#' vignettes, R assumes that vignettes are self-contained (a reasonable
#' assumption when most vignettes were PDFs) and only copies files explicitly
Expand All @@ -107,7 +114,7 @@
#' Note that you can not use the `fig.path` to change the output directory of
#' generated figures as its default value is a strong assumption of rmarkdown.
#'
#' @section Embedding Shiny apps:
#' # Embedding Shiny apps
#' If you would like to embed a Shiny app into an article, the app will have
#' to be hosted independently, (e.g. <https://www.shinyapps.io>). Then, you
#' can embed the app into your article using an `<iframe>`, e.g.
Expand All @@ -116,7 +123,7 @@
#' See <https://github.com/r-lib/pkgdown/issues/838#issuecomment-430473856> for
#' some hints on how to customise the appearance with CSS.
#'
#' @section Output formats:
#' # Output formats
#' By default, pkgdown builds all articles using the
#' [rmarkdown::html_document()] `output` format, ignoring whatever is set in
#' your YAML metadata. This is necessary because pkgdown has to integrate the
Expand Down Expand Up @@ -148,15 +155,15 @@
#'
#' Additionally, htmlwidgets do not work when `as_is: true`.
#'
#' @inheritSection build_reference Figures
#'
#' @section Suppressing vignettes:
#' # Suppressing vignettes
#' If you want articles that are not vignettes, either put them in
#' subdirectories or list in `.Rbuildignore`. An articles link will be
#' automatically added to the default navbar if the vignettes directory is
#' present: if you do not want this, you will need to customise the navbar. See
#' [build_site()] details.
#'
#' @inheritSection build_reference Figures
#'
#' @inheritParams as_pkgdown
#' @param quiet Set to `FALSE` to display output of knitr and
#' pandoc. This is useful when debugging.
Expand All @@ -174,6 +181,9 @@ build_articles <- function(pkg = ".",
override = list(),
preview = NA) {
pkg <- section_init(pkg, depth = 1L, override = override)
check_bool(quiet)
check_bool(lazy)
check_number_whole(seed, allow_null = TRUE)

if (nrow(pkg$vignettes) == 0L) {
return(invisible())
Expand All @@ -182,14 +192,14 @@ build_articles <- function(pkg = ".",
cli::cli_rule("Building articles")

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

preview_site(pkg, "articles", preview = preview)
}
Expand Down Expand Up @@ -248,10 +258,10 @@ build_article <- function(name,
as_is <- isTRUE(purrr::pluck(front, "pkgdown", "as_is"))

default_data <- list(
pagetitle = front$title,
pagetitle = escape_html(front$title),
toc = toc <- front$toc %||% TRUE,
opengraph = list(description = front$description %||% pkg$package),
source = repo_source(pkg, path_rel(input, pkg$src_path)),
source = repo_source(pkg, input),
filename = path_file(input),
output_file = output_file,
as_is = as_is
Expand Down Expand Up @@ -297,7 +307,8 @@ build_article <- function(name,
output_options = options,
seed = seed,
new_process = new_process,
quiet = quiet
quiet = quiet,
call = quote(build_article())
)
}

Expand Down Expand Up @@ -391,6 +402,9 @@ data_articles_index <- function(pkg = ".") {
)
}

# Remove internal section after missing vignettes check
sections <- Filter(function(x) x$title != "internal", sections)

print_yaml(list(
pagetitle = tr_("Articles"),
sections = sections
Expand Down
11 changes: 6 additions & 5 deletions R/build-favicons.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,12 @@ build_favicons <- function(pkg = ".", overwrite = FALSE) {
copy_favicons <- function(pkg = ".") {
pkg <- as_pkgdown(pkg)

favicons <- path(pkg$src_path, "pkgdown", "favicon")
if (!dir_exists(favicons))
return()

dir_copy_to(pkg, favicons, pkg$dst_path)
dir_copy_to(
src_dir = path(pkg$src_path, "pkgdown", "favicon"),
src_root = pkg$src_path,
dst_dir = pkg$dst_path,
dst_root = pkg$dst_path
)
}

has_favicons <- function(pkg = ".") {
Expand Down
Loading

0 comments on commit 8e313ae

Please sign in to comment.