Skip to content

Commit

Permalink
pre-release tm_file_viewer document update (#665)
Browse files Browse the repository at this point in the history
part of #624

~blocked by #651~
  • Loading branch information
averissimo authored Feb 26, 2024
1 parent cb07cce commit 51ef394
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 38 deletions.
39 changes: 20 additions & 19 deletions R/tm_file_viewer.R
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
#' 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 (`list`) of the input paths, optional. Each element can be:
#'
#' @export
#' 1. Specific path to 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.
#'
#' @inherit shared_params return
#'
#' 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"
#' )
#' )
#' )
#' )
#' if (interactive()) {
#' shinyApp(app$ui, app$server)
#' }
#' @export
#'
tm_file_viewer <- function(label = "File Viewer Module",
input_path = list("Current Working Directory" = ".")) {
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down
39 changes: 20 additions & 19 deletions man/tm_file_viewer.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 51ef394

Please sign in to comment.