### Reproducible Examples in pkgdown Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-reference.md Shows that examples in `pkgdown` are reproducible by default, respecting the 'seed' setting. The output demonstrates a sequence of random numbers generated with a specific seed. ```R cat(examples) ``` -------------------------------- ### Build Redirect Example Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-redirects.md Demonstrates the successful creation of a redirect using `build_redirect()` with a character vector specifying old and new paths. ```R build_redirect(c("old.html", "new.html#section"), 1, pkg = pkg) ``` -------------------------------- ### pkgdown_sitrep and check_pkgdown: All Checks Pass Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/check.md Example showing the output of both pkgdown_sitrep and check_pkgdown when all documentation and metadata checks pass successfully. ```R pkgdown_sitrep(pkg) check_pkgdown(pkg) ``` -------------------------------- ### Install pkgdown Development Version Source: https://github.com/r-lib/pkgdown/blob/main/README.md Install the latest development version of pkgdown directly from its GitHub repository using the 'pak' package manager. Ensure 'pak' is installed first if you don't have it. ```r # install.packages("pak") pak::pak("r-lib/pkgdown") ``` -------------------------------- ### Example Condition Check in R Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/rd-example.md This snippet demonstrates a condition check within R code, specifically for @examplesIf directives. It shows how a complex logical condition evaluates to FALSE, which would prevent the example from running. ```r expect_equal(strtrim(rd2ex(rd3), 40), strtrim(exp3, 40)) ``` -------------------------------- ### Handle Missing Template Package Error Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/utils-fs.md Demonstrates the custom error message generated when a specified template package is not installed. Ensure the template package is installed before use. ```R path_package_pkgdown("x", "missing", 3) ``` -------------------------------- ### Install pkgdown from CRAN Source: https://github.com/r-lib/pkgdown/blob/main/README.md Use this command to install the latest stable version of pkgdown from the Comprehensive R Archive Network (CRAN). ```r install.packages("pkgdown") ``` -------------------------------- ### Check Package Installation Failure Source: https://github.com/r-lib/pkgdown/blob/main/revdep/failures.md This snippet shows an error message indicating that a package ('multinma') failed to install during a revision check. It points to a log file for more details. ```text Installation failed. See ‘/tmp/workdir/multinma/new/multinma.Rcheck/00install.out’ for details. ``` -------------------------------- ### Validate unknown dark theme name in _pkgdown.yml Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/theme.md This example demonstrates error handling for unknown theme names when specifying a dark theme via `template.theme-dark` in `_pkgdown.yml`. ```R build_bslib_(`theme-dark` = "fruit") ``` -------------------------------- ### Handle Sexpr in Rd Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/rd-html.md Demonstrates the conversion of an Rd \Sexpr{} tag. This example shows an error when the object 'x' is not found. ```R rd2html("\Sexpr{x}") ``` -------------------------------- ### Validate Integrity with Mismatched SHA256 Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/external-deps.md Shows an example where `check_integrity` is called with a SHA256 hash that does not match the downloaded asset's integrity, leading to an error. ```R check_integrity(temp, "sha256-abc") ``` -------------------------------- ### Validate theme type in _pkgdown.yml Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/theme.md The `build_bslib_` function validates the `template.theme` field in `_pkgdown.yml`. This example demonstrates an error when the theme is specified as a number instead of a string. ```R build_bslib_(theme = 1) ``` -------------------------------- ### Data Home Sidebar - Custom Markdown Component Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-index.md Example of a custom markdown-formatted section ('Fancy section') that can be added to the pkgdown sidebar. ```html

Fancy section

