createMakefile: Create a compilation Makefile

View source: R/createMakefile.R

createMakefileR Documentation

Create a compilation Makefile

Description

Create a Makefile for compiling individual chapters, in a manner that respects the dependencies between chapters.

Usage

createMakefile(dir = ".", pattern = "\\.Rmd$", ..., fname = "Makefile")

Arguments

dir

String containing the path to the directory containing Rmarkdown reports. This is searched recursively for all files ending in ".Rmd".

...

Further arguments to pass to buildChapterGraph.

fname

String containing the name of the output Makefile.

Details

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 knitting 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.

Value

A Makefile is created in dir with the name fname and a NULL is invisibly returned.

Author(s)

Aaron Lun

See Also

buildChapterGraph, to detect dependencies between chapters.

Examples

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")


LTLA/rebook documentation built on June 5, 2023, 6:24 p.m.