# ---------------------------------------------------------------------------- #
# Workflow for rebuilding docs + site, testing/checking package and code quality
# dtc = document|test|check
# --- --- ---
# Interactive commands:
# [Ctrl + Shift D] rebuild docs devtools::document([...])
# [Ctrl + Shift + T] run tests devtools::test()
# [Ctrl + Shift + E] check package devtools::check()
# --- --- ---
rebuild_docs <- function() {
# Rebuild the man files
devtools::document(roclets = c('rd', 'collate', 'namespace', 'vignette'))
# Knit README.Rmd
devtools::build_readme()
}
# --- --- ---
# Build website with pkgdown
# seed_val is used for initialising the seed so that random examples are
# reproducible
rebuild_local_site <- function(seed_val = 10) {
# See also pkgdown::build_site_github_pages() which builds and pushes the
# documentation website to github-pages (and also adds a .nojekyll file to
# suppress rendering by Jekyll)
# Rebuild html documentation and local site for previewing before commit (note
# that GitHub actions is generally configured to automatically build and
# publish the pkgdown site)
pkgdown::clean_site()
pkgdown::build_site(seed = seed_val)
}
# --- --- ---
rebuild_docs_and_local_site <- function() {
rebuild_docs()
rebuild_local_site()
}
# --- --- ---
# Run devtools test and check
test_and_check <- function() {
devtools::test()
devtools::check()
}
# --- --- --- #
dtc_workflow <- function(check_code_qual = FALSE) {
rebuild_docs_and_local_site()
if (check_code_qual) {
# Run the goodpractice code check
goodpractice::gp()
}
}
# ------------------------------------ #
# rebuild_docs()
# rebuild_local_site()
# rebuild_docs_and_local_site()
# test_and_check()
# goodpractice::gp()
# By default this will rebuild docs and the website; run dtc_workflow(TRUE) to
# also run the goodpractice code check
dtc_workflow()
# ---------------------------------------------------------------------------- #
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.