R/find_functions.R

Defines functions find_functions

#' Find Function Names
#'
#' @param file a character string linking to a R file path
#'
#' @return a character vector
#' @noRd
find_functions <- function(file = ".", text = NULL) {

  # get information about parsed data
  dat <- get_parsed_data(file = file,
                         text = text)
  if (nrow(dat) == 0) {
    return(character(0))
  }

  # the corresponding symbols are the function names
  fun_names <- dat[dat$usage == "FUNCTION_DEFINITION", "text"]
  fun_names <- fun_names[!is.na(fun_names)]

  return(fun_names)
}

Try the origin package in your browser

Any scripts or data that you put into this service are public.

origin documentation built on April 3, 2025, 11:03 p.m.