diff --git a/R/app.R b/R/app.R index 7e56ce5..14297f3 100644 --- a/R/app.R +++ b/R/app.R @@ -4,15 +4,21 @@ #' @param port The port to serve the application on. #' @param custom_dataset This allows to set a custom dataset (return value of #' [analyze()]) as the default dataset of the UI. +#' @param show_api_docs Whether to show the API documentation. Use [run_api()] +#' to actually serve the API. #' #' @seealso [app()] for retrieving a Shiny app object. #' #' @export run_app <- function(host = "127.0.0.1", port = 3464, - custom_dataset = NULL) { + custom_dataset = NULL, + show_api_docs = FALSE) { runApp( - app(custom_dataset = custom_dataset), + app( + custom_dataset = custom_dataset, + show_api_docs = show_api_docs + ), host = host, port = port ) @@ -22,14 +28,21 @@ run_app <- function(host = "127.0.0.1", #' #' @param custom_dataset This allows to set a custom dataset (return value of #' [analyze()]) as the default dataset of the UI. +#' @param show_api_docs Whether to show the API documentation. Use [run_api()] +#' to actually serve the API. #' #' @seealso [run_app()] for immediately running the application. #' #' @export -app <- function(custom_dataset = NULL) { +app <- function(custom_dataset = NULL, show_api_docs = FALSE) { shinyApp( - ui(custom_dataset = custom_dataset), - server(custom_dataset = custom_dataset) + ui( + custom_dataset = custom_dataset, + show_api_docs = show_api_docs + ), + server( + custom_dataset = custom_dataset + ) ) } diff --git a/R/ui.R b/R/ui.R index 1f676b0..7623ba0 100644 --- a/R/ui.R +++ b/R/ui.R @@ -1,6 +1,6 @@ #' Function for creating the main user interface. #' @noRd -ui <- function(custom_dataset = NULL) { +ui <- function(custom_dataset = NULL, show_api_docs = FALSE) { div( custom_css(), rclipboard::rclipboardSetup(), @@ -305,13 +305,17 @@ ui <- function(custom_dataset = NULL) { includeMarkdown(system.file("content", "help.md", package = "ubigen")) ) ), - tabPanel( - title = "API access", - div( - class = "container", - includeMarkdown(system.file("content", "api.md", package = "ubigen")) + if (show_api_docs) { + tabPanel( + title = "API access", + div( + class = "container", + includeMarkdown( + system.file("content", "api.md", package = "ubigen") + ) + ) ) - ) + } ) ) }