@@ -80,25 +80,35 @@ extractManuals <- function(reposRoot, srcContrib, destDir) {
80
80
# # helper function to unpack pdf & Rd files from the vig
81
81
cleanUnpackDir(tarball , unpackDir , " man" , " .*\\ .(pdf|Rd|rd)$" )
82
82
ret <- unpack(tarball , unpackDir , " " )
83
- if (ret != 0 )
84
- stop(" non-zero exit status " , ret , " extracting " , tarball )
83
+ if (ret != 0 ) {
84
+ warning(" non-zero exit status " , ret , " extracting " , tarball )
85
+ return (FALSE )
86
+ }
85
87
pkg <- pkgName(tarball )
86
88
pkgDir <- file.path(unpackDir , pkg )
87
89
pkgManDir <- file.path(pkgDir , " man" )
88
- if (dir.exists(pkgManDir ))
89
- unlink(pkgManDir , recursive = TRUE )
90
- tmp_file <- paste(file.path(pkgDir , pkg ), " pdf" , sep = " ." )
90
+ # Remove if exists without an .Rd file
91
+ if (dir.exists(pkgManDir ) &&
92
+ length(list.files(pkgManDir , pattern = " .*\\ .(Rd|rd)" )) == 0 )
93
+ unlink(pkgManDir , recursive = TRUE )
94
+ tmp_file <- file.path(pkgDir , paste0(pkg , " .pdf" ))
91
95
r_path <- file.path(Sys.getenv(" R_HOME" ), " bin" , " R" )
92
96
CmdRd2pdf <- paste0(" CMD Rd2pdf --no-preview --output=" , tmp_file ,
93
- " --title=" , pkg , " " , pkgDir )
94
- print(paste(r_path , CmdRd2pdf ))
95
- system2(r_path , CmdRd2pdf , stdout = FALSE , stderr = FALSE )
96
- if (! file.exists(tmp_file ))
97
- stop(" non-zero exit status " , ret , " building ref man: " , pkg )
97
+ " --force --title=" , pkg , " " , pkgDir )
98
+ ret <- system2(r_path , CmdRd2pdf , stdout = FALSE , stderr = FALSE )
99
+ if (! file.exists(tmp_file ) || ret != 0 ) {
100
+ warning(" non-zero exit status " , ret , " building ref man " , pkg )
101
+ return (FALSE )
102
+ }
98
103
if (! dir.exists(pkgManDir ))
99
104
dir.create(pkgManDir )
100
- file.rename(tmp_file ,
101
- paste(file.path(pkgManDir , pkg ), " pdf" , sep = " ." ))
105
+ file.copy(tmp_file , file.path(pkgManDir , paste0(pkg , " .pdf" )),
106
+ overwrite = TRUE )
107
+ pkgFiles <- list.files(pkgDir )
108
+ pkgFiles <- pkgFiles [! grepl(" man" , pkgFiles )]
109
+ pkgFiles <- unname(sapply(pkgFiles ,
110
+ function (pkgFiles ) file.path(pkgDir , pkgFiles )))
111
+ unlink(pkgFiles , recursive = TRUE )
102
112
cleanUnpackDir(tarball , unpackDir , " man" , " .*\\ .(Rd|rd)$" )
103
113
TRUE
104
114
}
0 commit comments