Merge branch 'move-data' of https://github.com/fmichonneau/styles into fmichonneau...
authorGreg Wilson <gvwilson@third-bit.com>
Tue, 28 Jun 2016 16:01:44 +0000 (12:01 -0400)
committerGreg Wilson <gvwilson@third-bit.com>
Tue, 28 Jun 2016 16:01:44 +0000 (12:01 -0400)
_episodes_rmd/data/.gitkeep [new file with mode: 0644]
bin/generate_md_episodes.R

diff --git a/_episodes_rmd/data/.gitkeep b/_episodes_rmd/data/.gitkeep
new file mode 100644 (file)
index 0000000..e69de29
index cbb6783d6dbb79ab5bb3680da6589ba150897a18..43bf65e118eea26b7900b3fd1a31d8ec2170ffd2 100644 (file)
@@ -1,15 +1,23 @@
-if (require("knitr")) {
-    if (packageVersion("knitr") < '1.9.19') {
-        stop("knitr must be version 1.9.20 or higher")
-    }
-} else stop("knitr 1.9.20 or above is needed to build the lessons.")
+generate_md_episodes <- function() {
 
-if (!require("stringr"))
-    stop("The package stringr is required for generating the lessons.")
+    if (require("knitr")) {
+        if (packageVersion("knitr") < '1.9.19') {
+            stop("knitr must be version 1.9.20 or higher")
+        }
+    } else stop("knitr 1.9.20 or above is needed to build the lessons.")
 
-src_rmd <- list.files(pattern = "??-*.Rmd$", path = "_episodes_rmd", full.names = TRUE)
-dest_md <- file.path("_episodes", gsub("Rmd$", "md", basename(src_rmd)))
+    if (!require("stringr"))
+        stop("The package stringr is required for generating the lessons.")
 
-mapply(function(x, y) {
+    ## find all the Rmd files, and generates the paths for their respective outputs
+    src_rmd <- list.files(pattern = "??-*.Rmd$", path = "_episodes_rmd", full.names = TRUE)
+    dest_md <- file.path("_episodes", gsub("Rmd$", "md", basename(src_rmd)))
+
+    ## knit the Rmd into markdown
+    mapply(function(x, y) {
         knitr::knit(x, output = y)
     }, src_rmd, dest_md)
+
+}
+
+generate_md_episodes()