Skip to content

Commit

Permalink
Merge branch 'main' into argument-anchors
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley authored Apr 29, 2024
2 parents 60dc9b5 + 6aff501 commit e1b226b
Show file tree
Hide file tree
Showing 23 changed files with 134 additions and 50 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Suggests:
diffviewer,
evaluate,
gert,
gt,
htmltools,
htmlwidgets,
knitr,
Expand Down
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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* 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).
Expand Down
25 changes: 25 additions & 0 deletions R/build-redirects.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
#' Build redirects
#'
#' @description
#' 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
#' everywhere that you might deploy your site.
#'
#' 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
#' exclude it from the search index, see `?build_search`.
#'
#' @inheritParams as_pkgdown
#' @export
build_redirects <- function(pkg = ".",
override = list()) {
pkg <- section_init(pkg, depth = 1L, override = override)
Expand Down
22 changes: 1 addition & 21 deletions R/build.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#' * [build_articles()]
#' * [build_tutorials()]
#' * [build_news()]
#' * [build_redirects()]
#'
#' See the documentation for the each function to learn how to control
#' that aspect of the site. This page documents options that affect the
Expand Down Expand Up @@ -276,27 +277,6 @@
#' install_metadata: true
#' ```
#'
#' # Redirects
#' 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
#' everywhere that you might deploy your site.
#'
#' 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
#' exclude it from the search index, see `?build_search`.
#'
#' # Options
#' Users with limited internet connectivity can disable CRAN checks by setting
#' `options(pkgdown.internet = FALSE)`. This will also disable some features
Expand Down
12 changes: 12 additions & 0 deletions R/pkgdown_print.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,15 @@ pkgdown_print.htmlwidget <- function(x, visible = TRUE) {
x$height <- x$height %||% (settings$fig.height * settings$dpi)
x
}

#' @export
pkgdown_print.gt_tbl <- function(x, visible = TRUE) {
if (!visible) {
return(invisible())
}

htmltools::div(
class = "gt-table",
gt::as_raw_html(x)
)
}
9 changes: 9 additions & 0 deletions R/test.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ NULL
#' text(2, 5, "Hello", srt = 30, cex = 2)
NULL

#' Test case: tables
#'
#' @name test-tables
#' @keywords internal
#' @family tests
#' @examples
#' gt::gt(head(mtcars))
NULL

#' Test case: don't
#'
#' @name test-dont
Expand Down
6 changes: 6 additions & 0 deletions inst/BS5/assets/pkgdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,12 @@ pre {
padding: 1rem 0.5rem;
}

// Spacing tweaks for gt table
pre div.gt-table {
white-space: normal;
margin-top: 1rem;
}

// "Pop" code out of page margins on small screens to give a little more room
@include media-breakpoint-down(sm) {
// div.section div.sourceCode pre
Expand Down
34 changes: 34 additions & 0 deletions man/build_redirects.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 1 addition & 21 deletions man/build_site.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/index.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/test-crayon.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/test-dont.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/test-figures.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/test-links.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/test-lists.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/test-long-lines.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/test-output-styles.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/test-params.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/test-sexpr-title.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions man/test-tables.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/test-verbatim.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,8 @@ reference:
desc: Build a complete site or one of its components.
contents:
- build_site
- build_articles
- build_favicons
- build_home
- build_news
- build_tutorials
- build_reference
- build_search
- starts_with("build_")
- -build_site_github_pages
- init_site
- preview_site
- pkgdown_sitrep
Expand Down

0 comments on commit e1b226b

Please sign in to comment.