Skip to content

Commit ba02f7b

Browse files
committed
format with air
1 parent ba68b3e commit ba02f7b

File tree

9 files changed

+105
-31
lines changed

9 files changed

+105
-31
lines changed

R/list.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#' @importFrom cli cli_abort
1515
#' @importFrom utils read.table
1616
#' @export
17-
quarto_list_extensions <- function(quiet = FALSE, quarto_args = NULL){
17+
quarto_list_extensions <- function(quiet = FALSE, quarto_args = NULL) {
1818
quarto_bin <- find_quarto()
1919

2020
args <- c("extensions", if (quiet) cli_arg_quiet(), quarto_args)
@@ -23,11 +23,17 @@ quarto_list_extensions <- function(quiet = FALSE, quarto_args = NULL){
2323
stderr_cleaned <- gsub("\\s+$", "", x$stderr)
2424
if (grepl("No extensions are installed", stderr_cleaned)) {
2525
invisible()
26-
} else{
27-
invisible(utils::read.table(text = stderr_cleaned, header = TRUE, fill = TRUE, sep = "", stringsAsFactors = FALSE))
26+
} else {
27+
invisible(utils::read.table(
28+
text = stderr_cleaned,
29+
header = TRUE,
30+
fill = TRUE,
31+
sep = "",
32+
stringsAsFactors = FALSE
33+
))
2834
}
2935
}
3036

31-
quarto_list <- function(args = character(), ...){
37+
quarto_list <- function(args = character(), ...) {
3238
quarto_run_what("list", args = args, ...)
3339
}

R/remove.R

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,22 @@
2727
#' @importFrom rlang is_interactive
2828
#' @importFrom cli cli_abort
2929
#' @export
30-
quarto_remove_extension <- function(extension = NULL, no_prompt = FALSE, quiet = FALSE, quarto_args = NULL) {
30+
quarto_remove_extension <- function(
31+
extension = NULL,
32+
no_prompt = FALSE,
33+
quiet = FALSE,
34+
quarto_args = NULL
35+
) {
3136
rlang::check_required(extension)
3237

3338
quarto_bin <- find_quarto()
3439

3540
# This will ask for approval or stop installation
36-
approval <- check_removal_approval(no_prompt, extension, "https://quarto.org/docs/extensions/managing.html")
41+
approval <- check_removal_approval(
42+
no_prompt,
43+
extension,
44+
"https://quarto.org/docs/extensions/managing.html"
45+
)
3746

3847
if (approval) {
3948
args <- c(extension, "--no-prompt", if (quiet) cli_arg_quiet(), quarto_args)

R/theme.R

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#' @param fg The foreground color
1111
#' @param brand_yml The path to a brand.yml file
1212

13-
1413
#' @rdname theme_helpers
1514
#'
1615
#' @export
@@ -41,7 +40,8 @@ theme_colors_ggplot <- function(bg, fg) {
4140
if (!requireNamespace("ggplot2", quietly = TRUE)) {
4241
return(NULL)
4342
}
44-
ggplot2::`%+%`(ggplot2::theme_minimal(base_size = 11),
43+
ggplot2::`%+%`(
44+
ggplot2::theme_minimal(base_size = 11),
4545
ggplot2::theme(
4646
panel.border = ggplot2::element_blank(),
4747
panel.grid.major.y = ggplot2::element_blank(),
@@ -54,7 +54,8 @@ theme_colors_ggplot <- function(bg, fg) {
5454
plot.background = ggplot2::element_rect(fill = bg, colour = NA),
5555
axis.line = ggplot2::element_line(colour = fg),
5656
axis.ticks = ggplot2::element_line(colour = fg)
57-
))
57+
)
58+
)
5859
}
5960

6061
#' @rdname theme_helpers
@@ -92,10 +93,12 @@ theme_brand_gt <- function(brand_yml) {
9293
#' @export
9394
theme_colors_plotly <- function(bg, fg) {
9495
(function(plot) {
95-
plot |> plotly::layout(paper_bgcolor = bg,
96-
plot_bgcolor = bg,
97-
font = list(color = fg)
98-
)
96+
plot |>
97+
plotly::layout(
98+
paper_bgcolor = bg,
99+
plot_bgcolor = bg,
100+
font = list(color = fg)
101+
)
99102
})
100103
}
101104

@@ -116,7 +119,8 @@ theme_colors_thematic <- function(bg, fg) {
116119
thematic::thematic_rmd(
117120
bg = bg,
118121
fg = fg,
119-
)})
122+
)
123+
})
120124
}
121125

122126
#' @rdname theme_helpers

R/update.R

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,22 @@
3131
#' @importFrom rlang is_interactive
3232
#' @importFrom cli cli_abort
3333
#' @export
34-
quarto_update_extension <- function(extension = NULL, no_prompt = FALSE, quiet = FALSE, quarto_args = NULL) {
34+
quarto_update_extension <- function(
35+
extension = NULL,
36+
no_prompt = FALSE,
37+
quiet = FALSE,
38+
quarto_args = NULL
39+
) {
3540
rlang::check_required(extension)
3641

3742
quarto_bin <- find_quarto()
3843

3944
# This will ask for approval or stop installation
40-
approval <- check_extension_approval(no_prompt, "Quarto extensions", "https://quarto.org/docs/extensions/managing.html")
45+
approval <- check_extension_approval(
46+
no_prompt,
47+
"Quarto extensions",
48+
"https://quarto.org/docs/extensions/managing.html"
49+
)
4150

4251
if (approval) {
4352
args <- c(extension, "--no-prompt", if (quiet) cli_arg_quiet(), quarto_args)

R/utils-prompt.R

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ check_extension_approval <- function(
3232
}
3333
}
3434

35-
check_removal_approval <- function(no_prompt = FALSE, what = "Something", see_more_at = NULL) {
35+
check_removal_approval <- function(
36+
no_prompt = FALSE,
37+
what = "Something",
38+
see_more_at = NULL
39+
) {
3640
if (no_prompt) return(TRUE)
3741

3842
if (!is_interactive()) {
@@ -44,7 +48,10 @@ check_removal_approval <- function(no_prompt = FALSE, what = "Something", see_mo
4448
}
4549
))
4650
} else {
47-
prompt_value <- tolower(readline(sprintf("? Are you sure you'd like to remove %s (Y/n)? ", what)))
51+
prompt_value <- tolower(readline(sprintf(
52+
"? Are you sure you'd like to remove %s (Y/n)? ",
53+
what
54+
)))
4855
if (!prompt_value %in% "y") {
4956
return(invisible(FALSE))
5057
}

tests/testthat/test-remove.R

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@ test_that("Removing an extension", {
33
skip_if_offline("github.com")
44
qmd <- local_qmd_file(c("content"))
55
withr::local_dir(dirname(qmd))
6-
expect_null(quarto_remove_extension("quarto-ext/fontawesome", no_prompt = TRUE, quiet = TRUE))
6+
expect_null(quarto_remove_extension(
7+
"quarto-ext/fontawesome",
8+
no_prompt = TRUE,
9+
quiet = TRUE
10+
))
711
quarto_add_extension("quarto-ext/fontawesome", no_prompt = TRUE, quiet = TRUE)
812
expect_true(dir.exists("_extensions/quarto-ext/fontawesome"))
9-
quarto_remove_extension("quarto-ext/fontawesome", no_prompt = TRUE, quiet = TRUE)
13+
quarto_remove_extension(
14+
"quarto-ext/fontawesome",
15+
no_prompt = TRUE,
16+
quiet = TRUE
17+
)
1018
expect_true(!dir.exists("_extensions/quarto-ext/fontawesome"))
1119
})

tests/testthat/test-theme.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
test_that("render flextable", {
32
skip_if_no_quarto()
43
quarto_render("theme/flextable.qmd", quiet = TRUE)
@@ -45,4 +44,3 @@ test_that("render thematic", {
4544
expect_true(file.exists("theme/thematic.html"))
4645
unlink("theme/thematic.html")
4746
})
48-

tests/testthat/test-update.R

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@ test_that("Updating an extension", {
33
skip_if_offline("github.com")
44
qmd <- local_qmd_file(c("content"))
55
withr::local_dir(dirname(qmd))
6-
expect_error(quarto_add_extension("quarto-ext/[email protected]"), "explicit approval")
7-
quarto_update_extension("quarto-ext/fontawesome", no_prompt = TRUE, quiet = TRUE)
6+
expect_error(
7+
quarto_add_extension("quarto-ext/[email protected]"),
8+
"explicit approval"
9+
)
10+
quarto_update_extension(
11+
"quarto-ext/fontawesome",
12+
no_prompt = TRUE,
13+
quiet = TRUE
14+
)
815
expect_true(dir.exists("_extensions/quarto-ext/fontawesome"))
9-
current_version <- yaml::read_yaml("_extensions/quarto-ext/fontawesome/_extension.yml")$version
16+
current_version <- yaml::read_yaml(
17+
"_extensions/quarto-ext/fontawesome/_extension.yml"
18+
)$version
1019
expect_false(identical(current_version, "v0.0.1"))
1120
})

tests/testthat/test-utils-prompt.R

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ test_that("Checking extension with approval prompt mocked y", {
44
is_interactive = function() TRUE
55
)
66
expect_true({
7-
check_extension_approval(FALSE, "Quarto extensions", "https://quarto.org/docs/extensions/managing.html")
7+
check_extension_approval(
8+
FALSE,
9+
"Quarto extensions",
10+
"https://quarto.org/docs/extensions/managing.html"
11+
)
812
})
913
})
1014

@@ -14,23 +18,43 @@ test_that("Checking extension with approval prompt mocked n", {
1418
is_interactive = function() TRUE
1519
)
1620
expect_false({
17-
check_extension_approval(FALSE, "Quarto extensions", "https://quarto.org/docs/extensions/managing.html")
21+
check_extension_approval(
22+
FALSE,
23+
"Quarto extensions",
24+
"https://quarto.org/docs/extensions/managing.html"
25+
)
1826
})
1927
})
2028

2129
test_that("Checking extension approval", {
2230
skip_if_no_quarto()
2331
skip_if_offline("github.com")
2432

25-
expect_true(check_extension_approval(TRUE, "Quarto extensions", "https://quarto.org/docs/extensions/managing.html"))
26-
expect_true(check_extension_approval(TRUE, "Quarto templates", "https://quarto.org/docs/extensions/formats.html#distributing-formats"))
33+
expect_true(check_extension_approval(
34+
TRUE,
35+
"Quarto extensions",
36+
"https://quarto.org/docs/extensions/managing.html"
37+
))
38+
expect_true(check_extension_approval(
39+
TRUE,
40+
"Quarto templates",
41+
"https://quarto.org/docs/extensions/formats.html#distributing-formats"
42+
))
2743

2844
expect_error({
2945
local_reproducible_output(rlang_interactive = FALSE)
30-
check_extension_approval(FALSE, "Quarto extensions", "https://quarto.org/docs/extensions/managing.html")
46+
check_extension_approval(
47+
FALSE,
48+
"Quarto extensions",
49+
"https://quarto.org/docs/extensions/managing.html"
50+
)
3151
})
3252
expect_error({
3353
local_reproducible_output(rlang_interactive = FALSE)
34-
check_extension_approval(TRUE, "Quarto extensions", "https://quarto.org/docs/extensions/managing.html")
54+
check_extension_approval(
55+
TRUE,
56+
"Quarto extensions",
57+
"https://quarto.org/docs/extensions/managing.html"
58+
)
3559
})
3660
})

0 commit comments

Comments
 (0)