Skip to content

Commit

Permalink
Refer to canonical pacakge in case of duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Sep 26, 2023
1 parent 290f6e9 commit a9b6916
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,19 @@ unique_obj <- function(name, pkgs) {
objs <- lapply(pkgs, getExportedValue, name)
names(objs) <- pkgs

pkgs[!duplicated(objs)]
env_names <- map_chr(objs, function(obj) {
tryCatch(
getNamespaceName(environment(obj)),
error = function(e) ""
)
})

env_names <- unique(env_names[env_names != ""])

canonical_objs <- c(objs[env_names], objs)
canonical_pkgs <- c(env_names, pkgs)

canonical_pkgs[!duplicated(canonical_objs)]
}

style_object <- function(pkg, name, winner = FALSE) {
Expand Down

0 comments on commit a9b6916

Please sign in to comment.