Skip to content

Commit

Permalink
cosmetics for debugging
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@87098 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
maechler committed Sep 5, 2024
1 parent c2b71f8 commit c501d00
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/library/utils/R/Sweave.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# File src/library/utils/R/Sweave.R
# Part of the R package, https://www.R-project.org
#
# Copyright (C) 1995-2023 The R Core Team
# Copyright (C) 1995-2024 The R Core Team
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -181,7 +181,7 @@ Sweave <- function(file, driver = RweaveLatex(),
on.exit() # clear action to finish with error = TRUE
drobj$srcFilenames <- srcFilenames
driver$finish(drobj)
}
} ## end{ Sweave }

SweaveReadFile <- function(file, syntax, encoding = "")
{
Expand Down Expand Up @@ -285,8 +285,7 @@ SweaveReadFile <- function(file, syntax, encoding = "")
attr(text, "srcLinenum") <- srcLinenum
attr(text, "srcFilenum") <- srcFilenum
text
}

} ## end{ SweaveReadFile }


###**********************************************************
Expand Down Expand Up @@ -416,14 +415,17 @@ SweaveHooks <- function(options, run = FALSE, envir = .GlobalEnv)
}

### For R CMD xxxx ------------------------------------------
.Sweave <- function(args = NULL, no.q = interactive())
.Sweave <- function(args = NULL, no.q = interactive(),
verbose = no.q || nzchar(Sys.getenv("R_DEBUG_dotSweave")))
{
options(warn = 1)
op <- options(warn = 1)
if(no.q) on.exit(options(op))
if (is.null(args)) {
args <- commandArgs(TRUE)
args <- paste(args, collapse=" ")
args <- strsplit(args,'nextArg', fixed = TRUE)[[1L]][-1L]
}
if(verbose) { cat(".Sweave args:\n"); str(args) }

Usage <- function() {
cat("Usage: R CMD Sweave [options] file",
Expand Down Expand Up @@ -515,20 +517,21 @@ SweaveHooks <- function(options, run = FALSE, envir = .GlobalEnv)
Usage()
do_exit(1L)
}
## arguments for buildVignette():
args <- list(file=file, tangle=FALSE, latex=toPDF, engine=engine, clean=clean)
if(nzchar(driver)) args <- c(args, driver = driver)
args <- c(args, encoding = encoding)
if(nzchar(options)) {
opts <- eval(str2expression(paste0("list(", options, ")")))
args <- c(args, opts)
}
if(verbose) { cat("Calling tools::buildVignette() with args\n"); str(args) }
output <- do.call(tools::buildVignette, args)
message("Output file: ", output)
if (toPDF && compact != "no"
&& length(output) == 1 && grepl(".pdf$", output, ignore.case=TRUE)) {
## <NOTE>
## Same code as used for --compact-vignettes in
## .build_packages() ...
## Same code as used for --compact-vignettes in .build_packages()
message("Compacting PDF document")
if(compact %in% c("gs", "gs+qpdf", "both")) {
gs_cmd <- tools::find_gs_cmd(Sys.getenv("R_GSCMD", ""))
Expand All @@ -548,11 +551,12 @@ SweaveHooks <- function(options, run = FALSE, envir = .GlobalEnv)
message(paste(format(res), collapse = "\n"))
}
do_exit()
}
} # end {.Sweave}

.Stangle <- function(args = NULL, no.q = interactive())
{
options(warn = 1)
op <- options(warn = 1)
if(no.q) on.exit(options(op))
if (is.null(args)) {
args <- commandArgs(TRUE)
args <- paste(args, collapse=" ")
Expand Down

0 comments on commit c501d00

Please sign in to comment.