-
Notifications
You must be signed in to change notification settings - Fork 336
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
WIP: display package dependencies #2520
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
data_dependencies <- function(pkg = ".") { | ||
pkg <- as_pkgdown(pkg) | ||
|
||
deps <- pkg$desc$get_deps() | ||
deps <- deps[order(deps$type, deps$package), c("package", "type")] | ||
deps <- deps[deps$package != "R", ] | ||
|
||
recursive <- sort(unique(unlist(tools::package_dependencies(deps$package[deps$type %in% c("Depends", "Imports")])))) | ||
recursive <- setdiff(recursive, deps$package) | ||
deps <- rbind(deps, data.frame(package = recursive, type = "Recursive")) | ||
|
||
deps$package <- purrr::map_chr(deps$package, package_link) | ||
rownames(deps) <- NULL | ||
|
||
deps | ||
} | ||
|
||
package_link <- function(package) { | ||
href <- downlit::href_package(package) | ||
|
||
if (is.na(href)) { | ||
if (is_base_package(package)) { | ||
href <- NA | ||
} else { | ||
href <- paste0("https://cran.r-project.org/web/packages/", package) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think CRAN would rather want us to create canonical links like href <- paste0(" https://CRAN.R-project.org/package=", package) (hostname is case-insensitive, of course) |
||
} | ||
} | ||
|
||
a(package, href) | ||
} | ||
|
||
is_base_package <- function(x) { | ||
x %in% c( | ||
"base", "compiler", "datasets", "graphics", "grDevices", "grid", | ||
"methods", "parallel", "splines", "stats", "stats4", "tcltk", | ||
"tools", "utils" | ||
) | ||
Comment on lines
+44
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe better use cf. https://stackoverflow.com/questions/21567057/programmatically-get-list-of-base-packages |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For base R packages, we could link to one of the unofficial documentation renderings, e.g.
https://r-universe.dev/manuals/PKG.html
(example: https://r-universe.dev/manuals/parallel.html)https://rdrr.io/r/#PKG
(example: https://rdrr.io/r/#parallel)