|
31 | 31 | #' A warning is issued to alert users that behavior may differ between interactive use and Quarto rendering, |
32 | 32 | #' as in this case the computed path may be wrong. |
33 | 33 | #' |
| 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 | +#' |
34 | 46 | #' @param ... Character vectors of path components to be joined |
35 | 47 | #' @param root Project root directory. If `NULL` (default), automatic detection |
36 | 48 | #' is used following the hierarchy described above |
@@ -157,17 +169,25 @@ project_path <- function(..., root = NULL) { |
157 | 169 | #' in an IDE (even within a Quarto project directory), as these specific |
158 | 170 | #' environment variables are only set during Quarto command execution. |
159 | 171 | #' |
| 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 | +#' |
160 | 184 | #' @return Character Quarto project root path from set environment variables. |
161 | 185 | #' |
162 | 186 | #' @seealso |
163 | 187 | #' * [find_project_root()] for finding the Quarto project root directory |
164 | 188 | #' * [project_path()] for constructing paths relative to the project root |
165 | 189 | #' @examples |
166 | 190 | #' \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) |
171 | 191 | #' get_running_project_root() |
172 | 192 | #' } |
173 | 193 | #' @export |
|
0 commit comments