# nocov start
# This script is used to precompile vignettes and should be run for
# each new version of the package
# Get current wd (to restore later)
old_wd <- getwd()
# Set wd to vignettes to avoid saving to base directory
setwd("vignettes/")
# Precompile vignettes
library(knitr)
vignettes <- c("rredlist.Rmd", "benchmarks.Rmd", "research_workflows.Rmd")
to_edit <- c()
for (vig in vignettes) {
src <- paste0("./source/_", vig)
if (!file.exists(vig) || file.info(src)$mtime > file.info(vig)$mtime) {
knit(src, vig)
to_edit <- append(to_edit, vig)
}
}
# Build vignettes
library(devtools)
build_vignettes()
# x = vignette file name including file extension (e.g., "rredlist.Rmd")
read_only <- function(x) {
# Create file
tmp <- file(x)
# write lines
writeLines(c(c("---"),
c("# Generated by vignettes/precompile.R: do not edit by hand."),
paste0("# Please edit source in vignettes/source/_", x),
readLines(x)[2:length(readLines(x))]), tmp)
close(tmp)
}
# Add read only info
for (vig in to_edit) {
read_only(vig)
}
rm(read_only)
# Restore wd
setwd(old_wd)
# nocov end
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.