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 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
)
)
}

8
R/ui.R
View file

@ -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"))
)
),
if (show_api_docs) {
tabPanel(
title = "API access",
div(
class = "container",
includeMarkdown(system.file("content", "api.md", package = "ubigen"))
includeMarkdown(
system.file("content", "api.md", package = "ubigen")
)
)
)
}
)
)
}