knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
pyramidi::install_miditapyr(envname = "r-reticulate")

The following diagram depicts the structure of the pyramidi package and its python counterpart miditapyr.

Hover over nodes to see additional information. Many of the nodes are also clickable for further information.

library(pyramidi)
library(stringr)
library(purrr)
library(DiagrammeR)

mt_funs <- c("frame_midi", "unnest_midi", "nest_midi", "write_midi")

mt_fun_descrs <- map_chr(mt_funs, ~miditapyr[[.x]]$`__doc__`) %>% 
  str_split("\\n\\n") %>% 
  map_chr(1) %>% 
  str_replace_all("\\n", " ") %>% 
  str_squish() %>% 
  str_remove_all(":.*?:") %>% 
  str_remove_all("[`~]") 


pm_funs <- c(
  "pivot_long_notes",
  "pivot_wide_notes",
  "tab_measures",
  "merge_midi_frames",
  "split_midi_frame"
)
# inspired by:
# https://stackoverflow.com/a/8928894 &
# https://stackoverflow.com/a/23897916
get_help <- function(...){
    thefile <- help(...)
    capture.output(
        tools:::Rd2txt(utils:::.getHelpFile(thefile))
    )
}


pm_fun_descrs_raw <- map(pm_funs, get_help) %>% 
  map(~.x[-c(1:4)])


title_until_line_ints <- pm_fun_descrs_raw %>% 
  map_dbl(~str_which(.x, "^$") %>% min() %>% {. - 1})

pm_fun_descrs <- map2_chr(
  pm_fun_descrs_raw,
  title_until_line_ints,
  ~ .x[1:.y] %>% paste(collapse = " ") %>% str_squish() %>% str_remove_all("[`'\"’‘]")
)
gv <- grViz("package_workflow.gv")
# chunk options from here: https://stackoverflow.com/a/43213737
gv


urswilke/pyramidi documentation built on March 7, 2024, 3:48 p.m.