Skip to content

Commit

Permalink
it is too early to decide whether to turn off tangle in vig_engine(),…
Browse files Browse the repository at this point in the history
… because vig_engine() is called during package startup
  • Loading branch information
yihui committed Apr 23, 2015
1 parent 08e04c4 commit 0016c22
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions R/utils-vignettes.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#' vig_list[['knitr::docco_classic']][c('weave', 'tangle')]
NULL

vweave = vtangle = function(file, driver, syntax, encoding = 'UTF-8', quiet = FALSE, ...) {
vweave = function(file, driver, syntax, encoding = 'UTF-8', quiet = FALSE, ...) {
opts_chunk$set(error = FALSE) # should not hide errors
knit_hooks$set(purl = hook_purl) # write out code while weaving
options(markdown.HTML.header = NULL)
Expand All @@ -39,7 +39,14 @@ vweave = vtangle = function(file, driver, syntax, encoding = 'UTF-8', quiet = FA
)
}

body(vtangle)[5L] = expression(purl(file, encoding = encoding, quiet = quiet))
vtangle = function(file, ..., encoding = 'UTF-8', quiet = FALSE) {
if (is_R_CMD_check()) {
file = sub_ext(file, 'R')
file.create(file)
return(file)
}
purl(file, encoding = encoding, quiet = quiet)
}

vweave_docco_linear = vweave
body(vweave_docco_linear)[5L] = expression(knit2html(
Expand Down Expand Up @@ -99,11 +106,6 @@ register_vignette_engines = function(pkg) {
}
# all engines use the same tangle and package arguments, so factor them out
vig_engine = function(..., tangle = vtangle) {
if (missing(tangle) && is_R_CMD_check()) tangle = function(file, ...) {
file = sub_ext(file, 'R')
file.create(file)
file
}
vig_engine0(..., tangle = tangle, package = 'knitr', aspell = list(
filter = knit_filter
))
Expand Down

0 comments on commit 0016c22

Please sign in to comment.