Skip to content

Commit

Permalink
Fix #208
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Dec 24, 2024
1 parent 083ca89 commit bbbfe9b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Description: Function-oriented Make-like declarative pipelines for
reproducible pipelines concisely and compactly.
The methods in this package were influenced by the 'targets' R package.
by Will Landau (2018) <doi:10.21105/joss.00550>.
Version: 0.11.0.9002
Version: 0.11.0.9003
License: MIT + file LICENSE
URL: https://docs.ropensci.org/tarchetypes/, https://github.com/ropensci/tarchetypes
BugReports: https://github.com/ropensci/tarchetypes/issues
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# tarchetypes 0.11.0.9002
# tarchetypes 0.11.0.9003

* Fix `tar_combine()` help file examples (#206, @weberse2).
* Account for project-level `output_dir` in non-project `tar_quarto()` calls (#207, @brndngrhm).
* Use name when passing the `quiet` argument to `quarto_inspect()` (#208, @yusuke-sasaki-jprep).
* Explicitly pass the `profile` argument to `quarto_inspect()` and `quarto_render()`. Requires R package `quarto >= 1.4`, which is already in the `DESCIRPTION`.

# tarchetypes 0.11.0

Expand Down
23 changes: 14 additions & 9 deletions R/tar_quarto_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,10 @@ tar_quarto_files <- function(path = ".", profile = NULL, quiet = TRUE) {
targets::tar_assert_scalar(profile %|||% ".")
targets::tar_assert_chr(profile %|||% ".")
targets::tar_assert_nzchar(profile %|||% ".")
if (!is.null(profile)) {
withr::local_envvar(.new = c(QUARTO_PROFILE = profile))
}
out <- if_any(
fs::is_dir(path),
tar_quarto_files_project(path, quiet),
tar_quarto_files_document(path, quiet)
tar_quarto_files_project(path, profile, quiet),
tar_quarto_files_document(path, profile, quiet)
)
for (field in c("sources", "output", "input")) {
out[[field]] <- as.character(fs::path_rel(out[[field]]))
Expand All @@ -58,8 +55,12 @@ tar_quarto_files <- function(path = ".", profile = NULL, quiet = TRUE) {
out
}

tar_quarto_files_document <- function(path, quiet) {
info <- quarto::quarto_inspect(input = path, quiet = quiet)
tar_quarto_files_document <- function(path, profile, quiet) {
info <- quarto::quarto_inspect(
input = path,
profile = profile,
quiet = quiet
)
out <- list()
# Collect data about source files.
out$sources <- tar_quarto_files_get_source_files(info$fileInformation)
Expand All @@ -82,8 +83,12 @@ tar_quarto_files_document <- function(path, quiet) {
out
}

tar_quarto_files_project <- function(path, quiet) {
info <- quarto::quarto_inspect(input = path, quiet)
tar_quarto_files_project <- function(path, profile, quiet) {
info <- quarto::quarto_inspect(
input = path,
profile = profile,
quiet = quiet
)
targets::tar_assert_nonempty(
info$config$project$`output-dir`,
paste(
Expand Down
13 changes: 5 additions & 8 deletions R/tar_quarto_raw.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ tar_quarto_command <- function(
quiet = quiet,
quarto_args = quarto_args,
pandoc_args = pandoc_args,
profile = profile,
as_job = FALSE
),
env = list(
Expand All @@ -152,7 +153,8 @@ tar_quarto_command <- function(
debug = debug,
quiet = quiet,
quarto_args = quarto_args,
pandoc_args = pandoc_args
pandoc_args = pandoc_args,
profile = profile
)
)
deps <- sort(unique(unlist(map(sources, ~knitr_deps(.x)))))
Expand All @@ -164,8 +166,7 @@ tar_quarto_command <- function(
deps = deps,
sources = sources,
output = output,
input = input,
profile = profile
input = input
)
as.expression(as.call(expr))
}
Expand All @@ -184,7 +185,6 @@ tar_quarto_command <- function(
#' @param output Character vector of Quarto output files and directories.
#' @param input Character vector of non-source Quarto input files
#' and directories.
#' @param profile Quarto profile.
#' @examples
#' if (identical(Sys.getenv("TAR_LONG_EXAMPLES"), "true")) {
#' targets::tar_dir({ # tar_dir() runs code from a temporary directory.
Expand All @@ -207,13 +207,10 @@ tar_quarto_command <- function(
#' file.exists(files)
#' })
#' }
tar_quarto_run <- function(args, deps, sources, output, input, profile) {
tar_quarto_run <- function(args, deps, sources, output, input) {
rm(deps)
gc()
assert_quarto()
if (!is.null(profile)) {
withr::local_envvar(.new = c(QUARTO_PROFILE = profile))
}
args <- args[!map_lgl(args, is.null)]
do.call(what = quarto::quarto_render, args = args)
support <- sprintf("%s_files", fs::path_ext_remove(basename(args$input)))
Expand Down
4 changes: 1 addition & 3 deletions man/tar_quarto_run.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bbbfe9b

Please sign in to comment.