diff --git a/DESCRIPTION b/DESCRIPTION index 411b8d2f..c3cd3c29 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: golem Title: A Framework for Robust Shiny Applications -Version: 0.3.3.9000 +Version: 0.3.4 Authors@R: c(person(given = "Colin", family = "Fay", @@ -82,11 +82,12 @@ Suggests: testthat, tools, withr, - attachment (>= 0.2.5) + attachment (>= 0.2.5), + renv VignetteBuilder: knitr Config/testthat/edition: 3 Encoding: UTF-8 Language: en-US Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.0 +RoxygenNote: 7.2.1 diff --git a/R/add_dockerfiles.R b/R/add_dockerfiles.R index 56a62789..22dc7b87 100644 --- a/R/add_dockerfiles.R +++ b/R/add_dockerfiles.R @@ -52,25 +52,25 @@ talk_once <- function(.f, msg = "") { #' @examples #' \donttest{ #' # Add a standard Dockerfile -#' if (interactive()) { +#' if (interactive() & requireNamespace("dockerfiler")) { #' add_dockerfile() #' } #' # Crete a 'deploy' folder containing everything needed to deploy #' # the golem using docker based on {renv} -#' if (interactive()) { +#' if (interactive() & requireNamespace("dockerfiler")) { #' add_dockerfile_with_renv( #' # lockfile = "renv.lock", # uncomment to use existing renv.lock file #' output_dir = "deploy" #' ) #' } #' # Add a Dockerfile for ShinyProxy -#' if (interactive()) { +#' if (interactive() & requireNamespace("dockerfiler")) { #' add_dockerfile_shinyproxy() #' } #' #' # Crete a 'deploy' folder containing everything needed to deploy #' # the golem with ShinyProxy using docker based on {renv} -#' if (interactive()) { +#' if (interactive() & requireNamespace("dockerfiler")) { #' add_dockerfile_with_renv( #' # lockfile = "renv.lock",# uncomment to use existing renv.lock file #' output_dir = "deploy" @@ -78,7 +78,7 @@ talk_once <- function(.f, msg = "") { #' } #' #' # Add a Dockerfile for Heroku -#' if (interactive()) { +#' if (interactive() & requireNamespace("dockerfiler")) { #' add_dockerfile_heroku() #' } #' } diff --git a/R/add_r_files.R b/R/add_r_files.R index ef05a1b0..575fc362 100644 --- a/R/add_r_files.R +++ b/R/add_r_files.R @@ -67,10 +67,6 @@ add_r_files <- function( } if (with_test) { - rlang::check_installed( - "usethis", - "to build the test structure." - ) usethis::use_test( basename( file_path_sans_ext( diff --git a/R/test_helpers.R b/R/test_helpers.R index 5236ecec..14baa080 100644 --- a/R/test_helpers.R +++ b/R/test_helpers.R @@ -8,9 +8,6 @@ #' @return A testthat result. #' @export #' @rdname testhelpers -#' -#' @examples -#' expect_shinytag(shiny::tags$span("1")) expect_shinytag <- function(object) { rlang::check_installed( "testthat", @@ -27,8 +24,6 @@ expect_shinytag <- function(object) { #' @export #' @rdname testhelpers -#' @examples -#' expect_shinytaglist(shiny::tagList(1)) expect_shinytaglist <- function(object) { rlang::check_installed( "testthat", diff --git a/R/with_opt.R b/R/with_opt.R index dfde7a5d..14af6d68 100644 --- a/R/with_opt.R +++ b/R/with_opt.R @@ -64,38 +64,38 @@ with_golem_options <- function( #' @return The value of the option. #' #' @examples -#' \dontrun{ #' #' # Define and use golem_options +#' if (interactive()) { +#' # 1. Pass parameters to `run_app` #' -#' # 1. Pass parameters to `run_app` +#' # to set default value, edit run_app like this : #' -#' # to set default value, edit run_app like this : -#' run_app <- function( +#' run_app <- function( #' title = "this", #' content = "that" -#' ) { -#' with_golem_options( -#' app = shinyApp( -#' ui = app_ui, -#' server = app_server -#' ), -#' golem_opts = list( -#' p1 = p1, -#' p3 = p3 +#' ) { +#' with_golem_options( +#' app = shinyApp( +#' ui = app_ui, +#' server = app_server +#' ), +#' golem_opts = list( +#' p1 = p1, +#' p3 = p3 +#' ) #' ) -#' ) -#' } +#' } #' -#' # 2. Get the values from the UI side +#' # 2. Get the values from the UI side #' -#' h1(get_golem_options("title")) +#' h1(get_golem_options("title")) #' -#' # 3. Get the value from the server-side +#' # 3. Get the value from the server-side #' -#' output$param <- renderPrint({ -#' paste("param p2 = ", get_golem_options("p2")) -#' }) +#' output$param <- renderPrint({ +#' paste("param p2 = ", get_golem_options("p2")) +#' }) #' } #' get_golem_options <- function(which = NULL) { diff --git a/man/dockerfiles.Rd b/man/dockerfiles.Rd index 53129521..d5a4f59c 100644 --- a/man/dockerfiles.Rd +++ b/man/dockerfiles.Rd @@ -167,25 +167,25 @@ a generic Dockerfile, while \code{add_dockerfile_shinyproxy()}, \code{add_docker \examples{ \donttest{ # Add a standard Dockerfile -if (interactive()) { +if (interactive() & requireNamespace("dockerfiler")) { add_dockerfile() } # Crete a 'deploy' folder containing everything needed to deploy # the golem using docker based on {renv} -if (interactive()) { +if (interactive() & requireNamespace("dockerfiler")) { add_dockerfile_with_renv( # lockfile = "renv.lock", # uncomment to use existing renv.lock file output_dir = "deploy" ) } # Add a Dockerfile for ShinyProxy -if (interactive()) { +if (interactive() & requireNamespace("dockerfiler")) { add_dockerfile_shinyproxy() } # Crete a 'deploy' folder containing everything needed to deploy # the golem with ShinyProxy using docker based on {renv} -if (interactive()) { +if (interactive() & requireNamespace("dockerfiler")) { add_dockerfile_with_renv( # lockfile = "renv.lock",# uncomment to use existing renv.lock file output_dir = "deploy" @@ -193,7 +193,7 @@ if (interactive()) { } # Add a Dockerfile for Heroku -if (interactive()) { +if (interactive() & requireNamespace("dockerfiler")) { add_dockerfile_heroku() } } diff --git a/man/get_golem_options.Rd b/man/get_golem_options.Rd index b768d479..a0e2895f 100644 --- a/man/get_golem_options.Rd +++ b/man/get_golem_options.Rd @@ -18,38 +18,38 @@ server and UI from your app, in order to call the parameters passed to \code{run_app()}. } \examples{ -\dontrun{ # Define and use golem_options +if (interactive()) { + # 1. Pass parameters to `run_app` -# 1. Pass parameters to `run_app` + # to set default value, edit run_app like this : -# to set default value, edit run_app like this : -run_app <- function( + run_app <- function( title = "this", content = "that" -) { - with_golem_options( - app = shinyApp( - ui = app_ui, - server = app_server - ), - golem_opts = list( - p1 = p1, - p3 = p3 + ) { + with_golem_options( + app = shinyApp( + ui = app_ui, + server = app_server + ), + golem_opts = list( + p1 = p1, + p3 = p3 + ) ) - ) -} + } -# 2. Get the values from the UI side + # 2. Get the values from the UI side -h1(get_golem_options("title")) + h1(get_golem_options("title")) -# 3. Get the value from the server-side + # 3. Get the value from the server-side -output$param <- renderPrint({ - paste("param p2 = ", get_golem_options("p2")) -}) + output$param <- renderPrint({ + paste("param p2 = ", get_golem_options("p2")) + }) } } diff --git a/man/testhelpers.Rd b/man/testhelpers.Rd index 6ad0ed56..0b516339 100644 --- a/man/testhelpers.Rd +++ b/man/testhelpers.Rd @@ -35,7 +35,3 @@ A testthat result. These functions are designed to be used inside the tests in your Shiny app package. } -\examples{ -expect_shinytag(shiny::tags$span("1")) -expect_shinytaglist(shiny::tagList(1)) -} diff --git a/tests/testthat/test-add_deploy_helpers.R b/tests/testthat/test-add_deploy_helpers.R index 7057e65a..b798603f 100644 --- a/tests/testthat/test-add_deploy_helpers.R +++ b/tests/testthat/test-add_deploy_helpers.R @@ -1,5 +1,8 @@ test_that("add_dockerfiles", { - skip_if_not_installed("dockerfiler", "0.1.4") + skip_if_not_installed("renv") + skip_if_not_installed("dockerfiler", "0.2.0") + skip_if_not_installed("attachment", "0.2.5") + with_dir(pkg, { for (fun in list( add_dockerfile, diff --git a/tests/testthat/test-extra_sysreqs.R b/tests/testthat/test-extra_sysreqs.R index 2b5f34d8..6530b095 100644 --- a/tests/testthat/test-extra_sysreqs.R +++ b/tests/testthat/test-extra_sysreqs.R @@ -1,4 +1,7 @@ test_that("test extra sysreqs", { + skip_if_not_installed("renv") + skip_if_not_installed("dockerfiler", "0.2.0") + skip_if_not_installed("attachment", "0.2.5") with_dir(pkg, { for (fun in list( add_dockerfile, diff --git a/tests/testthat/test-renv_stuff.R b/tests/testthat/test-renv_stuff.R index 43d74c15..f63449e4 100644 --- a/tests/testthat/test-renv_stuff.R +++ b/tests/testthat/test-renv_stuff.R @@ -1,6 +1,7 @@ test_that("add_dockerfiles_renv and add_dockerfile_with_renv_shinyproxy all output file are present", { + skip_if_not_installed("renv") skip_if_not_installed("dockerfiler", "0.2.0") - + skip_if_not_installed("attachment", "0.2.5") with_dir(pkg, { for (fun in list( add_dockerfile_with_renv,