Compile the vignette with `devtools :: build_vignette` so that the .md file is stored in the vignette directory

I am trying to compile a package vignette such that the .md file stays in the vignette folder so that it still shows up on github. I use devtools

for all this. I reviewed this approach and outlined it below:

I have auto-generated vignette template using devtools::use_vignette()

. Then I changed the file .Rmd

to look like this (a truncated version of the template):

---
  title: "package"
author: "author"
date: "`r Sys.Date()`"
output:
  rmarkdown::html_vignette:
  toc: true
  keep_md: true
vignette: >
  %\VignetteIndexEntry{Vignette Title}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

  Vignettes are long form documentation commonly included in packages. Because they are part of the distribution of the package, they need to be as compact as possible. The `html_vignette` output type provides a custom style sheet (and tweaks some options) to ensure that the resulting html is as small as possible. The `html_vignette` format:

  - Never uses retina figures
- Has a smaller default figure size
- Uses a custom CSS stylesheet instead of the default Twitter Bootstrap style

## Vignette Info

Note the various macros within the `vignette` section of the metadata block above. These are required in order to instruct R how to build the vignette. Note that you should change the `title` field and the `\VignetteIndexEntry` to match the title of your vignette.

      

So .yaml

changed, but when I compile with devtools::build_vignettes()

, it doesn't leave the file .md

in the vignette directory. No error message and vignette are constructed in a way that is a little confusing.

So, to summarize the question, does anyone know how to compile a vignette using devtools::build_vignette

so that the main markdown file is stored in the vignette directory?

+3


source to share


1 answer


If you are open to functions other than build_vignette()

, then this is pretty straightforward, because at the end of the day, this is all just a wrapper for an outer binary pandoc

.

/tmp/vig> ls -l     ## start with nothing but Rmd
total 4
-rw-r--r-- 1 user grp 1015 Aug 10 14:21 soVig.Rmd
/tmp/vig> 
/tmp/vig> Rscript -e 'rmarkdown::render("soVig.Rmd", clean=FALSE)'


processing file: soVig.Rmd
  |.................................................................| 100%
   inline R code fragments


output file: soVig.knit.md

/usr/bin/pandoc +RTS -K512m -RTS soVig.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output soVig.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /usr/local/lib/R/site-library/rmarkdown/rmd/h/default.html --highlight-style pygments --css /usr/local/lib/R/site-library/rmarkdown/rmarkdown/templates/html_vignette/resources/vignette.css --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' 

Output created: soVig.html
/tmp/vig> ls -l soVig.*
-rw-r--r-- 1 user grp 7066 Aug 10 14:24 soVig.html
-rw-r--r-- 1 user grp 1011 Aug 10 14:24 soVig.knit.md
-rw-r--r-- 1 user grp 1015 Aug 10 14:21 soVig.Rmd
-rw-r--r-- 1 user grp 1011 Aug 10 14:24 soVig.utf8.md
/tmp/vig> 

      



so just to say render()

not to clean up, we get to save the source of the markdown.

+8


source







All Articles