View source: R/createMakefile.R
createMakefile | R Documentation |
Create a Makefile for compiling individual chapters, in a manner that respects the dependencies between chapters.
createMakefile(dir = ".", pattern = "\\.Rmd$", ..., fname = "Makefile")
dir |
String containing the path to the directory containing Rmarkdown reports.
This is searched recursively for all files ending in |
... |
Further arguments to pass to |
fname |
String containing the name of the output Makefile. |
The main benefit of using a Makefile is that the generation of the chapter caches can be done in parallel. Then, the bookdown step can just serially retrieve the cache contents for rapid rendering.
The Makefile uses the markdown output file as an indicator of successful knit
ting of a chapter.
Caches are left in the current working directory after the compilation of each report.
It is assumed that bookdown's render_book
is smart enough to find and use these caches.
A Makefile is created in dir
with the name fname
and a NULL
is invisibly returned.
Aaron Lun
buildChapterGraph
, to detect dependencies between chapters.
dir <- tempfile()
dir.create(dir)
tmp1 <- file.path(dir, "alpha.Rmd")
write(file=tmp1, "```{r, echo=FALSE, results='asis'}
rebook::chapterPreamble()
```
```{r}
rodan <- 1
```")
tmp2 <- file.path(dir, "bravo.Rmd")
write(file=tmp2, "```{r, echo=FALSE, results='asis'}
rebook::chapterPreamble()
```
```{r}
extractCached('alpha.Rmd')
```")
# Creating the Makefile:
createMakefile(dir)
cat(readLines(file.path(dir, "Makefile")), sep="\n")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.