Speeding up roxygen
Asked Answered
Z

1

11

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?

Zaragoza answered 20/1, 2011 at 15:29 Comment(0)
F
12

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.

Fletafletch answered 20/1, 2011 at 20:43 Comment(4)
Is your fork of Roxygen available on GitHub?Proteose
Not yet - I still keep hoping that roxygen development will come back to life.Fletafletch
Couldn't hurt to post it with a disabled issue tracker and a disclaimer that states you are not the maintainer and directs users to the Roxygen mailing list. The increased traffic could motivate development efforts.Proteose
Thanks, downloaded your version of roxygen and it's indeed lots faster.Zaragoza

© 2022 - 2024 — McMap. All rights reserved.