``` -------------------------------- ### Error Handling for Invalid Reference Index Configuration Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-reference-index.md Provides examples of error messages produced by `data_reference_index()` when the reference index configuration in `_pkgdown.yml` is invalid. This includes incorrect data types for titles, subtitles, and contents, as well as empty or malformed entries. ```r data_reference_index_(1) ``` ```r data_reference_index_(list(1)) ``` ```r data_reference_index_(list(list(title = 1))) ``` ```r data_reference_index_(list(list(title = "a\n\nb"))) ``` ```r data_reference_index_(list(list(subtitle = 1))) ``` ```r data_reference_index_(list(list(subtitle = "a\n\nb"))) ``` ```r data_reference_index_(list(list(title = "bla", contents = 1))) ``` ```r data_reference_index_(list(list(title = "bla", contents = NULL))) ``` ```r data_reference_index_(list(list(title = "bla", contents = list("a", NULL)))) ``` ```r data_reference_index_(list(list(title = "bla", contents = list()))) ``` ```r data_reference_index_(list(list(title = "bla", contents = "notapackage::lala"))) ``` ```r data_reference_index_(list(list(title = "bla", contents = "rlang::lala"))) ``` -------------------------------- ### Check unknown bslib theme Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/theme.md Use `check_bslib_theme` to validate theme names against available Bootswatch/bslib themes. This example shows an error when an unknown theme is provided for Bootstrap version 4. ```R check_bslib_theme("paper", pkg, bs_version = 4) ``` -------------------------------- ### Allow Email in BugReports Link Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-index.md Example showing how an email address in BugReports is correctly rendered as a mailto link in the generated HTML. ```html Report a bug Citing testpackage ``` -------------------------------- ### Initialize pkgdown Site Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/init.md Demonstrates the output of the `init_site()` function when initializing a new pkgdown site. It shows the files being copied and updated. ```text -- Initialising site ----------------------------------------------------------- Copying /BS5/assets/katex-auto.js to katex-auto.js Copying /BS5/assets/lightswitch.js to lightswitch.js Copying /BS5/assets/link.svg to link.svg Copying /BS5/assets/pkgdown.js to pkgdown.js Updating deps/bootstrap-5.3.1/bootstrap.bundle.min.js Updating deps/bootstrap-5.3.1/bootstrap.bundle.min.js.map Updating deps/bootstrap-5.3.1/bootstrap.min.css Updating deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js Updating deps/clipboard.js-2.0.11/clipboard.min.js Updating deps/font-awesome-6.5.2/css/all.css Updating deps/font-awesome-6.5.2/css/all.min.css Updating deps/font-awesome-6.5.2/css/v4-shims.css Updating deps/font-awesome-6.5.2/css/v4-shims.min.css Updating deps/font-awesome-6.5.2/webfonts/fa-brands-400.ttf Updating deps/font-awesome-6.5.2/webfonts/fa-brands-400.woff2 Updating deps/font-awesome-6.5.2/webfonts/fa-regular-400.ttf Updating deps/font-awesome-6.5.2/webfonts/fa-regular-400.woff2 Updating deps/font-awesome-6.5.2/webfonts/fa-solid-900.ttf Updating deps/font-awesome-6.5.2/webfonts/fa-solid-900.woff2 Updating deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.ttf Updating deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.woff2 Updating deps/headroom-0.11.0/headroom.min.js Updating deps/headroom-0.11.0/jQuery.headroom.min.js Updating deps/jquery-3.6.0/jquery-3.6.0.js Updating deps/jquery-3.6.0/jquery-3.6.0.min.js Updating deps/jquery-3.6.0/jquery-3.6.0.min.map Updating deps/search-1.0.0/autocomplete.jquery.min.js Updating deps/search-1.0.0/fuse.min.js Updating deps/search-1.0.0/mark.min.js ``` -------------------------------- ### Build Home Index with pkgdown Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-index.md Demonstrates the process of building the home index for a pkgdown website, showing messages for reading DESCRIPTION and writing index.html. ```r build_home_index(pkg) ``` -------------------------------- ### C++ Compilation Error during CRAN Package Installation Source: https://github.com/r-lib/pkgdown/blob/main/revdep/failures.md This snippet illustrates a C++ compilation failure during the installation of a package from CRAN. It is identical to the 'Devel' installation error, indicating a common compilation issue with g++ and Stan. ```bash * installing *source* package ‘multinma’ ... ** this is package ‘multinma’ version ‘0.8.1’ ** package ‘multinma’ successfully unpacked and MD5 sums checked ** using staged installation ** libs using C++ compiler: ‘g++ (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0’ using C++17 g++ -std=gnu++17 -I"/opt/R/4.5.1/lib/R/include" -DNDEBUG -I"../inst/include" -I"/usr/local/lib/R/site-library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DBOOST_MATH_OVERFLOW_ERROR_POLICY=errno_on_error -DUSE_STANC3 -D_HAS_AUTO_PTR_ETC=0 -I'/usr/local/lib/R/site-library/BH/include' -I'/usr/local/lib/R/site-library/Rcpp/include' -I'/usr/local/lib/R/site-library/RcppEigen/include' -I'/usr/local/lib/R/site-library/RcppParallel/include' -I'/usr/local/lib/R/site-library/rstan/include' -I'/usr/local/lib/R/site-library/StanHeaders/include' -I/usr/local/include -I'/usr/local/lib/R/site-library/RcppParallel/include' -D_REENTRANT -DSTAN_THREADS -fpic -g -O2 -c RcppExports.cpp -o RcppExports.o ... /usr/local/lib/R/site-library/StanHeaders/include/src/stan/mcmc/hmc/hamiltonians/dense_e_metric.hpp:22:0: required from ‘double stan::mcmc::dense_e_metric::T(stan::mcmc::dense_e_point&) [with Model = model_survival_param_namespace::model_survival_param; BaseRNG = boost::random::additive_combine_engine, boost::random::linear_congruential_engine >]’ /usr/local/lib/R/site-library/StanHeaders/include/src/stan/mcmc/hmc/hamiltonians/dense_e_metric.hpp:21:0: required from here /usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:654:74: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits::type’ {aka ‘__m128d’} [-Wignored-attributes] 654 | return internal::first_aligned::alignment),Derived>(m); | ^~~~~~~~~ g++: fatal error: Killed signal terminated program cc1plus compilation terminated. make: *** [/opt/R/4.5.1/lib/R/etc/Makeconf:209: stanExports_survival_param.o] Error 1 ERROR: compilation failed for package ‘multinma’ * removing ‘/tmp/workdir/multinma/old/multinma.Rcheck/multinma’ ``` -------------------------------- ### Build pkgdown Site Locally Source: https://github.com/r-lib/pkgdown/blob/main/README.md Execute this command to locally build and preview your package website before deploying it. This allows you to check the site's appearance and functionality. ```r pkgdown::build_site() ``` -------------------------------- ### Build Home Sidebar with Before and After Text Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-authors.md Demonstrates how to include custom 'before' and 'after' text in the developer list on the home page sidebar. ```R cat(data_home_sidebar_authors(pkg)) ``` -------------------------------- ### C++ Compilation Error during Package Installation Source: https://github.com/r-lib/pkgdown/blob/main/revdep/failures.md This snippet shows a typical C++ compilation error during R package installation, specifically when using g++. It indicates a 'Killed signal terminated program cc1plus' error, often due to resource limitations or compiler issues. ```bash * installing *source* package ‘multinma’ ... ** this is package ‘multinma’ version ‘0.8.1’ ** package ‘multinma’ successfully unpacked and MD5 sums checked ** using staged installation ** libs using C++ compiler: ‘g++ (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0’ using C++17 g++ -std=gnu++17 -I"/opt/R/4.5.1/lib/R/include" -DNDEBUG -I"../inst/include" -I"/usr/local/lib/R/site-library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DBOOST_MATH_OVERFLOW_ERROR_POLICY=errno_on_error -DUSE_STANC3 -D_HAS_AUTO_PTR_ETC=0 -I'/usr/local/lib/R/site-library/BH/include' -I'/usr/local/lib/R/site-library/Rcpp/include' -I'/usr/local/lib/R/site-library/RcppEigen/include' -I'/usr/local/lib/R/site-library/RcppParallel/include' -I'/usr/local/lib/R/site-library/rstan/include' -I'/usr/local/lib/R/site-library/StanHeaders/include' -I/usr/local/include -I'/usr/local/lib/R/site-library/RcppParallel/include' -D_REENTRANT -DSTAN_THREADS -fpic -g -O2 -c RcppExports.cpp -o RcppExports.o ... /usr/local/lib/R/site-library/StanHeaders/include/src/stan/mcmc/hmc/hamiltonians/dense_e_metric.hpp:22:0: required from ‘double stan::mcmc::dense_e_metric::T(stan::mcmc::dense_e_point&) [with Model = model_survival_param_namespace::model_survival_param; BaseRNG = boost::random::additive_combine_engine, boost::random::linear_congruential_engine >]’ /usr/local/lib/R/site-library/StanHeaders/include/src/stan/mcmc/hmc/hamiltonians/dense_e_metric.hpp:21:0: required from here /usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:654:74: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits::type’ {aka ‘__m128d’} [-Wignored-attributes] 654 | return internal::first_aligned::alignment),Derived>(m); | ^~~~~~~~~ g++: fatal error: Killed signal terminated program cc1plus compilation terminated. make: *** [/opt/R/4.5.1/lib/R/etc/Makeconf:209: stanExports_survival_param.o] Error 1 ERROR: compilation failed for package ‘multinma’ * removing ‘/tmp/workdir/multinma/new/multinma.Rcheck/multinma’ ``` -------------------------------- ### Simple Navbar Components Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/navbar-menu.md Illustrates the output of basic navbar components like headings, links, separators, and search bars. These components render as expected without specific warnings. ```R cat(navbar_html(menu_heading("a"))) ``` ```R cat(navbar_html(menu_link("a", "b"))) ``` ```R cat(navbar_html(menu_separator())) ``` ```R cat(navbar_html(menu_search())) ``` -------------------------------- ### Constructing a Theme Switcher Navbar Menu Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/navbar-menu.md Demonstrates the creation of a theme switcher dropdown menu. This allows users to select between light, dark, or automatic theme modes. ```R cat(navbar_html(lightswitch)) ``` -------------------------------- ### Constructing a Navbar Menu with Children Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/navbar-menu.md Demonstrates how to create a dropdown menu with a heading, divider, and a link. Ensure the menu structure is correctly defined as a named list. ```R cat(navbar_html(menu)) ``` -------------------------------- ### Build News Articles Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-news.md Builds news articles for a package, generating HTML files for each version and an index page. ```R build_news(pkg) ``` -------------------------------- ### repo_source() with empty and single file input Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/repo.md Demonstrates the output of repo_source() when provided with an empty character vector and a single file name. This shows the basic formatting for source links. ```R cat(repo_source(pkg, character())) cat(repo_source(pkg, "a")) ``` -------------------------------- ### Configure pkgdown with usethis Source: https://github.com/r-lib/pkgdown/blob/main/README.md Run this command once to set up your R package to use pkgdown for website generation and configure it for deployment via GitHub Pages. This command adds necessary files and configurations to your package. ```r usethis::use_pkgdown_github_pages() ``` -------------------------------- ### repo_source() with multiple file input and truncation Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/repo.md Illustrates the automatic truncation behavior of repo_source() when given a vector of multiple file names. It shows how the output summarizes the links when the list exceeds a certain threshold. ```R cat(repo_source(pkg, letters[1:10])) ``` -------------------------------- ### Get External Topic Info Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/topics-external.md Use `ext_topics` to retrieve structured information about an external R function. This is useful for understanding function details from other packages. ```r str(ext_topics("base::mean")) ``` -------------------------------- ### Pre-format Text with pre() Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/highlight.md Shows basic text pre-formatting using the `pre()` function. ```r cat(pre("x")) ``` -------------------------------- ### Data Home Sidebar - Custom HTML File Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-index.md Shows an error when the 'home.sidebar.html' in _pkgdown.yml specifies a non-existent HTML file. ```r data_home_sidebar(pkg) ``` -------------------------------- ### Pre-format Text with R Code Highlighting Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/highlight.md Demonstrates pre-formatting text with R code highlighting enabled using `pre(r_code = TRUE)`. ```r cat(pre("x", r_code = TRUE)) ``` -------------------------------- ### Build Home Index - Reading DESCRIPTION Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-index.md Shows the message indicating that the DESCRIPTION file is being read during the build home index process. ```r build_home_index(pkg) ``` -------------------------------- ### Non-existent path input for preview_site Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/preview.md Shows the error message when the specified 'path' does not exist. ```r preview_site(pkg, path = "foo") ``` -------------------------------- ### Configure Repository URLs for Source Links Source: https://github.com/r-lib/pkgdown/blob/main/NEWS.md Configure links to source files, issues, and users by specifying repository URLs in `_pkgdown.yml`. Ensure URLs have trailing slashes. ```yaml repo: url: home: https://github.com/r-lib/pkgdown/ source: https://github.com/r-lib/pkgdown/blob/main/ issue: https://github.com/r-lib/pkgdown/issues/ user: https://github.com/ ``` -------------------------------- ### config_check_list error for missing list components Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/config.md Demonstrates the error from `config_check_list_` when a list is missing required named components. ```R config_check_list_(list(x = 1, y = 1), has_names = c("y", "z")) ``` -------------------------------- ### Build sitemap when updates occur Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-search-docs.md The `build_sitemap()` function provides messages indicating when it is building the sitemap and writing to `sitemap.xml`. It only shows these messages when an update actually occurs. ```r build_sitemap(pkg) ``` ```r build_sitemap(pkg) ``` -------------------------------- ### Check Built Site for Missing Images Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/check-built.md Use `check_built_site(pkg)` to identify missing images in the README.md. pkgdown can only use images from 'man/figures' and 'vignettes'. ```R check_built_site(pkg) ``` -------------------------------- ### Data Home - Validate YAML Metadata (Home Description String) Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-index.md Demonstrates validation for the 'home.description' field in _pkgdown.yml. It must be a string, not a number. ```r data_home_(home = list(description = 1)) ``` -------------------------------- ### Inspect build_search_index() output structure Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-search-docs.md Use `str()` to inspect the detailed structure of the output from `build_search_index()`. This helps understand the fields generated for each page in the search index. ```r str(build_search_index(pkg)) ``` -------------------------------- ### Package Version Heading Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-news.md Renders a package version heading with a muted text class for the CRAN release date. ```html

