bcgov / bcgovr

An R package to automate set up and sharing of R projects in bcgov GitHub following bcgov guidelines
Apache License 2.0
34 stars 5 forks source link

Package vignettes for package_skeleton #11

Closed boshek closed 7 years ago

boshek commented 7 years ago

Because the vast majority of packages created here will not end up on CRAN the build_vignettes() function in devtools may prove problematic because it doesn't keep a .md file around that is easily readable for github. For README's this isn't a problem as we can set the .yaml to something like this:

---
output:
  md_document:
    variant: markdown_github
---

However for a vignette this isn't the typical .yaml. Since vignettes are a critical way of communicating a package I wonder if some sort of custom rendering function might be useful. There are likely other ways to do this but one option is to define a function like this to keep the .md file so that at least it can pointed to on github

render_keep_md = function(vignette_name){
  rmarkdown::render(paste0("./vignettes/",vignette_name, ".Rmd"), clean=FALSE)
  files_to_remove = paste0("./vignettes/",vignette_name,c(".html",".md",".utf8.md"))
  lapply(files_to_remove, file.remove)

  file.rename(from = paste0("./vignettes/",vignette_name, ".knit.md"), to = paste0("./vignettes/",vignette_name, ".md"))
}
boshek commented 7 years ago

I think this is probably beyond the scope of bcgovr and more likely up to individual package authors.