Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: dependencies() to scan NAMESPACE files #1637

Closed
mmuurr opened this issue Aug 10, 2023 · 1 comment · Fixed by #1646
Closed

Feature request: dependencies() to scan NAMESPACE files #1637

mmuurr opened this issue Aug 10, 2023 · 1 comment · Fixed by #1646
Labels
dependencies 👶 feature a feature request or enhancement

Comments

@mmuurr
Copy link

mmuurr commented Aug 10, 2023

At present, dependencies() will perform a static analysis of R files. I find this very useful during development as a mechanism to help build the Imports section of a package's DESCRIPTION file; e.g.:

package_imports <- renv::dependencies("R/")$Package
purrr::walk(package_imports, usethis::use_package, type = "Imports", min_version = TRUE)

The only problem is the static analysis skips the NAMESPACE file, which itself is based on roxygen2 tags, and includes some imports. For example, I might have the tag #' @importFrom foo bar, yielding the NAMESPACE entry:

importFrom(foo, bar)

It'd be useful if dependencies() also read the NAMESPACE file to identify additional packages.

FWIW, there's a base parseNamespaceFile() function, which can be run (here from within the nascent package's root) like so:

parseNamespaceFile("packagename", "..")

One would still need to know how to deal with the various outputs -- each type corresponding to each unique NAMESPACE directive, but fortunately new NAMESPACE directives don't come around too often :-)

@kevinushey kevinushey added this to the 1.0.2 milestone Aug 10, 2023
@kevinushey kevinushey added feature a feature request or enhancement dependencies 👶 labels Aug 10, 2023
@mmuurr
Copy link
Author

mmuurr commented Aug 14, 2023

Amazing; thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies 👶 feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants