Skip to content

Commit 2068658

Browse files
committed
Merge commit '2fd494eb69f0dd6495bf6f8303075f451f8e8186'
2 parents c7b1678 + 2fd494e commit 2068658

23 files changed

+448
-49
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
#
4+
# NOTE: This workflow is overkill for most R packages and
5+
# check-standard.yaml is likely a better choice.
6+
# usethis::use_github_action("check-standard") will install it.
7+
on:
8+
push:
9+
branches: [main, master]
10+
pull_request:
11+
branches: [main, master]
12+
13+
name: R-CMD-check
14+
15+
jobs:
16+
R-CMD-check:
17+
runs-on: ${{ matrix.config.os }}
18+
19+
name: ${{ matrix.config.os }} (${{ matrix.config.r }}) [Quarto ${{ matrix.config.quarto || 'release' }}]
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
config:
25+
- {os: macos-latest, r: 'release'}
26+
- {os: macos-latest, r: 'release', quarto: 'pre-release'}
27+
28+
- {os: windows-latest, r: 'release'}
29+
- {os: windows-latest, r: 'release', quarto: 'pre-release'}
30+
# Use 3.6 to trigger usage of RTools35
31+
- {os: windows-latest, r: '3.6'}
32+
# use 4.1 to check with rtools40's older compiler
33+
- {os: windows-latest, r: '4.1'}
34+
35+
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
36+
- {os: ubuntu-latest, r: 'release'}
37+
- {os: ubuntu-latest, r: 'release', quarto: 'pre-release'}
38+
- {os: ubuntu-latest, r: 'oldrel-1'}
39+
- {os: ubuntu-latest, r: 'oldrel-2'}
40+
- {os: ubuntu-latest, r: 'oldrel-3'}
41+
- {os: ubuntu-latest, r: 'oldrel-4'}
42+
43+
env:
44+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
45+
R_KEEP_PKG_SOURCE: yes
46+
47+
steps:
48+
- uses: actions/checkout@v3
49+
50+
- uses: quarto-dev/quarto-actions/setup@v2
51+
with:
52+
version: ${{ matrix.config.quarto || 'release' }}
53+
54+
# replace with setting up QUARTO Pandoc for rmarkdown
55+
- uses: r-lib/actions/setup-pandoc@v2
56+
57+
- uses: r-lib/actions/setup-r@v2
58+
with:
59+
r-version: ${{ matrix.config.r }}
60+
http-user-agent: ${{ matrix.config.http-user-agent }}
61+
use-public-rspm: true
62+
63+
- uses: r-lib/actions/setup-r-dependencies@v2
64+
with:
65+
extra-packages: any::rcmdcheck
66+
needs: check
67+
68+
- uses: r-lib/actions/check-r-package@v2
69+
with:
70+
upload-snapshots: true

