Skip to content

Commit

Permalink
Merge pull request #17 from EVS-GIS/documentation
Browse files Browse the repository at this point in the history
add documentation panel and link website
  • Loading branch information
LouisManiere authored Nov 20, 2023
2 parents 914c9f4 + b72bc00 commit d86f650
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 4 deletions.
1 change: 1 addition & 0 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
app_server <- function(input, output, session) {
# Your application server logic
mod_explore_server("explore_1")
mod_documentation_server("documentation_1")
}
5 changes: 4 additions & 1 deletion R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ app_ui <- function(request){
theme = bs_theme(version = 5, bootswatch = "simplex"),
title =
img(src = "www/favicon_mapdo.png"),
tabPanel("Exploration", mod_explore_ui("explore_1"))
tabPanel("Exploration", mod_explore_ui("explore_1")),
tabPanel("Documentation",
icon = icon("info"),
mod_documentation_ui("documentation_1"))
)
}

Expand Down
39 changes: 39 additions & 0 deletions R/mod_documentation.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#' documentation UI Function
#'
#' @description A shiny Module.
#'
#' @param id,input,output,session Internal parameters for {shiny}.
#'
#' @noRd
#'
#' @import shiny
mod_documentation_ui <- function(id){
ns <- NS(id)
tagList(
golem_add_external_resources(),
fluidPage(
tags$a(
href = "https://evs-gis.github.io/mapdowebsite/",
icon("book"),
"Documentation",
target = "_blank"
)
)
)
}

#' documentation Server Functions
#'
#' @noRd
mod_documentation_server <- function(id){
moduleServer( id, function(input, output, session){
ns <- session$ns

})
}

## To be copied in the UI
# mod_documentation_ui("documentation_1")

## To be copied in the server
# mod_documentation_server("documentation_1")
1 change: 0 additions & 1 deletion R/mod_explore.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ mod_explore_ui <- function(id){
tagList(
# Leave this function for adding external resources
golem_add_external_resources(),
# UI elements
fluidPage(
useShinyjs(),
tags$head(
Expand Down
4 changes: 2 additions & 2 deletions dev/02_dev.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ shiny::reactlogShow()

## Add modules ----
## Create a module infrastructure in R/
golem::add_module(name = "explore_test", with_test = TRUE) # Name of the module
golem::add_module(name = "name_of_module2", with_test = TRUE) # Name of the module
golem::add_module(name = "explore", with_test = TRUE) # Name of the module
golem::add_module(name = "documentation", with_test = TRUE) # Name of the module

## Add dependencies

Expand Down
38 changes: 38 additions & 0 deletions tests/testthat/test-mod_documentation.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
testServer(
mod_documentation_server,
# Add here your module params
args = list()
, {
ns <- session$ns
expect_true(
inherits(ns, "function")
)
expect_true(
grepl(id, ns(""))
)
expect_true(
grepl("test", ns("test"))
)
# Here are some examples of tests you can
# run on your module
# - Testing the setting of inputs
# session$setInputs(x = 1)
# expect_true(input$x == 1)
# - If ever your input updates a reactiveValues
# - Note that this reactiveValues must be passed
# - to the testServer function via args = list()
# expect_true(r$x == 1)
# - Testing output
# expect_true(inherits(output$tbl$html, "html"))
})

test_that("module ui works", {
ui <- mod_documentation_ui(id = "test")
golem::expect_shinytaglist(ui)
# Check that formals have not been removed
fmls <- formals(mod_documentation_ui)
for (i in c("id")){
expect_true(i %in% names(fmls))
}
})

0 comments on commit d86f650

Please sign in to comment.