Skip to content

Commit 5b6a9f2

Browse files
committed
Add example in help page body
1 parent 6a4277a commit 5b6a9f2

File tree

3 files changed

+50
-8
lines changed

3 files changed

+50
-8
lines changed

R/utils-projects.R

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@
3131
#' A warning is issued to alert users that behavior may differ between interactive use and Quarto rendering,
3232
#' as in this case the computed path may be wrong.
3333
#'
34+
#' @section Use in Quarto document cells:
35+
#'
36+
#' This function is particularly useful in Quarto document cells where you want to
37+
#' use a path relative to the project root dynamically during rendering.
38+
#'
39+
#' ````markdown
40+
#' ```{r}`r ''`
41+
#' # Get a csv path from data directory in the Quarto project root
42+
#' data <- project_path("data", "my_data.csv")
43+
#' ```
44+
#' ````
45+
#'
3446
#' @param ... Character vectors of path components to be joined
3547
#' @param root Project root directory. If `NULL` (default), automatic detection
3648
#' is used following the hierarchy described above
@@ -157,17 +169,25 @@ project_path <- function(..., root = NULL) {
157169
#' in an IDE (even within a Quarto project directory), as these specific
158170
#' environment variables are only set during Quarto command execution.
159171
#'
172+
#' @section Use in Quarto document cells:
173+
#'
174+
#' This function is particularly useful in Quarto document cells where you want to
175+
#' get the project root path dynamically during rendering. Cell example:
176+
#'
177+
#' ````markdown
178+
#' ```{r}`r ''`
179+
#' # Get the project root path
180+
#' project_root <- get_running_project_root()
181+
#' ```
182+
#' ````
183+
#'
160184
#' @return Character Quarto project root path from set environment variables.
161185
#'
162186
#' @seealso
163187
#' * [find_project_root()] for finding the Quarto project root directory
164188
#' * [project_path()] for constructing paths relative to the project root
165189
#' @examples
166190
#' \dontrun{
167-
#' # This will be TRUE during `quarto render` in a project
168-
#' get_running_project_root()
169-
#'
170-
#' # This will be FALSE when not running during `quarto_render` (e.g. interactively)
171191
#' get_running_project_root()
172192
#' }
173193
#' @export

man/get_running_project_root.Rd

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

man/project_path.Rd

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

0 commit comments

Comments
 (0)