diff --git a/R/modules.R b/R/modules.R index 6f49a73b3c..56bbab7939 100644 --- a/R/modules.R +++ b/R/modules.R @@ -321,8 +321,10 @@ modules <- function(..., label = "root") { # printing methods ---- #' @rdname teal_modules +#' @param what character vector specifying which metadata to display. +#' Possible values: "data_sources", "properties", "ui_args", "server_args", "transformers" #' @export -format.teal_module <- function(x, indent = 0, is_last = FALSE, parent_prefix = "", ...) { +format.teal_module <- function(x, indent = 0, is_last = FALSE, parent_prefix = "", what = c("data_sources", "properties", "ui_args", "server_args", "transformers"), ...) { empty_text <- "─ none" branch <- if (is_last) "└─" else "├─" current_prefix <- paste0(parent_prefix, branch, " ") @@ -345,16 +347,42 @@ format.teal_module <- function(x, indent = 0, is_last = FALSE, parent_prefix = " empty_text } - paste0( - current_prefix, crayon::bold(x$label), "\n", - content_prefix, "├─ ", crayon::blue("Data Sources:"), " ", paste(x$datanames, collapse = ", "), "\n", - content_prefix, "├─ ", crayon::yellow("Properties:"), "\n", - content_prefix, "│ ├─ Bookmarkable: ", bookmarkable, "\n", - content_prefix, "│ └─ Reportable: ", reportable, "\n", - content_prefix, "├─ ", crayon::green("UI Arguments:"), " ", format_list(x$ui_args), "\n", - content_prefix, "├─ ", crayon::green("Server Arguments:"), " ", format_list(x$server_args), "\n", - content_prefix, "└─ ", crayon::magenta("Transformers:"), " ", transformers, "\n" - ) + output <- paste0(current_prefix, crayon::bold(x$label), "\n") + + if ("data_sources" %in% what) { + output <- paste0( + output, + content_prefix, "├─ ", crayon::blue("Data Sources:"), " ", paste(x$datanames, collapse = ", "), "\n" + ) + } + if ("properties" %in% what) { + output <- paste0( + output, + content_prefix, "├─ ", crayon::yellow("Properties:"), "\n", + content_prefix, "│ ├─ Bookmarkable: ", bookmarkable, "\n", + content_prefix, "│ └─ Reportable: ", reportable, "\n" + ) + } + if ("ui_args" %in% what) { + output <- paste0( + output, + content_prefix, "├─ ", crayon::green("UI Arguments:"), " ", format_list(x$ui_args), "\n" + ) + } + if ("server_args" %in% what) { + output <- paste0( + output, + content_prefix, "├─ ", crayon::green("Server Arguments:"), " ", format_list(x$server_args), "\n" + ) + } + if ("transformers" %in% what) { + output <- paste0( + output, + content_prefix, "└─ ", crayon::magenta("Transformers:"), " ", transformers, "\n" + ) + } + + output } #' @rdname teal_modules diff --git a/man/teal_modules.Rd b/man/teal_modules.Rd index b763c01513..ac378dcafe 100644 --- a/man/teal_modules.Rd +++ b/man/teal_modules.Rd @@ -6,10 +6,10 @@ \alias{teal_module} \alias{modules} \alias{format.teal_module} -\alias{print.teal_module} \alias{format.teal_modules} -\alias{set_datanames} +\alias{print.teal_module} \alias{print.teal_modules} +\alias{set_datanames} \title{Create \code{teal_module} and \code{teal_modules} objects} \usage{ module( @@ -26,15 +26,22 @@ module( modules(..., label = "root") -\method{format}{teal_module}(x, indent = 0, ...) +\method{format}{teal_module}( + x, + indent = 0, + is_last = FALSE, + parent_prefix = "", + what = c("data_sources", "properties", "ui_args", "server_args", "transformers"), + ... +) + +\method{format}{teal_modules}(x, indent = 0, is_root = TRUE, is_last = FALSE, parent_prefix = "", ...) \method{print}{teal_module}(x, ...) -\method{format}{teal_modules}(x, indent = 0, ...) +\method{print}{teal_modules}(x, ...) set_datanames(modules, datanames) - -\method{print}{teal_modules}(x, ...) } \arguments{ \item{label}{(\code{character(1)}) Label shown in the navigation item for the module or module group. @@ -93,6 +100,9 @@ Transformers' \code{datanames} are added to the \code{datanames}. See \code{\lin \item{indent}{(\code{integer(1)}) Indention level; each nested element is indented one level more.} +\item{what}{character vector specifying which metadata to display. +Possible values: "data_sources", "properties", "ui_args", "server_args", "transformers"} + \item{modules}{(\code{teal_module} or \code{teal_modules})} } \value{