| @@ -10,14 +10,12 @@ setup_theme_function <- function( | |||
| body = " eval(parse(text = call_style_xaringan()))" | |||
| ) { | |||
| if (file == "clip" && !requireNamespace("clipr", quietly = TRUE)) file <- "" | |||
| body <- c( | |||
| f_body <- c( | |||
| " # DO NOT EDIT - Generated from inst/scripts/generate_theme_functions.R", | |||
| body | |||
| ) | |||
| tv <- template | |||
| null_default <- purrr::map_lgl(tv$default, is.null) | |||
| tv[null_default, "default"] <- "{NULL}" | |||
| x <- c( | |||
| f_def <- c( | |||
| "# Generated by inst/scripts/generate_theme_functions.R: do not edit by hand\n", | |||
| as.character( | |||
| glue::glue_data( | |||
| @@ -43,12 +41,12 @@ setup_theme_function <- function( | |||
| " outfile = \"xaringan-themer.css\"", | |||
| ") {" | |||
| ) | |||
| if (!is.null(body)) x <- c(x, body, "}") | |||
| if (!is.null(f_body)) f_def <- c(f_def, f_body, "}") | |||
| if (file == "clip") { | |||
| clipr::write_clip(x) | |||
| clipr::write_clip(f_def) | |||
| message("Wrote ", f_name, " function signature to clipboard.") | |||
| } else { | |||
| cat(reflow_roxygen(x), sep = "\n", file = file) | |||
| cat(reflow_roxygen(f_def), sep = "\n", file = file) | |||
| message("Wrote ", f_name, " to ", file) | |||
| } | |||
| invisible() | |||