Skip to content

Commit 480e7c3

Browse files
committed
output_file arg
1 parent 87c0757 commit 480e7c3

19 files changed

+73
-38
lines changed

Diff for: DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Imports:
5454
Suggests:
5555
curl (>= 4.3),
5656
knitr (>= 1.28),
57-
quarto (>= 1.0),
57+
quarto (>= 1.4),
5858
rmarkdown (>= 2.1),
5959
testthat (>= 3.0.0),
6060
xml2 (>= 1.3.2)

Diff for: NEWS.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* `tar_map()` and other static branching target factories now append values to the target descriptions. Use the `descriptions` argument of those functions to customize.
55
* Ensure consistent `repository` settings in `tar_change()` and `tar_map_rep()`.
66
* `tar_knit()`, `tar_render()`, `tar_quarto()`, and their "rep" and "raw" versions all gain a `working_directory` argument to change the working directory the report knits from. Users who set `working_directory` need to supply the `store` argument of `tar_load()` and `tar_read()` relative to the working directory so the report knows where to find the data.
7+
* `tar_knit()`, `tar_render()`, `tar_quarto()`, and their "raw" versions all gain an `output_file` argument to more conveniently set the file path to the rendered output file.
78

89
# tarchetypes 0.7.12
910

Diff for: R/tar_knit.R

