Created
January 31, 2023 08:34
-
-
Save PietrH/450d44d373de346456f1cf17e9c36e94 to your computer and use it in GitHub Desktop.
Is a helper function used in any of the functions called in my package?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I'm wondering where readr::show_progress() is used in library(frictionless) | |
library(dplyr) | |
# map the current package | |
package_map <- pkgapi::map_package(".") | |
# load functions into env | |
devtools::load_all() | |
# extract arguments | |
arguments <- filter(package_map$defs,exported) %>% | |
pull(name) %>% | |
purrr::map(rlang::as_function) %>% | |
purrr::map(rlang::fn_fmls) %>% | |
purrr::set_names(pull(filter(package_map$defs,exported), name)) | |
# what functions call other functions internally? (edges of dependency network) | |
edges <- | |
purrr::map(arguments,names) %>% | |
purrr::map(~tibble(to=.x)) %>% | |
purrr::map2(names(.),~mutate(.x,from = .y)) %>% | |
purrr::map_df(bind_rows) | |
# function to find string (function usage) in file, in this case, | |
# in the code of the package I want to find it's usage in | |
search_in_file <- function(str_to_check) { | |
purrr::map_lgl(list.files("../frictionless-r/R", full.names = TRUE), | |
~any(grepl(str_to_check,readLines(file.path(.x))))) | |
} | |
# what functions within readr call show_progress()? (have the argument progress?) | |
to_check <- filter(edges,to == "progress") %>% | |
pull(from) %>% | |
sprintf("readr::%s",.) | |
# are these functions used in frictionless? (including comments) | |
purrr::map(to_check,~list.files("../frictionless-r/R")[search_in_file(.x)]) %>% | |
purrr::set_names(to_check) %>% | |
purrr::compact() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment