Skip to content

Commit

Permalink
Prepare for release
Browse files Browse the repository at this point in the history
  • Loading branch information
jgabry committed Apr 17, 2018
1 parent 0475740 commit 28360b1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 33 deletions.
8 changes: 3 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,16 @@ Description: Provides various tools for developers of R packages interfacing
across 'Stan'-based R packages, and vignettes with recommendations for
developers.
License: GPL (>=3)
URL: http://discourse.mc-stan.org/, http://mc-stan.org/, http://mc-stan.org/rstantools/
URL: http://discourse.mc-stan.org/, http://mc-stan.org/rstantools/
BugReports: https://github.com/stan-dev/rstantools/issues
Encoding: UTF-8
LazyData: true
Imports:
stats,
utils
Imports: stats, utils
Suggests:
bayesplot (>= 1.5.0),
rstan (>= 2.17.2),
rstanarm (>= 2.17.4),
shinystan (>= 2.3.0),
shinystan (>= 2.4.0),
loo (>= 2.0.0),
testthat,
covr,
Expand Down
10 changes: 7 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

(Github issue/PR numbers in parentheses)

* `rstan_package_skeleton` now calls `usethis::create_package` instead of `utils::package.skeleton`. (#28)
* New [vignette](http://mc-stan.org/rstantools/articles/) walking through the package creation process. (#9) (thanks to Stefan Siegert)

* `rstan_package_skeleton()` now calls `usethis::create_package()` instead of `utils::package.skeleton()`. (#28)

* Update `rstan_package_skeleton()` for latest build process (#19)
* `rstan_package_skeleton` now does a bit more work for the user to make sure the the NAMESPACE file is correct.

* `rstan_package_skeleton()` now does a bit more work for the user to make sure the the NAMESPACE file is correct.

* Simplify instructions in Read-and-delete-me (related to #19).
* New [vignette](http://mc-stan.org/rstantools/articles/) walking through the package creation process. (#9) (thanks to Stefan Siegert)

# rstantools 1.4.0

Expand Down
40 changes: 21 additions & 19 deletions R/rstan_package_skeleton.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
#' Create the skeleton of a new \R package with Stan programs
#'
#' @description
#' \if{html}{\figure{stanlogo.png}{options: width="50px" alt="http://mc-stan.org/about/logo/"}}
#' \if{html}{\figure{stanlogo.png}{options: width="25px" alt="http://mc-stan.org/about/logo/"}}
#' The \code{rstan_package_skeleton} function helps get you started developing
#' \R packages that interface with Stan via the \pkg{rstan} package.
#' As of \pkg{rstantools} v1.5.0, \code{rstan_package_skeleton}
#' calls \code{usethis::create_package} (instead of \code{utils::package.skeleton})
#' and then makes necessary adjustments so that the package can include Stan Programs that can be built into binary versions
#' (i.e., pre-compiled like \pkg{rstanarm}).
#' \R packages that interface with Stan via the \pkg{rstan} package. As of
#' \pkg{rstantools} v1.5.0, \code{rstan_package_skeleton} calls
#' \code{usethis::create_package} (instead of \code{utils::package.skeleton})
#' and then makes necessary adjustments so that the package can include Stan
#' Programs that can be built into binary versions (i.e., pre-compiled like
#' \pkg{rstanarm}).
#'
#' See the \strong{See Also} section below for links to recommendations for
#' developers and a step by step walkthrough of what to do after running
Expand Down Expand Up @@ -114,13 +115,13 @@ rstan_package_skeleton <-

# tools
usethis::use_directory("tools")
.download_rstanarm_file("tools/make_cc.R", pkg_dir = DIR)
use_rstanarm_file("tools/make_cc.R")


# src
usethis::use_directory("src")
.download_rstanarm_file("src/Makevars", pkg_dir = DIR)
.download_rstanarm_file("src/Makevars.win", pkg_dir = DIR)
use_rstanarm_file("src/Makevars")
use_rstanarm_file("src/Makevars.win")

# register cpp (src/init.cpp)
init_cpp(name, path = DIR)
Expand Down Expand Up @@ -156,7 +157,7 @@ rstan_package_skeleton <-

# R
message("Updating R directory ...", domain = NA)
.download_rstanarm_file("R/stanmodels.R", pkg_dir = DIR)
use_rstanarm_file("R/stanmodels.R")
system2(
"sed",
args = paste0("-i.bak 's@rstanarm@", name, "@g' ",
Expand Down Expand Up @@ -197,7 +198,7 @@ rstan_package_skeleton <-

message("Writing Read-and-delete-me file with additional instructions ...",
domain = NA)
.write_read_and_delete_me(DIR)
use_read_and_delete_me(DIR)


message("\nFinished skeleton for package: ", name)
Expand All @@ -215,21 +216,22 @@ rstan_package_skeleton <-


# internal ----------------------------------------------------------------
.rstanarm_path <- function(relative_path) {
base_url <- "https://raw.githubusercontent.com/stan-dev/rstanarm/master"
file.path(base_url, relative_path)
}

.download_rstanarm_file <- function(rstanarm_relative_path, pkg_dir) {
use_rstanarm_file <- function(rstanarm_relative_path) {
proj <- usethis::proj_get()
utils::download.file(
url = .rstanarm_path(rstanarm_relative_path),
destfile = file.path(pkg_dir, rstanarm_relative_path),
destfile = file.path(proj, rstanarm_relative_path),
quiet = TRUE
)
}

.rstanarm_path <- function(relative_path) {
base_url <- "https://raw.githubusercontent.com/stan-dev/rstanarm/master"
file.path(base_url, relative_path)
}


.write_read_and_delete_me <- function(pkg_dir) {
use_read_and_delete_me <- function(pkg_dir) {
cat(
"* The precompiled stanmodel objects will appear in a named list called 'stanmodels', ",
"and you can call them with something like rstan::sampling(stanmodels$foo, ...)",
Expand Down
13 changes: 7 additions & 6 deletions man/rstan_package_skeleton.Rd

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

0 comments on commit 28360b1

Please sign in to comment.