diff --git a/.Rbuildignore b/.Rbuildignore index 97b1bb3d..3240997f 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -10,3 +10,4 @@ LICENSE man-roxygen/* images/* ^\.github$ +^pkgdown$ diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 00000000..fa85f77e --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,56 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + # build dev site on merged pushes + push: + branches: [main, master] + # build full site on releases + release: + types: [published] + workflow_dispatch: + +name: pkgdown.yaml + +jobs: + pkgdown: + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} + cancel-in-progress: true + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::pkgdown, local::., any::withr, stan-dev/pkgdown-config, stan-dev/cmdstanr + + - name: Build site + run: | + withr::with_envvar( + c("NOT_CRAN" = "true"), # this should already be set by setup-r@v2? keeping because vignettes don't build otherwise + pkgdown::build_site_github_pages( + lazy = FALSE, # change to TRUE if runner times out. + run_dont_run = FALSE, # shinystan is interactive so hangs + examples = FALSE, + new_process = TRUE + ) + ) + shell: Rscript {0} + + - name: Deploy to GitHub pages 🚀 + uses: JamesIves/github-pages-deploy-action@v4 + with: + clean: false + branch: gh-pages + folder: docs diff --git a/R/shinystan-package.R b/R/shinystan-package.R index e3d23b59..1a3d4def 100644 --- a/R/shinystan-package.R +++ b/R/shinystan-package.R @@ -10,7 +10,6 @@ # You should have received a copy of the GNU General Public License along with # this program; if not, see . - #' \pkg{shinystan} R package ('ShinyStan' graphical user interface) #' #' @docType package @@ -18,7 +17,7 @@ #' #' @description #' \if{html}{ -#' \figure{stanlogo.png}{options: width="50" alt="mc-stan.org"} +#' \figure{logo.svg}{options: width="50" alt="mc-stan.org"} #' \emph{Stan Development Team} #' } #' @@ -54,7 +53,7 @@ #' publication. #' #' The \code{\link{deploy_shinystan}} function lets you easily deploy your own -#' ShinyStan apps online for any of your models using the shinyapps.io +#' ShinyStan apps online for any of your models using the shinyapps.io #' service from 'RStudio'. Each of your apps (each of your models) will have a #' unique url and will be compatible with most web browsers. #' @@ -79,7 +78,7 @@ #' @template seealso-as.shinystan #' @template seealso-demo #' @template seealso-launch -#' +#' #' @template reference-muth #' @template reference-bayesvis #' diff --git a/README.md b/README.md index a9cd59bf..f603f101 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ShinyStan +# ShinyStan [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/shinystan?color=blue)](http://cran.r-project.org/web/packages/shinystan) @@ -46,7 +46,7 @@ launch_shinystan_demo() ### Screenshots - + ### About ShinyStan diff --git a/_pkgdown.yml b/_pkgdown.yml new file mode 100644 index 00000000..11f73ae4 --- /dev/null +++ b/_pkgdown.yml @@ -0,0 +1,80 @@ +url: https://mc-stan.org/shinystan + +destination: "." + +development: + mode: auto + +template: + package: pkgdownconfig + +navbar: + title: "shinystan" + + structure: + left: [home, vignettes, functions, news, pkgs, stan] + right: [search, bluesky, forum, github, lightswitch] + + components: + pkgs: + text: Other Packages + menu: + - text: bayesplot + href: https://mc-stan.org/bayesplot + - text: cmdstanr + href: https://mc-stan.org/cmdstanr + - text: "loo" + href: https://mc-stan.org/loo + - text: posterior + href: https://mc-stan.org/posterior + - text: projpred + href: https://mc-stan.org/projpred + - text: rstan + href: https://mc-stan.org/rstan + - text: rstanarm + href: https://mc-stan.org/rstanarm + - text: rstantools + href: https://mc-stan.org/rstantools + +articles: + - title: "Getting Started" + desc: > + The best way to get started is to play around with the demo by running + launch_shinystan_demo(). The document below provides additional + information about some of the R functions in the package. + contents: + - shinystan-package + - title: "Hosting your App" + desc: > + The document below explains one way to host a shinystan app online. + contents: + - deploy_shinystan + +reference: + - title: "Package overview" + desc: > + Details about the shinystan R package. + contents: + - shinystan-package + - title: "Launching the app" + desc: > + Functions for launching the app using a particular model or launching a demo of the app. + contents: + - launch_shinystan + - launch_shinystan_demo + - title: "shinystan objects" + desc: > + Functions for creating, examining, and modifying shinystan objects. + contents: + - as.shinystan + - shinystan-class + - shinystan-metadata + - retrieve + - drop_parameters + - update_sso + - generate_quantity + - title: "Deploying apps" + desc: > + Functions for deploying shinystan apps on shinyapps.io. + contents: + - deploy_shinystan diff --git a/inst/ShinyStan/ui_utils.R b/inst/ShinyStan/ui_utils.R index 7a153309..9e6198ce 100644 --- a/inst/ShinyStan/ui_utils.R +++ b/inst/ShinyStan/ui_utils.R @@ -18,25 +18,28 @@ save_and_close_button <- function() { shinystan_version <- function() { # prevents error when deployed to shinyapps.io ver <- try(utils::packageVersion("shinystan")) - if (inherits(ver, "try-error")) + if (inherits(ver, "try-error")) { return() - else + } else { strong(paste("Version", ver)) + } } logo_and_name <- function() { - div(div( - img( - src = "wide_ensemble.png", - class = "wide-ensemble", - width = "100%" - ) - ), div( - style = "margin-top: 25px", - img(src = "stan_logo.png", class = "stan-logo"), - div(id = "shinystan-title", "ShinyStan") - )) + div( + img( + src = "wide_ensemble.png", + class = "wide-ensemble", + width = "100%" + ) + ), + div( + style = "margin-top: 25px", + img(src = "stan_logo.svg", class = "stan-logo"), + div(id = "shinystan-title", "ShinyStan") + ) + ) } @@ -56,34 +59,42 @@ save_and_close_reminder <- function(id) { # show/hide options/glossary --------------------------------------------- a_options <- function(name) { - lab <- if (name == "table") - "Table Options" else "Show/Hide Options" - div(class = "aoptions", - checkboxInput( - inputId = paste0(name, "_options_show"), - label = strong(style = "margin-top: 20px; color: #222222;", lab), - value = FALSE - )) + lab <- if (name == "table") { + "Table Options" + } else { + "Show/Hide Options" + } + div( + class = "aoptions", + checkboxInput( + inputId = paste0(name, "_options_show"), + label = strong(style = "margin-top: 20px; color: #222222;", lab), + value = FALSE + ) + ) } a_glossary <- function(id) { - div(class = "aoptions", - actionLink( - inputId = id, - label = strong(style = "margin-top: 20px; color: #222222;", "Glossary"), - icon = icon("book", lib = "glyphicon") - )) + div( + class = "aoptions", + actionLink( + inputId = id, + label = strong(style = "margin-top: 20px; color: #222222;", "Glossary"), + icon = icon("book", lib = "glyphicon") + ) + ) } - # plotOutput generators --------------------------------------------------- -dygraphOutput_175px <- function(id) +dygraphOutput_175px <- function(id) { dygraphs::dygraphOutput(id, height = "175px") -plotOutput_200px <- function(id, ...) +} +plotOutput_200px <- function(id, ...) { plotOutput(id, height = "200px") -plotOutput_400px <- function(id, ...) +} +plotOutput_400px <- function(id, ...) { plotOutput(id, height = "400px") - +} # conditionalPanel generator for EXPLORE/density ------------------------- @@ -91,25 +102,39 @@ condPanel_dens_together <- function(...) { conditionalPanel(condition = "input.dens_chain_split == 'Together'", ...) } condPanel_dens_prior <- function(dist, ...) { - cond <- paste0("input.dens_prior ==","'", dist,"'") + cond <- paste0("input.dens_prior ==", "'", dist, "'") conditionalPanel(cond, ...) } # conditional transparency settings --------------------------------------- alpha_calc_pt <- function(N) { - if (N <= 100) return(1) - else if (N <= 200) return(0.75) - else if (N >= 1500) return(0.15) - else 1 - pnorm(N/1500) + if (N <= 100) { + return(1) + } else if (N <= 200) { + return(0.75) + } else if (N >= 1500) { + return(0.15) + } else { + 1 - pnorm(N / 1500) + } } alpha_calc_lines <- function(N) { - if (N < 50) return(0.5) - if (N < 500) return(0.4) - if (N < 1000) return(0.3) - if (N < 5000) return(0.2) - else return(0.1) + if (N < 50) { + return(0.5) + } + if (N < 500) { + return(0.4) + } + if (N < 1000) { + return(0.3) + } + if (N < 5000) { + return(0.2) + } else { + return(0.1) + } } @@ -125,28 +150,38 @@ transformation_selectInput <- function(id) { transform_helpText <- function(var = "x") { div( - if (var == "x") - helpText(style = "font-size: 13px;", - "To apply a transformation", - "select a function and click", - code("Transform")) - else if (var == "x,y") - helpText(style = "font-size: 13px;", - "To apply transformations", - "select a function for x and/or y", - "and click", code("Transform")) - else - helpText(style = "font-size: 13px;", - "To apply transformations", - "select a function for x, y, and/or z", - "and click", code("Transform")) + if (var == "x") { + helpText( + style = "font-size: 13px;", + "To apply a transformation", + "select a function and click", + code("Transform") + ) + } else if (var == "x,y") { + helpText( + style = "font-size: 13px;", + "To apply transformations", + "select a function for x and/or y", + "and click", + code("Transform") + ) + } else { + helpText( + style = "font-size: 13px;", + "To apply transformations", + "select a function for x, y, and/or z", + "and click", + code("Transform") + ) + } ) } # diagnostics help text --------------------------------------------------- -hT11 <- function(...) +hT11 <- function(...) { helpText(style = "font-size: 11px;", ...) +} help_interval <- hT11("Highlighted interval shows \\(\\bar{x} \\pm sd(x)\\)") help_lines <- hT11("Lines are mean (solid) and median (dashed)") help_max_td <- hT11("Horizontal line indicates the max_treedepth setting") @@ -162,7 +197,6 @@ help_dynamic <- hT11( ) - # ppcheck plot descriptions ---------------------------------------------- plot_descriptions <- c( @@ -175,7 +209,6 @@ plot_descriptions <- ) - # stan manual reference --------------------------------------------------- stan_manual <- function() { helpText( @@ -209,8 +242,10 @@ if (!exists(".SHINYSTAN_OBJECT")) { isTRUE(.SHINYSTAN_OBJECT@misc$stanreg) && !is.null(.SHINYSTAN_OBJECT@misc$pp_check_plots) -if (exists("object")) +if (exists("object")) { rm(object) -if (exists(".SHINYSTAN_OBJECT")) +} +if (exists(".SHINYSTAN_OBJECT")) { rm(.SHINYSTAN_OBJECT) +} gc() diff --git a/man/figures/logo.svg b/man/figures/logo.svg index b4c09fc5..496f0402 100644 --- a/man/figures/logo.svg +++ b/man/figures/logo.svg @@ -1,96 +1 @@ - - - - + \ No newline at end of file diff --git a/man/figures/stanlogo.png b/man/figures/stanlogo.png deleted file mode 100644 index 4a4f06aa..00000000 Binary files a/man/figures/stanlogo.png and /dev/null differ diff --git a/man/shinystan-package.Rd b/man/shinystan-package.Rd index 525a57f2..f1d621eb 100644 --- a/man/shinystan-package.Rd +++ b/man/shinystan-package.Rd @@ -6,7 +6,7 @@ \title{\pkg{shinystan} R package ('ShinyStan' graphical user interface)} \description{ \if{html}{ - \figure{stanlogo.png}{options: width="50" alt="mc-stan.org"} + \figure{logo.svg}{options: width="50" alt="mc-stan.org"} \emph{Stan Development Team} }