diff --git a/NEWS.md b/NEWS.md index 67ec148..435f7d6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # tidytuesdayR (development version) +* [bug fix] `use_tidytemplate()` now explicitly takes an `ignore` argument, rather than passing (almost entirely overruled) `...` through to `usethis::use_template()`. (@jonthegeek, #76) + # tidytuesdayR 1.1.2 * [maintenance] tidytuesdayR now uses the {gh} package to manage all interactions with the GitHub API. This should make the package more stable and easier to maintain. (@jonthegeek, #78) diff --git a/R/use_tidytemplate.R b/R/use_tidytemplate.R index b1625f8..7be069c 100644 --- a/R/use_tidytemplate.R +++ b/R/use_tidytemplate.R @@ -3,10 +3,10 @@ #' Use the tidytemplate Rmd for starting your analysis with a leg up for #' processing #' -#' @param name name of your TidyTuesday analysis file -#' @param open should the file be opened after being created -#' @param ... arguments to be passed to [usethis::use_template()] -#' @param refdate date to use as reference to determine which TidyTuesday to use +#' @inheritParams usethis::use_template +#' @param name A name for your generated TidyTuesday analysis Rmd, such as +#' "My_TidyTuesday.Rmd". +#' @param refdate Date to use as reference to determine which TidyTuesday to use #' for the template. Either date object or character string in YYYY-MM-DD #' format. #' @@ -19,22 +19,24 @@ #' #' @export use_tidytemplate <- function(name = NULL, - open = interactive(), - ..., - refdate = today()) { - stopifnot(inherits(refdate, "Date") | valid_date(refdate)) + open = rlang::is_interactive(), + refdate = today(), + ignore = FALSE) { + stopifnot(valid_date(refdate)) last_tt <- last_tuesday(refdate) - if (is.null(name)) { name <- paste0(format(last_tt, "%Y_%m_%d"), "_tidy_tuesday.Rmd") } - usethis::use_template("tidytemplate.Rmd", + usethis::use_template( + "tidytemplate.Rmd", save_as = name, data = list( call_date = today(), call_tuesday = format(last_tt, "%Y-%m-%d") ), - package = "tidytuesdayR", ..., open = open + package = "tidytuesdayR", + ignore = ignore, + open = open ) } diff --git a/man/use_tidytemplate.Rd b/man/use_tidytemplate.Rd index 9dae200..2e894c4 100644 --- a/man/use_tidytemplate.Rd +++ b/man/use_tidytemplate.Rd @@ -4,18 +4,25 @@ \alias{use_tidytemplate} \title{Call and open the tidytemplate} \usage{ -use_tidytemplate(name = NULL, open = interactive(), ..., refdate = today()) +use_tidytemplate( + name = NULL, + open = rlang::is_interactive(), + refdate = today(), + ignore = FALSE +) } \arguments{ -\item{name}{name of your TidyTuesday analysis file} +\item{name}{A name for your generated TidyTuesday analysis Rmd, such as +"My_TidyTuesday.Rmd".} -\item{open}{should the file be opened after being created} +\item{open}{Open the newly created file for editing? Happens in RStudio, if +applicable, or via \code{\link[utils:file.edit]{utils::file.edit()}} otherwise.} -\item{...}{arguments to be passed to \code{\link[usethis:use_template]{usethis::use_template()}}} - -\item{refdate}{date to use as reference to determine which TidyTuesday to use +\item{refdate}{Date to use as reference to determine which TidyTuesday to use for the template. Either date object or character string in YYYY-MM-DD format.} + +\item{ignore}{Should the newly created file be added to \code{.Rbuildignore}?} } \value{ A logical vector indicating whether the file was created or modified, diff --git a/tests/testthat/test-use_tidytemplate.R b/tests/testthat/test-use_tidytemplate.R index dfc1a58..96756b3 100644 --- a/tests/testthat/test-use_tidytemplate.R +++ b/tests/testthat/test-use_tidytemplate.R @@ -20,6 +20,7 @@ test_that("use_tidytemplate processes inputs", { call_tuesday = "2024-08-20" ), package = "tidytuesdayR", + ignore = FALSE, open = FALSE ) )