From 1748ed8a2a2337ffd9f8478354df5c113a2ddd97 Mon Sep 17 00:00:00 2001 From: cedwards-dfw Date: Fri, 25 Oct 2024 14:03:52 -0700 Subject: [PATCH] Added second WDFW template, infrastructure for labeled templates --- R/initialize_project.R | 10 ++++++++-- inst/WDFW/coffee_quarto.yml | 15 +++++++++++++++ inst/WDFW/{_quarto.yml => green_quarto.yml} | 0 man/fetch_quarto_templates.Rd | 9 ++++++++- man/initialize_project.Rd | 3 +++ 5 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 inst/WDFW/coffee_quarto.yml rename inst/WDFW/{_quarto.yml => green_quarto.yml} (100%) diff --git a/R/initialize_project.R b/R/initialize_project.R index e1f810f..8fe39fa 100644 --- a/R/initialize_project.R +++ b/R/initialize_project.R @@ -18,6 +18,7 @@ #' @param organization Character, defaults to "WDFW". Specifies the set of quarto templates to use. Currently only supports "WDFW". #' @param renv Boolean to initialize renv. Defaults to FALSE. #' @param template.overwrite Boolean. Overwrite _quarto.yml and style.css files if they already exist? Defaults to TRUE +#' @param color Character string, defaults to "coffee". Specifies quarto template to use; organizations may have several. #' @param quiet Boolean, defaults to FALSE. If TRUE, suppresses informational messages. #' @export #' @examples @@ -37,6 +38,7 @@ initialize_project <- organization = "WDFW", renv = FALSE, template.overwrite = TRUE, + color = "coffee", quiet = TRUE) { organization <- rlang::arg_match(organization, c("WDFW")) @@ -61,6 +63,7 @@ initialize_project <- } fetch_quarto_templates(to.path = ".", organization = organization, + color = color, overwrite = template.overwrite) } @@ -95,18 +98,21 @@ initialize_project <- #' fetch_quarto_templates = function(to.path, organization = "WDFW", + color = "coffee", overwrite = FALSE) { rlang::arg_match(organization, c("WDFW")) ## add more as appropriate. + rlang::arg_match(color, c("green", "coffee")) ## The associated yaml and style files should be added to the `inst` folder with a subfolder ## that matches the organization name organization <- rlang::arg_match(organization, c("WDFW")) - yaml.path <- system.file(glue::glue("{organization}/_quarto.yml"), package = "framrsquared") + yaml.path <- system.file(glue::glue("{organization}/{color}_quarto.yml"), package = "framrsquared") style.path <- system.file(glue::glue("{organization}/style.css"), package = "framrsquared") invisible(file.copy ( c(yaml.path, style.path), - to = to.path, + to = c(glue::glue("{to.path}/_quarto.yml"), + glue::glue("{to.path}/style.css")), overwrite = overwrite )) } diff --git a/inst/WDFW/coffee_quarto.yml b/inst/WDFW/coffee_quarto.yml new file mode 100644 index 0000000..1f84d00 --- /dev/null +++ b/inst/WDFW/coffee_quarto.yml @@ -0,0 +1,15 @@ +date: last-modified +execute: + warning: false +message: false +format: + html: + code-fold: true +embed-resources: true +toc: true +title-block-banner: "#ede9da" +title-block-banner-color: "#967259" +css: style.css +project: + title: "" + output-dir: results/quarto_output/ diff --git a/inst/WDFW/_quarto.yml b/inst/WDFW/green_quarto.yml similarity index 100% rename from inst/WDFW/_quarto.yml rename to inst/WDFW/green_quarto.yml diff --git a/man/fetch_quarto_templates.Rd b/man/fetch_quarto_templates.Rd index cb338ed..da1f875 100644 --- a/man/fetch_quarto_templates.Rd +++ b/man/fetch_quarto_templates.Rd @@ -4,13 +4,20 @@ \alias{fetch_quarto_templates} \title{Creates quarto template files} \usage{ -fetch_quarto_templates(to.path, organization = "WDFW", overwrite = FALSE) +fetch_quarto_templates( + to.path, + organization = "WDFW", + color = "coffee", + overwrite = FALSE +) } \arguments{ \item{to.path}{Character string. Destination file path for template files. Typically, root of Rproject directory.} \item{organization}{Character, defaults to "WDFW". Specifies the set of quarto templates to use. Currently only supports "WDFW".} +\item{color}{Character string, defaults to "coffee". Specifies quarto template to use; organizations may have several.} + \item{overwrite}{Boolean. Overwrite _quarto.yml and style.css files if they already exist? Defaults to FALSE.} } \value{ diff --git a/man/initialize_project.Rd b/man/initialize_project.Rd index e866915..ac5ef96 100644 --- a/man/initialize_project.Rd +++ b/man/initialize_project.Rd @@ -12,6 +12,7 @@ initialize_project( organization = "WDFW", renv = FALSE, template.overwrite = TRUE, + color = "coffee", quiet = TRUE ) } @@ -26,6 +27,8 @@ initialize_project( \item{template.overwrite}{Boolean. Overwrite _quarto.yml and style.css files if they already exist? Defaults to TRUE} +\item{color}{Character string, defaults to "coffee". Specifies quarto template to use; organizations may have several.} + \item{quiet}{Boolean, defaults to FALSE. If TRUE, suppresses informational messages.} } \description{