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

WIP: display package dependencies #2520

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions R/build-home-deps.R
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
Copy link
Collaborator

@salim-b salim-b Jun 23, 2024

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.

} else {
href <- paste0("https://cran.r-project.org/web/packages/", package)
Copy link
Collaborator

@salim-b salim-b Jun 23, 2024

Choose a reason for hiding this comment

The 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better use x %in% rownames(installed.packages(priority="base"))?

cf. https://stackoverflow.com/questions/21567057/programmatically-get-list-of-base-packages

}
Loading