以下是对代码库调查的一些结果:
我们可以看到 'config' 变量bookdown::render_book
填充自_bookdown.yml
here https://github.com/rstudio/bookdown/blob/1254a81864c7d0e1d165eda58d9fb08fe3a9bc71/R/render.R#L63,通过一个名为load_config
可以在以下位置找到:utils.R https://github.com/rstudio/bookdown/blob/master/R/utils.R#L79.
load_config
似乎做了两件事 - 它存储的内容config
在名为的主选项列表中opts
, 其中config
只是一个元素,然后返回config
元素。
注意opts
最初定义为here https://github.com/rstudio/bookdown/blob/master/R/utils.R#L247。它是从一个创建的knitr:::new_defaults
可以找到here https://github.com/yihui/knitr/blob/f02600d24a9628c8a376df41078756dc9e63bfc2/R/defaults.R#L3.
The config
然后变量出现在代码库的多个部分中。
The 以下代码 https://github.com/rstudio/bookdown/blob/1254a81864c7d0e1d165eda58d9fb08fe3a9bc71/R/render.R#L88具有代表性:
if (is.na(new_session)) {
new_session = FALSE
if (is.logical(config[['new_session']])) new_session = config[['new_session']]
}
所以我们可以看到如果new_session
被直接传递到bookdown::render_book
作为函数参数,它被使用。否则会尝试从_bookdown.yml
file.
The config
作为一个参数被广泛传递bookdown::render_book
。例如,我们可以看到它被用于source_files https://github.com/rstudio/bookdown/blob/master/R/utils.R#L93函数于utils.R
.
我们得出什么结论?_bookdown.yml
允许您填充全局选项列表bookdown
包裹。每当你看到config
(这是一个列表)正在使用代码库,您可以通过填充来设置此列表的元素_bookdown.yml
我还没有找到可以在中指定的选项的完整列表_bookdown.yml
但轻松找出可能性的一种方法是.