From 81a6ac4b58cb0cdb98ab8af529922db49af1d4a4 Mon Sep 17 00:00:00 2001 From: Jenny Bryan Date: Tue, 20 Aug 2024 15:35:03 -0700 Subject: [PATCH 1/4] Work on docs --- R/create.R | 24 ++++++++++++++++-------- man/quarto_create_project.Rd | 25 +++++++++++++++++-------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/R/create.R b/R/create.R index 6f99d91..d90e4d7 100644 --- a/R/create.R +++ b/R/create.R @@ -1,23 +1,31 @@ #' Create a quarto project #' -#' This function calls `quarto create project `. It will create a -#' new directory with the project name and add some skeletons files for the -#' project type chosen. +#' This function calls `quarto create project `. It creates a new +#' directory with the project name, inside the requested parent directory, and +#' adds some starter files that are appropriate to the project type. #' #' # Quarto version required #' -#' This function require Quarto 1.4 or higher. Use [`quarto_version()`]to check -#' the version of Quarto detected. +#' This function requires Quarto 1.4 or higher. Use [quarto_version()] to see +#' your current Quarto version. #' -#' @param type The type of project to create. As of 1.4, it can be one of +#' @param type The type of project to create. As of Quarto 1.4, it can be one of #' `r paste0("\\code{", paste(quarto_project_type, collapse = "}, \\code{"),"}")`. #' @param name The name of the project and the directory that will be created. -#' @param dir The directory where to create the new Quarto project. +#' @param dir The directory in which to create the new Quarto project, i.e. the +#' parent directory. #' #' @seealso Quarto documentation on [Quarto projects](https://quarto.org/docs/projects/quarto-projects.html) #' #' @inheritParams quarto_render -#' @inheritParams quarto_add_extension +#' @param no_prompt Do not prompt to approve the creation of the new project +#' folder. +#' +#' @examples +#' \dontrun{ +#' quarto_create_project("my-first-quarto-project", dir = "~/tmp") +#' } +#' #' #' @export quarto_create_project <- function(name, type = "default", dir = ".", no_prompt = FALSE, quiet = FALSE, quarto_args = NULL) { diff --git a/man/quarto_create_project.Rd b/man/quarto_create_project.Rd index 806ec9f..8a7d46c 100644 --- a/man/quarto_create_project.Rd +++ b/man/quarto_create_project.Rd @@ -16,12 +16,14 @@ quarto_create_project( \arguments{ \item{name}{The name of the project and the directory that will be created.} -\item{type}{The type of project to create. As of 1.4, it can be one of +\item{type}{The type of project to create. As of Quarto 1.4, it can be one of \code{default}, \code{website}, \code{blog}, \code{book}, \code{manuscript}, \code{confluence}.} -\item{dir}{The directory where to create the new Quarto project.} +\item{dir}{The directory in which to create the new Quarto project, i.e. the +parent directory.} -\item{no_prompt}{Do not prompt to confirm approval to download external extension.} +\item{no_prompt}{Do not prompt to approve the creation of the new project +folder.} \item{quiet}{Suppress warning and other messages.} @@ -31,15 +33,22 @@ advanced usage and useful for CLI arguments which are not yet mirrored in a dedicated parameter of this \R function. See \verb{quarto render --help} for options.} } \description{ -This function calls \verb{quarto create project }. It will create a -new directory with the project name and add some skeletons files for the -project type chosen. +This function calls \verb{quarto create project }. It creates a new +directory with the project name, inside the requested parent directory, and +adds some starter files that are appropriate to the project type. } \section{Quarto version required}{ -This function require Quarto 1.4 or higher. Use \code{\link[=quarto_version]{quarto_version()}}to check -the version of Quarto detected. +This function requires Quarto 1.4 or higher. Use \code{\link[=quarto_version]{quarto_version()}} to see +your current Quarto version. } +\examples{ +\dontrun{ +quarto_create_project("my-first-quarto-project", dir = "~/tmp") +} + + +} \seealso{ Quarto documentation on \href{https://quarto.org/docs/projects/quarto-projects.html}{Quarto projects} } From 5b063f5ba1c069bca5ddd1205849777768245658 Mon Sep 17 00:00:00 2001 From: Jenny Bryan Date: Tue, 20 Aug 2024 15:35:30 -0700 Subject: [PATCH 2/4] "Enter" should be like "Y" --- R/create.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/create.R b/R/create.R index d90e4d7..6ec31eb 100644 --- a/R/create.R +++ b/R/create.R @@ -40,7 +40,7 @@ quarto_create_project <- function(name, type = "default", dir = ".", no_prompt = "This will create a new Quarto {.emph {type}} project as a folder named {.strong {name}} in {.path {xfun::normalize_path(dir)}}." )) prompt_value <- tolower(readline(sprintf("Do you want to proceed (Y/n)? "))) - if (!prompt_value %in% "y") { + if (!prompt_value %in% c("", "y")) { cli::cli_abort("Operation aborted.") } } From c93aae2812b381bb0fb20a071a9a3f0ab52f1d61 Mon Sep 17 00:00:00 2001 From: Jenny Bryan Date: Tue, 20 Aug 2024 15:35:53 -0700 Subject: [PATCH 3/4] Suppress the warning about no project title --- R/create.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/create.R b/R/create.R index 6ec31eb..554fe44 100644 --- a/R/create.R +++ b/R/create.R @@ -47,7 +47,7 @@ quarto_create_project <- function(name, type = "default", dir = ".", no_prompt = quarto_bin <- find_quarto() - args <- c("project", type, name, "--no-prompt", "--no-open", if (is_quiet(quiet)) cli_arg_quiet(), quarto_args = NULL) + args <- c("project", type, name, name, "--no-prompt", "--no-open", if (is_quiet(quiet)) cli_arg_quiet(), quarto_args = NULL) owd <- setwd(dir) on.exit(setwd(owd), add = TRUE, after = FALSE) From 9157ddd152a342971b1f65a0109b9a821870ab27 Mon Sep 17 00:00:00 2001 From: Jenny Bryan Date: Tue, 20 Aug 2024 15:36:29 -0700 Subject: [PATCH 4/4] Start running these tests --- tests/testthat/test-create.R | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/testthat/test-create.R b/tests/testthat/test-create.R index ec75e21..60d3e77 100644 --- a/tests/testthat/test-create.R +++ b/tests/testthat/test-create.R @@ -1,9 +1,5 @@ test_that("Create a quarto project", { skip_if_no_quarto("1.4") - # TODO: Fix the test once issue solve upstream - # - https://github.com/quarto-dev/quarto-cli/issues/8809 - # - https://github.com/quarto-dev/quarto-r/issues/153 - skip_if_quarto("1.5") expect_snapshot( error = TRUE, quarto_create_project() @@ -16,10 +12,6 @@ test_that("Create a quarto project", { test_that("Create a quarto project in another directory", { skip_if_no_quarto("1.4") - # TODO: Fix the test once issue solve upstream - # - https://github.com/quarto-dev/quarto-cli/issues/8809 - # - https://github.com/quarto-dev/quarto-r/issues/153 - skip_if_quarto("1.5") tempdir <- withr::local_tempdir() curr_wd <- getwd() expect_no_error(quarto_create_project(name = "test-project", dir = tempdir, quiet = TRUE))