R/utils_language.R

Defines functions produce_deparse_direct deparse_direct deparse_safe

deparse_safe <- function(expr, collapse = "\n", backtick = TRUE) {
  out <- deparse_direct(
    expr,
    control = deparse_control_custom,
    backtick = backtick
  )
  if (length(out) > 1L) {
    out <- paste(out, collapse = collapse)
  }
  out
}

deparse_control_custom <- .deparseOpts(
  c("keepNA", "keepInteger", "niceNames")
)

deparse_direct <- function(...) {
  produce_deparse_direct()(...)
}

produce_deparse_direct <- function() {
  .deparseOpts <- identity
  environment(deparse) <- environment()
  deparse
}
wlandau/crew documentation built on Feb. 8, 2025, 10:12 a.m.