Learn R Programming

litedown (version 1.0)

pkg_site: Build a website for an R package

Description

Generate a website from a template shipped with litedown, which contains pages for the package description, news, manual, vignettes, examples, and source code.

Usage

pkg_site(name = detect_pkg(), output = "site")

Value

Output file paths (invisibly).

Arguments

name

The package name (by default, it is automatically detected from the DESCRIPTION file if it exists in the current working directory or upper-level directories).

output

The directory in which the site is built (created if it does not exist). It holds both the site source (i.e., the template) and the output files.

Details

Template files are copied from system.file('site', package = 'litedown') to the output directory. Files that already exist under output are not overwritten, i.e., you can customize any page by providing your own version of it. Pages that do not apply to the package are deleted, e.g., news.Rmd is deleted if the package has neither NEWS.md nor inst/NEWS.Rd.

The source files copied from the template (e.g., index.Rmd and _litedown.yml) are removed after the site is built, so only your own files and the output remain in output.

Template pages that you do not want can be listed in the field exclude under site in _litedown.yml under output, e.g., exclude: [code.Rmd, news.Rmd]. They will not be copied. By default, only code.Rmd is excluded, and exclude: NA means to exclude nothing.

If the package contains a book project (i.e., book/_litedown.yml exists), the book will be built via fuse_book() and placed under the book/ subdirectory of the site.

The package must have been installed, because rendering the site requires the installed version of it (e.g., pkg_manual() reads its Rd database, and articles.Rmd lists its built vignettes). The pages generated from the package source (e.g., examples.Rmd and the book under book/) require the package root directory, which is taken from the path attribute of name.

See Also

fuse_site(), which renders the site after the template has been set up.

Examples

Run this code
if (FALSE) {
# run this in the root directory of a package
litedown::pkg_site()
}

Run the code above in your browser using DataLab