Hide API docs by default

This commit is contained in:
Elias Projahn 2025-03-05 17:03:07 +01:00
parent 709dc0d0ed
commit 753beeed71
2 changed files with 29 additions and 12 deletions

23
R/app.R
View file

@ -4,15 +4,21 @@
#' @param port The port to serve the application on. #' @param port The port to serve the application on.
#' @param custom_dataset This allows to set a custom dataset (return value of #' @param custom_dataset This allows to set a custom dataset (return value of
#' [analyze()]) as the default dataset of the UI. #' [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. #' @seealso [app()] for retrieving a Shiny app object.
#' #'
#' @export #' @export
run_app <- function(host = "127.0.0.1", run_app <- function(host = "127.0.0.1",
port = 3464, port = 3464,
custom_dataset = NULL) { custom_dataset = NULL,
show_api_docs = FALSE) {
runApp( runApp(
app(custom_dataset = custom_dataset), app(
custom_dataset = custom_dataset,
show_api_docs = show_api_docs
),
host = host, host = host,
port = port 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 #' @param custom_dataset This allows to set a custom dataset (return value of
#' [analyze()]) as the default dataset of the UI. #' [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. #' @seealso [run_app()] for immediately running the application.
#' #'
#' @export #' @export
app <- function(custom_dataset = NULL) { app <- function(custom_dataset = NULL, show_api_docs = FALSE) {
shinyApp( shinyApp(
ui(custom_dataset = custom_dataset), ui(
server(custom_dataset = custom_dataset) custom_dataset = custom_dataset,
show_api_docs = show_api_docs
),
server(
custom_dataset = custom_dataset
)
) )
} }

10
R/ui.R
View file

@ -1,6 +1,6 @@
#' Function for creating the main user interface. #' Function for creating the main user interface.
#' @noRd #' @noRd
ui <- function(custom_dataset = NULL) { ui <- function(custom_dataset = NULL, show_api_docs = FALSE) {
div( div(
custom_css(), custom_css(),
rclipboard::rclipboardSetup(), rclipboard::rclipboardSetup(),
@ -305,13 +305,17 @@ ui <- function(custom_dataset = NULL) {
includeMarkdown(system.file("content", "help.md", package = "ubigen")) includeMarkdown(system.file("content", "help.md", package = "ubigen"))
) )
), ),
if (show_api_docs) {
tabPanel( tabPanel(
title = "API access", title = "API access",
div( div(
class = "container", class = "container",
includeMarkdown(system.file("content", "api.md", package = "ubigen")) includeMarkdown(
) system.file("content", "api.md", package = "ubigen")
) )
) )
) )
} }
)
)
}