compileBook | R Documentation |
Copy a bookdown book to a separate workspace prior to compilation, and then copy the compiled book to a final location.
preCompileBook(src.dir, work.dir, desc = NULL)
postCompileBook(work.dir, final.dir, handle = NULL)
src.dir |
String containing the path to the book Rmarkdown sources. |
work.dir |
String containing the path to the versioned cache directory used to compile the book, see the dir.expiry package for details. |
desc |
String containing the path to a |
final.dir |
String containing the path to the final location for the compiled book's HTMLs. |
handle |
The lock handle returned by |
These two functions should bracket a render_book
call.
We do not make these into a single function as calling render_book
inside another function inside a package does not interact properly with some imports.
The offending example is that of cbind
, which fails to be converted into an S4 generic (this would normally happen when BiocGenerics gets attached).
preCompileBook
may take some time as it will compile all chapters via compileChapter
.
It does so by locking and unlocking each chapter as it is compiled, thus avoiding problems with concurrent attempts to compile the same chapter via extractFromPackage
.
(Concurrent compilation of different chapters is still supported and allows for parallel package builds.)
The actual compilation of the book with bookdown will simply re-use these caches for efficiency.
After compilation of the individual chapters, preCompileBook
will lock the entire work.dir
.
This ensures that bookdown's directory shuffling does not break concurrent processes using the knitr cache directories.
The lock can be released by passing the returned handle to handle
in postCompileBook
.
For preCompileBook
, work
is populated with the book sources and intermediate content (e.g., caches).
A lock handle is returned.
For postCompileBook
, final
is populated with the HTMLs.
Cache directories are moved out of _bookdown_files
into their original location.
In both cases, a NULL
is invisibly returned.
Aaron Lun
configureBook
, where this function is called in the Makefile.
bookCache
, the default choice for work.dir
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.