+18-6
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
tar_knit <- function(
7272
name,
7373
path,
74-
output = NULL,
74+
output_file = NULL,
7575
working_directory = NULL,
7676
tidy_eval = targets::tar_option_get("tidy_eval"),
7777
packages = targets::tar_option_get("packages"),
@@ -90,8 +90,8 @@ tar_knit <- function(
9090
) {
9191
targets::tar_assert_package("knitr")
9292
targets::tar_assert_file(path)
93-
targets::tar_assert_chr(output %|||% "x")
94-
targets::tar_assert_scalar(output %|||% "x")
93+
targets::tar_assert_chr(output_file %|||% "x")
94+
targets::tar_assert_scalar(output_file %|||% "x")
9595
if (!is.null(working_directory)) {
9696
targets::tar_assert_file(working_directory)
9797
}
@@ -103,7 +103,13 @@ tar_knit <- function(
103103
)
104104
targets::tar_target_raw(
105105
name = targets::tar_deparse_language(substitute(name)),
106-
command = tar_knit_command(path, output, working_directory, args, quiet),
106+
command = tar_knit_command(
107+
path,
108+
output_file,
109+
working_directory,
110+
args,
111+
quiet
112+
),
107113
packages = packages,
108114
library = library,
109115
format = "file",
@@ -120,9 +126,15 @@ tar_knit <- function(
120126
)
121127
}
122128

123-
tar_knit_command <- function(path, output, working_directory, args, quiet) {
129+
tar_knit_command <- function(
130+
path,
131+
output_file,
132+
working_directory,
133+
args,
134+
quiet
135+
) {
124136
args$input <- path
125-
args$output <- output
137+
args$output <- output_file
126138
args$quiet <- quiet
127139
deps <- call_list(as_symbols(knitr_deps(path)))
128140
fun <- call_ns("tarchetypes", "tar_knit_run")

Diff for: R/tar_knit_raw.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
tar_knit_raw <- function(
5858
name,
5959
path,
60-
output = NULL,
60+
output_file = NULL,
6161
working_directory = NULL,
6262
packages = targets::tar_option_get("packages"),
6363
library = targets::tar_option_get("library"),
@@ -76,8 +76,8 @@ tar_knit_raw <- function(
7676
targets::tar_assert_package("knitr")
7777
targets::tar_assert_file(path)
7878
targets::tar_assert_not_dirs(path)
79-
targets::tar_assert_chr(output %|||% "x")
80-
targets::tar_assert_scalar(output %|||% "x")
79+
targets::tar_assert_chr(output_file %|||% "x")
80+
targets::tar_assert_scalar(output_file %|||% "x")
8181
if (!is.null(working_directory)) {
8282
targets::tar_assert_file(working_directory)
8383
}
@@ -87,7 +87,7 @@ tar_knit_raw <- function(
8787
name = name,
8888
command = tar_knit_command(
8989
path,
90-
output,
90+
output_file,
9191
working_directory,
9292
knit_arguments,
9393
quiet

Diff for: R/tar_quarto.R

+2
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
tar_quarto <- function(
118118
name,
119119
path = ".",
120+
output_file = NULL,
120121
working_directory = NULL,
121122
extra_files = character(0),
122123
execute = TRUE,
@@ -149,6 +150,7 @@ tar_quarto <- function(
149150
tar_quarto_raw(
150151
name = name,
151152
path = path,
153+
output_file = output_file,
152154
working_directory = working_directory,
153155
extra_files = extra_files,
154156
execute = execute,

Diff for: R/tar_quarto_raw.R

+8
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
tar_quarto_raw <- function(
110110
name,
111111
path = ".",
112+
output_file = NULL,
112113
working_directory = NULL,
113114
extra_files = character(0),
114115
execute = TRUE,
@@ -138,6 +139,9 @@ tar_quarto_raw <- function(
138139
targets::tar_assert_chr(extra_files)
139140
targets::tar_assert_nzchar(extra_files)
140141
targets::tar_assert_file(path)
142+
targets::tar_assert_chr(output_file %|||% "x")
143+
targets::tar_assert_scalar(output_file %|||% "x")
144+
targets::tar_assert_nzchar(output_file %|||% "x")
141145
if (!is.null(working_directory)) {
142146
targets::tar_assert_file(working_directory)
143147
}
@@ -170,6 +174,7 @@ tar_quarto_raw <- function(
170174
}
171175
command <- tar_quarto_command(
172176
path = path,
177+
output_file = output_file,
173178
working_directory = working_directory,
174179
sources = sources,
175180
output = output,
@@ -202,6 +207,7 @@ tar_quarto_raw <- function(
202207

203208
tar_quarto_command <- function(
204209
path,
210+
output_file,
205211
working_directory,
206212
sources,
207213
output,
@@ -218,6 +224,7 @@ tar_quarto_command <- function(
218224
args <- substitute(
219225
list(
220226
input = path,
227+
output_file = output_file,
221228
execute = execute,
222229
execute_params = execute_params,
223230
execute_dir = execute_dir,
@@ -233,6 +240,7 @@ tar_quarto_command <- function(
233240
),
234241
env = list(
235242
path = path,
243+
output_file = output_file,
236244
execute = execute,
237245
execute_dir = working_directory %|||% quote(getwd()),
238246
execute_params = execute_params,

Diff for: R/tar_render.R

+6-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
#' @inheritParams rmarkdown::render
5151
#' @param path Character string, file path to the R Markdown source file.
5252
#' Must have length 1.
53-
#' @param output Character string, file path to the rendered output file.
53+
#' @param output_file Character string, file path to the rendered output file.
5454
#' @param working_directory Optional character string,
5555
#' path to the working directory
5656
#' to temporarily set when running the report.
@@ -123,7 +123,7 @@
123123
tar_render <- function(
124124
name,
125125
path,
126-
output = NULL,
126+
output_file = NULL,
127127
working_directory = NULL,
128128
tidy_eval = targets::tar_option_get("tidy_eval"),
129129
packages = targets::tar_option_get("packages"),
@@ -142,6 +142,9 @@ tar_render <- function(
142142
) {
143143
targets::tar_assert_package("rmarkdown")
144144
targets::tar_assert_file(path)
145+
targets::tar_assert_chr(output_file %|||% "x")
146+
targets::tar_assert_scalar(output_file %|||% "x")
147+
targets::tar_assert_nzchar(output_file %|||% "x")
145148
if (!is.null(working_directory)) {
146149
targets::tar_assert_file(working_directory)
147150
}
@@ -155,7 +158,7 @@ tar_render <- function(
155158
name = targets::tar_deparse_language(substitute(name)),
156159
command = tar_render_command(
157160
path,
158-
output,
161+
output_file,
159162
working_directory,
160163
args,
161164
quiet

Diff for: R/tar_render_raw.R

+5-5
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
tar_render_raw <- function(
8585
name,
8686
path,
87-
output = NULL,
87+
output_file = NULL,
8888
working_directory = NULL,
8989
packages = targets::tar_option_get("packages"),
9090
library = targets::tar_option_get("library"),
@@ -100,9 +100,9 @@ tar_render_raw <- function(
100100
) {
101101
targets::tar_assert_package("rmarkdown")
102102
targets::tar_assert_file(path)
103-
targets::tar_assert_chr(output %|||% "x")
104-
targets::tar_assert_scalar(output %|||% "x")
105-
targets::tar_assert_nzchar(output %|||% "x")
103+
targets::tar_assert_chr(output_file %|||% "x")
104+
targets::tar_assert_scalar(output_file %|||% "x")
105+
targets::tar_assert_nzchar(output_file %|||% "x")
106106
if (!is.null(working_directory)) {
107107
targets::tar_assert_file(working_directory)
108108
}
@@ -112,7 +112,7 @@ tar_render_raw <- function(
112112
name = name,
113113
command = tar_render_command(
114114
path,
115-
output,
115+
output_file,
116116
working_directory,
117117
render_arguments,
118118
quiet

Diff for: inst/WORDLIST

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Boneri
2323
Bostock
2424
brancher
2525
Broman
26+
CLI
2627
Broman's
2728
bugfix
2829
Bugfix

Diff for: man/tar_knit.Rd

+2-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_knit_raw.Rd

+2-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_quarto.Rd

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_quarto_raw.Rd

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_quarto_rep.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_quarto_rep_raw.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_render.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_render_raw.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)