DESCRIPTION

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
11
Package: quarto
22
Title: R Interface to 'Quarto' Markdown Publishing System
3-
Version: 1.3
4-
Authors@R:
5-
person(given = "JJ",
6-
family = "Allaire",
7-
role = c("aut", "cre"),
8-
email = "[email protected]",
9-
comment = c(ORCID = "0000-0003-0174-9868"))
10-
Description: Convert R Markdown documents and 'Jupyter' notebooks to a variety of
11-
output formats using 'Quarto'.
12-
Imports: utils,rmarkdown,jsonlite,yaml,processx,rstudioapi,later,rsconnect (>= 0.8.26)
13-
Suggests:
14-
knitr,
15-
testthat (>= 3.1.0)
16-
SystemRequirements: Quarto command line tools (https://github.com/quarto-dev/quarto-cli).
3+
Version: 1.3.3
4+
Authors@R: c(
5+
person("JJ", "Allaire", , "[email protected]", role = c("aut", "cre"),
6+
comment = c(ORCID = "0000-0003-0174-9868")),
7+
person("Christophe", "Dervieux", , "[email protected]", role = c("aut"),
8+
comment = c(ORCID = "0000-0003-4474-2498"))
9+
)
10+
Description: Convert R Markdown documents and 'Jupyter' notebooks to a
11+
variety of output formats using 'Quarto'.
1712
License: GPL (>= 2)
18-
URL: https://github.com/quarto-dev/quarto-r, https://quarto-dev.github.io/quarto-r/
13+
URL: https://github.com/quarto-dev/quarto-r,
14+
https://quarto-dev.github.io/quarto-r/
1915
BugReports: https://github.com/quarto-dev/quarto-r/issues
16+
Imports:
17+
jsonlite,
18+
later,
19+
processx,
20+
rmarkdown,
21+
rsconnect (>= 0.8.26),
22+
rstudioapi,
23+
utils,
24+
yaml
25+
Suggests:
26+
knitr,
27+
testthat (>= 3.1.0),
28+
withr,
29+
xfun
30+
VignetteBuilder:
31+
knitr
32+
Config/testthat/edition: 3
2033
Encoding: UTF-8
2134
Roxygen: list(markdown = TRUE)
2235
RoxygenNote: 7.2.3
23-
Config/testthat/edition: 3
24-
VignetteBuilder: knitr
36+
SystemRequirements: Quarto command line tools
37+
(https://github.com/quarto-dev/quarto-cli).

NEWS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# quarto (development version)
2+
3+
* Add `profile` arguments to `quarto_render()` and `quarto_inspect()` (thanks, #95, @andrewheiss, #123, @salim-b).
4+
5+
* Add `metadata` and `metadata_file` to `quarto_render()` to pass modify Quarto metadata from calling render. If both are set, `metadata` will be merged over `metadata_file` content. Internally, metadata will be passed as a `--metadata-file` to `quarto render` (thanks, @mcanouil, #52, @maelle, #49).
6+
7+
* Added a `NEWS.md` file to track changes to the package.
8+
9+
* `execute_params` in `quarto_render()` now converts boolean value to `true/false` correctly as expected by `quarto render` (thanks, @marianklose, #124).

R/backports.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
if (getRversion() < "3.5.0") {
3+
isFALSE <- function(x) identical(x, FALSE)
4+
}

R/inspect.R

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
#' config and engines. Inspecting an input path return its formats, engine,
55
#' and dependent resources.
66
#'
7+
#' @inheritParams quarto_render
78
#' @param input The input file or project directory to inspect.
89
#'
9-
#' @return Named list. For input files, the list has members engine, format,
10-
#' and resources. For projects the list has members engines and config
11-
#'
12-
#' @importFrom jsonlite fromJSON
10+
#' @return Named list. For input files, the list contains the elements
11+
#' `quarto`, `engines`, `formats`, `resources`, plus `project` if the file is
12+
#' part of a Quarto project. For projects, the list contains the elements
13+
#' `quarto`, `dir`, `engines`, `config` and `files`.
1314
#'
1415
#' @examples
1516
#' \dontrun{
@@ -18,18 +19,26 @@
1819
#'
1920
#' # Inspect project
2021
#' quarto_inspect("myproject")
21-
#' }
2222
#'
23+
#' # Inspect project's advanced profile
24+
#' quarto_inspect(
25+
#' input = "myproject",
26+
#' profile = "advanced"
27+
#' )}
28+
#' @importFrom jsonlite fromJSON
2329
#' @export
24-
quarto_inspect <- function(input = ".") {
30+
quarto_inspect <- function(input = ".",
31+
profile = NULL) {
2532

2633
quarto_bin <- find_quarto()
2734

28-
output <- system2(quarto_bin, stdout = TRUE, c(
29-
"inspect",
30-
path.expand(input)
31-
))
35+
args <- c("inspect", path.expand(input))
3236

33-
fromJSON(output)
34-
}
37+
if (!is.null(profile)) {
38+
args <- c(args, c("--profile", paste0(profile, collapse = ",")))
39+
}
40+
41+
res <- processx::run(quarto_bin, args, echo_cmd = getOption("quarto.echo_cmd", FALSE))
3542

43+
fromJSON(res$stdout)
44+
}

R/quarto-args.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cli_arg_profile <- function(profile, ...) {
2+
arg <- c("--profile", paste0(profile, collapse = ","))
3+
append_cli_args(arg, ...)
4+
}
5+
6+
append_cli_args <- function(new, append_to = NULL, after = length(append_to)) {
7+
if (!is.null(append_to)) return(append(append_to, new, after))
8+
new
9+
}

R/render.R

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,27 @@
2525
#' @param use_freezer Force use of frozen computations for an incremental
2626
#' file render.
2727
#' @param cache Cache execution output (uses knitr cache and jupyter-cache
28-
#' respectively for Rmd and Jupyter input files).
28+
#' respectively for Rmd and Jupyter input files).
2929
#' @param cache_refresh Force refresh of execution cache.
30+
#' @param metadata An optional named list used to override YAML
31+
#' metadata. It will be passed as a YAML file to `--metadata-file` CLI flag.
32+
#' This will be merged over `metadata-file` options if both are
33+
#' specified.
34+
#' @param metadata_file A yaml file passed to `--metadata-file` CLI flags to
35+
#' overrite metadata. This will be merged with `metadata` if both are
36+
#' specified, with low precedence on `metadata` options.
3037
#' @param debug Leave intermediate files in place after render.
3138
#' @param quiet Suppress warning and other messages.
39+
#' @param profile [Quarto project
40+
#' profile(s)](https://quarto.org/docs/projects/profiles.html) to use. Either
41+
#' a character vector of profile names or `NULL` to use the default profile.
3242
#' @param pandoc_args Additional command line options to pass to pandoc.
3343
#' @param as_job Render as an RStudio background job. Default is "auto",
3444
#' which will render individual documents normally and projects as
3545
#' background jobs. Use the `quarto.render_as_job` R option to control
3646
#' the default globally.
3747
#'
3848
#' @importFrom rmarkdown relative_to
39-
#' @importFrom yaml write_yaml
4049
#'
4150
#' @examples
4251
#' \dontrun{
@@ -49,6 +58,9 @@
4958
#'
5059
#' # Render Jupyter Markdown
5160
#' quarto_render("notebook.md")
61+
#'
62+
#' # Override metadata
63+
#' quarto_render("notebook.Rmd", override = list(lang = "fr", echo = "false"))
5264
#' }
5365
#' @export
5466
quarto_render <- function(input = NULL,
@@ -63,8 +75,11 @@ quarto_render <- function(input = NULL,
6375
use_freezer = FALSE,
6476
cache = NULL,
6577
cache_refresh = FALSE,
78+
metadata = NULL,
79+
metadata_file = NULL,
6680
debug = FALSE,
6781
quiet = FALSE,
82+
profile = NULL,
6883
pandoc_args = NULL,
6984
as_job = getOption("quarto.render_as_job", "auto")) {
7085

@@ -146,12 +161,28 @@ quarto_render <- function(input = NULL,
146161
if (isTRUE(cache_refresh)) {
147162
args <- c(args, "--cache-refresh")
148163
}
164+
# metadata to pass to quarto render
165+
if (!missing(metadata)) {
166+
# We merge meta if there is metadata_file passed
167+
if (!missing(metadata_file)) {
168+
metadata <- merge_list(yaml::read_yaml(metadata_file, eval.expr = FALSE), metadata)
169+
}
170+
meta_file <- tempfile(pattern = "quarto-meta", fileext = ".yml")
171+
on.exit(unlink(meta_file), add = TRUE)
172+
write_yaml(metadata, meta_file)
173+
args <- c(args, "--metadata-file", meta_file)
174+
} else if (!missing(metadata_file)) {
175+
args <- c(args, "--metadata-file", metadata_file)
176+
}
149177
if (isTRUE(debug)) {
150178
args <- c(args, "--debug")
151179
}
152180
if (isTRUE(quiet)) {
153181
args <- c(args, "--quiet")
154182
}
183+
if (!is.null(profile)) {
184+
args <- cli_arg_profile(profile, args)
185+
}
155186
if (!is.null(pandoc_args)) {
156187
args <- c(args, pandoc_args)
157188
}
@@ -162,9 +193,3 @@ quarto_render <- function(input = NULL,
162193
# no return value
163194
invisible(NULL)
164195
}
165-
166-
167-
168-
169-
170-

R/utils.R

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,22 @@
33
relative_to_wd <- function(path) {
44
relative_to(getwd(), path)
55
}
6+
7+
#' @importFrom yaml write_yaml
8+
write_yaml <- function(x, file) {
9+
handlers <- list(
10+
# Handle yes/no from 1.1 to 1.2
11+
# https://github.com/vubiostat/r-yaml/issues/131
12+
logical = function(x) {
13+
value <- ifelse(x, "true", "false")
14+
structure(value, class = "verbatim")
15+
})
16+
yaml::write_yaml(x, file, handlers = handlers)
17+
}
18+
19+
20+
# inline knitr:::merge_list()
21+
merge_list <- function(x, y) {
22+
x[names(y)] <- y
23+
x
24+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<!-- badges: start -->
44
[![CRAN status](https://www.r-pkg.org/badges/version/quarto)](https://CRAN.R-project.org/package=quarto)
5+
[![R-CMD-check](https://github.com/quarto-dev/quarto-r/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/quarto-dev/quarto-r/actions/workflows/R-CMD-check.yaml)
56
<!-- badges: end -->
67

78
[Quarto](https://quarto.org) is an open-source scientific and technical publishing system built on [Pandoc](https://pandoc.org).

man/quarto_inspect.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.

0 commit comments

Comments
 (0)