Build Website of Package Documentation

Authors: Ryan Hafen [aut, cre],Barret Schloerke [aut],Hadley Wickham [aut, cph]

Version: 0.4.1

License: MIT + file LICENSE

Description

Build a package documentation and function reference site and use it as the package vignette.

Depends

R (>= 3.1.1)

Imports

crayon, devtools, digest, evaluate, highlight, htmltools, lazyrmd (>= 0.2.0), magrittr, rmarkdown, stringr, tools, whisker, yaml

Suggests

testthat

Main Functions

init_vignettes

Initialize a new packagedocs project

Usage

init_vignettes(code_path = ".", title = NULL, subtitle = NULL, author = NULL)

Arguments

code_path
location of R package (defaults to current directory)
title
title of main page (will search in DESCRIPTION if NULL - can be changed later)
subtitle
subtitle of main page (can be changed later)
author
author (can be changed later)

build_vignettes

Build CRAN and gh-pages vignettes

Build CRAN html redirect vignettes that are placed in inst/doc/ that redirect to the gh-pages branch of the github url provided in the DESCRIPTION file. This function is heavily inspired by devtools::build_vignettes().

Usage

build_vignettes(pkg = ".", dependencies = "VignetteBuilder", output_dir = file.path(as.package(pkg)$path, "_gh-pages"), extra_dirs = file.path(as.package(pkg)$path, "vignettes", c(lazy_widgets_dir(), assets_dir())), delete_files = file.path(as.package(pkg)$path, "vignettes", c(".build.timestamp")), include_vignette_source = FALSE)

Arguments

pkg
path to package. Provided directly to devtools::as.package()
dependencies
supplied directly to devtools::install_deps()
output_dir
directory where the fully contained vignette directory should be exported
extra_dirs
list of directories that will be copied to the gh-pages that are not vignettes and should not be shipped with the package. Files that should be exist in both gh-pages and the package should be contained in the vignettes/.install_extras file.
delete_files
list of files that should be deleted if they still exist when the function ends
include_vignette_source
boolean to determine if the vignettes should be copied to the destination directory. Default behavior is to NOT copy the original vignettes

deploy_travis

Deploy to Github Pages from Travis-CI

This function will generate both the CRAN vignettes and gh-pages vignettes. It will look for your personal github token (GITHUB_TOKEN) that the function may deploy to the gh-pages branch of the your package’s github repo.

Usage

deploy_travis(repo = gsub(".*://([^.]*)\\.github.io/([^/]*).*", "\\1/\\2", read_rmd_yaml(file.path("vignettes", "docs.Rmd"))$redirect), valid_branches = "master", token_key = "GITHUB_PAT", email = "travis@travis-ci.org", name = "Travis CI", push_branch = "gh-pages", output_dir = "_gh-pages", build_fn = function(ouput_dir, ...) { devtools::install(".") build_vignettes(pkg = ".", output_dir = output_dir) })

Arguments

repo
character string that has the form USER/REPO
valid_branches
branch name(s) that are allowed to deploy
token_key
key name that will be autofilled
email
email for commit
name
name for commit
push_branch
branch the website should be pushed to. Defaults to gh-pages
output_dir
output directory to put the website in
build_fn
function to build the documentation. This function must take ouput_dir and for future expansion. Defaults to packagedocs::build_vignettes

Details

The function is designed so that packagedocs will never ask for your token directly. It will only issue commands to the terminal which should evaluate with the necessary information.

Documentation Helpers

Rendering Functions

Vignette Engines

Generate package docs

rmarkdown output formats for the main documentation and package reference pacakge respectively.

Usage

package_docs(toc = TRUE, toc_depth = 2, toc_collapse = FALSE, extra_dependencies = NULL, self_contained = FALSE, fig_width = 6.5, fig_height = 4, mathjax = NULL, lib_dir = assets_dir(), ..., lazyrmd_render_fn = "html_document", lazyrmd_render_package = "rmarkdown")
package_docs_rd(..., rd_index = "rd_index.yaml", code_path = ".", exclude = NULL)

Arguments

toc
should a table of contents be included?
toc_depth
depth of the table of contents (max is 2 for this template)
toc_collapse
should the table of contents have collapsible subsections?
extra_dependencies, self_contained, fig_width, fig_height, mathjax
passed to the rmarkdown rendering function
lazyrmd_render_fn, lazyrmd_render_package, lib_dir
arguments of lazyrmd::lazy_render. Defaults to render with rmarkdown::html_document
rd_index, code_path, exclude
parameters passed directly to rd_template
In pacakge_docs, the parameters are passed to the lazyrmd::lazy_render rendering function. In package_docs_rd, the parameters are passed to package_docs

render_redirect

Render vignette redirect

Create a html redirect file that will automatically redirect to another webpage. This is useful for making a html reidrect in a vignette. By submitting a small redirect vignette, the package is not bloated in size

Usage

render_redirect(input_file_rmd, output_file_html)

Arguments

input_file_rmd
input file name to read its yaml header with redirect key
output_file_html
output file name

rd_template

Generate the text to put in a rd.rmd file to build a package function reference

Usage

rd_template(code_path, rd_index = "rd_index.yaml", exclude = NULL)

Arguments

code_path
path to the source code directory of the package
rd_index
path to yaml file with index layout information
exclude
vector of Rd entry names to exclude from the resulting document

check_output

Check output for warnings and errors

Usage

check_output(ff)

Arguments

ff
path to a .html file output by render()