Question

Running R CMD roxygen on a big package can take quite a long time. It's obviously inefficient as well as it goes through everything regardless of whether a file has changed since the last roxygen call.

Any tips on how to speed things up?

Was it helpful?

Solution

Roxygen2 > 3.0.0 is substantially faster, and no longer needs caching.


In my local version of roxygen, I have:

library(memoize)
cached.parse.ref <- memoize(parse.ref)
cached.parse.srcfile <- memoize(parse.srcfile)

parse.file <- function(file) {
  srcfile <- srcfile(file)

  res <- try(cached.parse.srcfile(srcfile), silent = TRUE)
  if (inherits(res, "try-error")) {
    stop("Can't pass", file, "\n", res, call. = FALSE)
  }
  res
}

parse.srcfile <- function(srcfile) {
  srcrefs <- attributes(parse(srcfile$filename,
                              srcfile=srcfile))$srcref
  if (length(srcrefs) > 0)
    parse.refs(zip.list(prerefs(srcfile, srcrefs), srcrefs))
  else
    nil

}

I think those are the only changes you need, but I'm not sure. It speeds up roxygen by an order of magnitude.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top