[R-pkg-devel] Best practices for vignettes

Dirk Eddelbuettel edd at debian.org
Sun Jul 26 21:31:02 CEST 2015


On 26 July 2015 at 14:22, Dirk Eddelbuettel wrote:
| 
| On 26 July 2015 at 18:42, Lenth, Russell V wrote:
| | What's the best way to manage vignettes?
| 
| All the young ones will of course tell you to use Markdown :)
| 
| I still use Sweave / LaTeX as well, along with a custom driver: highlight, as
| we once figured out how to make it create pretty shaded boxen with code (as
| seen in the various Rcpp vignettes).
| 
| So for that I often keep a five-line script 'buildVignette.r' in the vignette
| directory.  With DESCRIPTION set up right (for the added vignette driver)
| this then works in the package when it works manually for the tests.

I was rambling here.  What I meant to say is

 - buildVignette.r as shown below allows me to build the vignette on the spot
   outside of package builds -- ie when I am in "vignette writing mode"

 - if the vignette builds during the manual builds, which by their design
   mock what the package build process does, then I am reasonably confident
   that the R CMD ... process works too.

Hope this clarifies.

Dirk

| 
| And during the R CMD build ... ; R CMD INSTALL ... steps the vignette does
| get rebuild.
| 
| Oh, but did I mention that markdown is easier?  ;-)   Earlier this year I
| converted to writing my LateX Beamer presentation in RMarkdown (which
| rmarkdown::render() then converts to LaTeX). I may, time permitting, look
| into converting vignetts.  But why mess with a working setup...
| 
| Dirk
| 
| 
| PS buildVignette.r from an older package I am currently working on
| 
| #!/usr/bin/Rscript
| 
| ## use given argument(s) as target files, or else default to .Rnw files in directory
| files <- if (length(commandArgs(TRUE)) == 0) dir(pattern="*.Rnw") else commandArgs(TRUE)
| 
| ## convert all files from Rnw to pdf using the highlight driver
| invisible(sapply(files, function(srcfile) {
|     Sweave(srcfile, driver=highlight::HighlightWeaveLatex(boxes=TRUE))
|     tools::texi2pdf(gsub(".Rnw", ".tex", srcfile))
| }))
| 
| 
| -- 
| http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
| 
| ______________________________________________
| R-package-devel at r-project.org mailing list
| https://stat.ethz.ch/mailman/listinfo/r-package-devel

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org



More information about the R-package-devel mailing list