From db820ec8b20b7ac2bc26389464ddb7ecaeff9f7d Mon Sep 17 00:00:00 2001 From: Alan Haynes Date: Thu, 27 Feb 2025 09:46:01 +0100 Subject: [PATCH 1/2] CTUtemplate 0.6.1 --------------------- addition of use_qmd_typst --- DESCRIPTION | 4 ++-- NAMESPACE | 1 + NEWS.md | 4 ++++ R/use_.R | 24 +++++++++++++++++++++++- man/use_qmd.Rd | 14 ++++++++++++++ 5 files changed, 44 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 802c8de..747b639 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,14 +2,14 @@ Package: CTUtemplate Title: Example RStudio Project Templates Author: Alan G. Haynes Maintainer: Alan G. Haynes -Version: 0.6.0 +Version: 0.6.1 Description: Templates and functions for use in CTU Bern. Depends: R (>= 3.3.2) License: GPL (>= 2) Encoding: UTF-8 LazyData: true -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 Imports: bookdown, fs, diff --git a/NAMESPACE b/NAMESPACE index fbdfb90..80b66a0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,6 +10,7 @@ export(use_qmd_html) export(use_qmd_htmlrecruitment) export(use_qmd_htmlsampsi) export(use_qmd_pres) +export(use_qmd_typst) export(use_quarto) export(use_recreport_template) export(use_report_template) diff --git a/NEWS.md b/NEWS.md index e13758c..6e765c4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +CTUtemplate 0.6.1 +--------------------- +addition of use_qmd_typst + CTUtemplate 0.6.0 --------------------- update templates to use DCR-like branding diff --git a/R/use_.R b/R/use_.R index 56ed46d..c922ac3 100644 --- a/R/use_.R +++ b/R/use_.R @@ -282,6 +282,27 @@ use_qmd_htmlsampsi <- function(save_in = ".", open = TRUE){ } +#' Use the CTU quarto typst template +#' This function will download and optionally open the quarto markdown (qmd) file +#' and the other necessary files from github. +#' @describeIn use_qmd Sample Size Report Template +#' @param save_in directory to save the main qmd in +#' @param open logical indicating whether to open the file +#' @export +#' @examples +#' # dir <- tempdir() +#' # file <- file.path(dir, "filename.qmd") +#' # use_qmd_html(file, FALSE) +#' # in practice at CTU: +#' # use_qmd_typst("08_Reports_xx/ReportName.qmd", TRUE) +use_qmd_typst <- function(save_in = ".", open = TRUE){ + + if_no_ping_stop() + + use_quarto("typst", save_in, open = open) + +} + #' Get a quarto template from the CTU-Bern quarto repository @@ -297,7 +318,7 @@ use_qmd_htmlsampsi <- function(save_in = ".", open = TRUE){ #' #use_quarto("html", ".") use_quarto <- function(x, dir, open = TRUE){ - if(!x %in% c("html", "html-ss", "html-rec", "pres")){ + if(!x %in% c("html", "html-ss", "html-rec", "pres", "typst")){ stop("unknown branch of CTU-Bern/quarto") } @@ -305,6 +326,7 @@ use_quarto <- function(x, dir, open = TRUE){ on.exit(setwd(wd)) setwd(dir) + if(length(list.files()) > 0) stop("'dir' is not empty - an empty 'dir' is necessary") system(glue("quarto use template CTU-Bern/quarto@{x} --no-prompt")) diff --git a/man/use_qmd.Rd b/man/use_qmd.Rd index 72bb412..9d17b6c 100644 --- a/man/use_qmd.Rd +++ b/man/use_qmd.Rd @@ -5,6 +5,7 @@ \alias{use_qmd_pres} \alias{use_qmd_htmlrecruitment} \alias{use_qmd_htmlsampsi} +\alias{use_qmd_typst} \title{Use the CTU quarto html template This function will download and optionally open the quarto markdown (qmd) file and the other necessary files from github.} @@ -16,6 +17,8 @@ use_qmd_pres(save_in = ".", open = TRUE) use_qmd_htmlrecruitment(save_in = ".", open = TRUE) use_qmd_htmlsampsi(save_in = ".", open = TRUE) + +use_qmd_typst(save_in = ".", open = TRUE) } \arguments{ \item{save_in}{directory to save the main qmd in} @@ -38,6 +41,10 @@ and the other necessary files from github. Use the CTU quarto html sample size report template This function will download and optionally open the quarto markdown (qmd) file and the other necessary files from github. + +Use the CTU quarto typst template +This function will download and optionally open the quarto markdown (qmd) file +and the other necessary files from github. } \section{Functions}{ \itemize{ @@ -47,6 +54,8 @@ and the other necessary files from github. \item \code{use_qmd_htmlsampsi()}: Sample Size Report Template +\item \code{use_qmd_typst()}: Sample Size Report Template + }} \examples{ # dir <- tempdir() @@ -69,4 +78,9 @@ and the other necessary files from github. # use_qmd_html(file, FALSE) # in practice at CTU: # use_qmd_htmlrecruitment("08_Reports_xx/ReportName.qmd", TRUE) +# dir <- tempdir() +# file <- file.path(dir, "filename.qmd") +# use_qmd_html(file, FALSE) +# in practice at CTU: +# use_qmd_typst("08_Reports_xx/ReportName.qmd", TRUE) } From 03a43d611791d070a54332ae53f050502f1b33d5 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 27 Feb 2025 08:48:48 +0000 Subject: [PATCH 2/2] Re-build README.Rmd --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6751763..232ca8e 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ # `CTUtemplate` -[![](https://img.shields.io/badge/dev%20version-0.6.0-blue.svg)](https://github.com/CTU-Bern/CTUtemplate) +[![](https://img.shields.io/badge/dev%20version-0.6.1-blue.svg)](https://github.com/CTU-Bern/CTUtemplate) `CTUtemplate` is a package to create a template directory structure (and files) and also includes the CTUs annual safety report function.