From 30d5720be89cf7f049bb4d3fd46b8a073d7b6cfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Wed, 7 Feb 2024 16:25:27 +0100 Subject: [PATCH] Removes examples for non-exported functions (#1091) # Pull Request Fixes #1084 --- R/include_css_js.R | 8 ---- R/module_filter_manager.R | 42 -------------------- R/module_nested_tabs.R | 63 ----------------------------- R/module_tabs_with_filters.R | 59 --------------------------- R/module_teal.R | 24 ----------- R/modules.R | 26 ------------ R/teal_slices-store.R | 23 ----------- man/include_teal_css_js.Rd | 9 ----- man/module_filter_manager_modal.Rd | 43 -------------------- man/module_nested_tabs.Rd | 64 ------------------------------ man/module_tabs_with_filters.Rd | 60 ---------------------------- man/module_teal.Rd | 25 ------------ man/modules_depth.Rd | 27 ------------- man/slices_store.Rd | 23 ----------- 14 files changed, 496 deletions(-) diff --git a/R/include_css_js.R b/R/include_css_js.R index e763555011..04cb27dd55 100644 --- a/R/include_css_js.R +++ b/R/include_css_js.R @@ -71,14 +71,6 @@ run_js_files <- function(files) { #' #' Simply add `include_teal_css_js()` as one of the UI elements. #' @return A `shiny.tag.list`. -#' @examples -#' # use non-exported function from teal -#' include_teal_css_js <- getFromNamespace("include_teal_css_js", "teal") -#' shiny_ui <- tagList( -#' include_teal_css_js(), -#' p("Hello") -#' ) -#' #' @keywords internal include_teal_css_js <- function() { tagList( diff --git a/R/module_filter_manager.R b/R/module_filter_manager.R index 88d2907ff8..b51bc3a107 100644 --- a/R/module_filter_manager.R +++ b/R/module_filter_manager.R @@ -28,48 +28,6 @@ NULL #' #' @name module_filter_manager_modal #' @inheritParams module_filter_manager -#' @examples -#' # use non-exported function from teal -#' filter_manager_modal_ui <- getFromNamespace("filter_manager_modal_ui", "teal") -#' filter_manager_modal_srv <- getFromNamespace("filter_manager_modal_srv", "teal") -#' -#' fd1 <- teal.slice::init_filtered_data(list(iris = list(dataset = iris))) -#' fd2 <- teal.slice::init_filtered_data( -#' list(iris = list(dataset = iris), mtcars = list(dataset = mtcars)) -#' ) -#' fd3 <- teal.slice::init_filtered_data( -#' list(iris = list(dataset = iris), women = list(dataset = women)) -#' ) -#' filter <- teal_slices( -#' teal.slice::teal_slice(dataname = "iris", varname = "Sepal.Length"), -#' teal.slice::teal_slice(dataname = "iris", varname = "Species"), -#' teal.slice::teal_slice(dataname = "mtcars", varname = "mpg"), -#' teal.slice::teal_slice(dataname = "women", varname = "height"), -#' mapping = list( -#' module2 = c("mtcars mpg"), -#' module3 = c("women height"), -#' global_filters = "iris Species" -#' ) -#' ) -#' -#' ui <- fluidPage( -#' filter_manager_modal_ui("manager") -#' ) -#' -#' server <- function(input, output, session) { -#' observe({ -#' filter_manager_modal_srv( -#' "manager", -#' filtered_data_list = list(module1 = fd1, module2 = fd2, module3 = fd3), -#' filter = filter -#' ) -#' }) -#' } -#' -#' if (interactive()) { -#' shinyApp(ui, server) -#' } -#' #' @keywords internal #' NULL diff --git a/R/module_nested_tabs.R b/R/module_nested_tabs.R index 6d88a3e946..2648c9751f 100644 --- a/R/module_nested_tabs.R +++ b/R/module_nested_tabs.R @@ -31,69 +31,6 @@ #' #' `srv_nested_tabs` returns a reactive which returns the active module that corresponds to the selected tab. #' -#' @examples -#' # use non-exported function from teal -#' include_teal_css_js <- getFromNamespace("include_teal_css_js", "teal") -#' teal_data_to_filtered_data <- getFromNamespace("teal_data_to_filtered_data", "teal") -#' ui_nested_tabs <- getFromNamespace("ui_nested_tabs", "teal") -#' srv_nested_tabs <- getFromNamespace("srv_nested_tabs", "teal") -#' -#' # create `teal_data` -#' data <- teal_data(iris = iris, mtcars = mtcars) -#' datanames <- datanames(data) -#' -#' # creates a hierarchy of `teal_modules` from which a `teal` app can be created. -#' mods <- modules( -#' label = "d1", -#' modules( -#' label = "d2", -#' modules( -#' label = "d3", -#' example_module(label = "aaa1", datanames = datanames), -#' example_module(label = "aaa2", datanames = datanames) -#' ), -#' example_module(label = "bbb", datanames = datanames) -#' ), -#' example_module(label = "ccc", datanames = datanames) -#' ) -#' -#' # creates nested list aligned with the module hierarchy created above, -#' # each leaf holding the same `FilteredData` object. -#' datasets <- teal_data_to_filtered_data(data) -#' datasets <- list( -#' "d2" = list( -#' "d3" = list( -#' "aaa1" = datasets, -#' "aaa2" = datasets -#' ), -#' "bbb" = datasets -#' ), -#' "ccc" = datasets -#' ) -#' -#' ui <- function() { -#' tagList( -#' include_teal_css_js(), -#' textOutput("info"), -#' fluidPage( # needed for nice tabs -#' ui_nested_tabs("dummy", modules = mods, datasets = datasets) -#' ) -#' ) -#' } -#' server <- function(input, output, session) { -#' active_module <- srv_nested_tabs( -#' "dummy", -#' datasets = datasets, -#' modules = mods -#' ) -#' output$info <- renderText({ -#' paste0("The currently active tab name is ", active_module()$label) -#' }) -#' } -#' if (interactive()) { -#' shinyApp(ui, server) -#' } -#' #' @keywords internal NULL diff --git a/R/module_tabs_with_filters.R b/R/module_tabs_with_filters.R index a9afb72711..49e2bea529 100644 --- a/R/module_tabs_with_filters.R +++ b/R/module_tabs_with_filters.R @@ -24,65 +24,6 @@ #' @return #' A `shiny.tag.list` containing the main menu, placeholders for filters and placeholders for the `teal` modules. #' -#' @examples -#' # use non-exported function from teal -#' include_teal_css_js <- getFromNamespace("include_teal_css_js", "teal") -#' teal_data_to_filtered_data <- getFromNamespace("teal_data_to_filtered_data", "teal") -#' ui_tabs_with_filters <- getFromNamespace("ui_tabs_with_filters", "teal") -#' srv_tabs_with_filters <- getFromNamespace("srv_tabs_with_filters", "teal") -#' -#' # creates `teal_data` -#' data <- teal_data(iris = iris, mtcars = mtcars) -#' datanames <- datanames(data) -#' -#' # creates a hierarchy of `teal_modules` from which a `teal` app can be created. -#' mods <- modules( -#' label = "d1", -#' modules( -#' label = "d2", -#' modules( -#' label = "d3", -#' example_module(label = "aaa1", datanames = datanames), -#' example_module(label = "aaa2", datanames = datanames) -#' ), -#' example_module(label = "bbb", datanames = datanames) -#' ), -#' example_module(label = "ccc", datanames = datanames) -#' ) -#' -#' # creates nested list aligned with the module hierarchy created above, -#' # each leaf holding the same `FilteredData` object. -#' datasets <- teal_data_to_filtered_data(data) -#' datasets <- list( -#' "d2" = list( -#' "d3" = list( -#' "aaa1" = datasets, -#' "aaa2" = datasets -#' ), -#' "bbb" = datasets -#' ), -#' "ccc" = datasets -#' ) -#' -#' ui <- function() { -#' tagList( -#' include_teal_css_js(), -#' textOutput("info"), -#' fluidPage( # needed for nice tabs -#' ui_tabs_with_filters("dummy", modules = mods, datasets = datasets) -#' ) -#' ) -#' } -#' server <- function(input, output, session) { -#' output$info <- renderText({ -#' paste0("The currently active tab name is ", active_module()$label) -#' }) -#' active_module <- srv_tabs_with_filters(id = "dummy", datasets = datasets, modules = mods) -#' } -#' -#' if (interactive()) { -#' shinyApp(ui, server) -#' } #' @keywords internal #' NULL diff --git a/R/module_teal.R b/R/module_teal.R index 1b319a9892..9dc1d7407e 100644 --- a/R/module_teal.R +++ b/R/module_teal.R @@ -39,30 +39,6 @@ #' @return #' Returns a `reactive` expression which returns the currently active module. #' -#' @examples -#' # use non-exported function from teal -#' ui_teal <- getFromNamespace("ui_teal", "teal") -#' srv_teal <- getFromNamespace("srv_teal", "teal") -#' -#' mods <- modules( -#' label = "example app", -#' example_module(label = "example dataset", datanames = c("iris", "mtcars")) -#' ) -#' -#' teal_data_rv <- reactive(teal_data(iris = iris, mtcars = mtcars)) -#' -#' ui <- function() { -#' ui_teal("dummy") -#' } -#' -#' server <- function(input, output, session) { -#' active_module <- srv_teal(id = "dummy", modules = mods, teal_data_rv = teal_data_rv) -#' } -#' -#' if (interactive()) { -#' shinyApp(ui, server) -#' } -#' #' @keywords internal #' NULL diff --git a/R/modules.R b/R/modules.R index 05b91cd2a5..73ba64de3c 100644 --- a/R/modules.R +++ b/R/modules.R @@ -391,32 +391,6 @@ is_arg_used <- function(modules, arg) { #' @param depth optional, integer determining current depth level #' #' @return Depth level for given module. -#' @examples -#' # use non-exported function from teal -#' modules_depth <- getFromNamespace("modules_depth", "teal") -#' -#' mods <- modules( -#' label = "d1", -#' modules( -#' label = "d2", -#' modules( -#' label = "d3", -#' module(label = "aaa1"), module(label = "aaa2"), module(label = "aaa3") -#' ), -#' module(label = "bbb") -#' ), -#' module(label = "ccc") -#' ) -#' stopifnot(modules_depth(mods) == 3L) -#' -#' mods <- modules( -#' label = "a", -#' modules( -#' label = "b1", module(label = "c") -#' ), -#' module(label = "b2") -#' ) -#' stopifnot(modules_depth(mods) == 2L) #' @keywords internal modules_depth <- function(modules, depth = 0L) { checkmate::assert_multi_class(modules, c("teal_module", "teal_modules")) diff --git a/R/teal_slices-store.R b/R/teal_slices-store.R index c9fcc6bd6f..f781895006 100644 --- a/R/teal_slices-store.R +++ b/R/teal_slices-store.R @@ -22,21 +22,6 @@ #' #' @seealso [teal_slices()] #' -#' @examples -#' # use non-exported function from teal -#' slices_store <- getFromNamespace("slices_store", "teal") -#' -#' # Create a teal_slices object -#' tss <- teal_slices( -#' teal_slice(dataname = "data", varname = "var"), -#' teal_slice(dataname = "data", expr = "x > 0", id = "positive_x", title = "Positive x") -#' ) -#' -#' slices_path <- tempfile(pattern = "teal_slices", fileext = ".json") -#' print(slices_path) -#' -#' # Store the teal_slices object to a file -#' slices_store(tss, slices_path) #' @keywords internal #' slices_store <- function(tss, file) { @@ -48,14 +33,6 @@ slices_store <- function(tss, file) { #' @rdname slices_store #' @return `slices_restore` returns a `teal_slices` object restored from the file. -#' @examples -#' -#' # use non-exported function from teal -#' slices_restore <- getFromNamespace("slices_restore", "teal") -#' -#' # Restore a teal_slices object from a file -#' tss_restored <- slices_restore(slices_path) -#' #' @keywords internal slices_restore <- function(file) { checkmate::assert_file_exists(file, access = "r", extension = "json") diff --git a/man/include_teal_css_js.Rd b/man/include_teal_css_js.Rd index a371ee2de8..1821d98769 100644 --- a/man/include_teal_css_js.Rd +++ b/man/include_teal_css_js.Rd @@ -18,14 +18,5 @@ Also initializes \code{shinyjs} so you can use it. } \details{ Simply add \code{include_teal_css_js()} as one of the UI elements. -} -\examples{ -# use non-exported function from teal -include_teal_css_js <- getFromNamespace("include_teal_css_js", "teal") -shiny_ui <- tagList( - include_teal_css_js(), - p("Hello") -) - } \keyword{internal} diff --git a/man/module_filter_manager_modal.Rd b/man/module_filter_manager_modal.Rd index e4308eae4e..e3f5c5225f 100644 --- a/man/module_filter_manager_modal.Rd +++ b/man/module_filter_manager_modal.Rd @@ -25,48 +25,5 @@ Specifies the initial filter using \code{\link[=teal_slices]{teal_slices()}}.} } \description{ Opens a modal containing the filter manager UI. -} -\examples{ -# use non-exported function from teal -filter_manager_modal_ui <- getFromNamespace("filter_manager_modal_ui", "teal") -filter_manager_modal_srv <- getFromNamespace("filter_manager_modal_srv", "teal") - -fd1 <- teal.slice::init_filtered_data(list(iris = list(dataset = iris))) -fd2 <- teal.slice::init_filtered_data( - list(iris = list(dataset = iris), mtcars = list(dataset = mtcars)) -) -fd3 <- teal.slice::init_filtered_data( - list(iris = list(dataset = iris), women = list(dataset = women)) -) -filter <- teal_slices( - teal.slice::teal_slice(dataname = "iris", varname = "Sepal.Length"), - teal.slice::teal_slice(dataname = "iris", varname = "Species"), - teal.slice::teal_slice(dataname = "mtcars", varname = "mpg"), - teal.slice::teal_slice(dataname = "women", varname = "height"), - mapping = list( - module2 = c("mtcars mpg"), - module3 = c("women height"), - global_filters = "iris Species" - ) -) - -ui <- fluidPage( - filter_manager_modal_ui("manager") -) - -server <- function(input, output, session) { - observe({ - filter_manager_modal_srv( - "manager", - filtered_data_list = list(module1 = fd1, module2 = fd2, module3 = fd3), - filter = filter - ) - }) -} - -if (interactive()) { - shinyApp(ui, server) -} - } \keyword{internal} diff --git a/man/module_nested_tabs.Rd b/man/module_nested_tabs.Rd index 39711d6e70..23185de1be 100644 --- a/man/module_nested_tabs.Rd +++ b/man/module_nested_tabs.Rd @@ -107,68 +107,4 @@ This module recursively calls all elements of \code{modules} and returns current } } -\examples{ -# use non-exported function from teal -include_teal_css_js <- getFromNamespace("include_teal_css_js", "teal") -teal_data_to_filtered_data <- getFromNamespace("teal_data_to_filtered_data", "teal") -ui_nested_tabs <- getFromNamespace("ui_nested_tabs", "teal") -srv_nested_tabs <- getFromNamespace("srv_nested_tabs", "teal") - -# create `teal_data` -data <- teal_data(iris = iris, mtcars = mtcars) -datanames <- datanames(data) - -# creates a hierarchy of `teal_modules` from which a `teal` app can be created. -mods <- modules( - label = "d1", - modules( - label = "d2", - modules( - label = "d3", - example_module(label = "aaa1", datanames = datanames), - example_module(label = "aaa2", datanames = datanames) - ), - example_module(label = "bbb", datanames = datanames) - ), - example_module(label = "ccc", datanames = datanames) -) - -# creates nested list aligned with the module hierarchy created above, -# each leaf holding the same `FilteredData` object. -datasets <- teal_data_to_filtered_data(data) -datasets <- list( - "d2" = list( - "d3" = list( - "aaa1" = datasets, - "aaa2" = datasets - ), - "bbb" = datasets - ), - "ccc" = datasets -) - -ui <- function() { - tagList( - include_teal_css_js(), - textOutput("info"), - fluidPage( # needed for nice tabs - ui_nested_tabs("dummy", modules = mods, datasets = datasets) - ) - ) -} -server <- function(input, output, session) { - active_module <- srv_nested_tabs( - "dummy", - datasets = datasets, - modules = mods - ) - output$info <- renderText({ - paste0("The currently active tab name is ", active_module()$label) - }) -} -if (interactive()) { - shinyApp(ui, server) -} - -} \keyword{internal} diff --git a/man/module_tabs_with_filters.Rd b/man/module_tabs_with_filters.Rd index e0f95b37d0..46b31dc8fd 100644 --- a/man/module_tabs_with_filters.Rd +++ b/man/module_tabs_with_filters.Rd @@ -50,64 +50,4 @@ all modules using the same \code{datasets} share the same filters. This works with nested modules of depth greater than 2, though the filter panel is inserted at the right of the modules at depth 1 and not at the leaves. } -\examples{ -# use non-exported function from teal -include_teal_css_js <- getFromNamespace("include_teal_css_js", "teal") -teal_data_to_filtered_data <- getFromNamespace("teal_data_to_filtered_data", "teal") -ui_tabs_with_filters <- getFromNamespace("ui_tabs_with_filters", "teal") -srv_tabs_with_filters <- getFromNamespace("srv_tabs_with_filters", "teal") - -# creates `teal_data` -data <- teal_data(iris = iris, mtcars = mtcars) -datanames <- datanames(data) - -# creates a hierarchy of `teal_modules` from which a `teal` app can be created. -mods <- modules( - label = "d1", - modules( - label = "d2", - modules( - label = "d3", - example_module(label = "aaa1", datanames = datanames), - example_module(label = "aaa2", datanames = datanames) - ), - example_module(label = "bbb", datanames = datanames) - ), - example_module(label = "ccc", datanames = datanames) -) - -# creates nested list aligned with the module hierarchy created above, -# each leaf holding the same `FilteredData` object. -datasets <- teal_data_to_filtered_data(data) -datasets <- list( - "d2" = list( - "d3" = list( - "aaa1" = datasets, - "aaa2" = datasets - ), - "bbb" = datasets - ), - "ccc" = datasets -) - -ui <- function() { - tagList( - include_teal_css_js(), - textOutput("info"), - fluidPage( # needed for nice tabs - ui_tabs_with_filters("dummy", modules = mods, datasets = datasets) - ) - ) -} -server <- function(input, output, session) { - output$info <- renderText({ - paste0("The currently active tab name is ", active_module()$label) - }) - active_module <- srv_tabs_with_filters(id = "dummy", datasets = datasets, modules = mods) -} - -if (interactive()) { - shinyApp(ui, server) -} -} \keyword{internal} diff --git a/man/module_teal.Rd b/man/module_teal.Rd index cd5b56413a..8996f0d6cc 100644 --- a/man/module_teal.Rd +++ b/man/module_teal.Rd @@ -72,30 +72,5 @@ updates the displayed datasets to filter for according to the active \code{datan of the tab. It is written as a \code{shiny} module so it can be added into other apps as well. -} -\examples{ -# use non-exported function from teal -ui_teal <- getFromNamespace("ui_teal", "teal") -srv_teal <- getFromNamespace("srv_teal", "teal") - -mods <- modules( - label = "example app", - example_module(label = "example dataset", datanames = c("iris", "mtcars")) -) - -teal_data_rv <- reactive(teal_data(iris = iris, mtcars = mtcars)) - -ui <- function() { - ui_teal("dummy") -} - -server <- function(input, output, session) { - active_module <- srv_teal(id = "dummy", modules = mods, teal_data_rv = teal_data_rv) -} - -if (interactive()) { - shinyApp(ui, server) -} - } \keyword{internal} diff --git a/man/modules_depth.Rd b/man/modules_depth.Rd index 98a65537a5..37a59c5f7d 100644 --- a/man/modules_depth.Rd +++ b/man/modules_depth.Rd @@ -22,31 +22,4 @@ Depth level for given module. Depth starts at 0, so a single \code{teal.module} has depth 0. Nesting it increases overall depth by 1. } -\examples{ -# use non-exported function from teal -modules_depth <- getFromNamespace("modules_depth", "teal") - -mods <- modules( - label = "d1", - modules( - label = "d2", - modules( - label = "d3", - module(label = "aaa1"), module(label = "aaa2"), module(label = "aaa3") - ), - module(label = "bbb") - ), - module(label = "ccc") -) -stopifnot(modules_depth(mods) == 3L) - -mods <- modules( - label = "a", - modules( - label = "b1", module(label = "c") - ), - module(label = "b2") -) -stopifnot(modules_depth(mods) == 2L) -} \keyword{internal} diff --git a/man/slices_store.Rd b/man/slices_store.Rd index f8d9f75f0e..6d2058938c 100644 --- a/man/slices_store.Rd +++ b/man/slices_store.Rd @@ -36,29 +36,6 @@ Date and date time objects are stored in the following formats: This format is assumed during \code{slices_restore}. All \code{POSIX*t} objects in \code{selected} or \code{choices} fields of \code{teal_slice} objects are always printed in \code{UTC} timezone as well. -} -\examples{ -# use non-exported function from teal -slices_store <- getFromNamespace("slices_store", "teal") - -# Create a teal_slices object -tss <- teal_slices( - teal_slice(dataname = "data", varname = "var"), - teal_slice(dataname = "data", expr = "x > 0", id = "positive_x", title = "Positive x") -) - -slices_path <- tempfile(pattern = "teal_slices", fileext = ".json") -print(slices_path) - -# Store the teal_slices object to a file -slices_store(tss, slices_path) - -# use non-exported function from teal -slices_restore <- getFromNamespace("slices_restore", "teal") - -# Restore a teal_slices object from a file -tss_restored <- slices_restore(slices_path) - } \seealso{ \code{\link[=teal_slices]{teal_slices()}}