Debian Codegraph @

R/caution.R

raw
1
2 caution <- function(fmt = "", ..., con = stdout()) {
3 enabled <- getOption("renv.caution.verbose", default = TRUE)
4 if (!is.null(fmt) && enabled)
5 writeLines(sprintf(fmt, ...), con = con)
6 }
7
8 bulletin <- function(preamble = NULL,
9 values = NULL,
10 postamble = NULL,
11 ...,
12 bullets = TRUE,
13 emitter = NULL)
14 {
15 if (empty(values))
16 return(invisible())
17
18 renv_dots_check(...)
19
20 lines <- c(
21 if (length(preamble)) paste(preamble, collapse = "\n"),
22 if (bullets)
23 paste("-", values, collapse = "\n")
24 else
25 paste(values, collapse = "\n"),
26 if (length(postamble)) paste(postamble, collapse = "\n"),
27 ""
28 )
29
30 text <- paste(lines, collapse = "\n")
31 renv_caution_impl(text, emitter)
32 }
33
34 renv_caution_impl <- function(text, emitter = NULL) {
35
36 # NOTE: Used by vetiver, so perhaps is part of the API.
37 # We should think of a cleaner way of exposing this.
38 # https://github.com/rstudio/renv/issues/1413
39 emitter <- emitter %||% {
40 getOption("renv.pretty.print.emitter", default = caution)
41 }
42
43 emitter(text)
44 invisible(NULL)
45
46 }