CRAN release: 2020-01-01

``` -------------------------------- ### Data Home - Validate YAML Metadata (Home List) Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-index.md Illustrates validation of the 'home' field in _pkgdown.yml. It must be a list, not a number. ```r data_home_(home = 1) ``` -------------------------------- ### Build GitHub Pages with pkgdown Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-github.md This snippet demonstrates the `build_github_pages()` function from the pkgdown package. It shows the output messages indicating the creation of extra files for GitHub pages, specifically a `.nojekyll` file and a `CNAME` file, which is generated if a URL is present in the package's metadata. ```r build_github_pages(pkg) ``` -------------------------------- ### Constructing Bullet Navbar Components Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/navbar-menu.md Shows how to create different types of bulleted navigation items: icons with links, headings, and simple links. Use `menu_icon` for icons, `menu_heading` for headers, and `menu_link` for standard links. ```R cat(navbar_html(menu_icon("fa-question", "https://example.com", "label"))) ``` ```R cat(navbar_html(menu_heading("Hi"))) ``` ```R cat(navbar_html(menu_link("Hi", "https://example.com"))) ``` -------------------------------- ### Reproducible output with seed in pkgdown Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-article.md Shows that the output is reproducible by default when a 'seed' is respected. ```R cat(output) ``` -------------------------------- ### Invalid path input for preview_site Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/preview.md Demonstrates the error when a non-string value is provided for the 'path' argument in preview_site. ```r preview_site(pkg, path = 1) ``` -------------------------------- ### Reordering Navbar Elements Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/navbar.md Demonstrates how to reorder the default left and right navigation elements by subsetting the output of data_navbar(). This allows for custom placement of elements like the GitHub link and search bar. ```R data_navbar(pkg)[c("left", "right")] ``` -------------------------------- ### Enable Bootstrap 5 for pkgdown Site Source: https://github.com/r-lib/pkgdown/blob/main/README.md To upgrade your pkgdown site to use Bootstrap 5, add this configuration to your `_pkgdown.yml` file. This is a required step for pkgdown 2.0.0 and later to opt-in to the new styling. ```yaml template: bootstrap: 5 ``` -------------------------------- ### Site Meta YAML Structure Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/init.md Shows the expected structure for the `_pkgdown.yml` file, which defines site metadata such as pandoc version, pkgdown version, article mappings, and build times. ```yaml pandoc: '{version}' pkgdown: '{version}' pkgdown_sha: '{sha}' articles: a: a.html b: b.html last_built: 2020-01-01T00:00Z ``` -------------------------------- ### Data Home Sidebar - Error Message for Multiple Missing Sidebar Components Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-index.md Shows the error when multiple specified components in 'home.sidebar.components' are missing. ```r data_home_sidebar_(structure = c("fancy", "cool")) ``` -------------------------------- ### Inspect Quarto Styles Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-quarto-articles.md This snippet shows how to inspect the included styles for Quarto articles. It is useful for debugging or understanding how Quarto integrates with the build system. ```R cat(data$includes$style) ``` -------------------------------- ### Write markdown lines to stdout Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-llm.md This snippet demonstrates writing lines read from a file to standard output. It's used in integration tests to simulate markdown processing. ```R write_lines(read_lines(path), stdout()) ``` -------------------------------- ### Handle Missing External Topic Documentation Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/topics-external.md When documentation for a specified external function does not exist, `ext_topics` will raise an error. Ensure the function name and package are correct. ```r ext_topics("base::doesntexist") ``` -------------------------------- ### Enable Bootstrap 5 Styling in pkgdown Source: https://github.com/r-lib/pkgdown/blob/main/NEWS.md Opt-in to Bootstrap 5 styling for your pkgdown site by setting the bootstrap version in your _pkgdown.yml configuration file. ```yaml template: bootstrap: 5 ``` -------------------------------- ### Data Home Sidebar - Error Message for Missing Sidebar Component Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-index.md Demonstrates the error when a specified component in 'home.sidebar.components' is missing. ```r data_home_sidebar_(structure = "fancy") ``` -------------------------------- ### config_check_list error for non-list path Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/config.md Illustrates the error from `config_check_list_` when the 'path' argument is not a list. ```R config_check_list_(1, has_names = "x") ``` -------------------------------- ### Data Home Sidebar - Default Output Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-index.md Generates the default sidebar HTML for a pkgdown site, including sections for Links, License, Citation, Developers, and Dev Status. ```r cat(data_home_sidebar(pkg)) ``` -------------------------------- ### Build Favicons with Existing Logo Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-favicons.md If favicons already exist and a package logo is present, `build_favicons()` informs the user that favicons are already created and provides an option to overwrite them by setting `overwrite = TRUE`. ```R build_favicons(pkg) ``` -------------------------------- ### Invalid preview argument for preview_site Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/preview.md Illustrates the error when an invalid value (not TRUE, FALSE, or NA) is supplied for the 'preview' argument. ```r preview_site(pkg, preview = 1) ``` -------------------------------- ### check_urls: Error for Missing URL in _pkgdown.yml Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/check.md Demonstrates the error message from check_urls when a URL is missing from the _pkgdown.yml configuration file. ```R check_urls(pkg) ``` -------------------------------- ### Check Bootstrap Version Compatibility Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/package.md Checks the bootstrap version, allowing 3 and 5, and issuing a warning for version 4, automatically upgrading it to 5. ```R expect_equal(check_bootstrap_version(4, pkg), 5) ``` -------------------------------- ### News Heading with Release Date Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-news.md Renders a news heading with a class attribute and a small tag for the release date. ```html
``` -------------------------------- ### Build Favicons with Missing Logo Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-favicons.md When a package logo is missing, `build_favicons()` generates an error message indicating that it cannot find the required PNG or SVG file. It suggests using `usethis::use_logo()` to add one. ```R expect_output(build_favicons(pkg), "Building favicons") ``` -------------------------------- ### pkgdown_sitrep: Bootstrap 3 Deprecation Warning Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/check.md Demonstrates the output of pkgdown_sitrep when Bootstrap 3 is detected, indicating it's deprecated and suggesting an upgrade to Bootstrap 5. ```R pkgdown_sitrep(pkg) ``` -------------------------------- ### Warning: No Version Headings Found Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-news.md Extracts news data and warns if no version headings are found in NEWS.md, indicating an unexpected structure. ```R . <- data_news(pkg) ``` -------------------------------- ### Render Nested Code Blocks with tweak_highlight_other() Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/highlight.md Illustrates rendering nested code blocks, specifically for roxygen2 versions 7.2.0 and above, using `tweak_highlight_other()`. ```r cat(xpath_text(div, "pre/code")) ``` -------------------------------- ### Rendering Navbar Links for Bootstrap 4 Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/navbar.md Demonstrates the HTML output of `render_navbar_links()` for a navigation bar when the package is configured for Bootstrap 4. Note the differences in HTML structure and attributes compared to Bootstrap 3. ```r cat(render_navbar_links(x, pkg = list(bs_version = 4))) ``` -------------------------------- ### Process Footnote with Code Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/tweak-tags.md Demonstrates how pkgdown processes footnotes that contain embedded code blocks. This is useful for documenting code within narrative text. ```r xpath_attr(html, ".//a", "data-bs-content") ``` ```text [1] "

Including code:

\n
1 +\n2 +
\n

And more text

" ``` -------------------------------- ### Data Home Sidebar - Table of Contents Component Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-index.md Demonstrates adding a 'Table of contents' component to the pkgdown sidebar, which renders a navigation TOC. ```html

Table of contents

``` -------------------------------- ### HTML Structure for Tabsets Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/tweak-tabset.md This HTML structure demonstrates how to create a tabset with pills. It uses Bootstrap's tab functionality to switch between content panes. ```html

Tabset

Contents 1

Contents 2

``` -------------------------------- ### Basic R Expression Source: https://github.com/r-lib/pkgdown/blob/main/NEWS.md A simple R expression demonstrating basic arithmetic. ```R 1 + 1 ``` -------------------------------- ### Validate unknown theme name in _pkgdown.yml Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/theme.md This snippet shows how `build_bslib_` reports an error when the `template.theme` in `_pkgdown.yml` refers to an unknown theme name. ```R build_bslib_(theme = "fruit") ``` -------------------------------- ### Configure DocSearch in pkgdown Source: https://github.com/r-lib/pkgdown/blob/main/inst/BS3/templates/docsearch.html This snippet shows how to configure the DocSearch functionality within a pkgdown project's YAML configuration. It includes parameters for appId, debug, apiKey, indexName, inputSelector, and a custom transformData function. ```html {{#yaml}}{{#docsearch}} docsearch({ {{#app_id}}appId: '{{.}}',{{/app_id}} {{#debug}}debug: {{{.}}},{{/debug}} apiKey: '{{api_key}}', indexName: '{{index_name}}', inputSelector: 'input#search-input.form-control', transformData: function(hits) { return hits.map(function (hit) { hit.url = updateHitURL(hit); return hit; }); } }); {{/docsearch}}{{/yaml}} ``` -------------------------------- ### Default pkgdown Footer Content Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-footer.md Shows the default HTML output for the left and right sides of the pkgdown footer, typically including developer information and the pkgdown build attribution. ```R $left [1] "

Developed by First Last.

" $right [1] "

Site built with pkgdown {version}.

" ``` -------------------------------- ### Build article with ANSI escape styling Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-article.md Shows how build_article styles ANSI escapes in the output. ```html ## X ``` -------------------------------- ### Handle Unknown Role Abbreviations Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-authors.md Shows the fallback behavior when an unknown role abbreviation is encountered. A warning is issued, and the original abbreviation is returned. ```R role_lookup("unknown") ``` -------------------------------- ### Generate Reference Index with Various Row Types Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-reference-index.md Demonstrates the output of `data_reference_index()` when generating a package index. It shows how different types of rows (titles, subtitles, topics) are structured and displayed. ```r data_reference_index(pkg) ``` -------------------------------- ### Data Home - Validate YAML Metadata (Home Title String) Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-index.md Shows validation for the 'home.title' field in _pkgdown.yml. It must be a string, not a number. ```r data_home_(home = list(title = 1)) ``` -------------------------------- ### Expect Error for Build Article Failure Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/rcmdcheck/build-article.md Shows how to use `expect_error` to capture and inspect errors from `build_article` when vignette rendering fails. This is useful for testing error conditions. ```R summary(expect_error(build_article("test", pkg))) ``` -------------------------------- ### Rendering Navbar Links for Bootstrap 3 Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/navbar.md Shows how `render_navbar_links()` generates HTML for a navigation bar when the package is configured for Bootstrap 3. This is useful for inspecting the generated HTML structure. ```r cat(render_navbar_links(x, pkg = list(bs_version = 3))) ``` -------------------------------- ### Unknown topic name or alias in select_topics_() Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/topics.md Shows errors when the provided string is not a recognized topic name or alias. ```R select_topics_("y", topics) ``` ```R select_topics_("starts_with", topics) ``` ```R select_topics_("a4", topics) ``` ```R select_topics_("c::a", topics) ``` -------------------------------- ### Configure Redirects in pkgdown Source: https://github.com/r-lib/pkgdown/blob/main/NEWS.md Use this YAML syntax to define redirects for old paths to new paths or URLs in your pkgdown site. ```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"] ``` -------------------------------- ### Control Articles Navbar with Meta Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/navbar.md Demonstrates how to control the articles section in the navbar using the 'articles' meta option. This allows for custom article titles and links. ```r navbar_articles(pkg()) ``` ```r navbar_articles(pkg(articles = list(list(name = "all", contents = c("a", "b"))))) ``` ```r navbar_articles(pkg(articles = list(list(name = "all", contents = c("a", "b"), navbar = NULL)))) ``` ```r navbar_articles(pkg(articles = list(list(name = "all", contents = c("a", "b"), navbar = "Label")))) ``` ```r navbar_articles(pkg(articles = list(list(name = "a", contents = "a", navbar = NULL), list(name = "b", contents = "b")))) ``` -------------------------------- ### Data Home Sidebar - Error Message for Invalid Structure Input Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-index.md Illustrates the error message when 'home.sidebar.structure' in _pkgdown.yml is not a character vector. ```r data_home_sidebar_(structure = 1) ``` -------------------------------- ### Data Home Sidebar - Error Message for Invalid HTML Input Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-index.md Shows the error message when 'home.sidebar.html' in _pkgdown.yml is not a string. ```r data_home_sidebar_(html = 1) ``` -------------------------------- ### Handle invalid code width in pkgdown config Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-article.md Demonstrates the error message when 'code.width' in _pkgdown.yml is not a whole number. ```R rmarkdown_setup_pkgdown(pkg) ``` -------------------------------- ### Data Home Sidebar - Error Message for Missing Component Sub-keys (Title) Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-index.md Illustrates the error when a required sub-key ('title') is missing for a custom sidebar component. ```r data_home_sidebar_(structure = "fancy", components = list(fancy = list(text = "bla"))) ``` -------------------------------- ### check_pkgdown: Error on Missing URL Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/check.md Illustrates the error condition raised by check_pkgdown when a required URL is missing from the package's DESCRIPTION file. ```R check_pkgdown(pkg) ``` -------------------------------- ### Handle Non-existent File Error Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/utils-fs.md Illustrates the error condition when the `out_of_date` function is called with a file path that does not exist. Verify file paths before calling this function. ```R out_of_date("doesntexist", temp1) ``` -------------------------------- ### Graceful Error on Metadata Parsing Failure Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/package.md Handles errors gracefully when the `_pkgdown.yml` configuration file fails to parse, providing a specific error message. ```R as_pkgdown(pkg$src_path) ``` -------------------------------- ### Handle Rd Parsing Errors in build_reference Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-reference.md Demonstrates an error encountered when `build_reference()` fails to parse an Rd file due to an invalid \url{} tag. This indicates a problem with the documentation source file. ```R build_reference(pkg) ``` -------------------------------- ### Unmatched topic selection in select_topics_() Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/topics.md Shows the warning generated when a selection pattern does not match any topics. ```R select_topics_("starts_with('y')", topics) ``` ```R select_topics_(c("a", "starts_with('unmatched')"), topics) ``` -------------------------------- ### CSS for pkgdown Styling Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/assets/-find-assets.html Core CSS rules for styling various elements on pkgdown documentation pages, including code blocks, tables, and headings. ```css code{white-space: pre-wrap;} span.smallcaps{font-variant: small-caps;} span.underline{text-decoration: underline;} div.column{display: inline-block; vertical-align: top; width: 50%;} div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} ul.task-list{list-style: none;} body { background-color: #fff; margin: 1em auto; max-width: 700px; overflow: visible; padding-left: 2em; padding-right: 2em; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 1.35; } #TOC { clear: both; margin: 0 0 10px 10px; padding: 4px; width: 400px; border: 1px solid #CCCCCC; border-radius: 5px; background-color: #f6f6f6; font-size: 13px; line-height: 1.3; } #TOC .toctitle { font-weight: bold; font-size: 15px; margin-left: 5px; } #TOC ul { padding-left: 40px; margin-left: -1.5em; margin-top: 5px; margin-bottom: 5px; } #TOC ul ul { margin-left: -2em; } #TOC li { line-height: 16px; } table { margin: 1em auto; border-width: 1px; border-color: #DDDDDD; border-style: outset; border-collapse: collapse; } table th { border-width: 2px; padding: 5px; border-style: inset; } table td { border-width: 1px; border-style: inset; line-height: 18px; padding: 5px 5px; } table, table th, table td { border-left-style: none; border-right-style: none; } table thead, table tr.even { background-color: #f7f7f7; } p { margin: 0.5em 0; } blockquote { background-color: #f6f6f6; padding: 0.25em 0.75em; } hr { border-style: solid; border: none; border-top: 1px solid #777; margin: 28px 0; } dl { margin-left: 0; } dl dd { margin-bottom: 13px; margin-left: 13px; } dl dt { font-weight: bold; } ul { margin-top: 0; } ul li { list-style: circle outside; } ul ul { margin-bottom: 0; } pre, code { background-color: #f7f7f7; border-radius: 3px; color: #333; white-space: pre-wrap; } pre { border-radius: 3px; margin: 5px 0px 10px 0px; padding: 10px; } pre:not([class]) { background-color: #f7f7f7; } code { font-family: Consolas, Monaco, 'Courier New', monospace; font-size: 85%; } p > code, li > code { padding: 2px 0px; } div.figure { text-align: center; } img { background-color: #FFFFFF; padding: 2px; border: 1px solid #DDDDDD; border-radius: 3px; border: 1px solid #CCCCCC; margin: 0 5px; } h1 { margin-top: 0; font-size: 35px; line-height: 40px; } h2 { border-bottom: 4px solid #f7f7f7; padding-top: 10px; padding-bottom: 2px; font-size: 145%; } h3 { border-bottom: 2px solid #f7f7f7; padding-top: 10px; font-size: 120%; } h4 { border-bottom: 1px solid #f7f7f7; margin-left: 8px; font-size: 105%; } h5, h6 { border-bottom: 1px solid #ccc; font-size: 105%; } a { color: #0033dd; text-decoration: none; } a:hover { color: #6666ff; } a:visited { color: #800080; } a:visited:hover { color: #BB00BB; } a[href^="http:"] { text-decoration: underline; } a[href^="https:"] { text-decoration: underline; } code > span.kw { color: #555; font-weight: bold; } code > span.dt { color: #902000; } code > span.dv { color: #40a070; } code > span.bn { color: #d14; } code > span.fl { color: #d14; } code > span.ch { color: #d14; } code > span.st { color: #d14; } code > span.co { color: #888888; font-style: italic; } code > span.ot { color: #007020; } code > span.al { color: #ff0000; font-weight: bold; } code > span.fu { color: #900; font-weight: bold; } code > span.er { color: #a61717; background-color: #e3d2d2; } ``` -------------------------------- ### check_favicons: Error for Missing Favicons Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/check.md Illustrates the error condition from check_favicons when a package logo is present but corresponding favicons are missing. ```R check_favicons(pkg) ``` -------------------------------- ### Data Home Sidebar - Error Message for Missing Component Sub-keys (Both) Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-index.md Shows the error when required sub-keys ('title' and 'text') are missing for a custom sidebar component. ```r data_home_sidebar_(structure = "fancy", components = list(fancy = list())) ``` -------------------------------- ### pkgdown Site Configuration Template Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/render.md This snippet shows the default structure of a _pkgdown.yml file used to configure a pkgdown website. It includes settings for package information, site metadata, translation strings, navigation, and footer content. ```yaml package: name: testpackage version: 1.0.0 site: root: '' title: testpackage year: lang: en translate: skip: Skip to contents toggle_nav: Toggle navigation on_this_page: On this page source: Source abstract: Abstract authors: Authors version: Version examples: Examples citation: Citation author_details: Additional details toc: Table of contents site_nav: Site navigation has_favicons: no opengraph: [] extra: css: ~ js: ~ yaml: .present: yes headdeps: '' development: destination: dev mode: default version_label: muted in_dev: no prefix: '' version_tooltip: '' navbar: bg: light type: light left: right: "
  • " footer: left:

    Developed by Jo Doe.

    right:

    Site built with pkgdown {version}.

    lightswitch: no uses_katex: no uses_mathjax: no ``` -------------------------------- ### Invalid R code syntax in select_topics_() Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/topics.md Demonstrates errors when the provided R code string is not valid. ```R select_topics_("x + ", topics) ``` -------------------------------- ### Math Rendering Configuration - Invalid Value Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/markdown.md Validates math rendering configuration in _pkgdown.yml. This snippet demonstrates an error when 'math-rendering' is set to an unsupported string value. ```R config_math_rendering_(`math-rendering` = "math") ``` -------------------------------- ### Validate Author Sidebar Before Field Type Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-authors.md Ensures the 'authors.sidebar.before' field in _pkgdown.yml is a string. Throws an error if it's not. ```R data_home_sidebar_authors_(authors = list(sidebar = list(before = 1))) ``` -------------------------------- ### Multiple Citations with HTML and BibTeX Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/build-home-authors.md Illustrates the structure of multiple citations, each providing both HTML and BibTeX formats. ```R [[1]] [[1]]$html [1] "

    A & B (2021): Proof of b < a > c.

    " [[1]]$bibtex [1] "@Misc{, title = {Proof of b < a > c}, author = {{A} and {B}}, year = {2021}, }" [[2]] [[2]]$html [1] "

    Two A (2022).\n“Title Two.”

    " [[2]]$bibtex [1] "@Misc{, title = {Title Two}, author = {Author Two}, year = {2022}, }" ``` -------------------------------- ### Convert Rd Unicode Shortcuts to HTML Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/rd-html.md Converts Rd unicode shortcuts like em dashes into their HTML equivalents. ```R rd2html("``a -- b --- c''") ``` -------------------------------- ### Validate Package Path Input Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/package.md Ensures the package path provided to `as_pkgdown` is a single string. ```R as_pkgdown(1) ``` -------------------------------- ### Handle Empty Rd Email Tag Source: https://github.com/r-lib/pkgdown/blob/main/tests/testthat/_snaps/rd-html.md Demonstrates the error produced by an empty \email{} tag in Rd documentation. ```R rd2html("\email{}") ```