Skip to content

Commit

Permalink
Merge pull request #744 from DyfanJones/main
Browse files Browse the repository at this point in the history
Improve performance of paws build functions
  • Loading branch information
DyfanJones authored Jan 12, 2024
2 parents b808ad3 + e8ebdee commit beb8e31
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions make.paws/R/sdk_helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -412,26 +412,30 @@ paws_gsub <- function(
cran_r <- lapply(
cran_pkg, \(x) fs::dir_ls(file.path(x, "R"))
)
cran_rd <- lapply(
cran_pkg, \(x) fs::dir_ls(file.path(x, "man"))
)
log_info(
"Removed escaped latex scripts from paws directory."
)

cran_file_gsub <- function(before, after, files) {
for (file in files) {
result <- readLines(file)
result <- gsub(before, after, result)
writeLines(result, file)
found <- grep(before, after, result)
if (length(found) > 0) {
result[found] <- gsub(before, after, result[found])
writeLines(result, file)
}
}
}
for (pkg in cran_pkg) {
cran_file_gsub(before, after, cran_r[[pkg]])
log_info("Successfully update package: %s", pkg)
}
for (file in paws_r) {
result <- readLines(file)
result <- gsub(before, after, result)
writeLines(result, file)
log_info("Successfully update package R scripts: %s", pkg)
cran_file_gsub(before, after, cran_rd[[pkg]])
log_info("Successfully update package rd documentation: %s", pkg)
}
cran_file_gsub(before, after, paws_r)
}

#' @title Rebuild paws documentation
Expand Down

0 comments on commit beb8e31

Please sign in to comment.