diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 0000000..37084ab --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,55 @@ +# 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 + + - 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 = TRUE, + 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/DESCRIPTION b/DESCRIPTION index 7d27a6f..2a9d70f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -53,6 +53,6 @@ Suggests: roxygen2 (>= 6.0.1), rmarkdown, rstudioapi -RoxygenNote: 7.3.2 +RoxygenNote: 7.3.3 VignetteBuilder: knitr Roxygen: list(markdown = TRUE) diff --git a/R/rstan_create_package.R b/R/rstan_create_package.R index f3a9236..caa15c1 100644 --- a/R/rstan_create_package.R +++ b/R/rstan_create_package.R @@ -21,7 +21,7 @@ #' @aliases rstan_package_skeleton #' #' @description -#' \if{html}{\figure{stanlogo.png}{options: width="25" alt="https://mc-stan.org/about/logo/"}} +#' \if{html}{\figure{logo.svg}{options: width="25" alt="https://mc-stan.org/about/logo/"}} #' The `rstan_create_package()` function helps get you started developing a #' new \R package that interfaces with Stan via the \pkg{rstan} package. First #' the basic package structure is set up via [usethis::create_package()]. diff --git a/R/rstantools-package.R b/R/rstantools-package.R index c347516..130e549 100644 --- a/R/rstantools-package.R +++ b/R/rstantools-package.R @@ -5,7 +5,7 @@ #' #' @description #' \if{html}{ -#' \figure{stanlogo.png}{options: width="50" alt="mc-stan.org"} +#' \figure{logo.svg}{options: width="50" alt="mc-stan.org"} #' } *Stan Development Team* #' #' The \pkg{rstantools} package provides various tools for developers of \R diff --git a/README.md b/README.md index ef5e8aa..e5a2fe5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# rstantools +# rstantools [![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/rstantools?color=blue)](https://cran.r-project.org/web/packages/rstantools) diff --git a/_pkgdown.yml b/_pkgdown.yml new file mode 100644 index 0000000..2c57c4d --- /dev/null +++ b/_pkgdown.yml @@ -0,0 +1,83 @@ +url: https://mc-stan.org/rstantools + +destination: "." + +template: + package: pkgdownconfig + +development: + mode: auto + +navbar: + title: "rstantools" + + 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: shinystan + href: https://mc-stan.org/shinystan + +articles: + - title: "Recommendations for R package development with Stan" + desc: > + This vignette provides many recommendations for developers interested in + creating an R package that interface with Stan. Topics include + development best practices, precompiling Stan programs, R code and + documentation, and more. + contents: + - developer-guidelines + - title: "Step-by-step guide" + desc: > + This vignette walks through the steps required to set up a package with + a precompiled Stan model, from creating the initial package structure to + adding the precompiled Stan program and writing the R function that users + will call to fit the model. + contents: + - minimal-rstan-package + +reference: + - title: "Package structure" + desc: > + Creating the basic structure of a Stan-based R package or add + Stan programs to an existing package. + contents: + - rstantools-package + - rstan_create_package + - use_rstan + - rstan_config + - rstantools_load_code + - title: "Generics" + desc: > + S3 generics (and some default methods) for adding functionality + to your package using the same naming conventions as **rstanarm** + and other Stan-based R packages. + contents: + - bayes_R2 + - log_lik + - loo-prediction + - posterior_interval + - posterior_epred + - posterior_linpred + - posterior_predict + - predictive_error + - predictive_interval + - prior_summary diff --git a/man/figures/logo.svg b/man/figures/logo.svg index b4c09fc..496f040 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 4a4f06a..0000000 Binary files a/man/figures/stanlogo.png and /dev/null differ diff --git a/man/rstan_create_package.Rd b/man/rstan_create_package.Rd index a3a987a..d7bfeb6 100644 --- a/man/rstan_create_package.Rd +++ b/man/rstan_create_package.Rd @@ -48,7 +48,7 @@ file. If \code{TRUE} (the default) adds the \verb{GPL (>= 3)} license (see whenever the package gets installed (see \strong{Details}). Defaults to \code{TRUE}.} } \description{ -\if{html}{\figure{stanlogo.png}{options: width="25" alt="https://mc-stan.org/about/logo/"}} +\if{html}{\figure{logo.svg}{options: width="25" alt="https://mc-stan.org/about/logo/"}} The \code{rstan_create_package()} function helps get you started developing a new \R package that interfaces with Stan via the \pkg{rstan} package. First the basic package structure is set up via \code{\link[usethis:create_package]{usethis::create_package()}}. diff --git a/man/rstantools-package.Rd b/man/rstantools-package.Rd index 7b6a5b2..327d82d 100644 --- a/man/rstantools-package.Rd +++ b/man/rstantools-package.Rd @@ -7,7 +7,7 @@ \title{Tools for Developing \R Packages Interfacing with Stan} \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} The \pkg{rstantools} package provides various tools for developers of \R @@ -40,7 +40,7 @@ Useful links: } \author{ -\strong{Maintainer}: Jonah Gabry \email{jsg2201@columbia.edu} +\strong{Maintainer}: Jonah Gabry \email{jgabry@gmail.com} Authors: \itemize{ diff --git a/vignettes/minimal-rstan-package.Rmd b/vignettes/minimal-rstan-package.Rmd index 050b451..e0fa99e 100644 --- a/vignettes/minimal-rstan-package.Rmd +++ b/vignettes/minimal-rstan-package.Rmd @@ -8,7 +8,7 @@ output: params: EVAL: !r identical(Sys.getenv("NOT_CRAN"), "true") vignette: > - %\VignetteIndexEntry{Step by step guide} + %\VignetteIndexEntry{Step by step guide for creating a package that depends on RStan} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- @@ -235,13 +235,14 @@ information about the package. With __roxygen__ documentation enabled, we need to generate the documentation for `lm_stan` and update the `NAMESPACE` so the function is exported, i.e., -available to users when the package is installed. This can be done with the +available to users when the package is installed. This can be done with the function `roxygen2::roxygenize()`, which needs to be called twice initially. ```{r, eval = FALSE} try(roxygen2::roxygenize(load_code = rstantools_load_code), silent = TRUE) roxygen2::roxygenize() ``` + ```{r, echo=FALSE, results="hide"} try(roxygen2::roxygenize(PATH, load_code = rstantools_load_code), silent = TRUE) roxygen2::roxygenize(PATH)