-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
Description
I don't think this is documented anywhere and it can be surprising
https://community.rstudio.com/t/r-studio-build-book-for-bookmark-fail-if-makefile-exists/102023
What is possible is currently comment only
Lines 28 to 30 in 36f4dca
# Custom render function. bookdown rendering is more complex than | |
# for most formats and as a result uses a custom R script (_render.R) | |
# or Makefile to define what's required to render the book. |
Lines 65 to 66 in 36f4dca
# render the book via _render.R or Makefile, or fallback to render_book() | |
render_book_script = function(output_format = NULL, envir = globalenv(), quiet = TRUE) { |
We should add in the book or in ?bookdown::bookdown_site
so that it is explained:
- When build book in the IDE:
_render.R
is sourced to build the book if it exists- if not,
make
is called ifMakefile
file exists in the book project - if not,
bookdown::render_book("index.Rmd", ...)
is used
This allows advanced workflows when creating a book in combination with _output.yaml
containing several formats.
Which is mentioned in the book in two places:
bookdown/inst/examples/05-editing.Rmd
Line 14 in b66380e
Once all formats are specified in `_output.yml`, it is easy to write an R or Shell script or Makefile to compile the book. Below is a simple example of using a Shell script to compile a book to HTML (with the GitBook style) and PDF: |
bookdown/inst/examples/06-publishing.Rmd
Line 58 in b66380e
After you have set up GIT, the rest of work can be automated via a script (Shell, R, or Makefile, depending on your preference). Basically, you compile the book to HTML, then run git commands to push the files to GitHub, but you probably do not want to do this over and over again manually and locally. It can be very handy to automate the publishing process completely on the cloud, so once it is set up correctly, all you have to do next is write the book and push the Rmd source files to GitHub, and your book will always be automatically built and published from the server side. |
igelstorm