Skip to content

Commit 628a36f

Browse files
jennybccderv
andauthored
Polish quarto_create_project() (#206)
* Work on docs * "Enter" should be like "Y" * Suppress the warning about no project title * Start running these tests * Add to NEWS and bump version --------- Co-authored-by: Christophe Dervieux <[email protected]>
1 parent d643d27 commit 628a36f

File tree

4 files changed

+37
-25
lines changed

4 files changed

+37
-25
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# quarto (development version)
22

3+
- `quarto_create_project()` offers better user experience now (thanks, @jennybc, #206, #153).
4+
35
- `quarto_preview()` gains a `quiet` argument to suppress any output from R or Quarto CLI (thanks, @cwickham, #232.)
46

57
- Add some helpers function `theme_brand_*` and `theme_colors_*` to help theme with dark and light brand using some common graph and table packages (thanks, @gordonwoodhull, [#234](https://github.com/quarto-dev/quarto-r/issues/234)).

R/create.R

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
#' Create a quarto project
22
#'
3-
#' This function calls `quarto create project <type> <name>`. It will create a
4-
#' new directory with the project name and add some skeletons files for the
5-
#' project type chosen.
3+
#' This function calls `quarto create project <type> <name>`. It creates a new
4+
#' directory with the project name, inside the requested parent directory, and
5+
#' adds some starter files that are appropriate to the project type.
66
#'
77
#' # Quarto version required
88
#'
9-
#' This function require Quarto 1.4 or higher. Use [`quarto_version()`]to check
10-
#' the version of Quarto detected.
9+
#' This function requires Quarto 1.4 or higher. Use [quarto_version()] to see
10+
#' your current Quarto version.
1111
#'
12-
#' @param type The type of project to create. As of 1.4, it can be one of
12+
#' @param type The type of project to create. As of Quarto 1.4, it can be one of
1313
#' `r paste0("\\code{", paste(quarto_project_type, collapse = "}, \\code{"),"}")`.
1414
#' @param name The name of the project and the directory that will be created.
15-
#' @param dir The directory where to create the new Quarto project.
15+
#' @param dir The directory in which to create the new Quarto project, i.e. the
16+
#' parent directory.
1617
#'
1718
#' @seealso Quarto documentation on [Quarto projects](https://quarto.org/docs/projects/quarto-projects.html)
1819
#'
1920
#' @inheritParams quarto_render
20-
#' @inheritParams quarto_add_extension
21+
#' @param no_prompt Do not prompt to approve the creation of the new project
22+
#' folder.
23+
#'
24+
#' @examples
25+
#' \dontrun{
26+
#' quarto_create_project("my-first-quarto-project", dir = "~/tmp")
27+
#' }
28+
#'
2129
#'
2230
#' @export
2331
quarto_create_project <- function(
@@ -43,7 +51,7 @@ quarto_create_project <- function(
4351
"This will create a new Quarto {.emph {type}} project as a folder named {.strong {name}} in {.path {xfun::normalize_path(dir)}}."
4452
))
4553
prompt_value <- tolower(readline(sprintf("Do you want to proceed (Y/n)? ")))
46-
if (!prompt_value %in% "y") {
54+
if (!prompt_value %in% c("", "y")) {
4755
cli::cli_abort("Operation aborted.")
4856
}
4957
}
@@ -54,6 +62,7 @@ quarto_create_project <- function(
5462
"project",
5563
type,
5664
name,
65+
name,
5766
"--no-prompt",
5867
"--no-open",
5968
if (is_quiet(quiet)) cli_arg_quiet(),

man/quarto_create_project.Rd

Lines changed: 17 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-create.R

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
test_that("Create a quarto project", {
22
skip_if_no_quarto("1.4")
3-
# TODO: Fix the test once issue solve upstream
4-
# - https://github.com/quarto-dev/quarto-cli/issues/8809
5-
# - https://github.com/quarto-dev/quarto-r/issues/153
6-
skip_if_quarto("1.5")
73
expect_snapshot(
84
error = TRUE,
95
quarto_create_project()
@@ -16,10 +12,6 @@ test_that("Create a quarto project", {
1612

1713
test_that("Create a quarto project in another directory", {
1814
skip_if_no_quarto("1.4")
19-
# TODO: Fix the test once issue solve upstream
20-
# - https://github.com/quarto-dev/quarto-cli/issues/8809
21-
# - https://github.com/quarto-dev/quarto-r/issues/153
22-
skip_if_quarto("1.5")
2315
tempdir <- withr::local_tempdir()
2416
curr_wd <- getwd()
2517
expect_no_error(quarto_create_project(

0 commit comments

Comments
 (0)