diff --git a/DESCRIPTION b/DESCRIPTION index fe958dc8..c22cbfec 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -17,7 +17,7 @@ URL: https://github.com/quarto-dev/quarto-r, BugReports: https://github.com/quarto-dev/quarto-r/issues Depends: R (>= 3.6) -Imports: +Imports: cli, jsonlite, later, @@ -29,6 +29,7 @@ Imports: utils, yaml Suggests: + bslib, callr, curl, dplyr, diff --git a/NAMESPACE b/NAMESPACE index 7fe0658d..c68157b1 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -19,12 +19,12 @@ export(quarto_update_extension) export(quarto_use_template) export(quarto_version) export(theme_brand_flextable) -export(theme_brand_ggplot) +export(theme_brand_ggplot2) export(theme_brand_gt) export(theme_brand_plotly) export(theme_brand_thematic) export(theme_colors_flextable) -export(theme_colors_ggplot) +export(theme_colors_ggplot2) export(theme_colors_gt) export(theme_colors_plotly) export(theme_colors_thematic) diff --git a/R/theme.R b/R/theme.R index d58d54c6..3fe32073 100644 --- a/R/theme.R +++ b/R/theme.R @@ -14,6 +14,10 @@ #' #' @export theme_colors_flextable <- function(bg, fg) { + rlang::check_installed( + "flextable", + "flextable is required for theme_colors_flextable" + ) (function(x) { if (!inherits(x, "flextable")) { stop("theme_colors_flextable only supports flextable objects.") @@ -28,7 +32,12 @@ theme_colors_flextable <- function(bg, fg) { #' #' @export theme_brand_flextable <- function(brand_yml) { - brand <- yaml::yaml.load_file(brand_yml) + rlang::check_installed( + "bslib", + "bslib is required for brand support in R", + version = "0.9.0" + ) + brand <- attr(bslib::bs_theme(brand = brand_yml), "brand") theme_colors_flextable(brand$color$background, brand$color$foreground) } @@ -36,10 +45,11 @@ theme_brand_flextable <- function(brand_yml) { #' @rdname theme_helpers #' #' @export -theme_colors_ggplot <- function(bg, fg) { - if (!requireNamespace("ggplot2", quietly = TRUE)) { - return(NULL) - } +theme_colors_ggplot2 <- function(bg, fg) { + rlang::check_installed( + "ggplot2", + "ggplot2 is required for theme_colors_ggplot2" + ) ggplot2::`%+%`( ggplot2::theme_minimal(base_size = 11), ggplot2::theme( @@ -61,9 +71,14 @@ theme_colors_ggplot <- function(bg, fg) { #' @rdname theme_helpers #' #' @export -theme_brand_ggplot <- function(brand_yml) { - brand <- yaml::yaml.load_file(brand_yml) - theme_colors_ggplot(brand$color$background, brand$color$foreground) +theme_brand_ggplot2 <- function(brand_yml) { + rlang::check_installed( + "bslib", + "bslib is required for brand support in R", + version = "0.9.0" + ) + brand <- attr(bslib::bs_theme(brand = brand_yml), "brand") + theme_colors_ggplot2(brand$color$background, brand$color$foreground) } @@ -71,6 +86,10 @@ theme_brand_ggplot <- function(brand_yml) { #' #' @export theme_colors_gt <- function(bg, fg) { + rlang::check_installed( + "gt", + "gt is required for theme_colors_gt" + ) (function(table) { table |> gt::tab_options( @@ -84,7 +103,12 @@ theme_colors_gt <- function(bg, fg) { #' #' @export theme_brand_gt <- function(brand_yml) { - brand <- yaml::yaml.load_file(brand_yml) + rlang::check_installed( + "bslib", + "bslib is required for brand support in R", + version = "0.9.0" + ) + brand <- attr(bslib::bs_theme(brand = brand_yml), "brand") theme_colors_gt(brand$color$background, brand$color$foreground) } @@ -92,6 +116,10 @@ theme_brand_gt <- function(brand_yml) { #' #' @export theme_colors_plotly <- function(bg, fg) { + rlang::check_installed( + "plotly", + "plotly is required for theme_colors_plotly" + ) (function(plot) { plot |> plotly::layout( @@ -106,7 +134,12 @@ theme_colors_plotly <- function(bg, fg) { #' #' @export theme_brand_plotly <- function(brand_yml) { - brand <- yaml::yaml.load_file(brand_yml) + rlang::check_installed( + "bslib", + "bslib is required for brand support in R", + version = "0.9.0" + ) + brand <- attr(bslib::bs_theme(brand = brand_yml), "brand") theme_colors_plotly(brand$color$background, brand$color$foreground) } @@ -115,6 +148,10 @@ theme_brand_plotly <- function(brand_yml) { #' #' @export theme_colors_thematic <- function(bg, fg) { + rlang::check_installed( + "thematic", + "thematic is required for theme_colors_thematic" + ) (function() { thematic::thematic_rmd( bg = bg, @@ -127,6 +164,11 @@ theme_colors_thematic <- function(bg, fg) { #' #' @export theme_brand_thematic <- function(brand_yml) { - brand <- yaml::yaml.load_file(brand_yml) + rlang::check_installed( + "bslib", + "bslib is required for brand support in R", + version = "0.9.0" + ) + brand <- attr(bslib::bs_theme(brand = brand_yml), "brand") theme_colors_thematic(brand$color$background, brand$color$foreground) } diff --git a/man/quarto_publish_doc.Rd b/man/quarto_publish_doc.Rd index 8e6ae6f6..df6c0114 100644 --- a/man/quarto_publish_doc.Rd +++ b/man/quarto_publish_doc.Rd @@ -50,12 +50,11 @@ Defaults to the name of the \code{input}.} supplied, will often be displayed in favor of the name. When deploying a new document, you may supply only the title to receive an auto-generated name} -\item{server}{Server name. Required only if you use the same account name on -multiple servers.} +\item{account, server}{Uniquely identify a remote server with either your +user \code{account}, the \code{server} name, or both. If neither are supplied, and +there are multiple options, you'll be prompted to pick one. -\item{account}{Account to deploy application to. This parameter is only -required for the initial deployment of an application when there are -multiple accounts configured on the system (see \link[rsconnect]{accounts}).} +Use \code{\link[rsconnect:accounts]{accounts()}} to see the full list of available options.} \item{render}{\code{local} to render locally before publishing; \code{server} to render on the server; \code{none} to use whatever rendered content currently @@ -63,7 +62,10 @@ exists locally. (defaults to \code{local})} \item{metadata}{Additional metadata fields to save with the deployment record. These fields will be returned on subsequent calls to -\code{\link[rsconnect:deployments]{deployments()}}.} +\code{\link[rsconnect:deployments]{deployments()}}. + +Multi-value fields are recorded as comma-separated values and returned in +that form. Custom value serialization is the responsibility of the caller.} \item{...}{Named parameters to pass along to \code{rsconnect::deployApp()}} } diff --git a/man/theme_helpers.Rd b/man/theme_helpers.Rd index 57f02303..fbec2824 100644 --- a/man/theme_helpers.Rd +++ b/man/theme_helpers.Rd @@ -3,8 +3,8 @@ \name{theme_colors_flextable} \alias{theme_colors_flextable} \alias{theme_brand_flextable} -\alias{theme_colors_ggplot} -\alias{theme_brand_ggplot} +\alias{theme_colors_ggplot2} +\alias{theme_brand_ggplot2} \alias{theme_colors_gt} \alias{theme_brand_gt} \alias{theme_colors_plotly} @@ -17,9 +17,9 @@ theme_colors_flextable(bg, fg) theme_brand_flextable(brand_yml) -theme_colors_ggplot(bg, fg) +theme_colors_ggplot2(bg, fg) -theme_brand_ggplot(brand_yml) +theme_brand_ggplot2(brand_yml) theme_colors_gt(bg, fg) diff --git a/tests/testthat/test-theme.R b/tests/testthat/test-theme.R index 22b05d22..638eb194 100644 --- a/tests/testthat/test-theme.R +++ b/tests/testthat/test-theme.R @@ -14,8 +14,8 @@ test_that("render ggiraph", { .render(test_path("theme/ggiraph.qmd")) }) -test_that("render ggplot", { - .render(test_path("theme/ggplot.qmd")) +test_that("render ggplot2", { + .render(test_path("theme/ggplot2.qmd")) }) test_that("render gt", { diff --git a/tests/testthat/theme/ggiraph.qmd b/tests/testthat/theme/ggiraph.qmd index 3b8bb607..44b801a0 100644 --- a/tests/testthat/theme/ggiraph.qmd +++ b/tests/testthat/theme/ggiraph.qmd @@ -12,8 +12,8 @@ library(quarto) library(ggplot2) library(ggiraph) -united_theme <- theme_brand_ggplot("united-brand.yml") -slate_theme <- theme_brand_ggplot("slate-brand.yml") +united_theme <- theme_brand_ggplot2("united-brand.yml") +slate_theme <- theme_brand_ggplot2("slate-brand.yml") ``` ```{r} diff --git a/tests/testthat/theme/ggplot.qmd b/tests/testthat/theme/ggplot2.qmd similarity index 78% rename from tests/testthat/theme/ggplot.qmd rename to tests/testthat/theme/ggplot2.qmd index 211240e4..cf18ac73 100644 --- a/tests/testthat/theme/ggplot.qmd +++ b/tests/testthat/theme/ggplot2.qmd @@ -12,8 +12,8 @@ brand: library(quarto) library(ggplot2) -united_theme <- theme_brand_ggplot("united-brand.yml") -slate_theme <- theme_brand_ggplot("slate-brand.yml") +united_theme <- theme_brand_ggplot2("united-brand.yml") +slate_theme <- theme_brand_ggplot2("slate-brand.yml") ``` ```{r} diff --git a/vignettes/theme-helpers.qmd b/vignettes/theme-helpers.qmd index 714b0e88..5896bd13 100644 --- a/vignettes/theme-helpers.qmd +++ b/vignettes/theme-helpers.qmd @@ -56,7 +56,7 @@ library(quarto) library(ggplot2) library(ggiraph) -blue_mauve_theme = theme_colors_ggplot("#111038", "#E0B0FF") +blue_mauve_theme = theme_colors_ggplot2("#111038", "#E0B0FF") cars <- ggplot(mtcars, aes(mpg, wt)) + geom_point_interactive(aes(colour = factor(cyl), tooltip = rownames(mtcars))) + @@ -76,7 +76,7 @@ Demonstrates a ggplot2 plot with near-black background and green-grey foreground library(quarto) library(ggplot2) -black_greyn <- theme_colors_ggplot("#050411", "#8faf8e") +black_greyn <- theme_colors_ggplot2("#050411", "#8faf8e") cars <- ggplot(mtcars, aes(mpg, wt)) + geom_point(aes(colour = factor(cyl))) +