Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rdev
Title: R Development Tools
Version: 1.13.0
Version: 1.14.0
Authors@R:
person("John", "Benninghoff", , "jbenninghoff@mac.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-6230-4742"))
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export(missing_deps)
export(new_branch)
export(open_files)
export(package_downloads)
export(package_type)
export(rmd_metadata)
export(setup_analysis)
export(setup_rdev)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# rdev 1.14.0

* Added utility function `package_type()`: determine rdev package type

* Added an option to update the spelling `WORDLIST` to `ci()` (on by default)

# rdev 1.13.0

* Added function `use_gitattributes()`: Install rdev .gitattributes template using `usethis::use_template()` to set GitHub Linguist [overrides](https://github.com/github-linguist/linguist/blob/main/docs/overrides.md)
Expand Down
33 changes: 26 additions & 7 deletions R/ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ print_tbl <- function(df) {
#' @param document run [devtools::document()]
#' @param normalize run [desc::desc_normalize()]
#' @param extra run [extra_deps()]
#' @param spelling update spelling [`WORDLIST`][spelling::wordlist]
#' @param urls validate URLs with [url_check()] and [html_url_check()]
#' @param rcmdcheck run `R CMD check` using:
#' [`rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "warning")`][rcmdcheck::rcmdcheck]
Expand All @@ -125,6 +126,7 @@ ci <- function(renv = TRUE, # nolint: cyclocomp_linter.
document = TRUE,
normalize = TRUE,
extra = TRUE,
spelling = TRUE,
urls = TRUE,
rcmdcheck = TRUE) {
checkmate::assert_flag(renv)
Expand All @@ -135,6 +137,7 @@ ci <- function(renv = TRUE, # nolint: cyclocomp_linter.
checkmate::assert_flag(document)
checkmate::assert_flag(normalize)
checkmate::assert_flag(extra)
checkmate::assert_flag(spelling)
checkmate::assert_flag(urls)
checkmate::assert_flag(rcmdcheck)

Expand All @@ -145,7 +148,8 @@ ci <- function(renv = TRUE, # nolint: cyclocomp_linter.
return(invisible(status))
}
if (any(
missing, pkgdown, is.null(styler), styler, lintr, document, normalize, extra, urls, rcmdcheck
missing, pkgdown, is.null(styler), styler, lintr, document, normalize, extra, spelling, urls,
rcmdcheck
)) {
writeLines("")
}
Expand All @@ -157,15 +161,19 @@ ci <- function(renv = TRUE, # nolint: cyclocomp_linter.
if (nrow(md) != 0) {
return(tibble::as_tibble(md))
}
if (any(pkgdown, is.null(styler), styler, lintr, document, normalize, extra, urls, rcmdcheck)) {
if (any(
pkgdown, is.null(styler), styler, lintr, document, normalize, extra, spelling, urls, rcmdcheck
)) {
writeLines("")
}
}

if (pkgdown && fs::file_exists("_pkgdown.yml")) {
writeLines("pkgdown::check_pkgdown()")
pkgdown::check_pkgdown()
if (any(is.null(styler), styler, lintr, document, normalize, extra, urls, rcmdcheck)) {
if (any(
is.null(styler), styler, lintr, document, normalize, extra, spelling, urls, rcmdcheck
)) {
writeLines("")
}
}
Expand All @@ -177,7 +185,7 @@ ci <- function(renv = TRUE, # nolint: cyclocomp_linter.
if (styler) {
writeLines("style_all()")
style_all()
if (any(lintr, document, normalize, extra, urls, rcmdcheck)) writeLines("")
if (any(lintr, document, normalize, extra, spelling, urls, rcmdcheck)) writeLines("")
}

if (lintr) {
Expand All @@ -186,24 +194,35 @@ ci <- function(renv = TRUE, # nolint: cyclocomp_linter.
if (length(lints) > 0) {
return(lints)
}
if (any(document, normalize, extra, urls, rcmdcheck)) writeLines("")
if (any(document, normalize, extra, spelling, urls, rcmdcheck)) writeLines("")
}

if (document) {
writeLines("devtools::document()")
devtools::document()
if (any(normalize, extra, urls, rcmdcheck)) writeLines("")
if (any(normalize, extra, spelling, urls, rcmdcheck)) writeLines("")
}

if (normalize) {
writeLines("desc::desc_normalize()")
desc::desc_normalize()
if (any(extra, urls, rcmdcheck)) writeLines("")
if (any(extra, spelling, urls, rcmdcheck)) writeLines("")
}

if (extra) {
writeLines("extra_deps()")
print_tbl(extra_deps())
if (any(spelling, urls, rcmdcheck)) writeLines("")
}

if (spelling) {
if (package_type() == "rdev") {
writeLines("spelling::update_wordlist()")
spelling::update_wordlist()
} else {
writeLines("update_wordlist_notebooks()")
update_wordlist_notebooks()
}
if (any(urls, rcmdcheck)) writeLines("")
}

Expand Down
7 changes: 4 additions & 3 deletions R/release.R
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,14 @@ stage_release <- function(pkg = ".",
gert::git_add("DESCRIPTION")
gert::git_commit(rel_message)

if (fs::file_exists("_quarto.yml")) {
pkg_type <- package_type(pkg = pkg, strict = TRUE)
if (pkg_type == "quarto") { # nolint: if_switch_linter. `if` is cleaner here.
builder <- paste0("build_quarto_site(unfreeze = ", unfreeze, ")")
build_quarto_site(unfreeze = unfreeze)
} else if (fs::file_exists("pkgdown/_base.yml")) {
} else if (pkg_type == "analysis") {
builder <- "build_analysis_site()"
build_analysis_site()
} else if (fs::file_exists("_pkgdown.yml")) {
} else if (pkg_type == "rdev") {
builder <- "build_rdev_site()"
build_rdev_site()
} else {
Expand Down
5 changes: 2 additions & 3 deletions R/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ use_package_r <- function(open = FALSE) {
#'
#' @export
use_gitattributes <- function(open = FALSE) {
# TODO: consider refactoring to an internal function to determine package type
# here and in stage_release()
if (fs::dir_exists("analysis")) {
pkg_type <- package_type()
if (pkg_type == "analysis" || pkg_type == "quarto") {
gitattributes <- "gitattributes-analysis"
} else {
gitattributes <- "gitattributes-rdev"
Expand Down
37 changes: 37 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,43 @@ extra_deps <- function() {
deps_check("extra")
}

#' Determine rdev package type
#'
#' Use heuristics (when `strict = FALSE`) or presence of specific files (when `strict = TRUE`) to
#' determine package type. If one of the files is found, the package is strictly determined:
#'
#' - If `_quarto.yml` is found, the type is `quarto`
#' - If `pkgdown/_base.yml` is found, the type is `analysis`
#' - If `_pkgdown.yml` is found, the type is `rdev`
#'
#' `package_type` will return `unknown` if `strict = TRUE` and none of the files are present. When
#' strict checking is disabled, the package is assumed to be `analysis` if an `analysis` directory
#' is present, and `rdev` if not.
#'
#' @param pkg path to package
#' @param strict strictly determine package type (see description)
#'
#' @return type string, one of `c("unknown", rdev", "analysis", "quarto")`
#' @export
package_type <- function(pkg = ".", strict = FALSE) {
checkmate::assert_character(pkg, min.chars = 1, any.missing = FALSE)
checkmate::assert_flag(strict)
if (fs::file_exists(fs::path(pkg, "_quarto.yml"))) {
type <- "quarto"
} else if (fs::file_exists(fs::path(pkg, "pkgdown/_base.yml"))) {
type <- "analysis"
} else if (fs::file_exists(fs::path(pkg, "_pkgdown.yml"))) {
type <- "rdev"
} else if (strict) {
type <- "unknown"
} else if (fs::dir_exists(fs::path(pkg, "analysis"))) {
type <- "analysis"
} else {
type <- "rdev"
}
type
}

#' Open rdev files
#'
#' Open a standard set of files for editing in RStudio.
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,21 @@ ci()
#> 2 Suggests diffviewer *
#> 3 Suggests DT *
#>
#> spelling::update_wordlist()
#> No changes required to /Users/agamemnon/GitHub/rdev/inst/WORDLIST
#>
#> url_check()
#> # A tibble: 1 × 9
#> URL From Status Message New CRAN Spaces R root
#> <chr> <nam> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 https://code.visualstudio… <chr> 500 Intern… "" "" "" "" /Use…
#> html_url_check()
#> # A tibble: 4 × 9
#> # A tibble: 3 × 9
#> URL From Status Message New CRAN Spaces R root
#> <chr> <nam> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 http://covr.r-lib.org/ref… <chr> 200 OK "htt… "" "" "" /Use…
#> 2 http://r-lib.github.io/rc… <chr> 200 OK "htt… "" "" "" /Use…
#> 3 https://code.visualstudio… <chr> 500 Intern… "" "" "" "" /Use…
#> 4 https://societyinforisk.o… <chr> 404 Not Fo… "" "" "" "" /Use…
#>
#> Setting env vars: NOT_CRAN="true", CI="true"
#> rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "warning")
Expand All @@ -235,10 +237,10 @@ ci()
#> * creating vignettes ... OK
#> * checking for LF line-endings in source and make files and shell scripts
#> * checking for empty or unneeded directories
#> * building ‘rdev_1.13.0.tar.gz’
#> * building ‘rdev_1.14.0.tar.gz’
#>
#> ── R CMD check ─────────────────────────────────────────────────────────────────
#> * using log directory ‘/private/var/folders/vn/cw5f9gws42v9m8mdsds_zbl00000gp/T/RtmpRj1WuE/file1544866a7d1f/rdev.Rcheck’
#> * using log directory ‘/private/var/folders/vn/cw5f9gws42v9m8mdsds_zbl00000gp/T/Rtmp2kPcE7/file32c077538441/rdev.Rcheck’
#> * using R version 4.5.1 (2025-06-13)
#> * using platform: aarch64-apple-darwin20
#> * R was compiled by
Expand All @@ -248,7 +250,7 @@ ci()
#> * using session charset: UTF-8
#> * using option ‘--no-manual’
#> * checking for file ‘rdev/DESCRIPTION’ ... OK
#> * this is package ‘rdev’ version ‘1.13.0’
#> * this is package ‘rdev’ version ‘1.14.0’
#> * package encoding: UTF-8
#> * checking package namespace information ... OK
#> * checking package dependencies ... OK
Expand Down Expand Up @@ -303,8 +305,8 @@ ci()
#> * DONE
#>
#> Status: OK
#> ── R CMD check results ──────────────────────────────────────── rdev 1.13.0 ────
#> Duration: 21.7s
#> ── R CMD check results ──────────────────────────────────────── rdev 1.14.0 ────
#> Duration: 23.9s
#>
#> 0 errors ✔ | 0 warnings ✔ | 0 notes ✔
```
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ reference:
- sort_rbuildignore
- spell_check_notebooks
- update_wordlist_notebooks
- package_type
- local_temppkg
- missing_deps
- extra_deps
Expand Down
2 changes: 1 addition & 1 deletion docs/404.html

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

2 changes: 1 addition & 1 deletion docs/LICENSE-text.html

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

2 changes: 1 addition & 1 deletion docs/LICENSE.html

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

2 changes: 1 addition & 1 deletion docs/TODO.html

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

2 changes: 1 addition & 1 deletion docs/articles/analysis-package-layout.html

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

2 changes: 1 addition & 1 deletion docs/articles/index.html

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

2 changes: 1 addition & 1 deletion docs/articles/rdev.html

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

2 changes: 1 addition & 1 deletion docs/articles/style-guide.html

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

6 changes: 3 additions & 3 deletions docs/authors.html

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

Loading
Loading