Description
roxygen2::roxygenize()
requires loading the package because it runs pkgload::load_all()
. It was requested to loosen this requirement, but unsuccessfully: r-lib/roxygen2#771. Package loading requires all dependencies (depends, imports, suggests) to be present in the renv. No other hook requires this currently and I don't think pre-commit is designed to work that way. Only the hook repo is installed, not the repo where the hooks are ran. Also, this would need a different renv for every user repo (thanks to the renv cache, this is not a big deal in terms of disk space). Using additional_dependencies: ["."]
does not work, e.g. because of cache invalidation.
Potential ways out:
- make roxygenize no longer needing to load the package.
- use
language: script
for roxygen hook (knowing this won't work on pre-commit.ci). - listing all dependencies in
additional_dependencies
,potentially parse and write them with(can't be done because comments are lost with read/write with {yaml}).precommit::use_precommit()
. Add validation hook that copies over fromDESCRIPTION
to pre-commit config (or in roxygenize hook itself). Be careful with versions use secondary library path for roxygen hook(complicated with {renv}, different local file systems etc.).
Maybe add tests for roxygenize. There are only tests for cache functionality for this hook (can't remember but probably it was hard to do so). Probably use file_transformer
in run_test()
.