Skip to content

Commit f6416a9

Browse files
committed
copy_manifest_files: fix when keep_full_path=TRUE
If a full path was required, we need to create any subdirs under codecheck/ before copying the files.
1 parent 3868bbb commit f6416a9

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

R/codecheck.R

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ copy_manifest_files <- function(root, metadata, dest_dir,
7272

7373
dest_files = file.path(dest_dir,
7474
if ( keep_full_path) outputs else basename(outputs))
75+
76+
## See if we need to make extra directories in the codecheck/outputs
77+
if (keep_full_path) {
78+
for (d in dest_files) {
79+
dir = dirname(d)
80+
if ( !dir.exists(dir) )
81+
dir.create(dir, recursive=TRUE)
82+
}
83+
}
7584
file.copy(src_files, dest_files, overwrite=TRUE)
7685
dest_files
7786
manifest_df = data.frame(output=outputs,
@@ -164,17 +173,30 @@ latex_summary_of_metadata <- function(metadata) {
164173
##' Format a latex table that summarises the main CODECHECK manifest
165174
##' @title Print a latex table to summarise CODECHECK metadata
166175
##' @param manifest_df - The manifest data frame
176+
##' @param root - root directory of the project
177+
##' @param align - alignment flags for the table.
167178
##' @return The latex table, suitable for including in the Rmd
168179
##' @author Stephen Eglen
169180
##' @export
170-
latex_summary_of_manifest <- function(manifest_df) {
181+
latex_summary_of_manifest <- function(manifest_df,
182+
root,
183+
align=c('l', 'p{6cm}', 'p{6cm}', 'p{2cm}')
184+
) {
171185
m = manifest_df[, c("output", "comment", "size")]
186+
urls = sub(root, sprintf('%s/blob/master', metadata$repository), manifest_df$dest)
187+
m1 = sprintf('\\href{%s}{\\path{%s}}',
188+
urls,
189+
m[,1],
190+
m[,1])
191+
m[,1] = m1
172192
names(m) = c("Output", "Comment", "Size (b)")
173193
xt = xtable(m,
174194
digits=0,
175195
caption="Summary of output files generated",
176-
align=c('l', 'p{5cm}', 'p{5cm}', 'p{2cm}'))
177-
print(xt, include.rownames=FALSE, comment=FALSE)
196+
align=align)
197+
print(xt, include.rownames=FALSE,
198+
sanitize.text.function = function(x){x},
199+
comment=FALSE)
178200
}
179201

180202
##' Print the latex code to include the CODECHECK logo

0 commit comments

Comments
 (0)