File: spelling.R

package info (click to toggle)
r-cran-usethis 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,228 kB
  • sloc: sh: 26; makefile: 17; cpp: 6; ansic: 3
file content (28 lines) | stat: -rw-r--r-- 1,238 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#' Use spell check
#'
#' Adds a unit test to automatically run a spell check on documentation and,
#' optionally, vignettes during `R CMD check`, using the
#' [spelling][spelling::spell_check_package] package. Also adds a `WORDLIST`
#' file to the package, which is a dictionary of whitelisted words. See
#' [spelling::wordlist] for details.
#'
#' @param vignettes Logical, `TRUE` to spell check all `rmd` and `rnw` files in
#'   the `vignettes/` folder.
#' @param lang Preferred spelling language. Usually either `"en-US"` or
#'   `"en-GB"`.
#' @param error Logical, indicating whether the unit test should fail if
#'   spelling errors are found. Defaults to `FALSE`, which does not error, but
#'   prints potential spelling errors
#' @export
use_spell_check <- function(vignettes = TRUE,
                            lang = "en-US",
                            error = FALSE) {
  check_is_package("use_spell_check()")
  check_installed("spelling")
  use_dependency("spelling", "Suggests")
  proj_desc_field_update("Language", lang, overwrite = TRUE)
  spelling::spell_check_setup(
    pkg = proj_get(), vignettes = vignettes, lang = lang, error = error
  )
  ui_bullets(c("_" = "Run {.run devtools::check()} to trigger spell check."))
}