Skip to content

Commit a4c97d8

Browse files
committed
fix #932: deprecate the clean_envir argument of render_book(), and use xfun::Rscript_call() to render multiple output formats (with each format in a new R session, so the formats aren rendered independently)
1 parent 4bff22c commit a4c97d8

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: bookdown
22
Type: Package
33
Title: Authoring Books and Technical Documents with R Markdown
4-
Version: 0.20.4
4+
Version: 0.20.5
55
Authors@R: c(
66
person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
77
person("JJ", "Allaire", role = "ctb"),
@@ -62,7 +62,7 @@ Imports:
6262
htmltools (>= 0.3.6),
6363
knitr (>= 1.22),
6464
rmarkdown (>= 2.3),
65-
xfun (>= 0.6),
65+
xfun (>= 0.13),
6666
tinytex (>= 0.12)
6767
Suggests:
6868
htmlwidgets,

NEWS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
- Make sure `search_index.json` contains valid characters for the JSON format (thanks, @wlandau, #913).
88

9-
## MINOR CHANGES
9+
## MAJOR CHANGES
1010

1111
- The `--file-scope` behavior introduced in bookdown v0.20 is now disabled by default. This is due to broken TOC links for duplicate section names (e.g., "Exercises"; see #909) that have automatically generated identifiers.
1212

13+
- The `clean_envir` argument of `bookdown::render_book()` has been deprecated and will be removed in the future (thanks, @jenslaufer, #932).
14+
1315
# CHANGES IN bookdown VERSION 0.20
1416

1517
## NEW FEATURES

R/render.R

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
#' @param output_format,...,clean,envir Arguments to be passed to
1616
#' \code{rmarkdown::\link{render}()}. For \code{preview_chapter()}, \code{...}
1717
#' is passed to \code{render_book()}.
18-
#' @param clean_envir Whether to clean up the environment \code{envir} before
19-
#' rendering the book. By default, the environment is cleaned when rendering
20-
#' the book in a non-interactive R session.
18+
#' @param clean_envir This argument has been deprecated and will be removed in
19+
#' future versions of \pkg{bookdown}.
2120
#' @param output_dir The output directory. If \code{NULL}, a field named
2221
#' \code{output_dir} in the configuration file \file{_bookdown.yml} will be
2322
#' used (possibly not specified, either, in which case a directory name
@@ -51,15 +50,18 @@ render_book = function(
5150
output_format = rmarkdown::all_output_formats(input)
5251
}
5352
if (length(output_format) > 1) {
54-
return(unlist(lapply(output_format, function(fmt) render_book(
53+
return(unlist(lapply(output_format, function(fmt) xfun::Rscript_call(render_book, list(
5554
input, fmt, ..., clean = clean, envir = envir, output_dir = output_dir,
5655
new_session = new_session, preview = preview, config_file = config_file
57-
))))
56+
)))))
5857
}
5958
format = target_format(output_format)
6059
}
6160

62-
if (clean_envir) rm(list = ls(envir, all.names = TRUE), envir = envir)
61+
if (!missing(clean_envir)) warning(
62+
"The argument 'clean_envir' has been deprecated and will be removed in future ",
63+
"versions of bookdown."
64+
)
6365

6466
if (config_file != '_bookdown.yml') {
6567
unlink(tmp_config <- tempfile('_bookdown_', '.', '.yml'))

man/render_book.Rd

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)