Skip to content

Commit 9152666

Browse files
author
hornik
committed
Tweaks for .R_top_srcdir_from_Rd().
git-svn-id: https://svn.r-project.org/R/trunk@89012 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 56e6c74 commit 9152666

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

src/library/tools/R/admin.R

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -871,12 +871,14 @@ function(dir, outDir, encoding = "unknown")
871871
}
872872
pathsFile <- file.path(manOutDir, "paths.rds")
873873
## Avoid (costly) rebuilding if not needed.
874-
## 'make Rdobjects' now takes 13s compared to 0.5s if remaking skips the below.
875-
## This tests if the Rd DB from a previous 'make' can be fully kept or needs
876-
## updating, but ignores that a dynamic help page may need reprocessing even
877-
## without modifying the source Rd file. With the advent of \bibshow, many
878-
## help pages have become dynamic and always rebuilding these is tedious ...
879-
## So for now only do a full rebuild when the system macros were touched.
874+
## 'make Rdobjects' now takes 13s compared to 0.5s if remaking skips
875+
## the below. This tests if the Rd DB from a previous 'make' can be
876+
## fully kept or needs updating, but ignores that a dynamic help
877+
## page may need reprocessing even without modifying the source Rd
878+
## file. With the advent of \bibshow, many help pages have become
879+
## dynamic and always rebuilding these is tedious ...
880+
## So for now only do a full rebuild when the system macros were
881+
## touched.
880882
system_file <- file.path(R.home("share"), "Rd", "macros", "system.Rd")
881883
if (!file.exists(db_file) || # first build, including from .install_packages
882884
file_test("-nt", system_file, db_file)) {
@@ -891,9 +893,13 @@ function(dir, outDir, encoding = "unknown")
891893
db <- .build_Rd_db(dir, manfiles, db_file = db_file,
892894
encoding = encoding, built_file = built_file)
893895
nm <- as.character(names(db)) # Might be NULL
894-
saveRDS(structure(nm,
895-
first = nchar(file.path(mandir)) + 2L),
896-
pathsFile)
896+
at <- c(list(first = nchar(file.path(mandir)) + 2L),
897+
if(basename(dir) == "tools") {
898+
## We could use 3 dirname() calls, but perhaps more
899+
## easily:
900+
list(top = substr(dir, 1L, nchar(dir) - 18L))
901+
})
902+
saveRDS(`attributes<-`(nm, at), pathsFile)
897903
names(db) <- sub("\\.[Rr]d$", "", basename(nm))
898904
makeLazyLoadDB(db, file.path(manOutDir, packageName))
899905
}

src/library/tools/R/utils.R

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -627,12 +627,8 @@ function(year)
627627

628628
.R_top_srcdir_from_Rd <-
629629
function() {
630-
filebase <-
631-
file_path_sans_ext(system.file("help", "tools.rdb",
632-
package = "tools"))
633-
path <- attr(fetchRdDB(filebase, "QC"), "Rdfile")
634-
## We could use 5 dirname() calls, but perhaps more easily:
635-
substr(path, 1L, nchar(path) - 28L)
630+
attr(readRDS(system.file("help", "paths.rds", package = "tools")),
631+
"top")
636632
}
637633

638634
## Unfortunately,

0 commit comments

Comments
 (0)