From 239bbdd748b527bdeeae792477d91645f79b0816 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, 21 Feb 2024 20:58:33 +0100 Subject: [PATCH 1/4] docs: update tm_file_viewer for pre-release --- R/tm_file_viewer.R | 39 ++++++++++++++++++++------------------- man/tm_file_viewer.Rd | 39 ++++++++++++++++++++------------------- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/R/tm_file_viewer.R b/R/tm_file_viewer.R index 7a3ae61ff..2db90bf6b 100644 --- a/R/tm_file_viewer.R +++ b/R/tm_file_viewer.R @@ -1,34 +1,32 @@ -#' File Viewer `teal` Module +#' File viewer module #' #' The file viewer module provides a tool to view static files. -#' Supported formats include text formats, \code{PDF}, \code{PNG}, \code{APNG}, -#' \code{JPEG}, \code{SVG}, \code{WEBP}, \code{GIF} and \code{BMP}. +#' Supported formats include text formats, `PDF`, `PNG` `APNG`, +#' `JPEG` `SVG`, `WEBP`, `GIF` and `BMP`. #' #' @inheritParams teal::module #' @inheritParams shared_params -#' @param input_path optional, (`list`) of the input paths to either: specific files of accepted formats, -#' a directory or a URL. The paths can be specified as absolute paths or relative to the running -#' directory of the application. Will default to current working directory if not supplied. +#' @param input_path (optional `list`) of the input paths to either: #' -#' @export +#' 1. Specific files of accepted formats +#' 2. A directory or a URL #' -#' @examples -#' data <- teal_data() -#' data <- within(data, { -#' data <- data.frame(1) -#' }) -#' datanames(data) <- c("data") +#' The paths can be specified as absolute paths or relative to the running +#' directory of the application. +#' Default to the current working directory if not supplied. +#' +#' @return Object of class `teal_module` to be used in `teal` applications. #' -#' app <- teal::init( -#' data = data, -#' modules = teal::modules( -#' teal.modules.general::tm_file_viewer( +#' @examples +#' app <- init( +#' data = teal_data(data = 1), # Mock dataset to initialize the app without error +#' modules = modules( +#' tm_file_viewer( #' input_path = list( #' folder = system.file("sample_files", package = "teal.modules.general"), #' png = system.file("sample_files/sample_file.png", package = "teal.modules.general"), #' txt = system.file("sample_files/sample_file.txt", package = "teal.modules.general"), -#' url = -#' "https://www.fda.gov/files/drugs/published/Portable-Document-Format-Specifications.pdf" +#' url = "https://fda.gov/files/drugs/published/Portable-Document-Format-Specifications.pdf" #' ) #' ) #' ) @@ -36,6 +34,7 @@ #' if (interactive()) { #' shinyApp(app$ui, app$server) #' } +#' @export #' tm_file_viewer <- function(label = "File Viewer Module", input_path = list("Current Working Directory" = ".")) { @@ -90,6 +89,7 @@ tm_file_viewer <- function(label = "File Viewer Module", ) } +# UI function for the file viewer module ui_viewer <- function(id, ...) { args <- list(...) ns <- NS(id) @@ -116,6 +116,7 @@ ui_viewer <- function(id, ...) { ) } +# Server function for the file viewer module srv_viewer <- function(id, input_path) { moduleServer(id, function(input, output, session) { temp_dir <- tempfile() diff --git a/man/tm_file_viewer.Rd b/man/tm_file_viewer.Rd index ace7d9e6d..482b24f71 100644 --- a/man/tm_file_viewer.Rd +++ b/man/tm_file_viewer.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/tm_file_viewer.R \name{tm_file_viewer} \alias{tm_file_viewer} -\title{File Viewer \code{teal} Module} +\title{File viewer module} \usage{ tm_file_viewer( label = "File Viewer Module", @@ -13,32 +13,34 @@ tm_file_viewer( \item{label}{(\code{character(1)}) Label shown in the navigation item for the module or module group. For \code{modules()} defaults to \code{"root"}. See \code{Details}.} -\item{input_path}{optional, (\code{list}) of the input paths to either: specific files of accepted formats, -a directory or a URL. The paths can be specified as absolute paths or relative to the running -directory of the application. Will default to current working directory if not supplied.} +\item{input_path}{(optional \code{list}) of the input paths to either: +\enumerate{ +\item Specific files of accepted formats +\item A directory or a URL +} + +The paths can be specified as absolute paths or relative to the running +directory of the application. +Default to the current working directory if not supplied.} +} +\value{ +Object of class \code{teal_module} to be used in \code{teal} applications. } \description{ The file viewer module provides a tool to view static files. -Supported formats include text formats, \code{PDF}, \code{PNG}, \code{APNG}, -\code{JPEG}, \code{SVG}, \code{WEBP}, \code{GIF} and \code{BMP}. +Supported formats include text formats, \code{PDF}, \code{PNG} \code{APNG}, +\code{JPEG} \code{SVG}, \code{WEBP}, \code{GIF} and \code{BMP}. } \examples{ -data <- teal_data() -data <- within(data, { - data <- data.frame(1) -}) -datanames(data) <- c("data") - -app <- teal::init( - data = data, - modules = teal::modules( - teal.modules.general::tm_file_viewer( +app <- init( + data = teal_data(data = 1), # Mock dataset to initialize the app without error + modules = modules( + tm_file_viewer( input_path = list( folder = system.file("sample_files", package = "teal.modules.general"), png = system.file("sample_files/sample_file.png", package = "teal.modules.general"), txt = system.file("sample_files/sample_file.txt", package = "teal.modules.general"), - url = - "https://www.fda.gov/files/drugs/published/Portable-Document-Format-Specifications.pdf" + url = "https://fda.gov/files/drugs/published/Portable-Document-Format-Specifications.pdf" ) ) ) @@ -46,5 +48,4 @@ app <- teal::init( if (interactive()) { shinyApp(app$ui, app$server) } - } From 89df0d7a7b544b30e155606c67ddee4a2329720d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Thu, 22 Feb 2024 14:49:26 +0100 Subject: [PATCH 2/4] docs: inherit return tag --- R/tm_file_viewer.R | 2 +- man/tm_file_viewer.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/tm_file_viewer.R b/R/tm_file_viewer.R index 2db90bf6b..3f39ec708 100644 --- a/R/tm_file_viewer.R +++ b/R/tm_file_viewer.R @@ -15,7 +15,7 @@ #' directory of the application. #' Default to the current working directory if not supplied. #' -#' @return Object of class `teal_module` to be used in `teal` applications. +#' @inherit shared_params return #' #' @examples #' app <- init( diff --git a/man/tm_file_viewer.Rd b/man/tm_file_viewer.Rd index 482b24f71..ae91e65fc 100644 --- a/man/tm_file_viewer.Rd +++ b/man/tm_file_viewer.Rd @@ -24,7 +24,7 @@ directory of the application. Default to the current working directory if not supplied.} } \value{ -Object of class \code{teal_module} to be used in \code{teal} applications. +Object of class \code{teal_module} to be used in \code{teal} applications } \description{ The file viewer module provides a tool to view static files. From 28447d08f6c433de24da1e1ad7fc41bf595d3c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:12:31 +0100 Subject: [PATCH 3/4] docs: update docs --- man/tm_file_viewer.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/tm_file_viewer.Rd b/man/tm_file_viewer.Rd index ae91e65fc..482b24f71 100644 --- a/man/tm_file_viewer.Rd +++ b/man/tm_file_viewer.Rd @@ -24,7 +24,7 @@ directory of the application. Default to the current working directory if not supplied.} } \value{ -Object of class \code{teal_module} to be used in \code{teal} applications +Object of class \code{teal_module} to be used in \code{teal} applications. } \description{ The file viewer module provides a tool to view static files. From 76b8c622ade6759a7ef04a013d98e19ed1b733a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:51:28 +0100 Subject: [PATCH 4/4] docs: update notation with optional string --- R/tm_file_viewer.R | 4 ++-- man/tm_file_viewer.Rd | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/tm_file_viewer.R b/R/tm_file_viewer.R index 3f39ec708..8be167330 100644 --- a/R/tm_file_viewer.R +++ b/R/tm_file_viewer.R @@ -6,9 +6,9 @@ #' #' @inheritParams teal::module #' @inheritParams shared_params -#' @param input_path (optional `list`) of the input paths to either: +#' @param input_path (`list`) of the input paths, optional. Each element can be: #' -#' 1. Specific files of accepted formats +#' 1. Specific path to files of accepted formats #' 2. A directory or a URL #' #' The paths can be specified as absolute paths or relative to the running diff --git a/man/tm_file_viewer.Rd b/man/tm_file_viewer.Rd index 482b24f71..79a3476f3 100644 --- a/man/tm_file_viewer.Rd +++ b/man/tm_file_viewer.Rd @@ -13,9 +13,9 @@ tm_file_viewer( \item{label}{(\code{character(1)}) Label shown in the navigation item for the module or module group. For \code{modules()} defaults to \code{"root"}. See \code{Details}.} -\item{input_path}{(optional \code{list}) of the input paths to either: +\item{input_path}{(\code{list}) of the input paths, optional. Each element can be: \enumerate{ -\item Specific files of accepted formats +\item Specific path to files of accepted formats \item A directory or a URL }