@@ -826,39 +826,41 @@ function(dir) {
826826
827827# ## * .install_package_Rd_objects
828828
829- # # called from src/library/Makefile
829+ # # called from src/library/Makefile and .install_packages
830830.install_package_Rd_objects <-
831831function (dir , outDir , encoding = " unknown" )
832832{
833+ packageName <- basename(outDir )
833834 dir <- file_path_as_absolute(dir )
834835 mandir <- file.path(dir , " man" )
835836 manfiles <- if (! dir.exists(mandir )) character ()
836- else list_files_with_type(mandir , " docs" )
837+ else list_files_with_type(mandir , " docs" )
837838 manOutDir <- file.path(outDir , " help" )
838839 dir.create(manOutDir , FALSE )
839- db_file <- file.path(manOutDir ,
840- paste0(basename(outDir ), " .rdx" ))
840+ db_file <- file.path(manOutDir , paste0(packageName , " .rdx" ))
841841 built_file <- file.path(dir , " build" , " partial.rdb" )
842- macro_files <- list.files(file.path(dir , " man" , " macros" ), pattern = " \\ .Rd$" , full.names = TRUE )
842+ macro_files <- list.files(file.path(dir , " man" , " macros" ),
843+ pattern = " \\ .Rd$" , full.names = TRUE )
843844 if (length(macro_files )) {
844845 macroDir <- file.path(manOutDir , " macros" )
845846 dir.create(macroDir , FALSE )
846847 file.copy(macro_files , macroDir , overwrite = TRUE )
847848 }
848849 # # Avoid (costly) rebuilding if not needed.
849- # # Actually, it seems no more costly than these tests, which it also does
850+ # # Remaking Rdobjects of base packages takes 4s, but only 0.5s if skipped.
850851 pathsFile <- file.path(manOutDir , " paths.rds" )
851- if (! file_test(" -f" , db_file ) || ! file.exists(pathsFile ) ||
852- ! identical(sort(manfiles ), sort(readRDS(pathsFile ))) ||
853- ! all(file_test(" -nt" , db_file , manfiles ))) {
852+ upToDate <- file_test(" -f" , db_file ) && file.exists(pathsFile ) &&
853+ identical(sort(manfiles ), sort(readRDS(pathsFile ))) &&
854+ all(file_test(" -nt" , db_file , manfiles ))
855+ if (! upToDate ) {
854856 db <- .build_Rd_db(dir , manfiles , db_file = db_file ,
855857 encoding = encoding , built_file = built_file )
856858 nm <- as.character(names(db )) # Might be NULL
857859 saveRDS(structure(nm ,
858860 first = nchar(file.path(mandir )) + 2L ),
859861 pathsFile )
860862 names(db ) <- sub(" \\ .[Rr]d$" , " " , basename(nm ))
861- makeLazyLoadDB(db , file.path(manOutDir , basename( outDir ) ))
863+ makeLazyLoadDB(db , file.path(manOutDir , packageName ))
862864 }
863865 invisible ()
864866}
0 commit comments