This can be achieved with the following code:
extract_functions_from_package <- function(episode, package) {
stopifnot(
length(episode) == 1,
length(package) == 1
)
code <- knitr::purl(episode, output = tempfile(fileext = ".R"), quiet = TRUE)
parse(file = code) |>
xmlparsedata::xml_parse_data() |>
xml2::as_xml_document() |>
xml2::xml_find_all(
glue::glue("//SYMBOL_PACKAGE[text() = '{package}']/parent::expr")
) |>
xml2::xml_text() |>
unique()
}
episodes <- fs::dir_ls("episodes", type = "file")
packages <- c("cleanepi", "epiparameter")
used_fcts <- expand.grid(episode = episodes, package = packages, stringsAsFactors = FALSE) |>
dplyr::mutate(functions = purrr::map2(episode, package, extract_functions_from_package))
# Get full list of cleanepi functions
used_fcts |>
dplyr::filter(package == "cleanepi") |>
dplyr::pull(functions) |>
unlist() |>
unique()
@lgbermeo, how should the output be formatted? Where should it be stored or displayed?
This can be achieved with the following code:
@lgbermeo, how should the output be formatted? Where should it be stored or displayed?