├── .github ├── .gitignore ├── 404.md ├── CODEOWNERS ├── workflows │ ├── test-coverage.yaml │ └── no-pandoc.yaml └── CODE_OF_CONDUCT.md ├── inst ├── BS3 │ ├── templates │ │ ├── header.html │ │ ├── after-body.html │ │ ├── before-body.html │ │ ├── in-header.html │ │ ├── footer.html │ │ ├── layout-redirect.html │ │ ├── content-home.html │ │ ├── content-tutorial-index.html │ │ ├── content-tutorial.html │ │ ├── content-news-index.html │ │ ├── content-title-body.html │ │ ├── content-article-index.html │ │ ├── content-news.html │ │ ├── layout.html │ │ ├── docsearch.html │ │ ├── content-citation-authors.html │ │ ├── content-reference-topic.html │ │ ├── content-reference-index.html │ │ ├── content-article.html │ │ └── navbar.html │ └── assets │ │ └── link.svg ├── BS5 │ ├── templates │ │ ├── header.html │ │ ├── after-body.html │ │ ├── before-body.html │ │ ├── in-header.html │ │ ├── content-home.html │ │ ├── layout-redirect.html │ │ ├── footer.html │ │ ├── content-tutorial.html │ │ ├── content-title-body.html │ │ ├── content-news.html │ │ ├── content-tutorial-index.html │ │ ├── content-news-index.html │ │ ├── layout.html │ │ ├── content-authors.html │ │ ├── content-article-index.html │ │ ├── content-reference-index.html │ │ ├── content-citation-authors.html │ │ ├── content-reference-topic.html │ │ ├── navbar.html │ │ └── content-article.html │ └── assets │ │ └── link.svg ├── po │ ├── de │ │ └── LC_MESSAGES │ │ │ └── R-pkgdown.mo │ ├── dk │ │ └── LC_MESSAGES │ │ │ └── R-pkgdown.mo │ ├── es │ │ └── LC_MESSAGES │ │ │ └── R-pkgdown.mo │ ├── fr │ │ └── LC_MESSAGES │ │ │ └── R-pkgdown.mo │ ├── ko │ │ └── LC_MESSAGES │ │ │ └── R-pkgdown.mo │ ├── kr │ │ └── LC_MESSAGES │ │ │ └── R-pkgdown.mo │ ├── pt │ │ └── LC_MESSAGES │ │ │ └── R-pkgdown.mo │ ├── tr │ │ └── LC_MESSAGES │ │ │ └── R-pkgdown.mo │ └── zh_CN │ │ └── LC_MESSAGES │ │ └── R-pkgdown.mo ├── rstudio │ └── addins.dcf └── highlight-styles │ ├── monochrome.scss │ ├── haddock.scss │ ├── espresso.scss │ ├── zenburn.scss │ ├── a11y-dark.scss │ ├── a11y-light.scss │ └── arrow-light.scss ├── revdep ├── README.md ├── failures.md ├── problems.md ├── email.yml ├── .gitignore └── cran.md ├── tests ├── testthat │ ├── .gitignore │ ├── assets │ │ ├── sidebar │ │ │ ├── _pkgdown.yml │ │ │ ├── DESCRIPTION │ │ │ └── README.md │ │ ├── init-extra-1 │ │ │ ├── pkgdown │ │ │ │ └── extra.css │ │ │ ├── README.md │ │ │ └── DESCRIPTION │ │ ├── init-extra-2 │ │ │ ├── pkgdown │ │ │ │ ├── extra.css │ │ │ │ └── extra.js │ │ │ ├── README.md │ │ │ └── DESCRIPTION │ │ ├── man-figures │ │ │ ├── .gitignore │ │ │ ├── vignettes │ │ │ │ ├── .gitignore │ │ │ │ ├── another-kitten.jpg │ │ │ │ └── kitten.Rmd │ │ │ ├── README.md │ │ │ ├── _pkgdown.yml │ │ │ ├── man │ │ │ │ ├── figures │ │ │ │ │ └── kitten.jpg │ │ │ │ └── kitten.Rd │ │ │ ├── DESCRIPTION │ │ │ └── man-figures.Rproj │ │ ├── articles-resources │ │ │ ├── vignettes │ │ │ │ ├── external.png │ │ │ │ └── resources.Rmd │ │ │ └── DESCRIPTION │ │ ├── init-asset-subdirs │ │ │ ├── README.md │ │ │ ├── pkgdown │ │ │ │ ├── assets │ │ │ │ │ └── subdir1 │ │ │ │ │ │ ├── file1.txt │ │ │ │ │ │ └── subdir2 │ │ │ │ │ │ └── file2.txt │ │ │ │ └── _pkgdown.yml │ │ │ └── DESCRIPTION │ │ ├── bad-images │ │ │ ├── README.md │ │ │ ├── vignettes │ │ │ │ └── html-vignette.Rmd │ │ │ └── DESCRIPTION │ │ ├── home-readme-rmd │ │ │ ├── README.md │ │ │ ├── NAMESPACE │ │ │ ├── README.Rmd │ │ │ └── DESCRIPTION │ │ ├── reference │ │ │ ├── _pkgdown.yml │ │ │ ├── NAMESPACE │ │ │ ├── DESCRIPTION │ │ │ ├── man │ │ │ │ ├── e.Rd │ │ │ │ ├── a.Rd │ │ │ │ ├── b.Rd │ │ │ │ ├── c.Rd │ │ │ │ └── help.Rd │ │ │ └── R │ │ │ │ └── funs.R │ │ ├── open-graph │ │ │ ├── _pkgdown.yml │ │ │ ├── R │ │ │ │ └── f.R │ │ │ ├── NAMESPACE │ │ │ ├── logo.png │ │ │ ├── man │ │ │ │ └── f.Rd │ │ │ ├── DESCRIPTION │ │ │ └── vignettes │ │ │ │ └── open-graph.Rmd │ │ ├── reference-pre-post │ │ │ ├── pkgdown │ │ │ │ ├── pre-reference.R │ │ │ │ └── post-reference.R │ │ │ └── DESCRIPTION │ │ ├── cname │ │ │ ├── _pkgdown.yml │ │ │ └── DESCRIPTION │ │ ├── site-bad-logo │ │ │ ├── _pkgdown.yml │ │ │ ├── logo.png │ │ │ └── DESCRIPTION │ │ ├── site-empty │ │ │ ├── NAMESPACE │ │ │ └── DESCRIPTION │ │ ├── home-old-skool │ │ │ ├── NAMESPACE │ │ │ └── DESCRIPTION │ │ ├── templates-local │ │ │ ├── pkgdown │ │ │ │ └── templates │ │ │ │ │ ├── content-article.html │ │ │ │ │ └── footer-article.html │ │ │ └── DESCRIPTION │ │ ├── pandoc-fail.Rmd │ │ ├── home-index-rmd │ │ │ ├── index.Rmd │ │ │ └── DESCRIPTION │ │ ├── open-graph-customized │ │ │ ├── R │ │ │ │ └── f.R │ │ │ ├── NAMESPACE │ │ │ ├── man │ │ │ │ ├── figures │ │ │ │ │ └── card.png │ │ │ │ └── f.Rd │ │ │ ├── _pkgdown.yml │ │ │ ├── DESCRIPTION │ │ │ └── vignettes │ │ │ │ ├── no-description.Rmd │ │ │ │ └── open-graph.Rmd │ │ ├── reference-fail │ │ │ ├── NAMESPACE │ │ │ ├── R │ │ │ │ └── f.R │ │ │ ├── man │ │ │ │ └── f.Rd │ │ │ └── DESCRIPTION │ │ ├── reference-html-dep │ │ │ ├── NAMESPACE │ │ │ ├── _pkgdown.yml │ │ │ ├── DESCRIPTION │ │ │ ├── man │ │ │ │ └── a.Rd │ │ │ └── R │ │ │ │ └── funs.R │ │ ├── figure │ │ │ ├── _pkgdown.yml │ │ │ ├── vignettes │ │ │ │ └── figures.Rmd │ │ │ ├── man │ │ │ │ └── figure.Rd │ │ │ └── DESCRIPTION │ │ ├── site-dot-github │ │ │ ├── .github │ │ │ │ ├── 404.md │ │ │ │ ├── SUPPORT.md │ │ │ │ └── CODE_OF_CONDUCT.md │ │ │ ├── README.Rmd │ │ │ └── DESCRIPTION │ │ ├── articles │ │ │ ├── vignettes │ │ │ │ ├── width.Rmd │ │ │ │ ├── articles │ │ │ │ │ └── nested.Rmd │ │ │ │ ├── standard.Rmd │ │ │ │ ├── widget.Rmd │ │ │ │ ├── toc-false.Rmd │ │ │ │ ├── html-document.Rmd │ │ │ │ ├── html-vignette.Rmd │ │ │ │ └── html-deps.Rmd │ │ │ └── DESCRIPTION │ │ ├── site-favicons │ │ │ ├── logo.png │ │ │ ├── pkgdown │ │ │ │ └── favicon │ │ │ │ │ └── favicon.ico │ │ │ └── DESCRIPTION │ │ ├── site-citation │ │ │ ├── encoding-latin1 │ │ │ │ ├── DESCRIPTION │ │ │ │ └── inst │ │ │ │ │ └── CITATION │ │ │ ├── multi │ │ │ │ ├── DESCRIPTION │ │ │ │ └── inst │ │ │ │ │ └── CITATION │ │ │ └── encoding-UTF-8 │ │ │ │ ├── DESCRIPTION │ │ │ │ └── inst │ │ │ │ └── CITATION │ │ ├── search-site │ │ │ ├── _pkgdown.yml │ │ │ └── DESCRIPTION │ │ ├── news │ │ │ ├── NEWS.md │ │ │ ├── README.md │ │ │ └── DESCRIPTION │ │ ├── vignette-with-crayon.Rmd │ │ ├── tutorials │ │ │ ├── DESCRIPTION │ │ │ └── vignettes │ │ │ │ └── tutorials │ │ │ │ └── test-1 │ │ │ │ └── tutorial-test-1.dcf │ │ ├── sidebar-comment │ │ │ └── DESCRIPTION │ │ ├── version-formatting │ │ │ └── DESCRIPTION │ │ └── vignette-with-img.Rmd │ ├── _snaps │ │ ├── build-redirects.md │ │ ├── build-logo.md │ │ ├── markdown.md │ │ ├── sitrep.md │ │ ├── build-footer.md │ │ ├── development.md │ │ ├── highlight.md │ │ ├── package.md │ │ ├── build-favicons.md │ │ ├── init.md │ │ ├── build-home-community.md │ │ ├── tweak-tags.md │ │ ├── build-home.md │ │ ├── build-articles.md │ │ ├── build-reference.md │ │ ├── build-home-citation.md │ │ ├── check.md │ │ ├── repo.md │ │ ├── utils-yaml.md │ │ ├── topics-external.md │ │ ├── tweak-homepage.md │ │ ├── build-home-authors.md │ │ ├── rmarkdown.md │ │ ├── tweak-tabset.md │ │ ├── render.md │ │ ├── topics.md │ │ └── build-news.md │ ├── test-topics-external.R │ ├── test-build.R │ ├── test-sitrep.R │ ├── test-build-favicons.R │ ├── test-build-logo.R │ ├── test-deploy-site.R │ ├── test-build-github.R │ ├── test-utils-yaml.R │ ├── test-figure.R │ ├── test-build-home-license.R │ ├── test-check.R │ ├── test-build-home-community.R │ ├── test-pkgdown_print.R │ ├── test-utils.R │ ├── test-html-build.R │ ├── test-build-tutorials.R │ ├── test-highlight.R │ ├── test-rmarkdown.R │ ├── test-render.R │ ├── test-build-redirects.R │ ├── test-init.R │ ├── test-markdown.R │ ├── test-development.R │ ├── test-build-footer.R │ └── test-build-search-docs.R └── testthat.R ├── vignettes ├── test │ ├── test.txt │ ├── bacon.jpg │ ├── short.Rmd │ ├── pdf.Rmd │ ├── jss.bib │ ├── long-toc.Rmd │ ├── widgets.Rmd │ └── jss.Rmd └── .gitignore ├── .gitattributes ├── LICENSE ├── man ├── figures │ ├── bacon.jpg │ ├── logo.png │ ├── lifecycle-stable.svg │ ├── lifecycle-defunct.svg │ ├── lifecycle-archived.svg │ ├── lifecycle-maturing.svg │ ├── lifecycle-deprecated.svg │ ├── lifecycle-superseded.svg │ ├── lifecycle-experimental.svg │ └── lifecycle-questioning.svg ├── clean_site.Rd ├── check_pkgdown.Rd ├── in_pkgdown.Rd ├── pkgdown_sitrep.Rd ├── preview_site.Rd ├── as_pkgdown.Rd ├── index.Rd ├── rd2html.Rd ├── test-params.Rd ├── test-sexpr-title.Rd ├── test-figures.Rd ├── test-crayon.Rd ├── pkgdown_print.Rd ├── templates.Rd ├── test-long-lines.Rd ├── autolink_html.Rd ├── test-links.Rd ├── fig_settings.Rd ├── rmd-fragments │ ├── redirects-configuration.Rmd │ └── footer-configuration.Rmd ├── test-output-styles.Rd ├── init_site.Rd ├── build_favicons.Rd ├── build_search.Rd ├── pkgdown-package.Rd ├── render_page.Rd ├── build_site_github_pages.Rd ├── test-dont.Rd ├── test-verbatim.Rd └── deploy_to_branch.Rd ├── .gitignore ├── pkgdown └── favicon │ ├── favicon.ico │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── apple-touch-icon.png │ ├── apple-touch-icon-60x60.png │ ├── apple-touch-icon-76x76.png │ ├── apple-touch-icon-120x120.png │ ├── apple-touch-icon-152x152.png │ └── apple-touch-icon-180x180.png ├── codecov.yml ├── cran-comments.md ├── R ├── check.R ├── tweak.R ├── clean.R ├── preview.R ├── build-404.R ├── build-logo.R ├── sitrep.R ├── utils-io.R ├── autolink_html.R ├── build-home-community.R ├── template.R ├── topics-external.R ├── html-build.R ├── pkgdown_print.R ├── build-home-md.R ├── build-footer.R ├── build-home.R ├── pkgdown.R ├── build-redirects.R ├── utils-yaml.R └── highlight.R ├── .Rbuildignore ├── pkgdown.Rproj └── LICENSE.md /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /inst/BS3/templates/header.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/BS5/templates/header.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /revdep/README.md: -------------------------------------------------------------------------------- 1 | # Revdeps 2 | 3 | -------------------------------------------------------------------------------- /tests/testthat/.gitignore: -------------------------------------------------------------------------------- 1 | assets/*/docs 2 | -------------------------------------------------------------------------------- /tests/testthat/assets/sidebar/_pkgdown.yml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /revdep/failures.md: -------------------------------------------------------------------------------- 1 | *Wow, no problems at all. :)* -------------------------------------------------------------------------------- /revdep/problems.md: -------------------------------------------------------------------------------- 1 | *Wow, no problems at all. :)* -------------------------------------------------------------------------------- /vignettes/test/test.txt: -------------------------------------------------------------------------------- 1 | a 2 | b 3 | c 4 | d 5 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | docs/* linguist-generated=false 2 | -------------------------------------------------------------------------------- /tests/testthat/assets/init-extra-1/pkgdown/extra.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/testthat/assets/init-extra-2/pkgdown/extra.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/testthat/assets/init-extra-2/pkgdown/extra.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | *.log 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2014--2018 2 | COPYRIGHT HOLDER: RStudio 3 | -------------------------------------------------------------------------------- /tests/testthat/assets/init-extra-1/README.md: -------------------------------------------------------------------------------- 1 | # Test 2 | -------------------------------------------------------------------------------- /tests/testthat/assets/init-extra-2/README.md: -------------------------------------------------------------------------------- 1 | # Test 2 | -------------------------------------------------------------------------------- /tests/testthat/assets/man-figures/.gitignore: -------------------------------------------------------------------------------- 1 | inst/doc 2 | -------------------------------------------------------------------------------- /tests/testthat/assets/articles-resources/vignettes/external.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/testthat/assets/init-asset-subdirs/README.md: -------------------------------------------------------------------------------- 1 | # Test 2 | -------------------------------------------------------------------------------- /tests/testthat/assets/bad-images/README.md: -------------------------------------------------------------------------------- 1 | 2 | ![](foo.png) 3 | -------------------------------------------------------------------------------- /tests/testthat/assets/home-readme-rmd/README.md: -------------------------------------------------------------------------------- 1 | 2 | This is a test 3 | -------------------------------------------------------------------------------- /tests/testthat/assets/man-figures/vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference/_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: http://test.org 2 | -------------------------------------------------------------------------------- /tests/testthat/assets/open-graph/_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: http://example.com/pkg 2 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference-pre-post/pkgdown/pre-reference.R: -------------------------------------------------------------------------------- 1 | a <- 1 2 | -------------------------------------------------------------------------------- /inst/BS3/templates/after-body.html: -------------------------------------------------------------------------------- 1 | {{#includes}}{{{after_body}}}{{/includes}} 2 | -------------------------------------------------------------------------------- /inst/BS3/templates/before-body.html: -------------------------------------------------------------------------------- 1 | {{#includes}}{{{before_body}}}{{/includes}} 2 | -------------------------------------------------------------------------------- /inst/BS3/templates/in-header.html: -------------------------------------------------------------------------------- 1 | {{#includes}}{{{in_header}}}{{/includes}} 2 | -------------------------------------------------------------------------------- /inst/BS5/templates/after-body.html: -------------------------------------------------------------------------------- 1 | {{#includes}}{{{after_body}}}{{/includes}} 2 | -------------------------------------------------------------------------------- /inst/BS5/templates/before-body.html: -------------------------------------------------------------------------------- 1 | {{#includes}}{{{before_body}}}{{/includes}} 2 | -------------------------------------------------------------------------------- /inst/BS5/templates/in-header.html: -------------------------------------------------------------------------------- 1 | {{#includes}}{{{in_header}}}{{/includes}} 2 | -------------------------------------------------------------------------------- /tests/testthat/assets/cname/_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: https://testpackage.r-lib.org 2 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference-pre-post/pkgdown/post-reference.R: -------------------------------------------------------------------------------- 1 | a <- a + 1 2 | -------------------------------------------------------------------------------- /tests/testthat/assets/site-bad-logo/_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: http://example.com/pkg 2 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(pkgdown) 3 | 4 | test_check("pkgdown") 5 | -------------------------------------------------------------------------------- /tests/testthat/assets/init-asset-subdirs/pkgdown/assets/subdir1/file1.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum 2 | -------------------------------------------------------------------------------- /.github/404.md: -------------------------------------------------------------------------------- 1 | # Page not found (404) 2 | 3 | Please use the links in the navigation bar. 4 | -------------------------------------------------------------------------------- /man/figures/bacon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/man/figures/bacon.jpg -------------------------------------------------------------------------------- /man/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/man/figures/logo.png -------------------------------------------------------------------------------- /tests/testthat/assets/init-asset-subdirs/pkgdown/assets/subdir1/subdir2/file2.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum 2 | -------------------------------------------------------------------------------- /tests/testthat/assets/site-empty/NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | inst/doc 5 | *.orig 6 | .env 7 | *.tex 8 | docs 9 | -------------------------------------------------------------------------------- /tests/testthat/assets/home-old-skool/NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | -------------------------------------------------------------------------------- /tests/testthat/assets/home-readme-rmd/NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | -------------------------------------------------------------------------------- /tests/testthat/assets/templates-local/pkgdown/templates/content-article.html: -------------------------------------------------------------------------------- 1 | CONTENT ARTICLE BODY 2 | -------------------------------------------------------------------------------- /tests/testthat/assets/templates-local/pkgdown/templates/footer-article.html: -------------------------------------------------------------------------------- 1 | CONTENT ARTICLE FOOTER 2 | -------------------------------------------------------------------------------- /vignettes/test/bacon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/vignettes/test/bacon.jpg -------------------------------------------------------------------------------- /pkgdown/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/pkgdown/favicon/favicon.ico -------------------------------------------------------------------------------- /tests/testthat/assets/init-asset-subdirs/pkgdown/_pkgdown.yml: -------------------------------------------------------------------------------- 1 | template: 2 | assets: pkgdown/assets 3 | -------------------------------------------------------------------------------- /tests/testthat/assets/open-graph/R/f.R: -------------------------------------------------------------------------------- 1 | #' Title 2 | #' 3 | #' @export 4 | f <- function() { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /revdep/email.yml: -------------------------------------------------------------------------------- 1 | release_date: ??? 2 | rel_release_date: ??? 3 | my_news_url: ??? 4 | release_version: ??? 5 | -------------------------------------------------------------------------------- /tests/testthat/assets/man-figures/README.md: -------------------------------------------------------------------------------- 1 | # This is a kitten 2 | 3 | 4 | -------------------------------------------------------------------------------- /tests/testthat/assets/open-graph/NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(f) 4 | -------------------------------------------------------------------------------- /tests/testthat/assets/pandoc-fail.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "pandoc-fail" 3 | --- 4 | 5 | ![](path-to-image.png) 6 | -------------------------------------------------------------------------------- /tests/testthat/assets/home-index-rmd/index.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | This is a test 6 | -------------------------------------------------------------------------------- /tests/testthat/assets/home-readme-rmd/README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | This is a test 6 | -------------------------------------------------------------------------------- /tests/testthat/assets/open-graph-customized/R/f.R: -------------------------------------------------------------------------------- 1 | #' Title 2 | #' 3 | #' @export 4 | f <- function() { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference-fail/NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(f) 4 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference-html-dep/NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(a) 4 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference-html-dep/_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: http://test.org 2 | 3 | template: 4 | bootstrap: 5 5 | -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/pkgdown/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/pkgdown/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /tests/testthat/assets/open-graph-customized/NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(f) 4 | -------------------------------------------------------------------------------- /inst/po/de/LC_MESSAGES/R-pkgdown.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/inst/po/de/LC_MESSAGES/R-pkgdown.mo -------------------------------------------------------------------------------- /inst/po/dk/LC_MESSAGES/R-pkgdown.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/inst/po/dk/LC_MESSAGES/R-pkgdown.mo -------------------------------------------------------------------------------- /inst/po/es/LC_MESSAGES/R-pkgdown.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/inst/po/es/LC_MESSAGES/R-pkgdown.mo -------------------------------------------------------------------------------- /inst/po/fr/LC_MESSAGES/R-pkgdown.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/inst/po/fr/LC_MESSAGES/R-pkgdown.mo -------------------------------------------------------------------------------- /inst/po/ko/LC_MESSAGES/R-pkgdown.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/inst/po/ko/LC_MESSAGES/R-pkgdown.mo -------------------------------------------------------------------------------- /inst/po/kr/LC_MESSAGES/R-pkgdown.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/inst/po/kr/LC_MESSAGES/R-pkgdown.mo -------------------------------------------------------------------------------- /inst/po/pt/LC_MESSAGES/R-pkgdown.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/inst/po/pt/LC_MESSAGES/R-pkgdown.mo -------------------------------------------------------------------------------- /inst/po/tr/LC_MESSAGES/R-pkgdown.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/inst/po/tr/LC_MESSAGES/R-pkgdown.mo -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/pkgdown/favicon/apple-touch-icon.png -------------------------------------------------------------------------------- /revdep/.gitignore: -------------------------------------------------------------------------------- 1 | checks 2 | library 3 | checks.noindex 4 | library.noindex 5 | data.sqlite 6 | *.html 7 | cloud.noindex 8 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference-fail/R/f.R: -------------------------------------------------------------------------------- 1 | #' Title 2 | #' 3 | #' \url{} 4 | #' @export 5 | f <- function() { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /vignettes/test/short.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "A short page" 3 | --- 4 | 5 | The footer should hug the bottom of the viewport. 6 | -------------------------------------------------------------------------------- /inst/po/zh_CN/LC_MESSAGES/R-pkgdown.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/inst/po/zh_CN/LC_MESSAGES/R-pkgdown.mo -------------------------------------------------------------------------------- /tests/testthat/assets/figure/_pkgdown.yml: -------------------------------------------------------------------------------- 1 | figures: 2 | dev: "jpeg" 3 | fig.ext: "jpg" 4 | fig.width: 3 5 | fig.asp: 1 6 | -------------------------------------------------------------------------------- /tests/testthat/assets/figure/vignettes/figures.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Test: Figures" 3 | --- 4 | 5 | ```{r} 6 | plot(1:10) 7 | ``` 8 | -------------------------------------------------------------------------------- /tests/testthat/assets/site-dot-github/.github/404.md: -------------------------------------------------------------------------------- 1 | # Page not found (404) 2 | 3 | Please use the links in the navigation bar. 4 | -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/pkgdown/favicon/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/pkgdown/favicon/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /tests/testthat/assets/articles/vignettes/width.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Width" 3 | --- 4 | 5 | ```{r} 6 | getOption("width") 7 | ``` 8 | 9 | -------------------------------------------------------------------------------- /tests/testthat/assets/man-figures/_pkgdown.yml: -------------------------------------------------------------------------------- 1 | figures: 2 | dev: "jpeg" 3 | fig.ext: "jpg" 4 | fig.width: 3 5 | fig.asp: 1 6 | -------------------------------------------------------------------------------- /tests/testthat/assets/open-graph/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/tests/testthat/assets/open-graph/logo.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/pkgdown/favicon/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/pkgdown/favicon/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/pkgdown/favicon/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /tests/testthat/assets/site-bad-logo/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/tests/testthat/assets/site-bad-logo/logo.png -------------------------------------------------------------------------------- /tests/testthat/assets/site-favicons/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/tests/testthat/assets/site-favicons/logo.png -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # CODEOWNERS for pkgdown 2 | # https://www.tidyverse.org/development/understudies 3 | .github/CODEOWNERS @hadley @jayhesselberth 4 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference/NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export("?") 4 | export(a) 5 | export(b) 6 | export(c) 7 | -------------------------------------------------------------------------------- /inst/rstudio/addins.dcf: -------------------------------------------------------------------------------- 1 | Name: Build pkgdown 2 | Description: Runs pkgdown on the current package 3 | Binding: build_site_external 4 | Interactive: true 5 | -------------------------------------------------------------------------------- /tests/testthat/assets/man-figures/man/figures/kitten.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/tests/testthat/assets/man-figures/man/figures/kitten.jpg -------------------------------------------------------------------------------- /tests/testthat/assets/man-figures/man/kitten.Rd: -------------------------------------------------------------------------------- 1 | \name{kitten} 2 | \alias{kitten} 3 | \title{A picture of a kitten} 4 | \description{ 5 | \figure{kitten.jpg} 6 | } 7 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/build-redirects.md: -------------------------------------------------------------------------------- 1 | # build_redirect() errors if one entry is not right. 2 | 3 | Entry 5 in redirects must be a character vector of length 2. 4 | 5 | -------------------------------------------------------------------------------- /tests/testthat/assets/man-figures/vignettes/another-kitten.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/tests/testthat/assets/man-figures/vignettes/another-kitten.jpg -------------------------------------------------------------------------------- /tests/testthat/assets/open-graph-customized/man/figures/card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/tests/testthat/assets/open-graph-customized/man/figures/card.png -------------------------------------------------------------------------------- /tests/testthat/assets/site-citation/encoding-latin1/DESCRIPTION: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/tests/testthat/assets/site-citation/encoding-latin1/DESCRIPTION -------------------------------------------------------------------------------- /tests/testthat/assets/site-favicons/pkgdown/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/tests/testthat/assets/site-favicons/pkgdown/favicon/favicon.ico -------------------------------------------------------------------------------- /tests/testthat/_snaps/build-logo.md: -------------------------------------------------------------------------------- 1 | # can handle logo in subdir 2 | 3 | Code 4 | copy_logo(pkg) 5 | Output 6 | Copying 'man/figures/logo.svg' to 'logo.svg' 7 | 8 | -------------------------------------------------------------------------------- /tests/testthat/assets/articles/vignettes/articles/nested.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Standard article" 3 | --- 4 | 5 | Source is nested in vignettes/articles, output should be in /articles/ 6 | -------------------------------------------------------------------------------- /tests/testthat/assets/site-citation/encoding-latin1/inst/CITATION: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/pkgdown/master/tests/testthat/assets/site-citation/encoding-latin1/inst/CITATION -------------------------------------------------------------------------------- /tests/testthat/assets/site-dot-github/README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | # test 6 | 7 | test link to [Contributor Code of Conduct](.github/CODE_OF_CONDUCT.md) 8 | -------------------------------------------------------------------------------- /vignettes/test/pdf.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "PDF" 3 | output: pdf_document 4 | pkgdown: 5 | as_is: true 6 | extension: pdf 7 | --- 8 | 9 | # Heading 10 | 11 | Some text 12 | 13 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/markdown.md: -------------------------------------------------------------------------------- 1 | # markdown_text_inline() works with inline markdown 2 | 3 | Can't use a block element in , need an inline element: 4 | x 5 | 6 | y 7 | 8 | -------------------------------------------------------------------------------- /tests/testthat/assets/search-site/_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: http://pkgdown.r-lib.org 2 | 3 | template: 4 | params: 5 | docsearch: 6 | api_key: test-api-key 7 | index_name: test-index-name 8 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A test package 5 | Authors@R: person("Hadley Wickham") 6 | RoxygenNote: 7.1.2 7 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference/man/e.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/funs.R 3 | \name{e} 4 | \alias{e} 5 | \title{E} 6 | \description{ 7 | E 8 | } 9 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference-html-dep/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A test package 5 | Authors@R: person("Hadley Wickham") 6 | RoxygenNote: 7.1.2 7 | -------------------------------------------------------------------------------- /tests/testthat/assets/bad-images/vignettes/html-vignette.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "test" 3 | --- 4 | 5 | ```{r include = FALSE} 6 | knitr::opts_chunk$set(collapse = TRUE, comment = "#>") 7 | ``` 8 | 9 | ![](foo.png) 10 | -------------------------------------------------------------------------------- /tests/testthat/assets/news/NEWS.md: -------------------------------------------------------------------------------- 1 | # testpackage 1.0.0.9000 2 | 3 | * bullet (#222 @someone) 4 | 5 | # testpackage 1.0.0 6 | 7 | ## sub-heading 8 | 9 | * first thing (#111 @githubuser) 10 | 11 | * second thing 12 | -------------------------------------------------------------------------------- /inst/BS3/templates/footer.html: -------------------------------------------------------------------------------- 1 | {{#footer}} 2 | 5 | 6 |
7 |

