Skip to content

Commit

Permalink
Load Rd macros if checking package (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi authored and jeroen committed Oct 8, 2019
1 parent 569a24f commit 540624d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 6 additions & 2 deletions R/check-files.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ spell_check_description_text <- function(file, dict){
spell_check_plain(lines, dict = dict)
}

spell_check_file_rd <- function(rdfile, dict){
text <- tools::RdTextFilter(rdfile)
spell_check_file_rd <- function(rdfile, macros = NULL, dict) {
if (is.null(macros)) {
text <- tools::RdTextFilter(rdfile)
} else {
text <- tools::RdTextFilter(rdfile, macros = macros)
}
Encoding(text) <- "UTF-8"
spell_check_plain(text, dict = dict)
}
Expand Down
7 changes: 6 additions & 1 deletion R/spell-check.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ spell_check_package <- function(pkg = ".", vignettes = TRUE, use_wordlist = TRUE

# Check Rd manual files
rd_files <- sort(list.files(file.path(pkg$path, "man"), "\\.rd$", ignore.case = TRUE, full.names = TRUE))
rd_lines <- lapply(rd_files, spell_check_file_rd, dict = dict)
macros <- tools::loadPkgRdMacros(pkg$path)
macros <- tools::loadRdMacros(
file.path(R.home("share"), "Rd", "macros", "system.Rd"),
macros = macros
)
rd_lines <- lapply(rd_files, spell_check_file_rd, dict = dict, macros = macros)

# Check 'DESCRIPTION' fields
pkg_fields <- c("title", "description")
Expand Down

0 comments on commit 540624d

Please sign in to comment.