Skip to content

Commit

Permalink
doc: update sliding vignette
Browse files Browse the repository at this point in the history
* rename to backtesting, simplify
* move out of articles and into dropdown
  • Loading branch information
dshemetov committed Oct 21, 2024
1 parent fe09e6a commit 2da0a9a
Show file tree
Hide file tree
Showing 8 changed files with 619 additions and 504 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: epipredict
Title: Basic epidemiology forecasting methods
Version: 0.1.2
Version: 0.1.3
Authors@R: c(
person("Daniel J.", "McDonald", , "[email protected]", role = c("aut", "cre")),
person("Ryan", "Tibshirani", , "[email protected]", role = "aut"),
Expand Down Expand Up @@ -36,6 +36,7 @@ Imports:
ggplot2,
glue,
hardhat (>= 1.3.0),
here,
lifecycle,
magrittr,
recipes (>= 1.0.4),
Expand Down
74 changes: 53 additions & 21 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
## Setting up the development environment

```r
install.packages(c('devtools', 'pkgdown', 'styler', 'lintr')) # install dev dependencies
devtools::install_deps(dependencies = TRUE) # install package dependencies
devtools::document() # generate package meta data and man files
devtools::build() # build package
install.packages(c('devtools', 'pkgdown', 'styler', 'lintr', 'pak')) # install dev dependencies
pak::pkg_install(".") # install package and dependencies
```

## Validating the package
Expand All @@ -13,35 +11,69 @@ devtools::build() # build package
styler::style_pkg() # format code
lintr::lint_package() # lint code

devtools::check() # run R CMD check, which runs everything below
devtools::document() # generate package meta data and man files
devtools::test() # test package
devtools::check() # check package for errors
devtools::build_vignettes() # build vignettes only
devtools::run_examples() # run doc examples
devtools::check(vignettes = FALSE) # check package without vignettes
```

## Developing the documentation site

The [documentation site](https://cmu-delphi.github.io/epipredict/) is built off of the `main` branch. The `dev` version of the site is available at https://cmu-delphi.github.io/epipredict/dev.

The documentation site can be previewed locally by running in R

```r
pkgdown::build_site(preview=TRUE)
```
Our CI builds two version of the documentation:

The `main` version is available at `file:///<local path>/epidatr/epipredict/index.html` and `dev` at `file:///<local path>/epipredict/docs/dev/index.html`.
- https://cmu-delphi.github.io/epipredict/ from the `main` branch and
- https://cmu-delphi.github.io/epipredict/dev from the `dev` branch.

You can also build the docs manually and launch the site with python. From the terminal, this looks like
We include the script `pkgdown-watch.R` that will automatically rebuild the
documentation locally and preview it. It can be used with:

```bash
R -e 'pkgdown::clean_site()'
R -e 'devtools::document()'
R -e 'pkgdown::build_site()'
python -m http.server -d docs
```sh
# Make sure you have servr installed
R -e 'renv::install("servr")'
# Will start a local server
Rscript pkgdown-watch.R
# You may need to first build the site with
R -e 'pkgdown::build_site(".", examples = FALSE, devel = TRUE, preview = FALSE)'
```

## Versioning

Please follow the guidelines in the [PR template document](.github/pull_request_template.md).

## Release process
## Planned CRAN release process

Open a release issue and then copy and follow this checklist in the issue (modified from the checklist generated by `usethis::use_release_issue(version = "1.0.2")`):

- [ ] `git pull` on `dev` branch.
- [ ] Make sure all changes are committed and pushed.
- [ ] Check [current CRAN check results](https://cran.rstudio.org/web/checks/check_results_epipredict.html).
- [ ] `devtools::check(".", manual = TRUE, env_vars = c(NOT_CRAN = "false"))`.
- Aim for 10/10, no notes.
- [ ] If check works well enough, merge to main. Otherwise open a PR to fix up.
- [ ] [Polish NEWS](https://github.com/cmu-delphi/epipredict/blob/dev/NEWS.md).
- Some [guidelines](https://style.tidyverse.org/news.html#news-release).
- [ ] `git checkout main`
- [ ] `git pull`
- [ ] `urlchecker::url_check()`.
- This may choke on the MIT license url, and that's ok.
- [ ] `devtools::build_readme()`
- [ ] `devtools::check_win_devel()`
- [ ] Have maintainer ("cre" in description) check email for problems.
- [ ] `revdepcheck::revdep_check(num_workers = 4)`.
- This may choke, it is very sensitive to the binary versions of packages on a given system. Either bypass or ask someone else to run it if you're concerned.
- [ ] Update `cran-comments.md`
- [ ] PR with any changes (and go through the list again) into `dev` and run through the list again.

Submit to CRAN:

- [ ] `devtools::submit_cran()`.
- [ ] Maintainer approves email.

Wait for CRAN...

TBD
- [ ] If accepted :tada:, move to next steps. If rejected, fix and resubmit.
- [ ] Open and merge a PR containing any updates made to `main` back to `dev`.
- [ ] `usethis::use_github_release(publish = FALSE)` (publish off, otherwise it won't push) will create a draft release based on the commit hash in CRAN-SUBMISSION and push a tag to the GitHub repo.
- [ ] Go to the repo, verify the release notes, and publish when ready.
44 changes: 22 additions & 22 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ navbar:
type: light

articles:
- title: Get started
navbar: ~
contents:
- epipredict
- preprocessing-and-models
- arx-classifier
- update
- title: Get started
navbar: ~
contents:
- epipredict
- preprocessing-and-models
- backtesting
- arx-classifier
- update

- title: Advanced methods
contents:
- articles/sliding
- articles/smooth-qr
- articles/symptom-surveys
- panel-data
- title: Advanced methods
contents:
- articles/smooth-qr
- articles/symptom-surveys
- panel-data

repo:
url:
Expand Down Expand Up @@ -79,15 +79,15 @@ reference:
- grf_quantiles
- title: Custom panel data forecasting workflows
contents:
- epi_recipe
- epi_workflow
- add_epi_recipe
- adjust_epi_recipe
- Add_model
- predict.epi_workflow
- fit.epi_workflow
- augment.epi_workflow
- forecast.epi_workflow
- epi_recipe
- epi_workflow
- add_epi_recipe
- adjust_epi_recipe
- Add_model
- predict.epi_workflow
- fit.epi_workflow
- augment.epi_workflow
- forecast.epi_workflow

- title: Epi recipe preprocessing steps
contents:
Expand Down
58 changes: 58 additions & 0 deletions pkgdown-watch.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Run with: Rscript pkgdown-watch.R
#
# Modifying this: https://gist.github.com/gadenbuie/d22e149e65591b91419e41ea5b2e0621
# - Removed docopts cli interface and various configs/features I didn't need.
# - Sped up reference building by not running examples.
#
# Note that the `pattern` regex is case sensitive, so make sure your Rmd files
# end in `.Rmd` and not `.rmd`.

rlang::check_installed(c("pkgdown", "servr", "devtools", "here", "cli", "fs"))

pkg <- pkgdown::as_pkgdown(".")

servr::httw(
dir = here::here("docs"),
watch = here::here(),
pattern = "[.](Rm?d|y?ml|s[ac]ss|css|js)$",
handler = function(files) {
devtools::load_all()

files_rel <- fs::path_rel(files, start = getwd())
cli::cli_inform("{cli::col_yellow('Updated')} {.val {files_rel}}")

articles <- grep("vignettes.+Rmd$", files, value = TRUE)

if (length(articles) == 1) {
name <- fs::path_ext_remove(fs::path_rel(articles, fs::path(pkg$src_path, "vignettes")))
pkgdown::build_article(name, pkg)
} else if (length(articles) > 1) {
pkgdown::build_articles(pkg, preview = FALSE)
}

refs <- grep("man.+R(m?d)?$", files, value = TRUE)
if (length(refs)) {
# TODO: This does not work for me, so I just run it manually.
# pkgdown::build_reference(pkg, preview = FALSE, examples = FALSE, lazy = FALSE)
}

pkgdown <- grep("pkgdown", files, value = TRUE)
if (length(pkgdown) && !pkgdown %in% c(articles, refs)) {
pkgdown::init_site(pkg)
}

pkgdown_index <- grep("index[.]Rmd$", files_rel, value = TRUE)
if (length(pkgdown_index)) {
devtools::build_rmd(pkgdown_index)
pkgdown::build_home(pkg)
}

readme <- grep("README[.]rmd$", files, value = TRUE, ignore.case = TRUE)
if (length(readme)) {
devtools::build_readme(".")
pkgdown::build_home(pkg)
}

cli::cli_alert("Site rebuild done!")
}
)
1 change: 1 addition & 0 deletions vignettes/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.html
*_cache/
*.R
!_common.R
23 changes: 23 additions & 0 deletions vignettes/_common.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
knitr::opts_chunk$set(
digits = 3,
comment = "#>",
collapse = TRUE,
cache = TRUE,
dev.args = list(bg = "transparent"),
dpi = 300,
cache.lazy = FALSE,
out.width = "90%",
fig.align = "center",
fig.width = 9,
fig.height = 6
)
ggplot2::theme_set(ggplot2::theme_bw())
options(
dplyr.print_min = 6,
dplyr.print_max = 6,
pillar.max_footer_lines = 2,
pillar.min_chars = 15,
stringr.view_n = 6,
pillar.bold = TRUE,
width = 77
)
Loading

0 comments on commit 2da0a9a

Please sign in to comment.