Skip to content

Commit

Permalink
WIP: display package dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed May 8, 2024
1 parent 2fa8ef9 commit 3347bd3
Showing 1 changed file with 38 additions and 0 deletions.
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
} else {
href <- paste0("https://cran.r-project.org/web/packages/", package)
}
}

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"
)
}

0 comments on commit 3347bd3

Please sign in to comment.