Skip to content

Commit

Permalink
Fix #503
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Jun 7, 2021
1 parent a79291f commit 9ae13b2
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 4 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ export(tar_group)
export(tar_helper)
export(tar_helper_raw)
export(tar_invalidate)
export(tar_knitr_engine)
export(tar_load)
export(tar_load_globals)
export(tar_load_raw)
Expand Down
19 changes: 17 additions & 2 deletions R/utils_knitr.R → R/tar_knitr_engine.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
knitr_engine <- function(options) {
#' @title Target Markdown `knitr` engine
#' @export
#' @family targetopia
#' @seealso <https://books.ropensci.org/targets/markdown.html>
#' @description `knitr` language engine that runs `{targets}`
#' code chunks in Target Markdown.
#' @return Character, output generated from `knitr::engine_output()`.
#' @param options A named list of `knitr` chunk options.
#' @examples
#' # Register the engine.
#' if (requireNamespace("knitr", quietly = TRUE)) {
#' knitr::knit_engines$set(targets = tar_knitr_engine)
#' }
#' # Then, {targets} code chunks in a knitr report will run
#' # as described at https://books.ropensci.org/targets/markdown.html.
tar_knitr_engine <- function(options) {
assert_package("knitr")
assert_list(options, "knitr chunk options must be a list.")
assert_chr(options$label, "knitr chunk must have a label")
Expand Down Expand Up @@ -193,6 +208,6 @@ warn_labels_unnamed <- function(options) {

knitr_engine_set <- function() {
if (requireNamespace("knitr", quietly = TRUE)) {
knitr::knit_engines$set(targets = function(options) knitr_engine(options))
knitr::knit_engines$set(targets = function(options) tar_knitr_engine(options))
}
}
2 changes: 1 addition & 1 deletion R/tar_test.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' @title Test code in a temporary directory.
#' @export
#' @family tar_test
#' @family targetopia
#' @description Runs a `test_that()` unit test inside a temporary
#' directory to avoid writing to the user's file space.
#' This helps ensure compliance with CRAN policies.
Expand Down
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,5 @@ reference:
- title: Targetopia
contents:
- '`tar_dir`'
- '`tar_knitr_engine`'
- '`tar_test`'
5 changes: 5 additions & 0 deletions man/tar_dir.Rd

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

34 changes: 34 additions & 0 deletions man/tar_knitr_engine.Rd

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

7 changes: 6 additions & 1 deletion man/tar_test.Rd

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

File renamed without changes.

0 comments on commit 9ae13b2

Please sign in to comment.