Skip to content

Commit

Permalink
tweak Rd2pdf's graphicspath setup, avoiding redundant rewrites
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@87660 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
smeyer committed Jan 28, 2025
1 parent 334afd6 commit 836c2a2
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/library/tools/R/Rd2pdf.R
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
outfile <- paste0(basename(pkgdir), "-pkg.tex")

hasFigures <- FALSE
graphicspath <- NULL

## First check for a latex dir (from R CMD INSTALL --latex).
## Second guess is this is a >= 2.10.0 package with stored .rds files.
Expand Down Expand Up @@ -262,15 +263,10 @@
outputEncoding = outputEncoding,
defines = NULL, # already processed
writeEncoding = FALSE)
if (attr(res, "hasFigures")) {
lines <- readLines(outfilename)
graphicspath <- file.path(pkgdir, "help", "figures")
writeLines(c(.file_path_to_LaTeX_graphicspath(graphicspath),
lines),
outfilename)
hasFigures <- TRUE
}
hasFigures <- hasFigures || attr(res, "hasFigures")
}
if (hasFigures)
graphicspath <- file.path(pkgdir, "help", "figures")
if (!silent) message(domain = NA)
} else {
## As from R 2.15.3, give priority to a man dir.
Expand Down Expand Up @@ -342,15 +338,10 @@
outputEncoding = outputEncoding,
writeEncoding = FALSE,
macros = macros)
if (attr(res, "hasFigures")) {
lines <- readLines(outfilename)
graphicspath <- file.path(mandir, "figures")
writeLines(c(.file_path_to_LaTeX_graphicspath(graphicspath),
lines),
outfilename)
hasFigures <- TRUE
}
hasFigures <- hasFigures || attr(res, "hasFigures")
}
if (hasFigures)
graphicspath <- file.path(mandir, "figures")
if (!silent) message(domain = NA)
}
}
Expand All @@ -371,6 +362,10 @@
cat("\n\\chapter{The \\texttt{", basename(pkgdir), "} package}\n",
sep = "", file = outcon)

if (!is.null(graphicspath))
cat(.file_path_to_LaTeX_graphicspath(graphicspath), "\n",
sep = "", file = outcon)

## Extract (LaTeX-escaped, ASCII) \name for sorting.
topics <- rep("", length(files))
names(topics) <- files
Expand Down

0 comments on commit 836c2a2

Please sign in to comment.