From 901755a128964809ef43f10fbd1765fa15ac821a Mon Sep 17 00:00:00 2001 From: olivroy Date: Tue, 29 Aug 2023 15:15:18 -0400 Subject: [PATCH] Add is_quarto_project criterion. --- NAMESPACE | 1 + R/root.R | 12 ++++++++++++ man/criteria.Rd | 5 +++++ tests/testthat/_snaps/root.md | 6 +++++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/NAMESPACE b/NAMESPACE index 5f1c7fa8..58d150f7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -27,6 +27,7 @@ export(is_drake_project) export(is_git_root) export(is_pkgdown_project) export(is_projectile_project) +export(is_quarto_project) export(is_r_package) export(is_remake_project) export(is_root_criterion) diff --git a/R/root.R b/R/root.R index ee8d0b82..fbb55c07 100644 --- a/R/root.R +++ b/R/root.R @@ -324,6 +324,9 @@ is_pkgdown_project <- has_file("_pkgdown.yml") | has_file("_pkgdown.yaml") | has #' @export is_projectile_project <- has_file(".projectile") +#' @export +is_quarto_project <- has_file("_quarto.yml") + #' @export is_git_root <- has_dir(".git") | has_file(".git", contents = "^gitdir: ") @@ -353,6 +356,7 @@ criteria <- structure( is_remake_project = is_remake_project, is_pkgdown_project = is_pkgdown_project, is_projectile_project = is_projectile_project, + is_quarto_project = is_quarto_project, is_git_root = is_git_root, is_svn_root = is_svn_root, is_vcs_root = is_vcs_root, @@ -416,6 +420,14 @@ str.root_criteria <- function(object, ...) { #' @export "is_projectile_project" +#' @details +#' `is_quarto_project` looks for a `_quarto.yml` file. +#' +#' @format NULL +#' @rdname criteria +#' @export +"is_quarto_project" + #' @details #' `is_git_root` looks for a `.git` directory. #' diff --git a/man/criteria.Rd b/man/criteria.Rd index 6b8505d8..5a89d224 100644 --- a/man/criteria.Rd +++ b/man/criteria.Rd @@ -9,6 +9,7 @@ \alias{is_drake_project} \alias{is_pkgdown_project} \alias{is_projectile_project} +\alias{is_quarto_project} \alias{is_git_root} \alias{is_svn_root} \alias{is_vcs_root} @@ -30,6 +31,8 @@ is_pkgdown_project is_projectile_project +is_quarto_project + is_git_root is_svn_root @@ -56,6 +59,8 @@ This is a collection of commonly used root criteria. \code{is_projectile_project} looks for a \code{.projectile} file. +\code{is_quarto_project} looks for a \verb{_quarto.yml} file. + \code{is_git_root} looks for a \code{.git} directory. \code{is_svn_root} looks for a \code{.svn} directory. diff --git a/tests/testthat/_snaps/root.md b/tests/testthat/_snaps/root.md index d6e0e15c..c82a107b 100644 --- a/tests/testthat/_snaps/root.md +++ b/tests/testthat/_snaps/root.md @@ -60,6 +60,9 @@ $is_projectile_project Root criterion: contains a file ".projectile" + $is_quarto_project + Root criterion: contains a file "_quarto.yml" + $is_git_root Root criterion: one of - contains a directory ".git" @@ -88,12 +91,13 @@ Code str(criteria) Output - List of 10 + List of 11 $ is_rstudio_project : chr "Root criterion: contains a file matching \"[.]Rproj$\" with contents matching \"^Version: \" in the first line" $ is_r_package : chr "Root criterion: contains a file \"DESCRIPTION\" with contents matching \"^Package: \"" $ is_remake_project : chr "Root criterion: contains a file \"remake.yml\"" $ is_pkgdown_project : chr [1:5] "Root criterion: one of" "- contains a file \"_pkgdown.yml\"" "- contains a file \"_pkgdown.yaml\"" "- contains a file \"pkgdown/_pkgdown.yml\"" ... $ is_projectile_project: chr "Root criterion: contains a file \".projectile\"" + $ is_quarto_project : chr "Root criterion: contains a file \"_quarto.yml\"" $ is_git_root : chr [1:3] "Root criterion: one of" "- contains a directory \".git\"" "- contains a file \".git\" with contents matching \"^gitdir: \"" $ is_svn_root : chr "Root criterion: contains a directory \".svn\"" $ is_vcs_root : chr [1:4] "Root criterion: one of" "- contains a directory \".git\"" "- contains a file \".git\" with contents matching \"^gitdir: \"" "- contains a directory \".svn\""