{{#right}}{{{.}}}{{/right}}

8 |
9 | {{/footer}} 10 | -------------------------------------------------------------------------------- /tests/testthat/assets/articles-resources/vignettes/resources.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Hidden External resource" 3 | --- 4 | 5 | There's a hidden external resource in this vignette. 6 | 7 | ![external dependency](`r "external.png"`) 8 | 9 | -------------------------------------------------------------------------------- /tests/testthat/assets/articles/vignettes/standard.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Standard vignette" 3 | --- 4 | 5 | Nothing out of the ordinary here 6 | 7 | ## One section 8 | 9 | Blabla 10 | 11 | ## Another one 12 | 13 | Blop 14 | -------------------------------------------------------------------------------- /revdep/cran.md: -------------------------------------------------------------------------------- 1 | ## revdepcheck results 2 | 3 | We checked 113 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. 4 | 5 | * We saw 0 new problems 6 | * We failed to check 0 packages 7 | 8 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/sitrep.md: -------------------------------------------------------------------------------- 1 | # pkgdown_sitrep works 2 | 3 | * url in '_pkgdown.yml' not configured. 4 | 5 | --- 6 | 7 | * URL missing from the DESCRIPTION URL field. 8 | 9 | --- 10 | 11 | All good :-) 12 | 13 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference/man/a.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/funs.R 3 | \name{a} 4 | \alias{a} 5 | \title{A} 6 | \usage{ 7 | a() 8 | } 9 | \description{ 10 | A 11 | } 12 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference/man/b.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/funs.R 3 | \name{b} 4 | \alias{b} 5 | \title{B} 6 | \usage{ 7 | b() 8 | } 9 | \description{ 10 | B 11 | } 12 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference/man/c.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/funs.R 3 | \name{c} 4 | \alias{c} 5 | \title{C} 6 | \usage{ 7 | c() 8 | } 9 | \description{ 10 | C 11 | } 12 | -------------------------------------------------------------------------------- /tests/testthat/assets/site-dot-github/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A test package 5 | Authors@R: person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")) 6 | -------------------------------------------------------------------------------- /inst/BS3/templates/layout-redirect.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /inst/BS5/templates/content-home.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | {{{index}}} 4 |
5 | 6 | 11 |
12 | -------------------------------------------------------------------------------- /inst/BS5/templates/layout-redirect.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /tests/testthat/assets/open-graph/man/f.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/f.R 3 | \name{f} 4 | \alias{f} 5 | \title{Title} 6 | \usage{ 7 | f() 8 | } 9 | \description{ 10 | Title 11 | } 12 | -------------------------------------------------------------------------------- /tests/testthat/assets/site-citation/multi/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Title: A test package 3 | Version: 1.0.0 4 | Author: Sebastian Meyer 5 | Maintainer: Sebastian Meyer 6 | Description: Test multiple citations. 7 | -------------------------------------------------------------------------------- /tests/testthat/assets/news/README.md: -------------------------------------------------------------------------------- 1 | # testpackage 2 | 3 | Very nice package 4 | 5 | ## Thing 6 | 7 | Very cool! 8 | 9 | ```r 10 | plot(1:10) 11 | ``` 12 | ## This section is unnumbered {-} 13 | 14 | But I do not expect a bug now. 15 | -------------------------------------------------------------------------------- /inst/BS5/templates/footer.html: -------------------------------------------------------------------------------- 1 | {{#footer}} 2 | 5 | 6 | 9 | {{/footer}} 10 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference/man/help.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/funs.R 3 | \name{?} 4 | \alias{?} 5 | \title{D} 6 | \usage{ 7 | \special{?topic} 8 | } 9 | \description{ 10 | D 11 | } 12 | -------------------------------------------------------------------------------- /tests/testthat/assets/site-dot-github/.github/SUPPORT.md: -------------------------------------------------------------------------------- 1 | # Getting help with pkgdown 2 | 3 | Thanks for using pkgdown. Before filing an issue, there are a few places 4 | to explore and pieces to put together to make the process as smooth as possible. 5 | -------------------------------------------------------------------------------- /tests/testthat/assets/open-graph-customized/man/f.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/f.R 3 | \name{f} 4 | \alias{f} 5 | \title{Title} 6 | \usage{ 7 | f() 8 | } 9 | \description{ 10 | Title 11 | } 12 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/build-footer.md: -------------------------------------------------------------------------------- 1 | # works by default 2 | 3 | $left 4 | [1] "

Developed by First Last.

" 5 | 6 | $right 7 | [1] "

Site built with pkgdown {version}.

" 8 | 9 | 10 | -------------------------------------------------------------------------------- /tests/testthat/assets/home-old-skool/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A test package 5 | Author: Hadley Wickham 6 | Maintainer: Hadley Wickham 7 | RoxygenNote: 6.1.1 8 | Encoding: UTF-8 9 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference-fail/man/f.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/f.R 3 | \name{f} 4 | \alias{f} 5 | \title{Title} 6 | \usage{ 7 | f() 8 | } 9 | \description{ 10 | Title 11 | 12 | \url{} 13 | } 14 | -------------------------------------------------------------------------------- /tests/testthat/assets/site-citation/multi/inst/CITATION: -------------------------------------------------------------------------------- 1 | bibentry("misc", title="Proof of b < a > c", author=c("A", "B"), year="2021", 2 | textVersion="A & B (2021): Proof of b < a > c.") 3 | bibentry("misc", title="Title Two", author="Author Two", year="2022") 4 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/development.md: -------------------------------------------------------------------------------- 1 | # bad mode yields good error 2 | 3 | Code 4 | check_mode("foo") 5 | Condition 6 | Error in `check_mode()`: 7 | ! `development.mode` in `_pkgdown.yml` must be one of auto, default, release, devel, unreleased 8 | 9 | -------------------------------------------------------------------------------- /tests/testthat/test-topics-external.R: -------------------------------------------------------------------------------- 1 | test_that("can get info about external function", { 2 | expect_snapshot(str(ext_topics("base::mean"))) 3 | }) 4 | 5 | test_that("fails if documentation not available", { 6 | expect_snapshot(ext_topics("base::doesntexist"), error = TRUE) 7 | }) 8 | -------------------------------------------------------------------------------- /inst/BS3/templates/content-home.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | {{{index}}} 4 |
5 | 6 | 11 |
12 | -------------------------------------------------------------------------------- /tests/testthat/assets/articles/vignettes/widget.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Widgets" 3 | --- 4 | 5 | ```{r} 6 | path1 <- tempfile() 7 | writeLines(letters, path1) 8 | path2 <- tempfile() 9 | writeLines(letters[-(10:11)], path2) 10 | 11 | diffviewer::visual_diff(path1, path2) 12 | ``` 13 | 14 | -------------------------------------------------------------------------------- /tests/testthat/assets/articles-resources/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A longer statement about the package. 5 | Authors@R: 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")) 7 | RoxygenNote: 6.0.1 8 | -------------------------------------------------------------------------------- /tests/testthat/assets/vignette-with-crayon.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Crayon" 3 | output: html_fragment 4 | --- 5 | 6 | ```{r include = FALSE} 7 | knitr::opts_chunk$set(collapse = TRUE, comment = "#>") 8 | ``` 9 | 10 | :::downlit 11 | ```{r} 12 | cat(crayon::red("X"), "\n") 13 | ``` 14 | ::: 15 | -------------------------------------------------------------------------------- /tests/testthat/assets/articles/vignettes/toc-false.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "No TOC" 3 | toc: false 4 | --- 5 | 6 | ## Introduction 7 | 8 | An otherwise standard vignette, without a TOC. 9 | 10 | ## More Content 11 | 12 | Adipiscing conubia leo molestie diam pulvinar turpis pellentesque augue? 13 | -------------------------------------------------------------------------------- /tests/testthat/assets/tutorials/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A test package 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | -------------------------------------------------------------------------------- /tests/testthat/assets/init-extra-1/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A test package 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | -------------------------------------------------------------------------------- /tests/testthat/assets/init-extra-2/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A test package 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | -------------------------------------------------------------------------------- /tests/testthat/assets/search-site/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A test package 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | 3 | coverage: 4 | status: 5 | project: 6 | default: 7 | target: auto 8 | threshold: 1% 9 | informational: true 10 | patch: 11 | default: 12 | target: auto 13 | threshold: 1% 14 | informational: true 15 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/highlight.md: -------------------------------------------------------------------------------- 1 | # pre() can produce needed range of outputs 2 | 3 | Code 4 | cat(pre("x")) 5 | Output 6 |
x
7 | Code 8 | cat(pre("x", r_code = TRUE)) 9 | Output 10 |
x
11 | 12 | -------------------------------------------------------------------------------- /tests/testthat/assets/init-asset-subdirs/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A test package 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## R CMD check results 2 | 3 | 0 errors | 0 warnings | 0 notes 4 | 5 | ## revdepcheck results 6 | 7 | We checked 113 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. 8 | 9 | * We saw 0 new problems 10 | * We failed to check 0 packages 11 | 12 | -------------------------------------------------------------------------------- /tests/testthat/assets/figure/man/figure.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/bacon.R 3 | \name{Figure} 4 | \alias{Figure} 5 | \title{Figure} 6 | \description{ 7 | Pulled pork is delicious 8 | } 9 | \examples{ 10 | plot(1:5) 11 | hist(1:3) 12 | } 13 | \keyword{internal} 14 | -------------------------------------------------------------------------------- /tests/testthat/assets/site-citation/encoding-UTF-8/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Type: Package 3 | Title: Test package 4 | Version: 0.2.5 5 | Date: 2018-02-02 6 | Authors@R: person("Florian", "Privé") 7 | Description: Test non-ASCII characters in Authors@R 8 | Encoding: UTF-8 9 | URL: http://github.com/test 10 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference-html-dep/man/a.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/funs.R 3 | \name{a} 4 | \alias{a} 5 | \title{Example with HTML dependency} 6 | \usage{ 7 | a() 8 | } 9 | \description{ 10 | Example with HTML dependency 11 | } 12 | \examples{ 13 | a() 14 | } 15 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/package.md: -------------------------------------------------------------------------------- 1 | # check_bootstrap_version() gives informative error otherwise 2 | 3 | Code 4 | check_bootstrap_version(1) 5 | Condition 6 | Error in `check_bootstrap_version()`: 7 | ! Boostrap version must be 3 or 5. 8 | x You specified a value of 1 in template.bootstrap. 9 | 10 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference/R/funs.R: -------------------------------------------------------------------------------- 1 | #' A 2 | #' @export 3 | a <- function() {} 4 | 5 | #' B 6 | #' @export 7 | b <- function() {} 8 | 9 | #' C 10 | #' @export 11 | c <- function() {} 12 | 13 | #' D 14 | #' @usage 15 | #' \special{?topic} 16 | #' @export 17 | `?` <- function() {} 18 | 19 | #' E 20 | #' @name e 21 | NULL 22 | -------------------------------------------------------------------------------- /tests/testthat/assets/site-empty/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A test package 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | RoxygenNote: 6.1.1 10 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/build-favicons.md: -------------------------------------------------------------------------------- 1 | # existing logo generates message 2 | 3 | Code 4 | build_favicons(pkg) 5 | Output 6 | -- Building favicons ----------------------------------------------------------- 7 | Message 8 | Favicons already exist in `pkgdown/`. Set `overwrite = TRUE` to re-create. 9 | 10 | -------------------------------------------------------------------------------- /tests/testthat/assets/home-index-rmd/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A test package 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | RoxygenNote: 6.0.1 10 | -------------------------------------------------------------------------------- /tests/testthat/assets/news/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A test package 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | Date/Publication: 2021-01-01 10 | -------------------------------------------------------------------------------- /vignettes/test/jss.bib: -------------------------------------------------------------------------------- 1 | @article{JSSv059i10, 2 | author = {Hadley Wickham}, 3 | title = {Tidy Data}, 4 | journal = {Journal of Statistical Software, Articles}, 5 | volume = {59}, 6 | number = {10}, 7 | year = {2014}, 8 | issn = {1548-7660}, 9 | pages = {1--23}, 10 | doi = {10.18637/jss.v059.i10} 11 | } 12 | -------------------------------------------------------------------------------- /tests/testthat/assets/site-dot-github/.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, we pledge to respect all people who 4 | contribute through reporting issues, posting feature requests, updating documentation, 5 | submitting pull requests or patches, and other activities. 6 | 7 | -------------------------------------------------------------------------------- /tests/testthat/test-build.R: -------------------------------------------------------------------------------- 1 | test_that("both versions of build_site have same arguments", { 2 | expect_equal(formals(build_site_local), formals(build_site_external)) 3 | }) 4 | 5 | test_that("can build package without any index/readme", { 6 | pkg <- local_pkgdown_site(test_path("assets/site-empty")) 7 | expect_output(build_site(pkg)) 8 | }) 9 | -------------------------------------------------------------------------------- /inst/BS3/templates/content-tutorial-index.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 6 | 7 |
    8 | {{#tutorials}} 9 |
  • {{title}}
  • 10 | {{/tutorials}} 11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/init.md: -------------------------------------------------------------------------------- 1 | # site meta doesn't break unexpectedly 2 | 3 | pandoc: '{version}' 4 | pkgdown: '{version}' 5 | pkgdown_sha: '{sha}' 6 | articles: {} 7 | last_built: 2020-01-01T00:00Z 8 | urls: 9 | reference: http://test.org/reference 10 | article: http://test.org/articles 11 | 12 | 13 | -------------------------------------------------------------------------------- /inst/BS3/templates/content-tutorial.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 6 |
7 | 8 |
9 |
10 | 11 |
12 |
13 | -------------------------------------------------------------------------------- /tests/testthat/assets/articles/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A longer statement about the package. 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | RoxygenNote: 6.0.1 10 | -------------------------------------------------------------------------------- /tests/testthat/assets/cname/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A longer statement about the package. 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | RoxygenNote: 6.0.1 10 | -------------------------------------------------------------------------------- /tests/testthat/assets/figure/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A longer statement about the package. 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | RoxygenNote: 6.0.1 10 | -------------------------------------------------------------------------------- /tests/testthat/assets/open-graph-customized/_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: http://example.com/pkg 2 | 3 | template: 4 | opengraph: 5 | image: 6 | src: man/figures/card.png 7 | alt: "The social media card of the example.com package" 8 | twitter: 9 | site: "@rstudio" 10 | creator: "@hadley" 11 | card: summary_large_image 12 | -------------------------------------------------------------------------------- /tests/testthat/assets/sidebar/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A test package 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | RoxygenNote: 6.0.1 10 | License: GPL-3 11 | -------------------------------------------------------------------------------- /inst/BS3/templates/content-news-index.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 6 | 11 |
12 |
13 | 14 | -------------------------------------------------------------------------------- /tests/testthat/assets/bad-images/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A longer statement about the package. 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | RoxygenNote: 6.0.1 10 | -------------------------------------------------------------------------------- /tests/testthat/assets/home-readme-rmd/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A test package 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | RoxygenNote: 6.1.1 10 | Encoding: UTF-8 11 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/build-home-community.md: -------------------------------------------------------------------------------- 1 | # handles CoC and SUPPORT if present 2 | 3 |
4 |

Community

5 | 9 |
10 | 11 | -------------------------------------------------------------------------------- /tests/testthat/assets/templates-local/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A longer statement about the package. 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | RoxygenNote: 6.0.1 10 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference-html-dep/R/funs.R: -------------------------------------------------------------------------------- 1 | #' Example with HTML dependency 2 | #' 3 | #' @examples 4 | #' a() 5 | #' @export 6 | a <- function() { 7 | x <- htmltools::tagList( 8 | htmltools::p("hello"), 9 | rmarkdown::html_dependency_jquery(), 10 | rmarkdown::html_dependency_bootstrap("flatly") 11 | ) 12 | htmltools::browsable(x) 13 | } 14 | -------------------------------------------------------------------------------- /tests/testthat/assets/sidebar-comment/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A test package 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd"), comment = c("Thank you!")) 8 | ) 9 | RoxygenNote: 6.0.1 10 | -------------------------------------------------------------------------------- /tests/testthat/assets/version-formatting/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0-9000 3 | Title: A test package 4 | Description: A longer statement about the package. 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | RoxygenNote: 6.0.1 10 | -------------------------------------------------------------------------------- /man/clean_site.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/clean.R 3 | \name{clean_site} 4 | \alias{clean_site} 5 | \title{Clean site} 6 | \usage{ 7 | clean_site(pkg = ".") 8 | } 9 | \arguments{ 10 | \item{pkg}{Path to package.} 11 | } 12 | \description{ 13 | Delete all files in \verb{docs/} (except for \code{CNAME}). 14 | } 15 | -------------------------------------------------------------------------------- /tests/testthat/assets/site-citation/encoding-UTF-8/inst/CITATION: -------------------------------------------------------------------------------- 1 | citEntry(entry = "Article", 2 | title="test non-ASCII character in authors *and* citation(auto = meta)", 3 | author="Florian Privé", 4 | journal="test", 5 | year="2017", 6 | publisher="test", 7 | textVersion="test" 8 | ) 9 | 10 | citation(auto = meta) 11 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference-fail/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A longer statement about the package. 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | RoxygenNote: 6.1.1 10 | Encoding: UTF-8 11 | -------------------------------------------------------------------------------- /tests/testthat/assets/site-favicons/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A longer statement about the package. 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | RoxygenNote: 6.1.1 10 | Encoding: UTF-8 11 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/tweak-tags.md: -------------------------------------------------------------------------------- 1 | # anchor html added to headings 2 | 3 |

abc

4 | 5 | # can process footnote with code 6 | 7 | Code 8 | xpath_attr(html, ".//a", "data-bs-content") 9 | Output 10 | [1] "

Including code:

\n
1 +\n2 +
\n

And more text

" 11 | 12 | -------------------------------------------------------------------------------- /tests/testthat/assets/open-graph-customized/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A longer statement about the package. 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | RoxygenNote: 6.1.1 10 | Encoding: UTF-8 11 | -------------------------------------------------------------------------------- /tests/testthat/assets/reference-pre-post/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A longer statement about the package. 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | RoxygenNote: 6.1.1 10 | Encoding: UTF-8 11 | -------------------------------------------------------------------------------- /tests/testthat/assets/open-graph-customized/vignettes/no-description.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: No Description 3 | opengraph: 4 | twitter: 5 | card: summary 6 | creator: "@dataandme" 7 | output: rmarkdown::html_vignette 8 | vignette: > 9 | %\VignetteIndexEntry{No Description} 10 | %\VignetteEngine{knitr::rmarkdown} 11 | %\VignetteEncoding{UTF-8} 12 | --- 13 | 14 | Content goes here 15 | -------------------------------------------------------------------------------- /tests/testthat/assets/tutorials/vignettes/tutorials/test-1/tutorial-test-1.dcf: -------------------------------------------------------------------------------- 1 | name: tutorial-test-1 2 | title: tutorial-test-1 3 | username: 4 | account: hadley 5 | server: shinyapps.io 6 | hostUrl: https://api.shinyapps.io/v1 7 | appId: 305391 8 | bundleId: 1282758 9 | url: https://hadley.shinyapps.io/tutorial-test-1/ 10 | when: 1521734722.72611 11 | asMultiple: FALSE 12 | asStatic: FALSE 13 | -------------------------------------------------------------------------------- /R/check.R: -------------------------------------------------------------------------------- 1 | #' Check `_pkgdown.yml` 2 | #' 3 | #' Check that your `_pkgdown.yml` is valid without building the whole 4 | #' site. 5 | #' 6 | #' @export 7 | #' @inheritParams as_pkgdown 8 | check_pkgdown <- function(pkg = ".") { 9 | pkg <- as_pkgdown(pkg) 10 | 11 | data_open_graph(pkg) 12 | data_articles_index(pkg) 13 | data_reference_index(pkg) 14 | 15 | inform("No problems found") 16 | } 17 | 18 | -------------------------------------------------------------------------------- /tests/testthat/assets/articles/vignettes/html-document.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "html_document + as_is" 3 | output: 4 | html_document: 5 | number_sections: true 6 | pkgdown: 7 | as_is: true 8 | --- 9 | 10 | ```{r include = FALSE} 11 | knitr::opts_chunk$set(collapse = TRUE, comment = "#>") 12 | ``` 13 | 14 | This should have section numbers on the headings. 15 | 16 | # Heading 1 17 | 18 | # Heading 2 19 | -------------------------------------------------------------------------------- /tests/testthat/assets/open-graph/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A longer statement about the package. 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | RoxygenNote: 6.1.1 10 | Encoding: UTF-8 11 | URL: http://example.com/pkg/ 12 | -------------------------------------------------------------------------------- /man/check_pkgdown.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/check.R 3 | \name{check_pkgdown} 4 | \alias{check_pkgdown} 5 | \title{Check \verb{_pkgdown.yml}} 6 | \usage{ 7 | check_pkgdown(pkg = ".") 8 | } 9 | \arguments{ 10 | \item{pkg}{Path to package.} 11 | } 12 | \description{ 13 | Check that your \verb{_pkgdown.yml} is valid without building the whole 14 | site. 15 | } 16 | -------------------------------------------------------------------------------- /man/in_pkgdown.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pkgdown.R 3 | \name{in_pkgdown} 4 | \alias{in_pkgdown} 5 | \title{Determine if code is executed by pkgdown} 6 | \usage{ 7 | in_pkgdown() 8 | } 9 | \description{ 10 | This is occasionally useful when you need different behaviour by 11 | pkgdown and regular documentation. 12 | } 13 | \examples{ 14 | in_pkgdown() 15 | } 16 | -------------------------------------------------------------------------------- /tests/testthat/assets/man-figures/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: kittens 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: A longer statement about the package. 5 | Authors@R: c( 6 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 7 | person("RStudio", role = c("cph", "fnd")) 8 | ) 9 | RoxygenNote: 6.0.1 10 | Suggests: 11 | knitr, 12 | rmarkdown 13 | VignetteBuilder: knitr 14 | -------------------------------------------------------------------------------- /tests/testthat/assets/open-graph/vignettes/open-graph.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | author: "Hadley Wickham" 3 | title: "Introduction to Open Graph" 4 | description: "The Open Graph protocol is a standard for web page metadata." 5 | output: rmarkdown::html_vignette 6 | vignette: > 7 | %\VignetteIndexEntry{Introduction to Open Graph} 8 | %\VignetteEngine{knitr::rmarkdown} 9 | %\VignetteEncoding{UTF-8} 10 | --- 11 | 12 | Content goes here 13 | -------------------------------------------------------------------------------- /R/tweak.R: -------------------------------------------------------------------------------- 1 | has_class <- function(html, class) { 2 | classes <- strsplit(xml2::xml_attr(html, "class"), " ") 3 | purrr::map_lgl(classes, ~ any(class %in% .x)) 4 | } 5 | 6 | tweak_class_prepend <- function(x, class) { 7 | if (length(x) == 0) { 8 | return(invisible()) 9 | } 10 | 11 | cur <- xml2::xml_attr(x, "class") 12 | xml2::xml_attr(x, "class") <- ifelse(is.na(cur), class, paste(class, cur)) 13 | invisible() 14 | } 15 | -------------------------------------------------------------------------------- /tests/testthat/assets/site-bad-logo/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: testpackage 2 | Version: 1.0.0 3 | Title: A test package 4 | Description: The logo.png file in this package is empty and can't be 5 | converted to favicons by the API. 6 | Authors@R: c( 7 | person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), 8 | person("RStudio", role = c("cph", "fnd")) 9 | ) 10 | RoxygenNote: 6.1.1 11 | Encoding: UTF-8 12 | -------------------------------------------------------------------------------- /tests/testthat/test-sitrep.R: -------------------------------------------------------------------------------- 1 | test_that("pkgdown_sitrep works", { 2 | # URL not in the pkgdown config 3 | pkg <- test_path("assets/figure") 4 | expect_snapshot_output(pkgdown_sitrep(pkg)) 5 | # URL only in the pkgdown config 6 | pkg <- test_path("assets/cname") 7 | expect_snapshot_output(pkgdown_sitrep(pkg)) 8 | # URL everywhere 9 | pkg <- test_path("assets/open-graph") 10 | expect_snapshot_output(pkgdown_sitrep(pkg)) 11 | }) 12 | -------------------------------------------------------------------------------- /inst/BS3/templates/content-title-body.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 6 | 7 | {{{body}}} 8 | 9 |
10 | 11 | 16 | 17 |
18 | 19 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/build-home.md: -------------------------------------------------------------------------------- 1 | # warns about missing images 2 | 3 | Code 4 | build_home(pkg) 5 | Output 6 | -- Building home --------------------------------------------------------------- 7 | Writing 'authors.html' 8 | Condition 9 | Warning: 10 | Missing images in 'README.md': 'foo.png' 11 | i pkgdown can only use images in 'man/figures' and 'vignettes' 12 | Output 13 | Writing '404.html' 14 | 15 | -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^\.travis\.yml$ 4 | ^inst/web$ 5 | ^docs$ 6 | ^_pkgdown\.yml$ 7 | ^README\.Rmd$ 8 | ^README-.*\.png$ 9 | ^pkgdown$ 10 | ^codecov\.yml$ 11 | ^CODE_OF_CONDUCT\.md$ 12 | ^LICENSE\.md$ 13 | ^tests/testthat/assets/site-citation$ 14 | ^tests/testthat/assets/site-dot-github/.github$ 15 | ^cran-comments\.md$ 16 | ^CRAN-RELEASE$ 17 | ^revdep$ 18 | ^appveyor\.yml$ 19 | ^\.github$ 20 | ^fake-index.html$ 21 | ^CRAN-SUBMISSION$ 22 | -------------------------------------------------------------------------------- /tests/testthat/assets/articles/vignettes/html-vignette.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "html_vignette + as_is" 3 | output: rmarkdown::html_vignette 4 | pkgdown: 5 | as_is: true 6 | vignette: > 7 | %\VignetteIndexEntry{html_vignette + as_is} 8 | --- 9 | 10 | ```{r include = FALSE} 11 | knitr::opts_chunk$set(collapse = TRUE, comment = "#>") 12 | ``` 13 | 14 | This should not break page css/js (i.e. does the navbar look ok?) 15 | 16 | # Heading 1 17 | 18 | # Heading 2 19 | 20 | -------------------------------------------------------------------------------- /tests/testthat/assets/articles/vignettes/html-deps.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "HTML Deps" 3 | --- 4 | 5 | ```{r} 6 | # Call some code that adds jquery/bootstrap 7 | htmltools::tagList( 8 | htmltools::p("hello"), 9 | rmarkdown::html_dependency_jquery(), 10 | rmarkdown::html_dependency_bootstrap("flatly") 11 | ) 12 | ``` 13 | 14 | 15 | ```{r} 16 | knitr::knit_hooks$set(document = function(x) { 17 | if (interactive()) { 18 | browser() 19 | } 20 | x 21 | }) 22 | ``` 23 | -------------------------------------------------------------------------------- /tests/testthat/test-build-favicons.R: -------------------------------------------------------------------------------- 1 | test_that("missing logo generates message", { 2 | pkg <- local_pkgdown_site(test_path("assets/site-empty")) 3 | 4 | expect_error( 5 | expect_output(build_favicons(pkg)), 6 | "Can't find package logo" 7 | ) 8 | }) 9 | 10 | test_that("existing logo generates message", { 11 | pkg <- local_pkgdown_site(test_path("assets/site-favicons")) 12 | 13 | expect_true(has_favicons(pkg)) 14 | expect_snapshot(build_favicons(pkg)) 15 | }) 16 | -------------------------------------------------------------------------------- /tests/testthat/assets/man-figures/man-figures.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: XeLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | -------------------------------------------------------------------------------- /vignettes/test/long-toc.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Long TOC" 3 | --- 4 | 5 | ```{r include = FALSE} 6 | knitr::opts_chunk$set(collapse = TRUE, comment = "#>") 7 | ``` 8 | 9 | This vignette tests has a very long TOC. You should be able to navigate to a heading near the bottom of the doc without having to scroll all the way down. 10 | 11 | ```{r, echo = FALSE} 12 | h2 <- paste0("## Heading ", t(outer(letters, 1:9, paste0))) 13 | knitr::asis_output(paste(h2, collapse = "\n\n")) 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /inst/BS5/templates/content-tutorial.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 6 |
7 | 12 |
13 | 14 |
15 |
16 | 17 |
18 | 19 | -------------------------------------------------------------------------------- /pkgdown.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageRoxygenize: rd,collate,namespace 22 | 23 | SpellingDictionary: en_AU 24 | -------------------------------------------------------------------------------- /inst/BS5/templates/content-title-body.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 8 | 9 | {{{body}}} 10 | 11 |
12 | 13 | 18 | 19 |
20 | -------------------------------------------------------------------------------- /man/pkgdown_sitrep.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sitrep.R 3 | \name{pkgdown_sitrep} 4 | \alias{pkgdown_sitrep} 5 | \title{Report package pkgdown situation} 6 | \usage{ 7 | pkgdown_sitrep(pkg = ".") 8 | } 9 | \arguments{ 10 | \item{pkg}{Path to package.} 11 | } 12 | \description{ 13 | \code{pkgdown_sitrep()} reports 14 | \itemize{ 15 | \item If there is an \code{url} field in the pkgdown configuration; 16 | \item If that pkgdown website URL is stored in the DESCRIPTION file. 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/build-articles.md: -------------------------------------------------------------------------------- 1 | # warns about missing images 2 | 3 | Code 4 | build_articles(pkg) 5 | Output 6 | -- Building articles ----------------------------------------------------------- 7 | Writing 'articles/index.html' 8 | Reading 'vignettes/html-vignette.Rmd' 9 | Writing 'articles/html-vignette.html' 10 | Condition 11 | Warning: 12 | Missing images in 'vignettes/html-vignette.Rmd': 'foo.png' 13 | i pkgdown can only use images in 'man/figures' and 'vignettes' 14 | 15 | -------------------------------------------------------------------------------- /tests/testthat/assets/vignette-with-img.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | author: "Hadley Wickham" 3 | title: "R Markdown Vignette with an Image" 4 | description: "The image is in a subdirectory, and we must be sure to copy it." 5 | output: rmarkdown::html_vignette 6 | vignette: > 7 | %\VignetteIndexEntry{R Markdown Vignette with an Image} 8 | %\VignetteEngine{knitr::rmarkdown} 9 | %\VignetteEncoding{UTF-8} 10 | --- 11 | 12 | Some words, and then an image like this: 13 | 14 | ```{r, echo = FALSE} 15 | knitr::include_graphics("open-graph/logo.png") 16 | ``` 17 | -------------------------------------------------------------------------------- /R/clean.R: -------------------------------------------------------------------------------- 1 | #' Clean site 2 | #' 3 | #' Delete all files in `docs/` (except for `CNAME`). 4 | #' 5 | #' @inheritParams build_site 6 | #' @export 7 | clean_site <- function(pkg = ".") { 8 | pkg <- as_pkgdown(pkg) 9 | 10 | if (!dir_exists(pkg$dst_path)) return(invisible()) 11 | 12 | top_level <- dir_ls(pkg$dst_path) 13 | top_level <- top_level[!path_file(top_level) %in% c("CNAME", "dev")] 14 | 15 | is_dir <- is_dir(top_level) 16 | dir_delete(top_level[is_dir]) 17 | file_delete(top_level[!is_dir]) 18 | 19 | invisible(TRUE) 20 | } 21 | -------------------------------------------------------------------------------- /inst/BS5/templates/content-news.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 8 | 9 | {{#contents}} 10 | {{{html}}} 11 | {{/contents}} 12 |
13 | 14 | 19 | 20 |
21 | -------------------------------------------------------------------------------- /man/preview_site.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/preview.R 3 | \name{preview_site} 4 | \alias{preview_site} 5 | \title{Open site in browser} 6 | \usage{ 7 | preview_site(pkg = ".", path = ".", preview = NA) 8 | } 9 | \arguments{ 10 | \item{pkg}{Path to package.} 11 | 12 | \item{path}{Path relative to destination} 13 | 14 | \item{preview}{If \code{TRUE}, or \code{is.na(preview) && interactive()}, will preview 15 | freshly generated section in browser.} 16 | } 17 | \description{ 18 | Open site in browser 19 | } 20 | -------------------------------------------------------------------------------- /inst/BS3/templates/content-article-index.html: -------------------------------------------------------------------------------- 1 |
22 | -------------------------------------------------------------------------------- /inst/BS3/templates/content-news.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 7 | 8 | {{#contents}} 9 | {{{html}}} 10 | {{/contents}} 11 |
12 | 13 | 18 | 19 |
20 | -------------------------------------------------------------------------------- /inst/BS5/templates/content-tutorial-index.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 7 | 8 |
    9 | {{#tutorials}} 10 |
  • {{title}}
  • 11 | {{/tutorials}} 12 |
13 |
14 | 15 | 20 |
21 | -------------------------------------------------------------------------------- /tests/testthat/test-build-logo.R: -------------------------------------------------------------------------------- 1 | test_that("can handle logo in subdir", { 2 | src <- withr::local_tempdir() 3 | dst <- withr::local_tempdir() 4 | 5 | dir_create(path(src, "man", "figures")) 6 | file_create(path(src, "man", "figures", "logo.svg")) 7 | pkg <- structure(list(src_path = src, dst_path = dst), class = "pkgdown") 8 | expect_true(has_logo(pkg)) 9 | 10 | expect_snapshot(copy_logo(pkg)) 11 | expect_true(file_exists(path(dst, "logo.svg"))) 12 | 13 | expect_equal(logo_path(pkg, 0), "logo.svg") 14 | expect_equal(logo_path(pkg, 1), "../logo.svg") 15 | }) 16 | -------------------------------------------------------------------------------- /R/preview.R: -------------------------------------------------------------------------------- 1 | #' Open site in browser 2 | #' 3 | #' @inheritParams build_article 4 | #' @param path Path relative to destination 5 | #' @export 6 | preview_site <- function(pkg = ".", path = ".", preview = NA) { 7 | pkg <- as_pkgdown(pkg) 8 | 9 | if (is.na(preview)) { 10 | preview <- interactive() && !is_testing() 11 | } 12 | 13 | if (preview) { 14 | rule("Previewing site") 15 | utils::browseURL(path(pkg$dst_path, path, "index.html")) 16 | } 17 | 18 | invisible() 19 | } 20 | 21 | is_testing <- function() { 22 | identical(Sys.getenv("TESTTHAT"), "true") 23 | } 24 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/build-reference.md: -------------------------------------------------------------------------------- 1 | # parse failures include file name 2 | 3 | Code 4 | build_reference(pkg) 5 | Output 6 | -- Building function reference ------------------------------------------------- 7 | Writing 'reference/index.html' 8 | Reading 'man/f.Rd' 9 | Condition 10 | Error in `.f()`: 11 | ! Failed to parse Rd in f.Rd 12 | i Failed to parse \url{}. 13 | i Check for empty \url{} tags. 14 | Caused by error in `stop_bad_tag()`: 15 | ! Failed to parse \url{}. 16 | i Check for empty \url{} tags. 17 | 18 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/build-home-citation.md: -------------------------------------------------------------------------------- 1 | # multiple citations all have HTML and BibTeX formats 2 | 3 | [[1]] 4 | [[1]]$html 5 | [1] "

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

" 6 | 7 | [[1]]$bibtex 8 | [1] "@Misc{,\n title = {Proof of b < a > c},\n author = {{A} and {B}},\n year = {2021},\n}" 9 | 10 | 11 | [[2]] 12 | [[2]]$html 13 | [1] "

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

" 14 | 15 | [[2]]$bibtex 16 | [1] "@Misc{,\n title = {Title Two},\n author = {Author Two},\n year = {2022},\n}" 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/check.md: -------------------------------------------------------------------------------- 1 | # fails if reference index incomplete 2 | 3 | Code 4 | check_pkgdown(pkg) 5 | Condition 6 | Error in `check_missing_topics()`: 7 | ! All topics must be included in reference index 8 | * Missing topics: ? 9 | 10 | # fails if article index incomplete 11 | 12 | Code 13 | check_pkgdown(pkg) 14 | Condition 15 | Error in `data_articles_index()`: 16 | ! Vignettes missing from index: 17 | 18 | # informs if everything is ok 19 | 20 | Code 21 | check_pkgdown(pkg) 22 | Message 23 | No problems found 24 | 25 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/repo.md: -------------------------------------------------------------------------------- 1 | # repo_source() truncates automatically 2 | 3 | Code 4 | cat(repo_source(pkg, character())) 5 | cat(repo_source(pkg, "a")) 6 | Output 7 | Source: a 8 | Code 9 | cat(repo_source(pkg, letters[1:10])) 10 | Output 11 | Source: a, b, c, and 7 more 12 | 13 | -------------------------------------------------------------------------------- /inst/BS5/templates/content-news-index.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 7 | 12 |
13 | 14 | 19 |
20 | 21 | -------------------------------------------------------------------------------- /inst/BS5/templates/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{{ head }}} 6 | {{{ in-header }}} 7 | 8 | 9 | 10 | {{#translate}}{{skip}}{{/translate}} 11 | {{{ before-body }}} 12 | {{{ navbar }}} 13 |
14 | {{{ content }}} 15 | 16 |
17 | {{{ footer }}} 18 |
19 |
20 | 21 | {{{ docsearch }}} 22 | 23 | {{{ after-body }}} 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /man/as_pkgdown.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/package.R 3 | \name{as_pkgdown} 4 | \alias{as_pkgdown} 5 | \title{Generate pkgdown data structure} 6 | \usage{ 7 | as_pkgdown(pkg = ".", override = list()) 8 | } 9 | \arguments{ 10 | \item{pkg}{Path to package.} 11 | 12 | \item{override}{An optional named list used to temporarily override 13 | values in \verb{_pkgdown.yml}} 14 | } 15 | \description{ 16 | You will generally not need to use this unless you need a custom site 17 | design and you're writing your own equivalent of \code{\link[=build_site]{build_site()}}. 18 | } 19 | -------------------------------------------------------------------------------- /tests/testthat/assets/man-figures/vignettes/kitten.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "kitten" 3 | output: rmarkdown::html_vignette 4 | vignette: > 5 | %\VignetteIndexEntry{kitten} 6 | %\VignetteEngine{knitr::rmarkdown} 7 | %\VignetteEncoding{UTF-8} 8 | --- 9 | 10 | ```{r, include = FALSE} 11 | knitr::opts_chunk$set( 12 | collapse = TRUE, 13 | comment = "#>" 14 | ) 15 | ``` 16 | 17 | ## `knitr::include_graphics()` 18 | 19 | ``` {r} 20 | knitr::include_graphics("../man/figures/kitten.jpg") 21 | ``` 22 | 23 | ## rmarkdown 24 | 25 | ![](../man/figures/kitten.jpg) 26 | 27 | ## Another kitten 28 | 29 | ![](another-kitten.jpg) 30 | -------------------------------------------------------------------------------- /man/index.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/test.R 3 | \name{index} 4 | \alias{index} 5 | \alias{test-index} 6 | \title{Index} 7 | \description{ 8 | Index 9 | } 10 | \seealso{ 11 | Other tests: 12 | \code{\link{test-crayon}}, 13 | \code{\link{test-dont}}, 14 | \code{\link{test-figures}}, 15 | \code{\link{test-links}}, 16 | \code{\link{test-lists}}, 17 | \code{\link{test-long-lines}}, 18 | \code{\link{test-output-styles}}, 19 | \code{\link{test-params}}, 20 | \code{\link{test-sexpr-title}}, 21 | \code{\link{test-verbatim}} 22 | } 23 | \concept{tests} 24 | \keyword{internal} 25 | -------------------------------------------------------------------------------- /tests/testthat/assets/open-graph-customized/vignettes/open-graph.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | author: "Mara Averick" 3 | title: "Introduction to Open Graph" 4 | description: "The Open Graph protocol is a standard for web page metadata." 5 | opengraph: 6 | description: This should be ignored 7 | image: 8 | src: "http://example.com/pkg/batpig.png" 9 | twitter: 10 | card: summary 11 | creator: "@dataandme" 12 | output: rmarkdown::html_vignette 13 | vignette: > 14 | %\VignetteIndexEntry{Introduction to Open Graph} 15 | %\VignetteEngine{knitr::rmarkdown} 16 | %\VignetteEncoding{UTF-8} 17 | --- 18 | 19 | Content goes here 20 | -------------------------------------------------------------------------------- /tests/testthat/test-deploy-site.R: -------------------------------------------------------------------------------- 1 | # ci_commit_sha() ------------------------------------------------------------ 2 | 3 | test_that("commit sha can be retrieved from travis or GitHub action env vars", { 4 | sha <- "XYZ" 5 | 6 | withr::with_envvar( 7 | c("TRAVIS_COMMIT" = sha, "GITHUB_SHA" = ""), 8 | expect_equal(ci_commit_sha(), sha) 9 | ) 10 | withr::with_envvar( 11 | c("TRAVIS_COMMIT" = "", "GITHUB_SHA" = sha), 12 | expect_equal(ci_commit_sha(), sha) 13 | ) 14 | withr::with_envvar( 15 | c("TRAVIS_COMMIT" = "", "GITHUB_SHA" = ""), 16 | expect_equal(ci_commit_sha(), "") 17 | ) 18 | }) 19 | -------------------------------------------------------------------------------- /R/build-404.R: -------------------------------------------------------------------------------- 1 | build_404 <- function(pkg = ".") { 2 | pkg <- as_pkgdown(pkg) 3 | 4 | # if this file exists, it will be handled by build_home_md() 5 | page_md <- path(pkg$src_path, ".github", "404.md") 6 | 7 | if (!file_exists(page_md)) { 8 | render_page( 9 | pkg, "title-body", 10 | data = list( 11 | pagetitle = tr_("Page not found (404)"), 12 | body = tr_("Content not found. Please use links in the navbar.") 13 | ), 14 | path = "404.html" 15 | ) 16 | update_html(path_abs("404.html", start = pkg$dst_path), tweak_link_absolute, pkg = pkg) 17 | } 18 | 19 | invisible() 20 | } 21 | -------------------------------------------------------------------------------- /inst/BS3/templates/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{{ head }}} 6 | {{{ in-header }}} 7 | 8 | 9 | 10 | {{{ before-body }}} 11 |
12 |
13 | {{{ navbar }}} 14 | {{{ header }}} 15 |
16 | 17 | {{{ content }}} 18 | 19 |
20 | {{{ footer }}} 21 |
22 |
23 | 24 | {{{ docsearch }}} 25 | 26 | {{{ after-body }}} 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /vignettes/test/widgets.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "HTML widgets" 3 | --- 4 | 5 | ```{r, include = FALSE} 6 | knitr::opts_chunk$set( 7 | collapse = TRUE, 8 | comment = "#>" 9 | ) 10 | ``` 11 | 12 | ## Widgets 13 | 14 | Test spacing above widget. 15 | 16 | ```{r, echo=FALSE} 17 | # set seed for reproducible widget id 18 | if (requireNamespace("htmltools", quietly = TRUE)) { 19 | htmlwidgets::setWidgetIdSeed(42) 20 | } 21 | 22 | path1 <- tempfile() 23 | writeLines(letters, path1) 24 | path2 <- tempfile() 25 | writeLines(letters[-(10:11)], path2) 26 | 27 | diffviewer::visual_diff(path1, path2) 28 | ``` 29 | 30 | Test spacing below widget. 31 | -------------------------------------------------------------------------------- /tests/testthat/test-build-github.R: -------------------------------------------------------------------------------- 1 | test_that("a CNAME record is built if a url exists in metadata", { 2 | pkg <- local_pkgdown_site(test_path("assets/cname")) 3 | 4 | dir_create(path(pkg$dst_path, "docs")) 5 | expect_output(build_github_pages(pkg)) 6 | expect_equal(read_lines(path(pkg$dst_path, "CNAME")), "testpackage.r-lib.org") 7 | }) 8 | 9 | test_that("CNAME URLs are valid", { 10 | expect_equal(cname_url("http://google.com/"), "google.com") 11 | expect_equal(cname_url("https://google.com/"), "google.com") 12 | 13 | # this is not a valid URL because it has a trailing path 14 | expect_null(cname_url("http://google.com/path/")) 15 | }) 16 | -------------------------------------------------------------------------------- /tests/testthat/test-utils-yaml.R: -------------------------------------------------------------------------------- 1 | test_that("pkgdown_field(s) produces useful description", { 2 | pkg <- local_pkgdown_site() 3 | file_touch(file.path(pkg$src_path, "_pkgdown.yml")) 4 | 5 | expect_snapshot({ 6 | pkgdown_field(pkg, c("a", "b")) 7 | pkgdown_fields(pkg, list(c("a", "b"), "c")) 8 | }) 9 | }) 10 | 11 | test_that("pkgdown_field(s) produces useful description", { 12 | pkg <- local_pkgdown_site() 13 | file_touch(file.path(pkg$src_path, "_pkgdown.yml")) 14 | 15 | expect_snapshot(error = TRUE, { 16 | check_yaml_has("x", where = "a", pkg = pkg) 17 | check_yaml_has(c("x", "y"), where = "a", pkg = pkg) 18 | }) 19 | }) 20 | -------------------------------------------------------------------------------- /man/rd2html.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rd.R 3 | \name{rd2html} 4 | \alias{rd2html} 5 | \title{Translate an Rd string to its HTML output} 6 | \usage{ 7 | rd2html(x, fragment = TRUE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{Rd string. Backslashes must be double-escaped ("\\\\").} 11 | 12 | \item{fragment}{logical indicating whether this represents a complete Rd file} 13 | 14 | \item{...}{additional arguments for as_html} 15 | } 16 | \description{ 17 | Translate an Rd string to its HTML output 18 | } 19 | \examples{ 20 | rd2html("a\n\%b\nc") 21 | 22 | rd2html("a & b") 23 | 24 | rd2html("\\\\strong{\\\\emph{x}}") 25 | 26 | } 27 | -------------------------------------------------------------------------------- /man/test-params.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/test.R 3 | \name{test-params} 4 | \alias{test-params} 5 | \title{Test case: params} 6 | \arguments{ 7 | \item{...}{ellipsis} 8 | } 9 | \description{ 10 | Test case: params 11 | } 12 | \seealso{ 13 | Other tests: 14 | \code{\link{index}}, 15 | \code{\link{test-crayon}}, 16 | \code{\link{test-dont}}, 17 | \code{\link{test-figures}}, 18 | \code{\link{test-links}}, 19 | \code{\link{test-lists}}, 20 | \code{\link{test-long-lines}}, 21 | \code{\link{test-output-styles}}, 22 | \code{\link{test-sexpr-title}}, 23 | \code{\link{test-verbatim}} 24 | } 25 | \concept{tests} 26 | \keyword{internal} 27 | -------------------------------------------------------------------------------- /tests/testthat/test-figure.R: -------------------------------------------------------------------------------- 1 | test_that("can override defaults in _pkgdown.yml", { 2 | skip_if_no_pandoc() 3 | withr::local_temp_libpaths() 4 | 5 | pkg <- local_pkgdown_site(test_path("assets/figure")) 6 | 7 | callr::rcmd("INSTALL", pkg$src_path, show = FALSE, fail_on_status = TRUE) 8 | 9 | expect_output(build_reference(pkg, devel = FALSE)) 10 | img <- path_file(dir_ls(path(pkg$dst_path, "reference"), glob = "*.jpg")) 11 | expect_setequal(img, c("figure-1.jpg", "figure-2.jpg")) 12 | 13 | expect_output(build_articles(pkg)) 14 | img <- path_file(dir_ls(path(pkg$dst_path, "articles"), glob = "*.jpg", recurse = TRUE)) 15 | expect_equal(img, "unnamed-chunk-1-1.jpg") 16 | }) 17 | -------------------------------------------------------------------------------- /man/test-sexpr-title.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/test.R 3 | \name{test-sexpr-title} 4 | \alias{test-sexpr-title} 5 | \title{Test case: \Sexpr[stage=render,results=rd]{"sexpr"}} 6 | \description{ 7 | Test case: \Sexpr[stage=render,results=rd]{"sexpr"} 8 | } 9 | \seealso{ 10 | Other tests: 11 | \code{\link{index}}, 12 | \code{\link{test-crayon}}, 13 | \code{\link{test-dont}}, 14 | \code{\link{test-figures}}, 15 | \code{\link{test-links}}, 16 | \code{\link{test-lists}}, 17 | \code{\link{test-long-lines}}, 18 | \code{\link{test-output-styles}}, 19 | \code{\link{test-params}}, 20 | \code{\link{test-verbatim}} 21 | } 22 | \concept{tests} 23 | \keyword{internal} 24 | -------------------------------------------------------------------------------- /inst/BS3/templates/docsearch.html: -------------------------------------------------------------------------------- 1 | {{#yaml}}{{#docsearch}} 2 | 3 | 18 | {{/docsearch}}{{/yaml}} 19 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/utils-yaml.md: -------------------------------------------------------------------------------- 1 | # pkgdown_field(s) produces useful description 2 | 3 | Code 4 | pkgdown_field(pkg, c("a", "b")) 5 | Output 6 | [1] "a.b in '_pkgdown.yml'" 7 | Code 8 | pkgdown_fields(pkg, list(c("a", "b"), "c")) 9 | Output 10 | [1] "a.b, c in '_pkgdown.yml'" 11 | 12 | --- 13 | 14 | Code 15 | check_yaml_has("x", where = "a", pkg = pkg) 16 | Condition 17 | Error in `check_yaml_has()`: 18 | ! Can't find component a.x in '_pkgdown.yml'. 19 | Code 20 | check_yaml_has(c("x", "y"), where = "a", pkg = pkg) 21 | Condition 22 | Error in `check_yaml_has()`: 23 | ! Can't find components a.x, a.y in '_pkgdown.yml'. 24 | 25 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/topics-external.md: -------------------------------------------------------------------------------- 1 | # can get info about external function 2 | 3 | Code 4 | str(ext_topics("base::mean")) 5 | Output 6 | tibble [1 x 6] (S3: tbl_df/tbl/data.frame) 7 | $ name : chr "base::mean" 8 | $ file_out: chr "https://rdrr.io/r/base/mean.html" 9 | $ title : chr "Arithmetic Mean (from base)" 10 | $ funs :List of 1 11 | ..$ : chr "mean()" 12 | $ alias :List of 1 13 | ..$ : chr(0) 14 | $ internal: logi FALSE 15 | 16 | # fails if documentation not available 17 | 18 | Code 19 | ext_topics("base::doesntexist") 20 | Condition 21 | Error in `.f()`: 22 | ! Could not find documentation for base::doesntexist 23 | 24 | -------------------------------------------------------------------------------- /inst/highlight-styles/monochrome.scss: -------------------------------------------------------------------------------- 1 | pre code span.al /* Alert */ {font-weight: bold} 2 | pre code span.an /* Annotation */ {font-style: italic} 3 | pre code span.cf /* ControlFlow */ {font-weight: bold} 4 | pre code span.co /* Comment */ {font-style: italic} 5 | pre code span.cv /* CommentVar */ {font-style: italic} 6 | pre code span.do /* Documentation */ {font-style: italic} 7 | pre code span.dt /* DataType */ {text-decoration: underline} 8 | pre code span.er /* Error */ {font-weight: bold} 9 | pre code span.in /* Information */ {font-style: italic} 10 | pre code span.kw /* Keyword */ {font-weight: bold} 11 | pre code span.pp /* Preprocessor */ {font-weight: bold} 12 | pre code span.wa /* Warning */ {font-style: italic} 13 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/tweak-homepage.md: -------------------------------------------------------------------------------- 1 | # can remove logo 2 | 3 | Code 4 | xpath_xml(html, ".//div") 5 | Output 6 | 9 | 10 | --- 11 | 12 | Code 13 | xpath_xml(html, ".//div") 14 | Output 15 | 18 | 19 | # can move badges to sidebar 20 | 21 | Code 22 | xpath_xml(html, ".//div") 23 | Output 24 |
25 |

Dev status

26 |
    27 |
  • 28 |
29 |
30 | 31 | -------------------------------------------------------------------------------- /tests/testthat/test-build-home-license.R: -------------------------------------------------------------------------------- 1 | test_that("link_license matchs exactly", { 2 | # R 3.1 uses http url 3 | skip_if_not(getRversion() >= "3.2.0") 4 | 5 | # Shouldn't match first GPL-2 6 | expect_equal( 7 | autolink_license("LGPL-2"), 8 | "LGPL-2" 9 | ) 10 | 11 | expect_equal( 12 | autolink_license("MPL-2.0"), 13 | "MPL-2.0" 14 | ) 15 | }) 16 | 17 | test_that("link_license matches LICENSE", { 18 | expect_equal( 19 | autolink_license("LICENSE"), 20 | "LICENSE" 21 | ) 22 | expect_equal( 23 | autolink_license("LICENCE"), 24 | "LICENCE" 25 | ) 26 | }) 27 | -------------------------------------------------------------------------------- /tests/testthat/test-check.R: -------------------------------------------------------------------------------- 1 | test_that("fails if reference index incomplete", { 2 | pkg <- local_pkgdown_site(test_path("assets/reference"), meta = " 3 | reference: 4 | - title: Title 5 | contents: [a, b, c, e] 6 | ") 7 | expect_snapshot(check_pkgdown(pkg), error = TRUE) 8 | }) 9 | 10 | 11 | test_that("fails if article index incomplete", { 12 | pkg <- local_pkgdown_site(test_path("assets/articles"), meta = " 13 | articles: 14 | - title: Title 15 | contents: [starts_with('html'), standard, toc-false, widget] 16 | ") 17 | expect_snapshot(check_pkgdown(pkg), error = TRUE) 18 | }) 19 | 20 | test_that("informs if everything is ok", { 21 | pkg <- local_pkgdown_site(test_path("assets/reference")) 22 | expect_snapshot(check_pkgdown(pkg)) 23 | }) 24 | -------------------------------------------------------------------------------- /inst/BS5/templates/content-authors.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 7 | 8 |
9 | {{{before}}} 10 |
    11 | {{#authors}} 12 |
  • 13 |

    {{{name}}}. {{{roles}}}. {{{orcid}}} 14 | {{#comment}}
    {{{.}}}{{/comment}}

    15 |
  • 16 | {{/authors}} 17 |
18 | {{{after}}} 19 |
20 |
21 | 22 | 27 |
28 | -------------------------------------------------------------------------------- /man/test-figures.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/test.R 3 | \name{test-figures} 4 | \alias{test-figures} 5 | \title{Test case: figures} 6 | \description{ 7 | \figure{bacon.jpg} 8 | } 9 | \examples{ 10 | x <- seq(0, 2 * pi, length.out = 25) 11 | plot(x, sin(x)) 12 | 13 | plot(1:10) 14 | lines(1:10) 15 | text(2, 5, "Hello", srt = 30, cex = 2) 16 | } 17 | \seealso{ 18 | Other tests: 19 | \code{\link{index}}, 20 | \code{\link{test-crayon}}, 21 | \code{\link{test-dont}}, 22 | \code{\link{test-links}}, 23 | \code{\link{test-lists}}, 24 | \code{\link{test-long-lines}}, 25 | \code{\link{test-output-styles}}, 26 | \code{\link{test-params}}, 27 | \code{\link{test-sexpr-title}}, 28 | \code{\link{test-verbatim}} 29 | } 30 | \concept{tests} 31 | \keyword{internal} 32 | -------------------------------------------------------------------------------- /inst/BS5/templates/content-article-index.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 7 | 8 | {{#sections}} 9 |
10 |

{{{title}}}

11 |

{{{desc}}}

12 | 13 |
14 | {{#contents}} 15 |
{{title}}
16 |
{{{description}}} 17 | {{/contents}} 18 |
19 |
20 | {{/sections}} 21 |
22 | 23 | 28 |
29 | -------------------------------------------------------------------------------- /R/build-logo.R: -------------------------------------------------------------------------------- 1 | copy_logo <- function(pkg = ".") { 2 | pkg <- as_pkgdown(pkg) 3 | 4 | logo_path <- find_logo(pkg$src_path) 5 | if (!is.null(logo_path)) { 6 | file_copy_to(pkg, logo_path, from_dir = path_dir(logo_path)) 7 | } 8 | } 9 | 10 | find_logo <- function(path) { 11 | path_first_existing( 12 | c( 13 | path(path, "logo.svg"), 14 | path(path, "man", "figures", "logo.svg"), 15 | path(path, "logo.png"), 16 | path(path, "man", "figures", "logo.png") 17 | ) 18 | ) 19 | } 20 | 21 | has_logo <- function(pkg) { 22 | logo_path <- find_logo(pkg$src_path) 23 | !is.null(logo_path) 24 | } 25 | 26 | logo_path <- function(pkg, depth) { 27 | path <- find_logo(pkg$src_path) 28 | if (is.null(path)) { 29 | return() 30 | } 31 | 32 | paste0(up_path(depth), fs::path_file(path)) 33 | } 34 | -------------------------------------------------------------------------------- /tests/testthat/assets/sidebar/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # pkgdown 5 | 6 | 7 | 8 | [![Lifecycle: 9 | maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing) 10 | [![CRAN 11 | Status](https://www.r-pkg.org/badges/version/pkgdown)](https://cran.r-project.org/package=pkgdown) 12 | [![R build 13 | status](https://github.com/r-lib/pkgdown/workflows/R-CMD-check/badge.svg)](https://github.com/r-lib/pkgdown/actions) 14 | [![Codecov test 15 | coverage](https://codecov.io/gh/r-lib/pkgdown/branch/master/graph/badge.svg)](https://codecov.io/gh/r-lib/pkgdown?branch=master) 16 | 17 | 18 | pkgdown is designed to make it quick and easy to build a website for 19 | your package. 20 | -------------------------------------------------------------------------------- /man/test-crayon.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/test.R 3 | \name{test-crayon} 4 | \alias{test-crayon} 5 | \title{Test case: crayon} 6 | \description{ 7 | Test case: crayon 8 | } 9 | \examples{ 10 | cat(crayon::red("This is red"), "\n") 11 | cat(crayon::blue("This is blue"), "\n") 12 | 13 | message(crayon::green("This is green")) 14 | 15 | warning(crayon::bold("This is bold")) 16 | } 17 | \seealso{ 18 | Other tests: 19 | \code{\link{index}}, 20 | \code{\link{test-dont}}, 21 | \code{\link{test-figures}}, 22 | \code{\link{test-links}}, 23 | \code{\link{test-lists}}, 24 | \code{\link{test-long-lines}}, 25 | \code{\link{test-output-styles}}, 26 | \code{\link{test-params}}, 27 | \code{\link{test-sexpr-title}}, 28 | \code{\link{test-verbatim}} 29 | } 30 | \concept{tests} 31 | \keyword{internal} 32 | -------------------------------------------------------------------------------- /man/pkgdown_print.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pkgdown_print.R 3 | \name{pkgdown_print} 4 | \alias{pkgdown_print} 5 | \title{Print object in pkgdown output} 6 | \usage{ 7 | pkgdown_print(x, visible = TRUE) 8 | } 9 | \arguments{ 10 | \item{x}{Object to display} 11 | 12 | \item{visible}{Whether it is visible or not} 13 | } 14 | \value{ 15 | Either a character vector representing printed output (which 16 | will be escaped for HTML as necessary) or literal HTML produced 17 | by the htmltools or htmlwidgets packages. 18 | } 19 | \description{ 20 | This lets package authors control how objects are printed just for 21 | pkgdown examples. The default is to call \code{\link[=print]{print()}} apart from htmlwidgets 22 | where the object is returned as is (with sizes tweaked). 23 | } 24 | \keyword{internal} 25 | -------------------------------------------------------------------------------- /R/sitrep.R: -------------------------------------------------------------------------------- 1 | #' Report package pkgdown situation 2 | #' 3 | #' @description 4 | #' 5 | #' `pkgdown_sitrep()` reports 6 | #' 7 | #' * If there is an `url` field in the pkgdown configuration; 8 | #' 9 | #' * If that pkgdown website URL is stored in the DESCRIPTION file. 10 | #' 11 | #' @inheritParams as_pkgdown 12 | #' 13 | #' @export 14 | #' 15 | pkgdown_sitrep <- function(pkg = ".") { 16 | pkg_dir <- pkg 17 | pkg <- as_pkgdown(pkg_dir) 18 | if (is.null(pkg$meta[["url"]])) { 19 | cat(sprintf("* %s not configured.", pkgdown_field(pkg, "url"))) 20 | } else { 21 | urls <- desc::desc(pkg_dir)$get_urls() 22 | urls <- sub("/$", "", urls) 23 | if (!pkg$meta[["url"]] %in% urls) { 24 | cat("* URL missing from the DESCRIPTION URL field.") 25 | } else { 26 | cat("All good :-)") 27 | } 28 | } 29 | 30 | invisible() 31 | } 32 | -------------------------------------------------------------------------------- /inst/BS3/assets/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /inst/BS5/assets/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/build-home-authors.md: -------------------------------------------------------------------------------- 1 | # data_home_sidebar_authors() works with text 2 | 3 | Code 4 | cat(data_home_sidebar_authors(pkg)) 5 | Output 6 |
7 |

Developers

8 |
    9 |
  • yay
  • 10 |
  • Hadley Wickham
    11 | Author, maintainer
  • 12 |
  • RStudio
    13 | Copyright holder, funder
  • 14 |
  • cool
  • 15 |
  • More about authors...
  • 16 |
17 |
18 | 19 | # role has multiple fallbacks 20 | 21 | Code 22 | role_lookup("unknown") 23 | Condition 24 | Warning: 25 | Unknown MARC role abbreviation 'unknown' 26 | Output 27 | [1] "unknown" 28 | 29 | -------------------------------------------------------------------------------- /man/templates.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/template.R 3 | \name{template_navbar} 4 | \alias{template_navbar} 5 | \alias{template_reference} 6 | \alias{template_articles} 7 | \title{Generate YAML templates} 8 | \usage{ 9 | template_navbar(path = ".") 10 | 11 | template_reference(path = ".") 12 | 13 | template_articles(path = ".") 14 | } 15 | \arguments{ 16 | \item{path}{Path to package root} 17 | } 18 | \description{ 19 | Use these function to generate the default YAML that pkgdown uses for 20 | the different parts of \verb{_pkgdown.yml}. This are useful starting 21 | points if you want to customise your site. 22 | } 23 | \examples{ 24 | \dontrun{ 25 | pkgdown::template_navbar() 26 | } 27 | 28 | \dontrun{ 29 | pkgdown::template_reference() 30 | } 31 | 32 | \dontrun{ 33 | pkgdown::template_articles() 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /tests/testthat/test-build-home-community.R: -------------------------------------------------------------------------------- 1 | test_that("handles CoC and SUPPORT if present", { 2 | # .github is build-ignored to prevent a NOTE about unexpected hidden directory 3 | # so need to skip when run from R CMD check 4 | skip_if_not(dir_exists(test_path("assets/site-dot-github/.github"))) 5 | 6 | pkg <- as_pkgdown(test_path("assets/site-dot-github")) 7 | expect_true(has_coc(pkg$src_path)) 8 | expect_true(has_support(pkg$src_path)) 9 | 10 | # And added to sidebar 11 | text <- data_home_sidebar_community(pkg) 12 | expect_snapshot_output(cat(text)) 13 | }) 14 | 15 | test_that("empty site doesn't have community asserts", { 16 | expect_false(has_contributing(test_path("assets/site-empty"))) 17 | expect_false(has_coc(test_path("assets/site-empty"))) 18 | 19 | text <- data_home_sidebar_community(test_path("assets/site-empty")) 20 | expect_equal(text, "") 21 | }) 22 | -------------------------------------------------------------------------------- /man/test-long-lines.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/test.R 3 | \name{test-long-lines} 4 | \alias{test-long-lines} 5 | \title{Test case: long-lines} 6 | \description{ 7 | The example results should have the copy button correctly placed when 8 | scrollings 9 | } 10 | \examples{ 11 | pkgdown:::ruler() 12 | 13 | cat(rep("x ", 100), sep = "") 14 | cat(rep("xy", 100), sep = "") 15 | cat(rep("x ", 100), sep = "") 16 | cat(rep("xy", 100), sep = "") 17 | } 18 | \seealso{ 19 | Other tests: 20 | \code{\link{index}}, 21 | \code{\link{test-crayon}}, 22 | \code{\link{test-dont}}, 23 | \code{\link{test-figures}}, 24 | \code{\link{test-links}}, 25 | \code{\link{test-lists}}, 26 | \code{\link{test-output-styles}}, 27 | \code{\link{test-params}}, 28 | \code{\link{test-sexpr-title}}, 29 | \code{\link{test-verbatim}} 30 | } 31 | \concept{tests} 32 | \keyword{internal} 33 | -------------------------------------------------------------------------------- /vignettes/test/jss.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | author: 3 | - name: FirstName LastName 4 | affiliation: University/Company 5 | address: > 6 | First line 7 | Second line 8 | email: \email{name@company.com} 9 | url: https://rstudio.com 10 | - name: Second Author 11 | affiliation: Affiliation 12 | title: 13 | plain: "JSS article" 14 | formatted: "JSS article" 15 | short: "JSS article" 16 | pagetitle: "JSS article" 17 | abstract: > 18 | The abstract of the article. 19 | keywords: 20 | plain: [keywords, not capitalized, Java] 21 | formatted: [keywords, not capitalized, "\\proglang{Java}"] 22 | output: rticles::jss_article 23 | documentclass: jss 24 | classoption: nojss 25 | bibliography: jss.bib 26 | pkgdown: 27 | as_is: true 28 | extension: pdf 29 | --- 30 | 31 | # Introduction 32 | 33 | Some text and a reference [@JSSv059i10]. 34 | 35 | ```{r} 36 | 1 + 37 | 2 38 | ``` 39 | 40 | -------------------------------------------------------------------------------- /tests/testthat/test-pkgdown_print.R: -------------------------------------------------------------------------------- 1 | test_that("widgets and browseable html are kept as is", { 2 | widget <- htmlwidgets::createWidget("test", list()) 3 | expect_s3_class(pkgdown_print(widget), "htmlwidget") 4 | 5 | html <- htmltools::browsable(htmltools::div("foo")) 6 | expect_s3_class(pkgdown_print(html), "shiny.tag") 7 | }) 8 | 9 | test_that("htmlwidgets get sized", { 10 | local_context_eval(list(fig.width = 7, dpi = 100, fig.asp = 1)) 11 | 12 | widget <- htmlwidgets::createWidget("test", list()) 13 | value <- pkgdown_print(widget) 14 | 15 | expect_equal(value$width, 700) 16 | expect_equal(value$height, 700) 17 | }) 18 | 19 | test_that("respect htmlwidgets width", { 20 | local_context_eval(list(fig.width = 7, dpi = 100, fig.asp = 1)) 21 | 22 | widget <- htmlwidgets::createWidget("test", list(), width = "100px") 23 | value <- pkgdown_print(widget) 24 | 25 | expect_equal(value$width, "100px") 26 | }) 27 | -------------------------------------------------------------------------------- /man/autolink_html.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/autolink_html.R 3 | \name{autolink_html} 4 | \alias{autolink_html} 5 | \title{Automatically link references and articles in an HTML page} 6 | \usage{ 7 | autolink_html(input, output = input, local_packages = character()) 8 | } 9 | \arguments{ 10 | \item{input, output}{Input and output paths for HTML file} 11 | 12 | \item{local_packages}{A named character vector providing relative paths 13 | (value) to packages (name) that can be reached with relative links 14 | from the target HTML document.} 15 | } 16 | \description{ 17 | Deprecated: please use \link[downlit:downlit_html_path]{downlit::downlit_html_path} instead. 18 | } 19 | \examples{ 20 | \dontrun{ 21 | autolink_html("path/to/file.html", 22 | local_packages = c( 23 | shiny = "shiny", 24 | shinydashboard = "shinydashboard" 25 | ) 26 | ) 27 | } 28 | } 29 | \keyword{internal} 30 | -------------------------------------------------------------------------------- /man/test-links.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/test.R 3 | \name{test-links} 4 | \alias{test-links} 5 | \title{Test case: links} 6 | \description{ 7 | \if{html}{\out{
}}\preformatted{magrittr::subtract(10, 1) 8 | }\if{html}{\out{
}} 9 | 10 | \if{html}{\out{
}}\preformatted{## [1] 9 11 | }\if{html}{\out{
}} 12 | } 13 | \examples{ 14 | magrittr::subtract(10, 1) 15 | 16 | library(magrittr, warn.conflicts = FALSE) 17 | subtract(10, 1) 18 | } 19 | \seealso{ 20 | Other tests: 21 | \code{\link{index}}, 22 | \code{\link{test-crayon}}, 23 | \code{\link{test-dont}}, 24 | \code{\link{test-figures}}, 25 | \code{\link{test-lists}}, 26 | \code{\link{test-long-lines}}, 27 | \code{\link{test-output-styles}}, 28 | \code{\link{test-params}}, 29 | \code{\link{test-sexpr-title}}, 30 | \code{\link{test-verbatim}} 31 | } 32 | \concept{tests} 33 | \keyword{internal} 34 | -------------------------------------------------------------------------------- /inst/BS3/templates/content-citation-authors.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 7 | 8 | {{{before}}} 9 |
    10 | {{#authors}} 11 |
  • 12 |

    {{{name}}}. {{{roles}}}. {{{orcid}}} 13 | {{#comment}}
    {{{.}}}{{/comment}}

    14 |
  • 15 | {{/authors}} 16 |
17 | {{{after}}} 18 |
19 |
20 |
21 |

Citation

22 | {{#source}}{{{.}}}{{/source}} 23 |
24 |
25 | 26 | 27 | {{#citations}} 28 | {{{html}}} 29 |
{{{bibtex}}}
30 | {{/citations}} 31 | 32 |
33 | 34 |
35 | 36 | -------------------------------------------------------------------------------- /man/figures/lifecycle-stable.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecyclestablestable -------------------------------------------------------------------------------- /man/figures/lifecycle-defunct.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecycledefunctdefunct -------------------------------------------------------------------------------- /man/figures/lifecycle-archived.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecyclearchivedarchived -------------------------------------------------------------------------------- /man/figures/lifecycle-maturing.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecyclematuringmaturing -------------------------------------------------------------------------------- /man/fig_settings.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/figure.R 3 | \name{fig_settings} 4 | \alias{fig_settings} 5 | \title{Get current settings for figures} 6 | \usage{ 7 | fig_settings() 8 | } 9 | \value{ 10 | A list containing the entries from the \code{figures} field in \verb{_pkgdown.yaml} 11 | (see \code{\link[=build_reference]{build_reference()}}), with default values added. Computed \code{width} and 12 | \code{height} values (in pixels) are also included. 13 | } 14 | \description{ 15 | You will generally not need to use this function unless you are handling 16 | custom plot output. 17 | 18 | Packages needing custom parameters should ask users to place them within 19 | the \code{other.parameters} entry under the package name, e.g. 20 | 21 | \if{html}{\out{
}}\preformatted{figures: 22 | other.parameters: 23 | rgl: 24 | fig.asp: 1 25 | }\if{html}{\out{
}} 26 | } 27 | \keyword{internal} 28 | -------------------------------------------------------------------------------- /man/figures/lifecycle-deprecated.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecycledeprecateddeprecated -------------------------------------------------------------------------------- /man/figures/lifecycle-superseded.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecyclesupersededsuperseded -------------------------------------------------------------------------------- /man/figures/lifecycle-experimental.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecycleexperimentalexperimental -------------------------------------------------------------------------------- /man/figures/lifecycle-questioning.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecyclequestioningquestioning -------------------------------------------------------------------------------- /man/rmd-fragments/redirects-configuration.Rmd: -------------------------------------------------------------------------------- 1 | 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. 2 | One or several now-absent pages can be redirected to a new page (or to a new section of a new page). 3 | 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. 4 | 5 | The syntax is the following, with old paths on the left, and new paths or URLs on the right. 6 | 7 | ```yaml 8 | redirects: 9 | - ["articles/old-vignette-name.html", "articles/new-vignette-name.html"] 10 | - ["articles/another-old-vignette-name.html", "articles/new-vignette-name.html"] 11 | - ["articles/yet-another-old-vignette-name.html", "https://pkgdown.r-lib.org/dev"] 12 | ``` 13 | 14 | If for some reason you choose to redirect an existing page make sure to exclude it from the search index, see `?build_search`. 15 | -------------------------------------------------------------------------------- /.github/workflows/test-coverage.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | 9 | name: test-coverage 10 | 11 | jobs: 12 | test-coverage: 13 | runs-on: ubuntu-latest 14 | env: 15 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | 20 | - uses: r-lib/actions/setup-pandoc@v2 21 | with: 22 | pandoc-version: '2.17.1' 23 | 24 | - uses: r-lib/actions/setup-r@v2 25 | with: 26 | use-public-rspm: true 27 | 28 | - uses: r-lib/actions/setup-r-dependencies@v2 29 | with: 30 | extra-packages: any::covr 31 | needs: coverage 32 | 33 | - name: Test coverage 34 | run: covr::codecov() 35 | shell: Rscript {0} 36 | -------------------------------------------------------------------------------- /man/test-output-styles.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/test.R 3 | \name{test-output-styles} 4 | \alias{test-output-styles} 5 | \title{Test case: output styles} 6 | \description{ 7 | Test case: output styles 8 | } 9 | \examples{ 10 | # This example illustrates some important output types 11 | # The following output should be wrapped over multiple lines 12 | a <- 1:100 13 | a 14 | 15 | cat("This some text!\n") 16 | message("This is a message!") 17 | warning("This is a warning!") 18 | 19 | # This is a multi-line block 20 | { 21 | 1 + 2 22 | 2 + 2 23 | } 24 | } 25 | \seealso{ 26 | Other tests: 27 | \code{\link{index}}, 28 | \code{\link{test-crayon}}, 29 | \code{\link{test-dont}}, 30 | \code{\link{test-figures}}, 31 | \code{\link{test-links}}, 32 | \code{\link{test-lists}}, 33 | \code{\link{test-long-lines}}, 34 | \code{\link{test-params}}, 35 | \code{\link{test-sexpr-title}}, 36 | \code{\link{test-verbatim}} 37 | } 38 | \concept{tests} 39 | \keyword{internal} 40 | -------------------------------------------------------------------------------- /.github/workflows/no-pandoc.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | 9 | name: no-pandoc 10 | 11 | jobs: 12 | R-CMD-check: 13 | runs-on: ubuntu-latest 14 | env: 15 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 16 | R_KEEP_PKG_SOURCE: yes 17 | steps: 18 | - uses: actions/checkout@v2 19 | 20 | - uses: r-lib/actions/setup-r@v2 21 | with: 22 | use-public-rspm: true 23 | 24 | - uses: r-lib/actions/setup-r-dependencies@v2 25 | with: 26 | extra-packages: any::rcmdcheck 27 | needs: check 28 | 29 | - uses: r-lib/actions/setup-tinytex@v2 30 | 31 | - run: sudo apt-get --purge remove pandoc 32 | - run: rm -rf vignettes 33 | 34 | - uses: r-lib/actions/check-r-package@v2 35 | -------------------------------------------------------------------------------- /R/utils-io.R: -------------------------------------------------------------------------------- 1 | # Reading ----------------------------------------------------------------- 2 | 3 | read_file <- function(path) { 4 | lines <- read_lines(path) 5 | paste0(lines, "\n", collapse = "") 6 | } 7 | 8 | # Inspired by roxygen2 utils-io.R (https://github.com/klutometis/roxygen/) ----------- 9 | 10 | readLines <- function(...) stop("Use read_lines!") 11 | writeLines <- function(...) stop("Use write_lines!") 12 | 13 | read_lines <- function(path, n = -1L) { 14 | base::readLines(path, n = n, encoding = "UTF-8", warn = FALSE) 15 | } 16 | 17 | write_lines <- function(text, path) { 18 | base::writeLines(enc2utf8(text), path, useBytes = TRUE) 19 | } 20 | 21 | # Other ------------------------------------------------------------------- 22 | 23 | file_equal <- function(src, dst) { 24 | if (!file_exists(dst)) 25 | return(FALSE) 26 | 27 | src_hash <- digest::digest(file = src, algo = "xxhash64") 28 | dst_hash <- digest::digest(file = dst, algo = "xxhash64") 29 | 30 | identical(src_hash, dst_hash) 31 | } 32 | 33 | -------------------------------------------------------------------------------- /inst/BS5/templates/content-reference-index.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 7 | 8 | {{#rows}}
9 | {{#title}}

{{{.}}}

{{/title}} 10 | {{#subtitle}}

{{{.}}}

{{/subtitle}} 11 | {{#desc}}

{{{desc}}}

{{/desc}} 12 | 13 | {{#topics}}
14 |
15 | {{#has_icons}}{{#icon}}{{/icon}}{{/has_icons}} 16 | {{#aliases}}{{{.}}} {{/aliases}} 17 |
18 |
{{{title}}}
19 |
{{/topics}} 20 |
{{/rows}} 21 |
22 | 23 | 28 |
29 | -------------------------------------------------------------------------------- /R/autolink_html.R: -------------------------------------------------------------------------------- 1 | #' Automatically link references and articles in an HTML page 2 | #' 3 | #' Deprecated: please use [downlit::downlit_html_path] instead. 4 | #' 5 | #' @param input,output Input and output paths for HTML file 6 | #' @param local_packages A named character vector providing relative paths 7 | #' (value) to packages (name) that can be reached with relative links 8 | #' from the target HTML document. 9 | #' @export 10 | #' @keywords internal 11 | #' @examples 12 | #' \dontrun{ 13 | #' autolink_html("path/to/file.html", 14 | #' local_packages = c( 15 | #' shiny = "shiny", 16 | #' shinydashboard = "shinydashboard" 17 | #' ) 18 | #' ) 19 | #' } 20 | autolink_html <- function(input, output = input, local_packages = character()) { 21 | withr::local_options(list( 22 | downlit.package = "", 23 | downlit.local_packages = local_packages 24 | )) 25 | 26 | html <- xml2::read_html(input, encoding = "UTF-8") 27 | downlit::downlit_html_node(html) 28 | 29 | xml2::write_html(html, output, format = FALSE) 30 | invisible() 31 | } 32 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/rmarkdown.md: -------------------------------------------------------------------------------- 1 | # render_rmarkdown yields useful error 2 | 3 | Code 4 | render_rmarkdown(pkg, "assets/pandoc-fail.Rmd", "test.html", output_format = rmarkdown::html_document( 5 | pandoc_args = "--fail-if-warnings")) 6 | Output 7 | Reading 'assets/pandoc-fail.Rmd' 8 | -- RMarkdown error ------------------------------------------------------------- 9 | [WARNING] Could not fetch resource path-to-image.png 10 | Failing because there were warnings. 11 | Error : pandoc document conversion failed with error 3 12 | -------------------------------------------------------------------------------- 13 | Condition 14 | Error in `render_rmarkdown()`: 15 | ! Failed to render RMarkdown 16 | Caused by error: 17 | ! callr subprocess failed: pandoc document conversion failed with error 3 18 | Caused by error: 19 | ! pandoc document conversion failed with error 3 20 | 21 | # render_rmarkdown styles ANSI escapes 22 | 23 | #> X 24 | 25 | -------------------------------------------------------------------------------- /tests/testthat/test-utils.R: -------------------------------------------------------------------------------- 1 | test_that("pkgdown.internet can be set and read", { 2 | options(pkgdown.internet = FALSE) 3 | expect_false(has_internet()) 4 | }) 5 | 6 | test_that("cran_unquote works", { 7 | expect_equal(cran_unquote("Quoting is CRAN's thing."), 8 | "Quoting is CRAN's thing.") 9 | expect_equal(cran_unquote("'R-hub' is great!"), 10 | "R-hub is great!") 11 | expect_equal(cran_unquote("From 'README' to 'html' with 'pkgdown'"), 12 | "From README to html with pkgdown") 13 | }) 14 | 15 | test_that("is_internal_link() works", { 16 | pkg=list(meta=list(url="https://pkgdown.r-lib.org")) 17 | expect_false(is_internal_link("https://github.com", pkg = pkg)) 18 | expect_false(is_internal_link("http://github.com", pkg = pkg)) 19 | expect_true(is_internal_link("https://pkgdown.r-lib.org/articles", pkg = pkg)) 20 | expect_true(is_internal_link("reference/index.html", pkg = pkg)) 21 | expect_true( 22 | all.equal( 23 | is_internal_link(c("reference/index.html", "https://github.com"), pkg = pkg), 24 | c(TRUE, FALSE) 25 | ) 26 | ) 27 | }) 28 | -------------------------------------------------------------------------------- /R/build-home-community.R: -------------------------------------------------------------------------------- 1 | has_contributing <- function(path = ".") { 2 | file_exists(path(path, 'CONTRIBUTING.md')) || 3 | file_exists(path(path, '.github', 'CONTRIBUTING.md')) 4 | } 5 | 6 | has_coc <- function(path = ".") { 7 | file_exists(path(path, 'CODE_OF_CONDUCT.md')) || 8 | file_exists(path(path, '.github', 'CODE_OF_CONDUCT.md')) 9 | } 10 | 11 | has_support <- function(path = ".") { 12 | file_exists(path(path, 'SUPPORT.md')) || 13 | file_exists(path(path, '.github', 'SUPPORT.md')) 14 | } 15 | 16 | data_home_sidebar_community <- function (pkg){ 17 | 18 | pkg <- as_pkgdown(pkg) 19 | 20 | links <- NULL 21 | 22 | if (has_contributing(pkg$src_path)) { 23 | links <- c(links, a(tr_("Contributing guide"), "CONTRIBUTING.html")) 24 | } 25 | 26 | if (has_coc(pkg$src_path)) { 27 | links <- c(links, a(tr_("Code of conduct"), "CODE_OF_CONDUCT.html")) 28 | } 29 | 30 | if (has_support(pkg$src_path)) { 31 | links <- c(links, a(tr_("Getting help"), "SUPPORT.html")) 32 | } 33 | 34 | if (is.null(links)) { 35 | return("") 36 | } 37 | 38 | sidebar_section(tr_("Community"), links) 39 | 40 | } 41 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/tweak-tabset.md: -------------------------------------------------------------------------------- 1 | # sections with class .tabset are converted to tabsets 2 | 3 |
4 |

Tabset 5 |

6 | 7 | 8 | 12 |
13 |
14 | 15 |

Contents 1

16 |
17 |
18 | 19 |

Contents 2

20 |
21 |
22 |
23 | 24 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2014-2018 RStudio 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /man/init_site.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/init.R 3 | \name{init_site} 4 | \alias{init_site} 5 | \title{Initialise site infrastructure} 6 | \usage{ 7 | init_site(pkg = ".") 8 | } 9 | \arguments{ 10 | \item{pkg}{Path to package.} 11 | } 12 | \description{ 13 | \code{init_site()}: 14 | \itemize{ 15 | \item creates the output directory (\verb{docs/}), 16 | \item generates a machine readable description of the site, used for autolinking, 17 | \item copies CSS/JS assets and extra files, and 18 | \item runs \code{build_favicons()}, if needed. 19 | } 20 | 21 | See \code{vignette("customise")} for the various ways you can customise the 22 | display of your site. 23 | } 24 | \section{Build-ignored files}{ 25 | 26 | We recommend using \code{\link[usethis:use_pkgdown]{usethis::use_pkgdown()}} to build-ignore \verb{docs/} and 27 | \verb{_pkgdown.yml}. If use another directory, or create the site manually, 28 | you'll need to add them to \code{.Rbuildignore} yourself. A \code{NOTE} about 29 | an unexpected file during \verb{R CMD CHECK} is an indication you have not 30 | correctly ignored these files. 31 | } 32 | 33 | -------------------------------------------------------------------------------- /R/template.R: -------------------------------------------------------------------------------- 1 | #' Generate YAML templates 2 | #' 3 | #' Use these function to generate the default YAML that pkgdown uses for 4 | #' the different parts of `_pkgdown.yml`. This are useful starting 5 | #' points if you want to customise your site. 6 | #' 7 | #' @param path Path to package root 8 | #' @rdname templates 9 | #' @examples 10 | #' \dontrun{ 11 | #' pkgdown::template_navbar() 12 | #' } 13 | #' 14 | #' @export 15 | template_navbar <- function(path = ".") { 16 | pkg <- as_pkgdown(path) 17 | 18 | print_yaml(list( 19 | navbar = list( 20 | structure = navbar_structure(), 21 | components = navbar_components(pkg) 22 | ) 23 | )) 24 | } 25 | 26 | #' @rdname templates 27 | #' @examples 28 | #' \dontrun{ 29 | #' pkgdown::template_reference() 30 | #' } 31 | #' 32 | #' @export 33 | template_reference <- function(path = ".") { 34 | print_yaml(list(reference = default_reference_index(path))) 35 | } 36 | 37 | #' @rdname templates 38 | #' @examples 39 | #' \dontrun{ 40 | #' pkgdown::template_articles() 41 | #' } 42 | #' 43 | #' @export 44 | template_articles <- function(path = ".") { 45 | print_yaml(list(articles = default_articles_index(path))) 46 | } 47 | -------------------------------------------------------------------------------- /inst/BS3/templates/content-reference-topic.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 8 | 9 |
10 | {{#description}} 11 | {{#contents}} 12 | {{{.}}} 13 | {{/contents}} 14 | {{/description}} 15 |
16 | 17 | {{#usage}} 18 |
{{#contents}} 19 | {{{.}}} 20 | {{/contents}}
21 | {{/usage}} 22 | 23 | {{#sections}} 24 |
25 |

{{{title}}}

26 | {{#contents}} 27 | {{{.}}} 28 | {{/contents}} 29 |
30 | {{/sections}} 31 | 32 | {{#examples}} 33 |
34 |

Examples

35 | {{{.}}} 36 |
37 | {{/examples}} 38 |
39 | 44 |
45 | -------------------------------------------------------------------------------- /man/build_favicons.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/build-favicons.R 3 | \name{build_favicons} 4 | \alias{build_favicons} 5 | \alias{build_favicon} 6 | \title{Create favicons from package logo} 7 | \usage{ 8 | build_favicons(pkg = ".", overwrite = FALSE) 9 | 10 | build_favicon(pkg, overwrite) 11 | } 12 | \arguments{ 13 | \item{pkg}{Path to package.} 14 | 15 | \item{overwrite}{If \code{TRUE}, re-create favicons from package logo.} 16 | } 17 | \description{ 18 | This function auto-detects the location of your package logo (with the name 19 | \code{logo.svg} (recommended format) or \code{logo.png}) and runs it through the 20 | \url{https://realfavicongenerator.net} API to build a complete set of favicons 21 | with different sizes, as needed for modern web usage. 22 | } 23 | \details{ 24 | You only need to run the function once. The favicon set will be stored in 25 | \code{pkgdown/favicon} and copied by \code{\link[=init_site]{init_site()}} to the relevant location when 26 | the website is rebuilt. 27 | 28 | Once complete, you should add \verb{pkgdown/} to \code{.Rbuildignore } to avoid a NOTE 29 | during package checking. 30 | } 31 | -------------------------------------------------------------------------------- /R/topics-external.R: -------------------------------------------------------------------------------- 1 | ext_topics <- function(match_strings) { 2 | pieces <- strsplit(match_strings, "::", fixed = TRUE) 3 | pkg <- purrr::map_chr(pieces, 1) 4 | fun <- sub("\\(\\)$", "", purrr::map_chr(pieces, 2)) 5 | 6 | ext_rd <- purrr::map2(pkg, fun, get_rd_from_help) 7 | ext_title <- purrr::map_chr(ext_rd, extract_title) 8 | ext_href <- purrr::map2_chr(fun, pkg, downlit::href_topic) 9 | ext_funs <- purrr::map(ext_rd, topic_funs) 10 | 11 | tibble::tibble( 12 | name = match_strings, 13 | file_out = ext_href, 14 | title = sprintf("%s (from %s)", ext_title, pkg), 15 | funs = ext_funs, # used list alternative names 16 | alias = list(character()), # used to find icons 17 | internal = FALSE 18 | ) 19 | } 20 | 21 | # Adatpted from roxygen2::get_rd_from_help 22 | get_rd_from_help <- function(package, alias) { 23 | check_installed(package, "as it's used in the reference index.") 24 | 25 | help <- utils::help((alias), (package)) 26 | if (length(help) == 0) { 27 | abort(sprintf("Could not find documentation for %s::%s", package, alias)) 28 | return() 29 | } 30 | 31 | out <- get(".getHelpFile", envir = asNamespace("utils"))(help) 32 | set_classes(out) 33 | } 34 | -------------------------------------------------------------------------------- /inst/BS5/templates/content-citation-authors.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 7 | 8 |
9 |

{{#translate}}{{authors}}{{/translate}}

10 | {{{before}}} 11 |
    12 | {{#authors}} 13 |
  • 14 |

    {{{name}}}. {{{roles}}}. {{{orcid}}} 15 | {{#comment}}
    {{{.}}}{{/comment}}

    16 |
  • 17 | {{/authors}} 18 |
19 | {{{after}}} 20 |
21 | 22 |
23 |

{{#translate}}{{citation}}{{/translate}}

24 |

{{#source}}{{{.}}}{{/source}}

25 | 26 | {{#citations}} 27 | {{{html}}} 28 |
{{{bibtex}}}
29 | {{/citations}} 30 |
31 |
32 | 33 | 38 |
39 | -------------------------------------------------------------------------------- /R/html-build.R: -------------------------------------------------------------------------------- 1 | a <- function(text, href) { 2 | ifelse(is.na(href), text, paste0("", text, "")) 3 | } 4 | 5 | link_url <- function(text, href) { 6 | if (!is.null(href)) { 7 | paste0("", text, "") 8 | } 9 | } 10 | 11 | linkify <- function(text) { 12 | text <- escape_html(text) 13 | text <- gsub( 14 | "<doi:([^&]+)>", # DOIs with < > & are not supported 15 | "<doi:\\1>", 16 | text, ignore.case = TRUE 17 | ) 18 | text <- gsub( 19 | "<arXiv:([^&]+)>", 20 | "<arXiv:\\1>", 21 | text, ignore.case = TRUE 22 | ) 23 | text <- gsub( 24 | "<((http|ftp)[^&]+)>", # URIs with & are not supported 25 | "<\\1>", 26 | text 27 | ) 28 | text 29 | } 30 | 31 | dont_index <- function(x) { 32 | paste0("
", x, "
") 33 | } 34 | 35 | escape_html <- function(x) { 36 | x <- gsub("&", "&", x) 37 | x <- gsub("<", "<", x) 38 | x <- gsub(">", ">", x) 39 | # x <- gsub("'", "'", x) 40 | # x <- gsub("\"", """, x) 41 | x 42 | } 43 | 44 | strip_html_tags <- function(x) gsub("<.*?>", "", x) 45 | -------------------------------------------------------------------------------- /man/build_search.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/build-search-docs.R 3 | \name{build_search} 4 | \alias{build_search} 5 | \title{Build search index} 6 | \usage{ 7 | build_search(pkg = ".", override = list()) 8 | } 9 | \arguments{ 10 | \item{pkg}{Path to package.} 11 | 12 | \item{override}{An optional named list used to temporarily override 13 | values in \verb{_pkgdown.yml}} 14 | } 15 | \description{ 16 | Build a JSON file encompassing all HTML pages, for use by the search script. 17 | } 18 | \section{YAML config}{ 19 | 20 | You can exclude some paths from the search index. 21 | Below we exclude the changelog from the search index. 22 | 23 | \if{html}{\out{
}}\preformatted{search: 24 | exclude: ['news/index.html'] 25 | }\if{html}{\out{
}} 26 | } 27 | 28 | \section{Debugging and local testing}{ 29 | 30 | 31 | Locally (as opposed to on GitHub Pages or Netlify for instance), 32 | search won't work if you simply use pkgdown preview of the static files. 33 | You can use \code{servr::httw("docs")} instead. 34 | 35 | If search is not working, run \code{pkgdown::pkgdown_sitrep()} to eliminate 36 | common issues such as the absence of URL in the pkgdown configuration file 37 | of your package. 38 | } 39 | 40 | -------------------------------------------------------------------------------- /man/rmd-fragments/footer-configuration.Rmd: -------------------------------------------------------------------------------- 1 | You can customise the footer with the `footer` field. 2 | It's made up of two pieces: `structure`, which defines the overall layout, and `components`, which defines what each piece looks like. 3 | This organisation makes it easy to mix and match the pkgdown defaults with your own customisations. 4 | 5 | This is the default structure: 6 | 7 | ``` yaml 8 | footer: 9 | structure: 10 | left: developed_by 11 | right: built_with 12 | ``` 13 | 14 | Which uses two of the three built-in components: 15 | 16 | - `developed_by`, a sentence describing the main authors of the package. (See `?build_home` if you want to tweak *which* authors appear in the footer.) 17 | - `built_with`, a sentence advertising pkgdown. 18 | - `package`, the name of the package. 19 | 20 | You can override these defaults with the `footer` field. 21 | The example below puts the authors' information on the right along with a legal disclaimer, and puts the pkgdown link on the left. 22 | 23 | ``` yaml 24 | footer: 25 | structure: 26 | left: pkgdown 27 | right: [authors, legal] 28 | components: 29 | legal: Provided without **any warranty**. 30 | ``` 31 | 32 | Each side is pasted into a single string (separated by `" "`) and then converted from markdown to HTML. 33 | -------------------------------------------------------------------------------- /man/pkgdown-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pkgdown.R 3 | \docType{package} 4 | \name{pkgdown-package} 5 | \alias{pkgdown} 6 | \alias{pkgdown-package} 7 | \title{pkgdown: Make Static HTML Documentation for a Package} 8 | \description{ 9 | \if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}} 10 | 11 | Generate an attractive and useful website from a source package. 'pkgdown' converts your documentation, vignettes, 'README', and more to 'HTML' making it easy to share information about your package online. 12 | } 13 | \seealso{ 14 | Useful links: 15 | \itemize{ 16 | \item \url{https://pkgdown.r-lib.org} 17 | \item \url{https://github.com/r-lib/pkgdown} 18 | \item Report bugs at \url{https://github.com/r-lib/pkgdown/issues} 19 | } 20 | 21 | } 22 | \author{ 23 | \strong{Maintainer}: Hadley Wickham \email{hadley@rstudio.com} (\href{https://orcid.org/0000-0003-4757-117X}{ORCID}) 24 | 25 | Authors: 26 | \itemize{ 27 | \item Jay Hesselberth (\href{https://orcid.org/0000-0002-6299-179X}{ORCID}) 28 | \item Maëlle Salmon (\href{https://orcid.org/0000-0002-2815-0399}{ORCID}) 29 | } 30 | 31 | Other contributors: 32 | \itemize{ 33 | \item RStudio [copyright holder, funder] 34 | } 35 | 36 | } 37 | \keyword{internal} 38 | -------------------------------------------------------------------------------- /R/pkgdown_print.R: -------------------------------------------------------------------------------- 1 | #' Print object in pkgdown output 2 | #' 3 | #' This lets package authors control how objects are printed just for 4 | #' pkgdown examples. The default is to call [print()] apart from htmlwidgets 5 | #' where the object is returned as is (with sizes tweaked). 6 | #' 7 | #' @param x Object to display 8 | #' @param visible Whether it is visible or not 9 | #' @return Either a character vector representing printed output (which 10 | #' will be escaped for HTML as necessary) or literal HTML produced 11 | #' by the htmltools or htmlwidgets packages. 12 | #' @keywords internal 13 | #' @export 14 | pkgdown_print <- function(x, visible = TRUE) { 15 | UseMethod("pkgdown_print") 16 | } 17 | 18 | #' @export 19 | pkgdown_print.default <- function(x, visible = TRUE) { 20 | if (!visible) { 21 | return(invisible()) 22 | } 23 | 24 | # inlined from htmltools::is.browsable() 25 | if (isTRUE(attr(x, "browsable_html", exact = TRUE))) { 26 | x 27 | } else { 28 | print(x) 29 | } 30 | } 31 | 32 | #' @export 33 | pkgdown_print.htmlwidget <- function(x, visible = TRUE) { 34 | if (!visible) { 35 | return(invisible()) 36 | } 37 | 38 | settings <- fig_settings() 39 | x$width <- x$width %||% (settings$fig.width * settings$dpi) 40 | x$height <- x$height %||% (settings$fig.height * settings$dpi) 41 | x 42 | } 43 | -------------------------------------------------------------------------------- /inst/highlight-styles/haddock.scss: -------------------------------------------------------------------------------- 1 | pre code span.al /* Alert */ {color:#ff0000} 2 | pre code span.an /* Annotation */ {color:#008000} 3 | pre code span.at /* Attribute */ {} 4 | pre code span.bu /* BuiltIn */ {} 5 | pre code span.cf /* ControlFlow */ {color:#0000ff} 6 | pre code span.ch /* Char */ {color:#008080} 7 | pre code span.cn /* Constant */ {} 8 | pre code span.co /* Comment */ {color:#008000} 9 | pre code span.cv /* CommentVar */ {color:#008000} 10 | pre code span.do /* Documentation */ {color:#008000} 11 | pre code span.er /* Error */ {color:#ff0000; font-weight: bold} 12 | pre code span.ex /* Extension */ {} 13 | pre code span.im /* Import */ {} 14 | pre code span.in /* Information */ {color:#008000} 15 | pre code span.kw /* Keyword */ {color:#0000ff} 16 | pre code span.op /* Operator */ {} 17 | pre code span.ot /* Other */ {color:#ff4000} 18 | pre code span.pp /* Preprocessor */ {color:#ff4000} 19 | pre code span.sc /* SpecialChar */ {color:#008080} 20 | pre code span.ss /* SpecialString */ {color:#008080} 21 | pre code span.st /* String */ {color:#008080} 22 | pre code span.va /* Variable */ {} 23 | pre code span.vs /* VerbatimString */ {color:#008080} 24 | pre code span.wa /* Warning */ {color:#008000; font-weight: bold} 25 | -------------------------------------------------------------------------------- /inst/BS5/templates/content-reference-topic.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 9 | 10 |
11 | {{#description}} 12 | {{#contents}} 13 | {{{.}}} 14 | {{/contents}} 15 | {{/description}} 16 |
17 | 18 | {{#usage}} 19 |
20 |

{{{title}}}

21 | {{#contents}} 22 | {{{.}}} 23 | {{/contents}} 24 |
25 | {{/usage}} 26 | 27 | {{#sections}} 28 |
29 |

{{{title}}}

30 | {{#contents}} 31 | {{{.}}} 32 | {{/contents}} 33 |
34 | {{/sections}} 35 | 36 | {{#examples}} 37 |
38 |

{{#translate}}{{examples}}{{/translate}}

39 | {{{.}}} 40 |
41 | {{/examples}} 42 |
43 | 48 |
49 | -------------------------------------------------------------------------------- /tests/testthat/test-html-build.R: -------------------------------------------------------------------------------- 1 | test_that("Stripping HTML tags", { 2 | expect_identical( 3 | strip_html_tags("

some text about data"), 4 | "some text about data" 5 | ) 6 | }) 7 | 8 | # links and references in the package description ------------------------- 9 | 10 | test_that("references in angle brackets are converted to HTML", { 11 | ## URL 12 | expect_identical( 13 | linkify("see ."), 14 | "see <https://CRAN.R-project.org/view=SpatioTemporal>." 15 | ) 16 | ## DOI 17 | expect_identical( 18 | linkify("M & H (2017) "), 19 | "M & H (2017) <doi:10.1093/biostatistics/kxw051>" 20 | ) 21 | ## arXiv 22 | expect_identical( 23 | linkify("see ."), 24 | "see <arXiv:1802.03967>." 25 | ) 26 | ## unsupported formats are left alone (just escaping special characters) 27 | unsupported <- c( 28 | "3.0.CO;2-P>", 29 | "" 30 | ) 31 | expect_identical(linkify(unsupported), escape_html(unsupported)) 32 | }) 33 | -------------------------------------------------------------------------------- /man/render_page.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/render.R 3 | \name{render_page} 4 | \alias{render_page} 5 | \alias{data_template} 6 | \title{Render page with template} 7 | \usage{ 8 | render_page(pkg = ".", name, data, path, depth = NULL, quiet = FALSE) 9 | 10 | data_template(pkg = ".", depth = 0L) 11 | } 12 | \arguments{ 13 | \item{pkg}{Path to package to document.} 14 | 15 | \item{name}{Name of the template (e.g. "home", "vignette", "news")} 16 | 17 | \item{data}{Data for the template. 18 | 19 | This is automatically supplemented with three lists: 20 | \itemize{ 21 | \item \code{site}: \code{title} and path to \code{root}. 22 | \item \code{yaml}: the \code{template} key from \verb{_pkgdown.yml}. 23 | \item \code{package}: package metadata including \code{name} and\code{version}. 24 | } 25 | 26 | See the full contents by running \code{\link[=data_template]{data_template()}}.} 27 | 28 | \item{path}{Location to create file; relative to destination directory.} 29 | 30 | \item{depth}{Depth of path relative to base directory.} 31 | 32 | \item{quiet}{If \code{quiet}, will suppress output messages} 33 | } 34 | \description{ 35 | Each page is composed of four templates: "head", "header", "content", and 36 | "footer". Each of these templates is rendered using the \code{data}, and 37 | then assembled into an overall page using the "layout" template. 38 | } 39 | -------------------------------------------------------------------------------- /tests/testthat/test-build-tutorials.R: -------------------------------------------------------------------------------- 1 | test_that("can autodetect tutorials", { 2 | # Can't embed in package because path is too long and gives R CMD check NOTE 3 | pkg <- test_path("assets/tutorials") 4 | dcf_src <- path(pkg, "vignettes/tutorials/test-1/") 5 | dcf_dst <- path(dcf_src, "rsconnect/documents/test-1.Rmd/shinyapps.io/hadley") 6 | dir_create(dcf_dst) 7 | file_copy(path(dcf_src, "tutorial-test-1.dcf"), dcf_dst, overwrite = TRUE) 8 | withr::defer(dir_delete(path(pkg, "vignettes/tutorials/test-1/rsconnect"))) 9 | 10 | out <- package_tutorials(pkg) 11 | expect_equal(out$name, "test-1") 12 | expect_equal(out$file_out, "tutorials/test-1.html") 13 | expect_equal(out$url, "https://hadley.shinyapps.io/tutorial-test-1/") 14 | 15 | # and aren't included in vignettes 16 | out <- package_vignettes(test_path("assets/tutorials")) 17 | expect_equal(nrow(out), 0) 18 | }) 19 | 20 | test_that("can manually supply tutorials", { 21 | meta <- list( 22 | tutorials = list( 23 | list(name = "1-name", title = "1-title", url = "1-url"), 24 | list(name = "2-name", title = "2-title", url = "2-url") 25 | ) 26 | ) 27 | 28 | out <- package_tutorials(test_path("assets/tutorials"), meta) 29 | expect_equal(out$name, c("1-name", "2-name")) 30 | expect_equal(out$file_out, c("tutorials/1-name.html", "tutorials/2-name.html")) 31 | expect_equal(out$url, c("1-url", "2-url")) 32 | }) 33 | -------------------------------------------------------------------------------- /R/build-home-md.R: -------------------------------------------------------------------------------- 1 | build_home_md <- function(pkg) { 2 | 3 | mds <- dir_ls(pkg$src_path, glob = "*.md") 4 | 5 | # Also looks in .github, if it exists 6 | github_path <- path(pkg$src_path, ".github") 7 | if (dir_exists(github_path)) { 8 | mds <- c(mds, dir_ls(github_path, glob = "*.md")) 9 | } 10 | 11 | # Remove files handled elsewhere 12 | handled <- c("README.md", "LICENSE.md", "LICENCE.md", "NEWS.md", "cran-comments.md") 13 | mds <- mds[!path_file(mds) %in% handled] 14 | 15 | # Do not build 404 page if in-dev 16 | if (pkg$development$in_dev) { 17 | mds <- mds[fs::path_file(mds) != "404.md"] 18 | } 19 | 20 | lapply(mds, render_md, pkg = pkg) 21 | invisible() 22 | } 23 | 24 | render_md <- function(pkg, filename) { 25 | cat_line("Reading ", src_path(path_rel(filename, pkg$src_path))) 26 | 27 | body <- markdown_body(filename, strip_header = TRUE) 28 | path <- path_ext_set(basename(filename), "html") 29 | 30 | render_page(pkg, "title-body", 31 | data = list( 32 | pagetitle = attr(body, "title"), 33 | body = body, 34 | filename = filename, 35 | source = repo_source(pkg, fs::path_rel(filename, pkg$src_path)) 36 | ), 37 | path = path 38 | ) 39 | 40 | if (path == "404.html") { 41 | update_html(path(pkg$dst_path, path), tweak_link_absolute, pkg = pkg) 42 | } 43 | check_missing_images(pkg, filename, path) 44 | 45 | invisible() 46 | } 47 | -------------------------------------------------------------------------------- /R/build-footer.R: -------------------------------------------------------------------------------- 1 | data_footer <- function(pkg = ".") { 2 | pkg <- as_pkgdown(pkg) 3 | 4 | meta_footer <- pkg$meta$footer 5 | components <- modify_list(footnote_components(pkg), meta_footer$components) 6 | structure <- modify_list(footnote_structure(), meta_footer$structure) 7 | 8 | left <- markdown_text_block(paste0(components[structure$left], collapse = " ")) 9 | right <- markdown_text_block(paste0(components[structure$right], collapse = " ")) 10 | 11 | list(left = left, right = right) 12 | } 13 | 14 | footnote_components <- function(pkg = ".") { 15 | pkg <- as_pkgdown(pkg) 16 | 17 | # Authors 18 | roles <- pkg$meta$authors$footer$roles %||% default_roles() 19 | authors <- data_authors(pkg, roles = roles)$main %>% 20 | purrr::map_chr("name") %>% 21 | paste(collapse = ", ") 22 | 23 | prefix <- pkg$meta$authors$footer$text %||% tr_("Developed by") 24 | developed_by <- paste0(trimws(prefix), " ", authors, ".") 25 | 26 | # pkgdown 27 | built_with <- sprintf( 28 | tr_('Site built with pkgdown %s.'), 29 | "https://pkgdown.r-lib.org/", 30 | utils::packageVersion("pkgdown") 31 | ) 32 | 33 | print_yaml(list( 34 | developed_by = developed_by, 35 | built_with = built_with, 36 | package = pkg[["package"]] 37 | )) 38 | } 39 | 40 | footnote_structure <- function() { 41 | print_yaml(list( 42 | left = "developed_by", 43 | right = "built_with" 44 | )) 45 | } 46 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/render.md: -------------------------------------------------------------------------------- 1 | # check_bootswatch_theme() works 2 | 3 | Can't find Bootswatch theme 'paper' (template.bootswatch) for Bootstrap version '4' (template.bootstrap). 4 | 5 | # capture data_template() 6 | 7 | package: 8 | name: testpackage 9 | version: 1.0.0 10 | logo: 11 | src: ~ 12 | site: 13 | root: '' 14 | title: testpackage 15 | year: 16 | lang: en 17 | translate: 18 | skip: Skip to contents 19 | toggle_nav: Toggle navigation 20 | search_for: Search for 21 | on_this_page: On this page 22 | source: Source 23 | abstract: Abstract 24 | authors: Authors 25 | version: Version 26 | examples: Examples 27 | citation: Citation 28 | has_favicons: no 29 | opengraph: [] 30 | extra: 31 | css: ~ 32 | js: ~ 33 | includes: [] 34 | yaml: 35 | .present: yes 36 | development: 37 | destination: dev 38 | mode: default 39 | version_label: default 40 | in_dev: no 41 | version_tooltip: '' 42 | navbar: 43 | type: default 44 | left: |- 45 |

  • 46 | Reference 47 |
  • 48 | right: '' 49 | footer: 50 | left:

    Developed by Hadley Wickham, RStudio.

    51 | right:

    Site built with pkgdown {version}.

    52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/testthat/test-highlight.R: -------------------------------------------------------------------------------- 1 | test_that("highlight_examples captures depencies", { 2 | withr::defer(unlink(test_path("Rplot001.png"))) 3 | 4 | dummy_dep <- htmltools::htmlDependency("dummy", "1.0.0", "dummy.js") 5 | widget <- htmlwidgets::createWidget("test", list(), dependencies = dummy_dep) 6 | out <- highlight_examples("widget", env = environment()) 7 | 8 | # htmlwidgets always get dependency on htmlwidgets.js 9 | expect_equal(attr(out, "dependencies")[-1], list(dummy_dep)) 10 | }) 11 | 12 | test_that("highlight_text & highlight_examples include sourceCode div", { 13 | withr::defer(unlink(test_path("Rplot001.png"))) 14 | 15 | html <- xml2::read_html(highlight_examples("a + a", "x")) 16 | expect_equal(xpath_attr(html, "./body/div", "class"), "sourceCode") 17 | 18 | html <- xml2::read_html(highlight_text("a + a")) 19 | expect_equal(xpath_attr(html, "./body/div", "class"), "sourceCode") 20 | }) 21 | 22 | test_that("pre() can produce needed range of outputs", { 23 | expect_snapshot({ 24 | cat(pre("x")) 25 | cat(pre("x", r_code = TRUE)) 26 | }) 27 | }) 28 | 29 | test_that("tweak_highlight_other() renders generic code blocks for roxygen2 >= 7.2.0", { 30 | div <- xml2::read_html('
    1+1\n
    ') %>% 31 | xml2::xml_find_first("//div") 32 | tweak_highlight_other(div) 33 | expect_equal( 34 | xml2::xml_text(xml2::xml_find_first(div, "pre/code")), 35 | "1+1" 36 | ) 37 | }) 38 | -------------------------------------------------------------------------------- /tests/testthat/test-rmarkdown.R: -------------------------------------------------------------------------------- 1 | test_that("render_rmarkdown copies image files in subdirectories", { 2 | skip_if_no_pandoc() 3 | tmp <- dir_create(file_temp()) 4 | pkg <- list(src_path = test_path("."), dst_path = tmp, bs_version = 3) 5 | 6 | expect_output( 7 | render_rmarkdown(pkg, "assets/vignette-with-img.Rmd", "test.html") 8 | ) 9 | expect_equal( 10 | as.character(path_rel(dir_ls(tmp, type = "file", recurse = TRUE), tmp)), 11 | c("open-graph/logo.png", "test.html") 12 | ) 13 | }) 14 | 15 | test_that("render_rmarkdown yields useful error", { 16 | skip_on_cran() # fragile due to pandoc dependency 17 | skip_if_no_pandoc("2.18") 18 | 19 | tmp <- dir_create(file_temp()) 20 | pkg <- list(src_path = test_path("."), dst_path = tmp, bs_version = 3) 21 | 22 | expect_snapshot(error = TRUE, { 23 | render_rmarkdown(pkg, "assets/pandoc-fail.Rmd", "test.html", 24 | output_format = rmarkdown::html_document(pandoc_args = "--fail-if-warnings")) 25 | }) 26 | }) 27 | 28 | test_that("render_rmarkdown styles ANSI escapes", { 29 | skip_if_no_pandoc() 30 | tmp <- dir_create(file_temp()) 31 | pkg <- list(src_path = test_path("."), dst_path = tmp, bs_version = 5) 32 | 33 | expect_output({ 34 | path <- render_rmarkdown(pkg, 35 | input = "assets/vignette-with-crayon.Rmd", 36 | output = "test.html" 37 | ) 38 | }) 39 | html <- xml2::read_html(path) 40 | expect_snapshot_output(xpath_xml(html, ".//code//span[@class='co']")) 41 | }) 42 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, we pledge to respect all people who 4 | contribute through reporting issues, posting feature requests, updating documentation, 5 | submitting pull requests or patches, and other activities. 6 | 7 | We are committed to making participation in this project a harassment-free experience for 8 | everyone, regardless of level of experience, gender, gender identity and expression, 9 | sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. 10 | 11 | Examples of unacceptable behavior by participants include the use of sexual language or 12 | imagery, derogatory comments or personal attacks, trolling, public or private harassment, 13 | insults, or other unprofessional conduct. 14 | 15 | Project maintainers have the right and responsibility to remove, edit, or reject comments, 16 | commits, code, wiki edits, issues, and other contributions that are not aligned to this 17 | Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed 18 | from the project team. 19 | 20 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by 21 | opening an issue or contacting one or more of the project maintainers. 22 | 23 | This Code of Conduct is adapted from the Contributor Covenant 24 | (http://contributor-covenant.org), version 1.0.0, available at 25 | http://contributor-covenant.org/version/1/0/0/ 26 | -------------------------------------------------------------------------------- /R/build-home.R: -------------------------------------------------------------------------------- 1 | #' Build home section 2 | #' 3 | #' @description 4 | #' `build_home()` function generates pages at the top-level of the site 5 | #' including: 6 | #' 7 | #' * The home page 8 | #' * HTML files from any `.md` files in `./` or `.github/`. 9 | #' * The authors page (from `DESCRIPTION`) 10 | #' * The citation page (from `inst/CITATION`, if present). 11 | #' * The license page 12 | #' * A default 404 page if `.github/404.md` is not found. 13 | #' 14 | #' `build_home_index()` rebuilds just the index page; it's useful for rapidly 15 | #' iterating when experimenting with site styles. 16 | #' 17 | #' ```{r child="man/rmd-fragments/home-configuration.Rmd"} 18 | #' ``` 19 | #' ```{r child="man/rmd-fragments/authors-configuration.Rmd"} 20 | #' ``` 21 | #' 22 | #' @section Sidebar: 23 | #' ```{r child="man/rmd-fragments/sidebar-configuration.Rmd"} 24 | #' ``` 25 | #' 26 | #' @inheritParams build_articles 27 | #' @export 28 | build_home <- function(pkg = ".", 29 | override = list(), 30 | preview = NA, 31 | quiet = TRUE) { 32 | 33 | pkg <- section_init(pkg, depth = 0L, override = override) 34 | rule("Building home") 35 | dir_create(pkg$dst_path) 36 | 37 | build_citation_authors(pkg) 38 | 39 | build_home_md(pkg) 40 | build_home_license(pkg) 41 | build_home_index(pkg, quiet = quiet) 42 | 43 | if (!pkg$development$in_dev) { 44 | build_404(pkg) 45 | } 46 | 47 | 48 | preview_site(pkg, "/", preview = preview) 49 | } 50 | -------------------------------------------------------------------------------- /tests/testthat/test-render.R: -------------------------------------------------------------------------------- 1 | test_that("check_bootswatch_theme() works", { 2 | expect_equal(check_bootswatch_theme("_default", 4, list()), NULL) 3 | expect_equal(check_bootswatch_theme("lux", 4, list()), "lux") 4 | expect_snapshot_error(check_bootswatch_theme("paper", 4, list())) 5 | }) 6 | 7 | test_that("capture data_template()", { 8 | pkg <- as_pkgdown(test_path("assets/site-empty")) 9 | data <- data_template(pkg) 10 | data$year <- "" 11 | data$footer$right <- gsub(packageVersion("pkgdown"), "{version}", data$footer$right, fixed = TRUE) 12 | expect_snapshot_output(data) 13 | }) 14 | 15 | test_that("can include text in header, before body, and after body", { 16 | pkg <- local_pkgdown_site(test_path("assets/site-empty"), ' 17 | template: 18 | includes: 19 | in_header: in header 20 | before_body: before body 21 | after_body: after body 22 | ') 23 | 24 | expect_named( 25 | data_template(pkg)$includes, 26 | c("in_header", "before_body", "after_body") 27 | ) 28 | 29 | pkg$bs_version <- 3 30 | html <- render_page_html(pkg, "title-body") 31 | expect_equal( 32 | xpath_text(html, ".//test"), 33 | c("in header", "before body", "after body") 34 | ) 35 | 36 | pkg$bs_version <- 5 37 | expect_output(init_site(pkg)) 38 | html <- render_page_html(pkg, "title-body") 39 | expect_equal( 40 | xpath_text(html, ".//test"), 41 | c("in header", "before body", "after body") 42 | ) 43 | }) 44 | -------------------------------------------------------------------------------- /tests/testthat/test-build-redirects.R: -------------------------------------------------------------------------------- 1 | test_that("build_redirect() works", { 2 | pkg <- list( 3 | src_path = withr::local_tempdir(), 4 | dst_path = withr::local_tempdir(), 5 | meta = list(url = "https://example.com"), 6 | prefix = "", 7 | bs_version = 5 8 | ) 9 | pkg <- structure(pkg, class = "pkgdown") 10 | build_redirect(c("old.html", "new.html#section"), 1, pkg = pkg) 11 | 12 | html <- xml2::read_html(path(pkg$dst_path, "old.html")) 13 | expect_equal( 14 | xpath_attr(html, "//link", "href"), 15 | "https://example.com/new.html#section" 16 | ) 17 | }) 18 | 19 | test_that("build_redirect() errors if one entry is not right.", { 20 | pkg <- list( 21 | src_path = withr::local_tempdir(), 22 | dst_path = withr::local_tempdir(), 23 | meta = list(url = "https://example.com"), 24 | prefix = "", 25 | bs_version = 5 26 | ) 27 | pkg <- structure(pkg, class = "pkgdown") 28 | expect_snapshot_error(build_redirect(c("old.html"), 5, pkg = pkg)) 29 | }) 30 | 31 | test_that("article_redirects() creates redirects for vignettes in vignettes/articles", { 32 | dir <- withr::local_tempdir() 33 | dir_create(path(dir, "vignettes", "articles")) 34 | file_create(path(dir, "vignettes", "articles", "test.Rmd")) 35 | 36 | pkg <- list( 37 | meta = list(url = "http://foo.com"), 38 | vignettes = package_vignettes(dir) 39 | ) 40 | 41 | expect_equal( 42 | article_redirects(pkg), 43 | list(c("articles/articles/test.html", "articles/test.html")) 44 | ) 45 | }) 46 | -------------------------------------------------------------------------------- /R/pkgdown.R: -------------------------------------------------------------------------------- 1 | #' @importFrom magrittr %>% 2 | #' @importFrom utils installed.packages 3 | #' @import rlang 4 | #' @import fs 5 | #' @keywords internal 6 | "_PACKAGE" 7 | 8 | release_bullets <- function() { 9 | c( 10 | "Check that 'test/widget.html' responds to mouse clicks" 11 | ) 12 | } 13 | 14 | #' Determine if code is executed by pkgdown 15 | #' 16 | #' This is occasionally useful when you need different behaviour by 17 | #' pkgdown and regular documentation. 18 | #' 19 | #' @export 20 | #' @examples 21 | #' in_pkgdown() 22 | in_pkgdown <- function() { 23 | identical(Sys.getenv("IN_PKGDOWN"), "true") 24 | } 25 | 26 | local_envvar_pkgdown <- function(pkg, scope = parent.frame()) { 27 | withr::local_envvar( 28 | IN_PKGDOWN = "true", 29 | LANGUAGE = pkg$lang, 30 | .local_envir = scope 31 | ) 32 | } 33 | 34 | local_pkgdown_site <- function(path = NULL, meta = NULL, env = parent.frame()) { 35 | if (is.null(path)) { 36 | path <- withr::local_tempdir(.local_envir = env) 37 | desc <- desc::desc("!new") 38 | desc$set("Package", "testpackage") 39 | desc$set("Title", "A test package") 40 | desc$write(file = file.path(path, "DESCRIPTION")) 41 | } 42 | 43 | if (is.character(meta)) { 44 | meta <- yaml::yaml.load(meta) 45 | } else if (is.null(meta)) { 46 | meta <- list() 47 | } 48 | pkg <- as_pkgdown(path, meta) 49 | pkg$dst_path <- withr::local_tempdir(.local_envir = env) 50 | 51 | withr::defer(unlink(pkg$dst_path, recursive = TRUE), envir = env) 52 | 53 | pkg 54 | } 55 | -------------------------------------------------------------------------------- /man/build_site_github_pages.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/build-github.R 3 | \name{build_site_github_pages} 4 | \alias{build_site_github_pages} 5 | \title{Build site for GitHub pages} 6 | \usage{ 7 | build_site_github_pages( 8 | pkg = ".", 9 | ..., 10 | dest_dir = "docs", 11 | clean = TRUE, 12 | install = FALSE, 13 | new_process = FALSE 14 | ) 15 | } 16 | \arguments{ 17 | \item{pkg}{Path to package.} 18 | 19 | \item{...}{Additional arguments passed to \code{\link[=build_site]{build_site()}}.} 20 | 21 | \item{dest_dir}{Directory to build site in.} 22 | 23 | \item{clean}{Clean all files from old site.} 24 | 25 | \item{install}{If \code{TRUE}, will install the package in a temporary library 26 | so it is available for vignettes.} 27 | 28 | \item{new_process}{If \code{TRUE}, will run \code{build_site()} in a separate process. 29 | This enhances reproducibility by ensuring nothing that you have loaded 30 | in the current process affects the build process.} 31 | } 32 | \description{ 33 | Designed to be run as part of automated workflows for deploying 34 | to GitHub pages. It cleans out the old site, builds the site into \code{dest_dir} 35 | adds a \code{.nojekyll} file to suppress rendering by Jekyll, and adds a \code{CNAME} 36 | file if needed. 37 | 38 | It is designed to be run in CI, so by default it: 39 | \itemize{ 40 | \item Clean out the old site. 41 | \item Does not install the package. 42 | \item Runs \code{\link[=build_site]{build_site()}} in process. 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /man/test-dont.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/test.R 3 | \name{test-dont} 4 | \alias{test-dont} 5 | \title{Test case: don't} 6 | \description{ 7 | Test case: don't 8 | } 9 | \examples{ 10 | \dontrun{ 11 | stop("This is an error!", call. = FALSE) 12 | } 13 | 14 | # Inline \donttest is silently ommitted 15 | \donttest{message("Hi!")} 16 | 17 | # Block \donttest indicated with comments 18 | \donttest{ 19 | # This is a comment 20 | 1 + 3 21 | } 22 | 23 | # And works even when not at the top level 24 | if (TRUE) { 25 | \donttest{ 26 | 1 + 2 27 | } 28 | } 29 | 30 | answer <- 1 31 | \dontshow{ 32 | answer <- 42 33 | } 34 | answer # should be 42 35 | 36 | # To hide the \dontshow part, for conditional examples 37 | \dontshow{if (FALSE) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 38 | answer <- 43 39 | \dontshow{\}) # examplesIf} 40 | answer # should be still 42 41 | 42 | # But this one runs, and the condition is hidden 43 | \dontshow{if (TRUE) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 44 | answer <- 43 45 | \dontshow{\}) # examplesIf} 46 | answer 47 | } 48 | \seealso{ 49 | Other tests: 50 | \code{\link{index}}, 51 | \code{\link{test-crayon}}, 52 | \code{\link{test-figures}}, 53 | \code{\link{test-links}}, 54 | \code{\link{test-lists}}, 55 | \code{\link{test-long-lines}}, 56 | \code{\link{test-output-styles}}, 57 | \code{\link{test-params}}, 58 | \code{\link{test-sexpr-title}}, 59 | \code{\link{test-verbatim}} 60 | } 61 | \concept{tests} 62 | \keyword{internal} 63 | -------------------------------------------------------------------------------- /man/test-verbatim.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/test.R 3 | \name{test-verbatim} 4 | \alias{test-verbatim} 5 | \title{Test case: preformatted blocks & syntax highlighting} 6 | \description{ 7 | Manual test cases for various ways of embedding code in sections. 8 | All code blocks should have copy and paste button. 9 | } 10 | \section{Should be highlighted}{ 11 | Valid R code in \verb{\preformatted{}}: 12 | 13 | \if{html}{\out{
    }}\preformatted{mean(a + 1) 14 | }\if{html}{\out{
    }} 15 | 16 | R code in \code{R} block: 17 | 18 | \if{html}{\out{
    }}\preformatted{mean(a + 1) 19 | }\if{html}{\out{
    }} 20 | 21 | R code in \code{r} block: 22 | 23 | \if{html}{\out{
    }}\preformatted{mean(a + 1) 24 | }\if{html}{\out{
    }} 25 | 26 | Yaml 27 | 28 | \if{html}{\out{
    }}\preformatted{yaml: [a, 1] 29 | }\if{html}{\out{
    }} 30 | } 31 | 32 | \section{Shouldn't be highlighted}{ 33 | Non-R code in \verb{\preformatted{}} 34 | 35 | \if{html}{\out{
    }}\preformatted{yaml: [a, b, c] 36 | }\if{html}{\out{
    }} 37 | } 38 | 39 | \seealso{ 40 | Other tests: 41 | \code{\link{index}}, 42 | \code{\link{test-crayon}}, 43 | \code{\link{test-dont}}, 44 | \code{\link{test-figures}}, 45 | \code{\link{test-links}}, 46 | \code{\link{test-lists}}, 47 | \code{\link{test-long-lines}}, 48 | \code{\link{test-output-styles}}, 49 | \code{\link{test-params}}, 50 | \code{\link{test-sexpr-title}} 51 | } 52 | \concept{tests} 53 | \keyword{internal} 54 | -------------------------------------------------------------------------------- /tests/testthat/test-init.R: -------------------------------------------------------------------------------- 1 | test_that("extra.css and extra.js copied and linked", { 2 | pkg <- local_pkgdown_site(test_path("assets/init-extra-2")) 3 | expect_output(init_site(pkg)) 4 | 5 | expect_true(file_exists(path(pkg$dst_path, "extra.css"))) 6 | expect_true(file_exists(path(pkg$dst_path, "extra.js"))) 7 | 8 | skip_if_no_pandoc() 9 | # Now check they actually get used . 10 | expect_output(build_home(pkg)) 11 | 12 | html <- xml2::read_html(path(pkg$dst_path, "index.html")) 13 | paths <- xpath_attr(html, ".//link", "href") 14 | 15 | expect_true("extra.css" %in% paths) 16 | }) 17 | 18 | test_that("single extra.css correctly copied", { 19 | pkg <- local_pkgdown_site(test_path("assets/init-extra-1")) 20 | expect_output(init_site(pkg)) 21 | 22 | expect_true(file_exists(path(pkg$dst_path, "extra.css"))) 23 | }) 24 | 25 | test_that("asset subdirectories are copied", { 26 | pkg <- local_pkgdown_site(test_path("assets/init-asset-subdirs")) 27 | expect_output(init_site(pkg)) 28 | 29 | expect_true(file_exists(path(pkg$dst_path, "subdir1", "file1.txt"))) 30 | expect_true(file_exists(path(pkg$dst_path, "subdir1", "subdir2", "file2.txt"))) 31 | }) 32 | 33 | test_that("site meta doesn't break unexpectedly", { 34 | pkgdown <- as_pkgdown(test_path("assets/reference")) 35 | 36 | # null out components that will vary 37 | yaml <- site_meta(pkgdown) 38 | yaml$pkgdown <- "{version}" 39 | yaml$pkgdown_sha <- "{sha}" 40 | yaml$pandoc <- "{version}" 41 | yaml$last_built <- timestamp(as.POSIXct("2020-01-01", tz = "UTC")) 42 | 43 | expect_snapshot_output(yaml) 44 | }) 45 | -------------------------------------------------------------------------------- /tests/testthat/test-markdown.R: -------------------------------------------------------------------------------- 1 | test_that("handles empty inputs", { 2 | expect_equal(markdown_text_inline(""), NULL) 3 | expect_equal(markdown_text_inline(NULL), NULL) 4 | 5 | expect_equal(markdown_text_block(NULL), NULL) 6 | expect_equal(markdown_text_block(""), NULL) 7 | }) 8 | 9 | test_that("header attributes are parsed", { 10 | text <- markdown_text_block("# Header {.class #id}") 11 | expect_match(text, "id=\"id\"") 12 | expect_match(text, "class=\".*? class\"") 13 | }) 14 | 15 | test_that("markdown_text_inline() works with inline markdown", { 16 | expect_equal(markdown_text_inline("**lala**"), "lala") 17 | expect_snapshot_error(markdown_text_inline("x\n\ny")) 18 | }) 19 | 20 | test_that("markdown_text_block() works with inline and block markdown", { 21 | skip_if_no_pandoc("2.17.1") 22 | 23 | expect_equal(markdown_text_block("**x**"), "

    x

    ") 24 | expect_equal(markdown_text_block("x\n\ny"), "

    x

    y

    ") 25 | }) 26 | 27 | test_that("markdown_body() captures title", { 28 | temp <- withr::local_tempfile() 29 | write_lines("# Title\n\nSome text", temp) 30 | 31 | html <- markdown_body(temp) 32 | expect_equal(attr(html, "title"), "Title") 33 | 34 | # And can optionally strip it 35 | html <- markdown_body(temp, strip_header = TRUE) 36 | expect_equal(attr(html, "title"), "Title") 37 | expect_false(grepl("Title", html)) 38 | }) 39 | 40 | test_that("markdown_text_*() handles UTF-8 correctly", { 41 | expect_equal(markdown_text_block("\u00f8"), "

    \u00f8

    ") 42 | expect_equal(markdown_text_inline("\u00f8"), "\u00f8") 43 | }) 44 | -------------------------------------------------------------------------------- /inst/BS5/templates/navbar.html: -------------------------------------------------------------------------------- 1 | {{#navbar}} 2 | 35 | {{/navbar}} 36 | -------------------------------------------------------------------------------- /R/build-redirects.R: -------------------------------------------------------------------------------- 1 | build_redirects <- function(pkg = ".", 2 | override = list()) { 3 | pkg <- section_init(pkg, depth = 1L, override = override) 4 | 5 | redirects <- c( 6 | article_redirects(pkg), 7 | pkg$meta$redirects 8 | ) 9 | 10 | if (is.null(redirects)) { 11 | return(invisible()) 12 | } 13 | 14 | rule("Building redirects") 15 | if (is.null(pkg$meta$url)) { 16 | abort(sprintf("%s required to generate redirects", pkgdown_field(pkg, "url"))) 17 | } 18 | 19 | purrr::iwalk( 20 | redirects, 21 | build_redirect, 22 | pkg = pkg 23 | ) 24 | } 25 | 26 | build_redirect <- function(entry, index, pkg) { 27 | if (!is.character(entry) || length(entry) != 2) { 28 | abort( 29 | sprintf( 30 | "Entry %s in %s must be a character vector of length 2.", 31 | index, 32 | pkgdown_field(pkg, "redirects") 33 | ) 34 | ) 35 | } 36 | 37 | new <- entry[2] 38 | old <- path(pkg$dst_path, entry[1]) 39 | 40 | path <- find_template("layout", "redirect", pkg = pkg) 41 | template <- read_file(path) 42 | 43 | url <- sprintf("%s/%s%s", pkg$meta$url, pkg$prefix, new) 44 | lines <- whisker::whisker.render(template, list(url = url)) 45 | dir_create(path_dir(old)) 46 | write_lines(lines, old) 47 | } 48 | 49 | article_redirects <- function(pkg) { 50 | if (is.null(pkg$meta$url)) { 51 | return(NULL) 52 | } 53 | 54 | is_vig_in_articles <- path_has_parent(pkg$vignettes$name, "articles") 55 | if (!any(is_vig_in_articles)) { 56 | return(NULL) 57 | } 58 | 59 | articles <- pkg$vignettes$file_out[is_vig_in_articles] 60 | purrr::map(articles, ~ paste0(c("articles/", ""), .x)) 61 | } 62 | -------------------------------------------------------------------------------- /tests/testthat/test-development.R: -------------------------------------------------------------------------------- 1 | test_that("empty yaml gets correct defaults", { 2 | dev <- meta_development(list()) 3 | expect_equal(dev$mode, "default") 4 | expect_equal(dev$in_dev, FALSE) 5 | expect_equal(dev$version_label, "default") 6 | }) 7 | 8 | test_that("mode = auto uses version", { 9 | dev <- meta_development( 10 | list(development = list(mode = "auto")), 11 | package_version("1.0.0.9000") 12 | ) 13 | expect_equal(dev$mode, "devel") 14 | expect_equal(dev$in_dev, TRUE) 15 | expect_equal(dev$version_label, "danger") 16 | }) 17 | 18 | test_that("mode overrides version", { 19 | dev <- meta_development( 20 | list(development = list(mode = "release")), 21 | package_version("1.0.0.9000") 22 | ) 23 | 24 | expect_equal(dev$mode, "release") 25 | expect_equal(dev$in_dev, FALSE) 26 | expect_equal(dev$version_label, "default") 27 | }) 28 | 29 | test_that("dev_mode recognises basic version structure", { 30 | expect_equal(dev_mode_auto("0.0.0.9000"), "unreleased") 31 | 32 | expect_equal(dev_mode_auto("0.0.1"), "release") 33 | 34 | expect_equal(dev_mode_auto("0.1"), "release") 35 | expect_equal(dev_mode_auto("0.1.0"), "release") 36 | expect_equal(dev_mode_auto("0.1.9000"), "devel") 37 | 38 | expect_equal(dev_mode_auto("1.0"), "release") 39 | expect_equal(dev_mode_auto("1.0.0"), "release") 40 | expect_equal(dev_mode_auto("1.0.0.9000"), "devel") 41 | }) 42 | 43 | test_that("can override dev_mode with env var", { 44 | withr::local_envvar("PKGDOWN_DEV_MODE" = "devel") 45 | expect_equal(dev_mode("1.0", list()), "devel") 46 | }) 47 | 48 | test_that("bad mode yields good error", { 49 | expect_snapshot(check_mode("foo"), error = TRUE) 50 | }) 51 | -------------------------------------------------------------------------------- /inst/BS5/templates/content-article.html: -------------------------------------------------------------------------------- 1 | {{^as_is}}$for(header-includes)$ 2 | $header-includes$ 3 | $endfor${{/as_is}} 4 | 5 |
    6 |
    7 | 35 | 36 | $for(include-before)$ 37 | $include-before$ 38 | $endfor$ 39 | 40 | $if(abstract)$ 41 |
    42 |

    Abstract

    43 | $abstract$ 44 |
    45 | $endif$ 46 | 47 | $body$ 48 |
    49 | {{#toc}} 50 | 55 | {{/toc}} 56 | 57 |
    58 | 59 | $for(include-after)$ 60 | $include-after$ 61 | $endfor$ 62 | -------------------------------------------------------------------------------- /man/deploy_to_branch.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/deploy-site.R 3 | \name{deploy_to_branch} 4 | \alias{deploy_to_branch} 5 | \title{Build and deploy a site locally} 6 | \usage{ 7 | deploy_to_branch( 8 | pkg = ".", 9 | commit_message = construct_commit_message(pkg), 10 | clean = TRUE, 11 | branch = "gh-pages", 12 | remote = "origin", 13 | github_pages = (branch == "gh-pages"), 14 | ..., 15 | subdir = NULL 16 | ) 17 | } 18 | \arguments{ 19 | \item{pkg}{Path to package.} 20 | 21 | \item{commit_message}{The commit message to be used for the commit.} 22 | 23 | \item{clean}{Clean all files from old site.} 24 | 25 | \item{branch}{The git branch to deploy to} 26 | 27 | \item{remote}{The git remote to deploy to} 28 | 29 | \item{github_pages}{Is this a GitHub pages deploy. If \code{TRUE}, adds a \code{CNAME} 30 | file for custom domain name support, and a \code{.nojekyll} file to suppress 31 | jekyll rendering.} 32 | 33 | \item{...}{Additional arguments passed to \code{\link[=build_site]{build_site()}}.} 34 | 35 | \item{subdir}{The sub-directory where the site should be built on the branch. 36 | This argument can be used to support a number of site configurations. 37 | For example, you could build version-specific documentation by setting 38 | \code{subdir = "v1.2.3"}; \code{deploy_to_branch()} will build and deploy the 39 | package documentation in the \verb{v.1.2.3/} directory of your site.} 40 | } 41 | \description{ 42 | Assumes that you're in a git clone of the project, and the package is 43 | already installed. Use \code{\link[usethis:use_pkgdown]{usethis::use_pkgdown_github_pages()}} to automate 44 | this process using GitHub actions. 45 | } 46 | -------------------------------------------------------------------------------- /R/utils-yaml.R: -------------------------------------------------------------------------------- 1 | check_yaml_has <- function(missing, where, pkg) { 2 | if (length(missing) == 0) { 3 | return() 4 | } 5 | 6 | missing_components <- lapply(missing, function(x) c(where, x)) 7 | missing_fields <- pkgdown_fields(pkg, missing_components) 8 | 9 | abort(paste0( 10 | "Can't find component", if (length(missing) > 1) "s", " ", 11 | missing_fields, "." 12 | )) 13 | } 14 | 15 | yaml_character <- function(pkg, where) { 16 | x <- purrr::pluck(pkg$meta, !!!where) 17 | 18 | if (identical(x, list()) || is.null(x)) { 19 | character() 20 | } else if (is.character(x)) { 21 | x 22 | } else { 23 | abort(paste0(pkgdown_field(pkg, where), " must be a character vector")) 24 | } 25 | } 26 | 27 | pkgdown_field <- function(pkg, field) { 28 | pkgdown_fields(pkg, list(field)) 29 | } 30 | 31 | pkgdown_fields <- function(pkg, fields, join = ", ") { 32 | fields <- purrr::map_chr(fields, ~ paste0(crayon::bold(.x), collapse = ".")) 33 | fields_str <- paste0(fields, collapse = join) 34 | 35 | config_path <- pkgdown_config_path(pkg$src_path) 36 | 37 | if (is.null(config_path)) { 38 | fields_str 39 | } else { 40 | config <- src_path(fs::path_rel(config_path, pkg$src_path)) 41 | paste0(fields_str, " in ", config) 42 | } 43 | } 44 | 45 | # print helper ------------------------------------------------------------ 46 | 47 | print_yaml <- function(x) { 48 | structure(x, class = "print_yaml") 49 | } 50 | #' @export 51 | print.print_yaml <- function(x, ...) { 52 | cat(yaml::as.yaml(x), "\n", sep = "") 53 | } 54 | 55 | # IO ---------------------------------------------------------------------- 56 | 57 | write_yaml <- function(x, path) { 58 | write_lines(yaml::as.yaml(x), path = path) 59 | } 60 | -------------------------------------------------------------------------------- /inst/BS3/templates/content-reference-index.html: -------------------------------------------------------------------------------- 1 |
    2 |
    3 | 6 | 7 | 8 | 9 | 10 | {{#has_icons}}{{/has_icons}} 11 | 12 | 13 | 14 | 15 | {{#rows}} 16 | {{#title}} 17 | 21 | {{/title}} 22 | {{#subtitle}} 23 | 27 | {{/subtitle}} 28 | {{#topics}} 29 | {{#has_icons}}{{/has_icons}} 30 | 33 | 34 | {{/topics}} 35 | {{/rows}} 36 |
    18 |

    {{{title}}}

    19 |

    {{{desc}}}

    20 |
    24 |

    {{{subtitle}}}

    25 |

    {{{desc}}}

    26 |
    {{#icon}}{{/icon}} 31 |

    {{#aliases}}{{{.}}} {{/aliases}}

    32 |

    {{{title}}}

    37 |
    38 | 39 | 44 |
    45 | -------------------------------------------------------------------------------- /tests/testthat/test-build-footer.R: -------------------------------------------------------------------------------- 1 | test_that("works by default", { 2 | pkg <- structure( 3 | list( 4 | desc = desc::desc(text = "Authors@R: person('First', 'Last', role = 'cre')") 5 | ), 6 | class = "pkgdown" 7 | ) 8 | footer <- data_footer(pkg) 9 | footer$right <- gsub(packageVersion("pkgdown"), "{version}", footer$right, fixed = TRUE) 10 | 11 | expect_snapshot_output(footer) 12 | }) 13 | 14 | test_that("includes package component", { 15 | pkg <- structure( 16 | list( 17 | package = "noodlr", 18 | desc = desc::desc(text = "Authors@R: person('First', 'Last', role = 'cre')"), 19 | meta = list( 20 | footer = list( 21 | structure = list(left = "package") 22 | ) 23 | ) 24 | ), 25 | class = "pkgdown" 26 | ) 27 | expect_equal(data_footer(pkg)$left, "

    noodlr

    ") 28 | }) 29 | 30 | test_that("can use custom components", { 31 | pkg <- structure(list( 32 | desc = desc::desc(text = "Authors@R: person('a', 'b', roles = 'cre')"), 33 | meta = list( 34 | footer = list( 35 | structure = list(left = "test"), 36 | components = list(test = "_test_") 37 | ) 38 | )), 39 | class = "pkgdown" 40 | ) 41 | expect_equal(data_footer(pkg)$left, "

    test

    ") 42 | }) 43 | 44 | test_that("multiple components are pasted together", { 45 | pkg <- structure(list( 46 | desc = desc::desc(text = "Authors@R: person('a', 'b', roles = 'cre')"), 47 | meta = list( 48 | footer = list( 49 | structure = list(left = c("a", "b")), 50 | components = list(a = "a", b = "b") 51 | ) 52 | )), 53 | class = "pkgdown" 54 | ) 55 | expect_equal(data_footer(pkg)$left, "

    a b

    ") 56 | }) 57 | 58 | -------------------------------------------------------------------------------- /inst/BS3/templates/content-article.html: -------------------------------------------------------------------------------- 1 | {{^as_is}}$for(header-includes)$ 2 | $header-includes$ 3 | $endfor${{/as_is}} 4 | 5 |
    6 |
    7 | 35 | 36 | $for(include-before)$ 37 | $include-before$ 38 | $endfor$ 39 | 40 | $if(abstract)$ 41 |
    42 |

    Abstract

    43 | $abstract$ 44 |
    45 | $endif$ 46 | 47 | $body$ 48 |
    49 | 50 | 61 | 62 |
    63 | 64 | $for(include-after)$ 65 | $include-after$ 66 | $endfor$ 67 | -------------------------------------------------------------------------------- /inst/BS3/templates/navbar.html: -------------------------------------------------------------------------------- 1 | {{#navbar}} 2 | 38 | {{/navbar}} 39 | -------------------------------------------------------------------------------- /inst/highlight-styles/espresso.scss: -------------------------------------------------------------------------------- 1 | pre {background-color: #2a211c; color: #bdae9d;} 2 | pre code span.al /* Alert */ {color:#ffff00} 3 | pre code span.an /* Annotation */ {color:#0066ff; font-weight: bold; font-style: italic} 4 | pre code span.at /* Attribute */ {} 5 | pre code span.bn /* BaseN */ {color:#44aa43} 6 | pre code span.bu /* BuiltIn */ {} 7 | pre code span.cf /* ControlFlow */ {color:#43a8ed; font-weight: bold} 8 | pre code span.ch /* Char */ {color:#049b0a} 9 | pre code span.cn /* Constant */ {} 10 | pre code span.co /* Comment */ {color:#0066ff; font-weight: bold; font-style: italic} 11 | pre code span.do /* Documentation */ {color:#0066ff; font-style: italic} 12 | pre code span.dt /* DataType */ {text-decoration: underline} 13 | pre code span.dv /* DecVal */ {color:#44aa43} 14 | pre code span.er /* Error */ {color:#ffff00; font-weight: bold} 15 | pre code span.ex /* Extension */ {} 16 | pre code span.fl /* Float */ {color:#44aa43} 17 | pre code span.fu /* Function */ {color:#ff9358; font-weight: bold} 18 | pre code span.im /* Import */ {} 19 | pre code span.in /* Information */ {color:#0066ff; font-weight: bold; font-style: italic} 20 | pre code span.kw /* Keyword */ {color:#43a8ed; font-weight: bold} 21 | pre code span.op /* Operator */ {} 22 | pre code span.pp /* Preprocessor */ {font-weight: bold} 23 | pre code span.sc /* SpecialChar */ {color:#049b0a} 24 | pre code span.ss /* SpecialString */ {color:#049b0a} 25 | pre code span.st /* String */ {color:#049b0a} 26 | pre code span.va /* Variable */ {} 27 | pre code span.vs /* VerbatimString */ {color:#049b0a} 28 | pre code span.wa /* Warning */ {color:#ffff00; font-weight: bold} 29 | -------------------------------------------------------------------------------- /inst/highlight-styles/zenburn.scss: -------------------------------------------------------------------------------- 1 | pre {background-color: #303030; color: #cccccc;} 2 | pre code span.al /* Alert */ {color:#ffcfaf} 3 | pre code span.an /* Annotation */ {color:#7f9f7f; font-weight: bold} 4 | pre code span.at /* Attribute */ {} 5 | pre code span.bn /* BaseN */ {color:#dca3a3} 6 | pre code span.bu /* BuiltIn */ {} 7 | pre code span.cf /* ControlFlow */ {color:#f0dfaf} 8 | pre code span.ch /* Char */ {color:#dca3a3} 9 | pre code span.cn /* Constant */ {color:#dca3a3; font-weight: bold} 10 | pre code span.co /* Comment */ {color:#7f9f7f} 11 | pre code span.cv /* CommentVar */ {color:#7f9f7f; font-weight: bold} 12 | pre code span.do /* Documentation */ {color:#7f9f7f} 13 | pre code span.dt /* DataType */ {color:#dfdfbf} 14 | pre code span.dv /* DecVal */ {color:#dcdccc} 15 | pre code span.er /* Error */ {color:#c3bf9f} 16 | pre code span.ex /* Extension */ {} 17 | pre code span.fl /* Float */ {color:#c0bed1} 18 | pre code span.fu /* Function */ {color:#efef8f} 19 | pre code span.im /* Import */ {} 20 | pre code span.in /* Information */ {color:#7f9f7f; font-weight: bold} 21 | pre code span.kw /* Keyword */ {color:#f0dfaf} 22 | pre code span.op /* Operator */ {color:#f0efd0} 23 | pre code span.ot /* Other */ {color:#efef8f} 24 | pre code span.pp /* Preprocessor */ {color:#ffcfaf; font-weight: bold} 25 | pre code span.sc /* SpecialChar */ {color:#dca3a3} 26 | pre code span.ss /* SpecialString */ {color:#cc9393} 27 | pre code span.st /* String */ {color:#cc9393} 28 | pre code span.va /* Variable */ {} 29 | pre code span.vs /* VerbatimString */ {color:#cc9393} 30 | pre code span.wa /* Warning */ {color:#7f9f7f; font-weight: bold} 31 | -------------------------------------------------------------------------------- /R/highlight.R: -------------------------------------------------------------------------------- 1 | # highligh_text() and highlight_examples() are only used for usage 2 | # and examples, and are specifically excluded in tweak_reference_highlighting() 3 | highlight_text <- function(text) { 4 | return(text) 5 | out <- downlit::highlight(text, classes = downlit::classes_pandoc()) 6 | if (!is.na(out)) { 7 | sourceCode(pre(out, r_code = TRUE)) 8 | } else { 9 | sourceCode(pre(escape_html(text))) 10 | } 11 | } 12 | 13 | highlight_examples <- function(code, topic, env = globalenv()) { 14 | bg <- fig_settings()$bg %||% NA 15 | 16 | # some options from testthat::local_reproducible_output() 17 | # https://github.com/r-lib/testthat/blob/47935141d430e002070a95dd8af6dbf70def0994/R/local.R#L86 18 | withr::local_options(list( 19 | crayon.enabled = TRUE, 20 | crayon.colors = 256, 21 | device = function(...) ragg::agg_png(..., bg = bg), 22 | rlang_interactive = FALSE, 23 | cli.dynamic = FALSE 24 | )) 25 | withr::local_envvar(RSTUDIO = NA) 26 | withr::local_collate("C") 27 | 28 | fig_save_topic <- function(plot, id) { 29 | name <- paste0(topic, "-", id) 30 | do.call(fig_save, c(list(plot, name), fig_settings())) 31 | } 32 | 33 | out <- downlit::evaluate_and_highlight( 34 | code, 35 | fig_save = fig_save_topic, 36 | env = child_env(env), 37 | output_handler = evaluate::new_output_handler(value = pkgdown_print) 38 | ) 39 | structure( 40 | sourceCode(pre(out, r_code = TRUE)), 41 | dependencies = attr(out, "dependencies") 42 | ) 43 | } 44 | 45 | pre <- function(x, r_code = FALSE) { 46 | paste0( 47 | "", "", 48 | x, 49 | "","" 50 | ) 51 | } 52 | 53 | sourceCode <- function(x) { 54 | paste0("
    ", x, "
    ") 55 | } 56 | -------------------------------------------------------------------------------- /inst/highlight-styles/a11y-dark.scss: -------------------------------------------------------------------------------- 1 | pre {background-color: #2b2b2b;} 2 | pre code /* Normal */ {color:#f8f8f2} 3 | pre code span.al /* Alert */ {color:#dcc6e0} 4 | pre code span.an /* Annotation */ {color:#d4d0ab} 5 | pre code span.at /* Attribute */ {color:#ffd700} 6 | pre code span.bn /* BaseN */ {color:#dcc6e0} 7 | pre code span.bu /* BuiltIn */ {} 8 | pre code span.cf /* ControlFlow */ {color:#ffa07a} 9 | pre code span.ch /* Char */ {color:#abe338} 10 | pre code span.cn /* Constant */ {color:#ffa07a} 11 | pre code span.co /* Comment */ {color:#d4d0ab} 12 | pre code span.cv /* CommentVar */ {color:#d4d0ab; font-style: italic} 13 | pre code span.do /* Documentation */ {color:#d4d0ab; font-style: italic} 14 | pre code span.dt /* DataType */ {color:#dcc6e0} 15 | pre code span.dv /* DecVal */ {color:#dcc6e0} 16 | pre code span.er /* Error */ {color:#dcc6e0} 17 | pre code span.ex /* Extension */ {} 18 | pre code span.fl /* Float */ {color:#f5ab35} 19 | pre code span.fu /* Function */ {color:#ffd700} 20 | pre code span.im /* Import */ {} 21 | pre code span.in /* Information */ {color:#d4d0ab} 22 | pre code span.kw /* Keyword */ {color:#ffa07a} 23 | pre code span.op /* Operator */ {color:#00e0e0} 24 | pre code span.ot /* Other */ {color:#ffa07a} 25 | pre code span.pp /* Preprocessor */ {color:#dcc6e0} 26 | pre code span.sc /* SpecialChar */ {color:#00e0e0} 27 | pre code span.ss /* SpecialString */ {color:#abe338} 28 | pre code span.st /* String */ {color:#abe338} 29 | pre code span.va /* Variable */ {color:#f5ab35} 30 | pre code span.vs /* VerbatimString */ {color:#abe338} 31 | pre code span.wa /* Warning */ {color:#d4d0ab; font-style: italic} 32 | -------------------------------------------------------------------------------- /inst/highlight-styles/a11y-light.scss: -------------------------------------------------------------------------------- 1 | pre {background-color: #fefefe;} 2 | pre code /* Normal */ {color:#545454} 3 | pre code span.al /* Alert */ {color:#7928a1} 4 | pre code span.an /* Annotation */ {color:#696969} 5 | pre code span.at /* Attribute */ {color:#aa5d00} 6 | pre code span.bn /* BaseN */ {color:#7928a1} 7 | pre code span.bu /* BuiltIn */ {} 8 | pre code span.cf /* ControlFlow */ {color:#d91e18} 9 | pre code span.ch /* Char */ {color:#008000} 10 | pre code span.cn /* Constant */ {color:#d91e18} 11 | pre code span.co /* Comment */ {color:#696969} 12 | pre code span.cv /* CommentVar */ {color:#696969; font-style: italic} 13 | pre code span.do /* Documentation */ {color:#696969; font-style: italic} 14 | pre code span.dt /* DataType */ {color:#7928a1} 15 | pre code span.dv /* DecVal */ {color:#7928a1} 16 | pre code span.er /* Error */ {color:#7928a1} 17 | pre code span.ex /* Extension */ {} 18 | pre code span.fl /* Float */ {color:#aa5d00} 19 | pre code span.fu /* Function */ {color:#06287e} 20 | pre code span.im /* Import */ {} 21 | pre code span.in /* Information */ {color:#696969} 22 | pre code span.kw /* Keyword */ {color:#d91e18} 23 | pre code span.op /* Operator */ {color:#007faa} 24 | pre code span.ot /* Other */ {color:#d91e18} 25 | pre code span.pp /* Preprocessor */ {color:#7928a1} 26 | pre code span.sc /* SpecialChar */ {color:#007faa} 27 | pre code span.ss /* SpecialString */ {color:#008000} 28 | pre code span.st /* String */ {color:#008000} 29 | pre code span.va /* Variable */ {color:#aa5d00} 30 | pre code span.vs /* VerbatimString */ {color:#008000} 31 | pre code span.wa /* Warning */ {color:#696969; font-style: italic} 32 | -------------------------------------------------------------------------------- /tests/testthat/test-build-search-docs.R: -------------------------------------------------------------------------------- 1 | test_that("docsearch.json and sitemap.xml are valid", { 2 | pkg <- local_pkgdown_site(test_path("assets/search-site")) 3 | 4 | expect_output(build_site(pkg, new_process = FALSE)) 5 | json <- path(pkg$dst_path, "docsearch.json") 6 | expect_true(jsonlite::validate(read_lines(json))) 7 | 8 | xml <- path(pkg$dst_path, "sitemap.xml") 9 | schema <- xml2::read_xml(path(pkg$src_path, "sitemaps-schema-0.9.xsd")) 10 | expect_true(xml2::xml_validate(xml2::read_xml(xml), schema)) 11 | }) 12 | 13 | test_that("build_search() builds the expected search`.json with an URL", { 14 | pkg <- local_pkgdown_site(test_path("assets/news"), ' 15 | url: https://example.com 16 | template: 17 | bootstrap: 5 18 | news: 19 | cran_dates: false 20 | development: 21 | mode: devel 22 | ') 23 | 24 | expect_output(init_site(pkg)) 25 | expect_output(build_news(pkg)) 26 | expect_output(build_home(pkg)) 27 | expect_output(build_sitemap(pkg)) 28 | 29 | json_path <- withr::local_tempfile() 30 | jsonlite::write_json(build_search_index(pkg), json_path, pretty = TRUE) 31 | expect_snapshot_file(json_path, "search.json") 32 | }) 33 | 34 | test_that("build_search() builds the expected search.json with no URL", { 35 | pkg <- local_pkgdown_site(test_path("assets/news"), ' 36 | template: 37 | bootstrap: 5 38 | news: 39 | cran_dates: false 40 | development: 41 | mode: devel 42 | ') 43 | 44 | expect_output(init_site(pkg)) 45 | expect_output(build_news(pkg)) 46 | expect_output(build_home(pkg)) 47 | expect_output(build_sitemap(pkg)) 48 | 49 | json_path <- withr::local_tempfile() 50 | jsonlite::write_json(build_search_index(pkg), json_path, pretty = TRUE) 51 | expect_snapshot_file(json_path, "search-no-url.json") 52 | }) 53 | -------------------------------------------------------------------------------- /inst/highlight-styles/arrow-light.scss: -------------------------------------------------------------------------------- 1 | pre {background-color: #f1f3f5;} 2 | pre code /* Normal */ {color:#003B4F} 3 | pre code span.al /* Alert */ {color:#AD0000} 4 | pre code span.an /* Annotation */ {color:#5E5E5E} 5 | pre code span.at /* Attribute */ {color:#657422} 6 | pre code span.bn /* BaseN */ {color:#AD0000} 7 | pre code span.bu /* BuiltIn */ {} 8 | pre code span.cf /* ControlFlow */ {color:#003B4F} 9 | pre code span.ch /* Char */ {color:#20794D} 10 | pre code span.cn /* Constant */ {color:#8f5902} 11 | pre code span.co /* Comment */ {color:#5E5E5E} 12 | pre code span.cv /* CommentVar */ {color:#5E5E5E; font-style: italic} 13 | pre code span.do /* Documentation */ {color:#5E5E5E; font-style: italic} 14 | pre code span.dt /* DataType */ {color:#AD0000} 15 | pre code span.dv /* DecVal */ {color:#AD0000} 16 | pre code span.er /* Error */ {color:#AD0000} 17 | pre code span.ex /* Extension */ {} 18 | pre code span.fl /* Float */ {color:#AD0000} 19 | pre code span.fu /* Function */ {color:#4758AB} 20 | pre code span.im /* Import */ {color:#00769E} 21 | pre code span.in /* Information */ {color:#5E5E5E} 22 | pre code span.kw /* Keyword */ {color:#003B4F} 23 | pre code span.op /* Operator */ {color:#5E5E5E} 24 | pre code span.ot /* Other */ {color:#003B4F} 25 | pre code span.pp /* Preprocessor */ {color:#AD0000} 26 | pre code span.sc /* SpecialChar */ {color:#5E5E5E} 27 | pre code span.ss /* SpecialString */ {color:#20794D} 28 | pre code span.st /* String */ {color:#20794D} 29 | pre code span.va /* Variable */ {color:#111111} 30 | pre code span.vs /* VerbatimString */ {color:#20794D} 31 | pre code span.wa /* Warning */ {color:#5E5E5E; font-style: italic} 32 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/topics.md: -------------------------------------------------------------------------------- 1 | # bad inputs give informative warnings 2 | 3 | Code 4 | t <- select_topics("x + ", topics) 5 | Condition 6 | Error: 7 | ! In '_pkgdown.yml', topic must be valid R code 8 | x Not 'x + ' 9 | Code 10 | t <- select_topics("y", topics) 11 | Condition 12 | Error: 13 | ! In '_pkgdown.yml', topic must be a known topic name or alias 14 | x Not 'y' 15 | Code 16 | t <- select_topics("paste(1)", topics) 17 | Condition 18 | Error: 19 | ! In '_pkgdown.yml', topic must be a known selector function 20 | x Not 'paste(1)' 21 | Caused by error in `paste()`: 22 | ! could not find function "paste" 23 | Code 24 | t <- select_topics("starts_with", topics) 25 | Condition 26 | Error: 27 | ! In '_pkgdown.yml', topic must be a known topic name or alias 28 | x Not 'starts_with' 29 | Code 30 | t <- select_topics("1", topics) 31 | Condition 32 | Error: 33 | ! In '_pkgdown.yml', topic must be a string or function call 34 | x Not '1' 35 | Code 36 | t <- select_topics("starts_with('y')", topics, check = TRUE) 37 | Condition 38 | Error in `select_topics()`: 39 | ! No topics matched in '_pkgdown.yml'. No topics selected. 40 | 41 | # can select by name or alias 42 | 43 | Code 44 | select_topics("a4", topics) 45 | Condition 46 | Error: 47 | ! In '_pkgdown.yml', topic must be a known topic name or alias 48 | x Not 'a4' 49 | 50 | # an unmatched selection generates a warning 51 | 52 | Code 53 | select_topics(c("a", "starts_with('unmatched')"), topics, check = TRUE) 54 | Condition 55 | Error: 56 | ! In '_pkgdown.yml', topic must match a function or concept 57 | x Not 'starts_with(\'unmatched\')' 58 | 59 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/build-news.md: -------------------------------------------------------------------------------- 1 | # data_news works as expected for h1 & h2 2 | 3 | # A tibble: 2 x 3 4 | version page anchor 5 | 6 | 1 1.0.0.9000 dev testpackage-1009000 7 | 2 1.0.0 1.0 testpackage-100 8 | 9 | --- 10 | 11 | # A tibble: 2 x 3 12 | version page anchor 13 | 14 | 1 1.0.0.9000 dev testpackage-1009000 15 | 2 1.0.0 1.0 testpackage-100 16 | 17 | # multi-page news are rendered 18 | 19 | # A tibble: 4 x 3 20 | version page anchor 21 | 22 | 1 2.0 2.0 testpackage-20 23 | 2 1.1 1.1 testpackage-11 24 | 3 1.0.1 1.0 testpackage-101 25 | 4 1.0.0 1.0 testpackage-100 26 | 27 | # news headings get class and release date 28 | 29 |
    30 | 33 |
    34 | 35 | --- 36 | 37 |
    38 |

    39 |

    CRAN release: 2020-01-01

    40 |

    41 | 42 | # clear error for bad hierarchy - bad nesting 43 | 44 | Invalid NEWS.md: inconsistent use of section headings. 45 | i Top-level headings must be either all

    or all

    . 46 | i See ?build_news for more details. 47 | 48 | # clear error for bad hierarchy - h3 49 | 50 | Invalid NEWS.md: inconsistent use of section headings. 51 | i Top-level headings must be either all

    or all

    . 52 | i See ?build_news for more details. 53 | 54 | # news can contain footnotes 55 | 56 | Code 57 | x <- data_news(pkg) 58 | Condition 59 | Warning: 60 | Footnotes in NEWS.md are not currently suppoted 61 | 62 | --------------------------------------------------------------------------------