r-lib / pkgdown

Generate static html documentation for an R package
https://pkgdown.r-lib.org/
Other
708 stars 323 forks source link
documentation-tool package r

pkgdown

<a href="https://cran.r-project.org/package=pkgdown" class="pkgdown-release"><img src="https://www.r-pkg.org/badges/version/pkgdown" alt="CRAN Status" /> <a href="https://github.com/r-lib/pkgdown/actions/workflows/R-CMD-check.yaml" class="pkgdown-devel"><img src="https://github.com/r-lib/pkgdown/actions/workflows/R-CMD-check.yaml/badge.svg" alt="R-CMD-check" /> Codecov test
coverage

pkgdown is designed to make it quick and easy to build a website for your package. You can see pkgdown in action at https://pkgdown.r-lib.org: this is the output of pkgdown applied to the latest version of pkgdown. Learn more in vignette("pkgdown") or ?build_site.

Installation

``` r # Install released version from CRAN install.packages("pkgdown") ```
``` r # Install development version from GitHub # install.packages("pak") pak::pak("r-lib/pkgdown") ```

Usage

Get started with usethis:

# Run once to configure your package to use and deploy pkgdown
usethis::use_pkgdown_github_pages()
# Preview your site locally before publishing
pkgdown::build_site()

This adds the necessary components and sets up GitHub Actions[^1] for automatic site building when deploying. Your README.md becomes the homepage, documentation in man/ generates a function reference, and vignettes will be rendered into articles/.

pkgdown 2.0.0 and Bootstrap 5

pkgdown 2.0.0 includes an upgrade from Bootstrap 3 to Bootstrap 5, which is accompanied by a whole bunch of minor UI improvements. If you’ve heavily customised your site, there’s a small chance that this will break your site, so everyone needs to explicitly opt-in to the upgrade by adding the following to _pkgdown.yml:

template:
  bootstrap: 5

Then learn about the many new ways to customise your site in vignette("customise").

In the wild

At last count, pkgdown is used by over 12,000 packages. Here are a few examples:

Comparing the source and output of these sites is a great way to learn new pkgdown techniques.

Code of conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

[^1]: If you don’t use GitHub, you can use usethis::use_pkgdown() + pkgdown::build_site() to create a website.