Skip to content

Commit

Permalink
Merge pull request #118 from stan-dev/prepare-v2.4.0
Browse files Browse the repository at this point in the history
rstantools v2.4.0
  • Loading branch information
jgabry authored Jan 22, 2024
2 parents 6f23cab + 2ddf110 commit 77fe508
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 15 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/check-standalone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ jobs:

- name: Checkout lgpr package
run: |
git clone https://github.com/andrjohns/lgpr
cd lgpr && git checkout array-syntax
git clone https://github.com/jtimonen/lgpr
- name: Check against CRAN StanHeaders and CRAN RStan
run: |
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: rstantools
Type: Package
Title: Tools for Developing R Packages Interfacing with 'Stan'
Version: 2.3.1.1
Date: 2023-07-18
Version: 2.4.0
Date: 2024-01-22
Authors@R:
c(person(given = "Jonah",
family = "Gabry",
Expand Down Expand Up @@ -53,6 +53,6 @@ Suggests:
roxygen2 (>= 6.0.1),
rmarkdown,
rstudioapi
RoxygenNote: 7.2.3
RoxygenNote: 7.3.0
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export(predictive_interval)
export(prior_summary)
export(rstan_config)
export(rstan_create_package)
export(rstantools_load_code)
export(use_rstan)
importFrom(RcppParallel,RcppParallelLibs)
importFrom(stats,quantile)
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# rstantools 2.4.0

* Update to match CRAN's patched version by @jgabry in #114
* Include additional template imports to suppress NOTEs by @andrjohns in #115
* Fix packages with stanfunctions under rstan 2.33+ by @andrjohns in #117


# rstantools 2.3.1

* Deprecated `init_cpp`. (#105)
Expand Down
2 changes: 1 addition & 1 deletion R/rstan_create_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#' @param stan_files A character vector with paths to `.stan` files to include
#' in the package.
#' @param roxygen Should \pkg{roxygen2} be used for documentation? Defaults to
#' `TRUE`. If so, a file `R/{pkgname}-package.R`` is added to the package with
#' `TRUE`. If so, a file `R/{pkgname}-package.R` is added to the package with
#' roxygen tags for the required import lines. See the **Note** section below
#' for advice specific to the latest versions of \pkg{roxygen2}.
#' @param travis Should a `.travis.yml` file be added to the package directory?
Expand Down
21 changes: 21 additions & 0 deletions R/rstan_package_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,24 @@
}
invisible(acc)
}

#' Helper function for loading code in roxygenise
#'
#' Adapted from the \code{sourceDir} function defined
#' by \code{example(source)}.
#'
#' @param path Path to directory containing code to load
#' @param trace Whether to print file names as they are loaded
#' @param ... Additional arguments passed to \code{\link{source}}
#'
#' @return \code{NULL}
#' @export
rstantools_load_code <- function(path, trace = TRUE, ...) {
op <- options(); on.exit(options(op)) # to reset after each
for (nm in list.files(path, pattern = "[.][RrSsQq]$")) {
if (trace) cat(nm, ":")
source(file.path(path, nm), ...)
if (trace) cat("\n")
options(op)
}
}
2 changes: 1 addition & 1 deletion man/rstan_create_package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions man/rstantools-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions man/rstantools_load_code.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/use_rstan.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions tests/testthat/test-rstan_create_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ for(ii in 1:ntest) {
skip_on_cran()
skip_on_travis()
}
example(source) # defines the sourceDir() function
try(roxygen2::roxygenize(pkg_dest_path, load_code = sourceDir), silent = TRUE)
try(roxygen2::roxygenize(pkg_dest_path, load_code = rstantools_load_code), silent = TRUE)
pkgbuild::compile_dll(pkg_dest_path)
tmp <- capture.output(load_out <- pkgload::load_all(pkg_dest_path,
export_all = TRUE,
Expand Down
7 changes: 2 additions & 5 deletions vignettes/minimal-rstan-package.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,12 @@ 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
function `roxygen2::roxygenize()`, which needs to be called twice initially.

```{r, results = "hide"}
example(source) # defines the sourceDir() function
```
```{r, eval = FALSE}
try(roxygen2::roxygenize(load_code = sourceDir), silent = TRUE)
try(roxygen2::roxygenize(load_code = rstantools_load_code), silent = TRUE)
roxygen2::roxygenize()
```
```{r, echo=FALSE, results="hide"}
try(roxygen2::roxygenize(PATH, load_code = sourceDir), silent = TRUE)
try(roxygen2::roxygenize(PATH, load_code = rstantools_load_code), silent = TRUE)
roxygen2::roxygenize(PATH)
```

Expand Down

0 comments on commit 77fe508

Please sign in to comment.