I am trying to follow closely @hadley's book to learn best practices in writing R packages. And I was thrilled to read these lines about the philosophy of the book:
anything that can be automated, should be automated. Do as little as possible by hand. Do as much as possible with functions.
So when I was reading about dependencies and the (sort of) confusing differences between import directives in the NAMESPACE file and the "Imports:" field in the DESCRIPTION file, I was hoping that roxygen2
would automatically handle both of them. After all
Every package mentioned in NAMESPACE must also be present in the Imports or Depends fields.
I was hoping that roxygen2
would take every @import in my functions and make sure it is included in the DESCRIPTION file. But it does not do that automatically.
So I either have to add it manually to the DESCRIPTION file or almost manually using devtools::use_package
.
Looking around for an answer, I found this question in SO, where @hadley confirms in the comments that
Currently, the namespace roclet will modify NAMESPACE but not DESCRIPTION
and other posts (e.g. here or here) where collate_roclet
is discussed, but "This only matters if your code has side-effects; most commonly because you’re using S4".
I wonder:
- the reason that DESCRIPTION is not automatically updated (sort of contradicting the aforementioned philosophy, which is presumably shared by
roxygen2
) and - If someone has already crafted a way to do it