simplify to single _episodes_rmd/data folder
[rnaseq-cwl-training.git] / bin / generate_md_episodes.R
1 generate_md_episodes <- function() {
2
3     if (require("knitr")) {
4         if (packageVersion("knitr") < '1.9.19') {
5             stop("knitr must be version 1.9.20 or higher")
6         }
7     } else stop("knitr 1.9.20 or above is needed to build the lessons.")
8
9     if (!require("stringr"))
10         stop("The package stringr is required for generating the lessons.")
11
12     ## find all the Rmd files, and generates the paths for their respective outputs
13     src_rmd <- list.files(pattern = "??-*.Rmd$", path = "_episodes_rmd", full.names = TRUE)
14     dest_md <- file.path("_episodes", gsub("Rmd$", "md", basename(src_rmd)))
15
16     ## knit the Rmd into markdown
17     mapply(function(x, y) {
18         knitr::knit(x, output = y)
19     }, src_rmd, dest_md)
20
21 }
22
23 generate_md_episodes()