Skip to content

Commit

Permalink
Include tangled source code in tarballs.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@62368 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
murdoch committed Mar 22, 2013
1 parent fd00c51 commit df53fc2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 30 deletions.
6 changes: 6 additions & 0 deletions doc/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,12 @@
\item Package vignettes can now be processed by other engines
besides \code{Sweave}; see \sQuote{Writing R Extensions} and the
\code{tools::vignetteEngine} help topic for details.
\item The \file{*.R} tangled \command{R CMD build} source code
for vignettes is now included in tarballs when \command{R CMD
build} is used to produce them. In \R 3.0.0, missing \file{*.R}
files will be produced at install time, but eventually this
will be dropped.
\item The package type \code{"mac.binary"} now results in a path
without Mac subtype (which used to be \code{"universal"}). This
Expand Down
9 changes: 6 additions & 3 deletions src/library/tools/R/admin.R
Original file line number Diff line number Diff line change
Expand Up @@ -521,12 +521,14 @@ function(dir, outDir, encoding = "")

loadVignetteBuilder(dir, mustwork = FALSE)

## install tangled versions of Sweave vignettes. FIXME: Custom
## engine vignettes should have been included when the package was built,
## install tangled versions of Sweave vignettes. FIXME: Vignette
## *.R files should have been included when the package was built,
## but in the interim before they are all built with the new code,
## this is needed for all packages.
## this is needed.
for(i in seq_along(vigns$docs)) {
file <- vigns$docs[i]
if (!is.null(vigns$sources) && !is.null(vigns$sources[i])) # already there?
next
file <- basename(file)
enc <- getVignetteEncoding(file, TRUE)
if(enc %in% c("non-ASCII", "unknown")) enc <- encoding
Expand All @@ -537,6 +539,7 @@ function(dir, outDir, encoding = "")
engine <- try(vignetteEngine(vigns$engines[i]), silent = TRUE)
if (!inherits(engine, "try-error"))
engine$tangle(file, quiet = TRUE, encoding = enc)
setwd(outVignetteDir) # just in case some strange tangle function changed it
}
setwd(cwd)

Expand Down
33 changes: 6 additions & 27 deletions src/library/tools/R/build.R
Original file line number Diff line number Diff line change
Expand Up @@ -344,16 +344,13 @@ get_exclude_patterns <- function()
Sys.setenv(R_LIBS = libdir)
}

# If a custom builder is used, we tangle all vignettes now in
# case the tangler is not available at INSTALL time.
# We could just tangle the custom ones, but mixed Sweave/custom
# vignettes are likely to be rare, and this is simpler
# Tangle all vignettes now. We'll try again at INSTALL time in 3.0.0,
# but eventually this is the only place the tangling will happen.

custom <- !is.na(desc["VignetteBuilder"])
cmd <- file.path(R.home("bin"), "Rscript")
args <- c("--vanilla",
"--default-packages=", # some vignettes assume methods
"-e", shQuote(paste0("tools::buildVignettes(dir = '.', tangle=", custom, ")")))
"-e", shQuote("tools::buildVignettes(dir = '.', tangle = TRUE)"))
## since so many people use 'R CMD' in Makefiles,
oPATH <- Sys.getenv("PATH")
Sys.setenv(PATH = paste(R.home("bin"), oPATH,
Expand All @@ -369,33 +366,15 @@ get_exclude_patterns <- function()
vigns <- pkgVignettes(dir = '.', output = TRUE, source = TRUE)
stopifnot(!is.null(vigns))

if (!custom) {
## Do any of the .R files which will be generated at install time
## exist in inst/doc? If so the latter should be removed.
sources <- basename(list_files_with_exts(doc_dir, "R"))
if (length(sources)) {
new_sources <- unlist(vigns$sources)
dups <- sources[sources %in% new_sources]
if(length(dups)) {
warningLog(Log)
printLog(Log,
paste(c(" Unused files in inst/doc which are pointless or misleading",
" as they will be re-created from the vignettes on installation:",
paste(" ", dups),
" have been removed", ""),
collapse = "\n"))
unlink(file.path(doc_dir, dups))
} else resultLog(Log, "OK")
} else resultLog(Log, "OK")
} else resultLog(Log, "OK")
resultLog(Log, "OK")
}

## We may need to install them.
if (basename(vigns$dir) == "vignettes") {
## inst may not yet exist
dir.create(doc_dir, recursive = TRUE, showWarnings = FALSE)
file.copy(c(vigns$docs, vigns$outputs), doc_dir)
unlink(vigns$outputs)
file.copy(c(vigns$docs, vigns$outputs, unlist(vigns$sources)), doc_dir)
unlink(c(vigns$outputs, unlist(vigns$sources)))
extras_file <- file.path("vignettes", ".install_extras")
if (file.exists(extras_file)) {
extras <- readLines(extras_file, warn = FALSE)
Expand Down

0 comments on commit df53fc2

Please sign in to comment.