Search code examples
rknitrtravis-civignette

Selectively suppress vignette build


I am converting the BUGS examples in https://github.com/stan-dev/example-models/tree/master/bugs_examples into an examples-only package, with an .Rmd vignette for each example. The full package will be build on TravisCI.

Building a vignette for one example needs at least 2 minutes, so for debug builds it should be possible to include/exclude individual vignettes. I know that I can run individual Knit runs manually, but sometimes running the whole build is required.

In my current workaround the Rmd files are moved to another directory, but the solution is not nice. I am looking for something like this:

---
title: "Rats: a normal hierarchical model"
date: "`r Sys.Date()`"
build: "`r Sys.getenv("build_bugs_rats") != ''`"
output: rmarkdown::html_vignette

Other ideas welcome.


Solution

  • I'm not aware of a built-in way to selectively build or not build vignettes. My hack for this would be to adjust the .travis.yml to do the following:

    • Keep the vignette source code and the vignette output on two separate branches (e.g. keep the output on gh-pages)
    • Check the commit message of the current build: if it includes a key word like BUILD_ALL_VIGNETTES, then build and check the whole package with vignettes and push the compiled vignettes to the gh-pages branch.
    • If the commit message doesn't include the keyword, then go through the list of files from the current commit. Delete all .Rmd files in /vignettes that were not part of the current commit. Then build and check the whole package with vignettes and push the compiled vignettes (if any) to the gh-pages branch.