From fc619eee5f60b933e3ce0cdc792d8ee8e4ccd5dd Mon Sep 17 00:00:00 2001 From: Jeroen Ooms Date: Tue, 8 Oct 2019 13:00:57 +0200 Subject: [PATCH] Cleanup and update NEWS --- NEWS | 3 +++ R/check-files.R | 6 +++--- R/spell-check.R | 3 +-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 4f53876..e18649c 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +2.2 + - spell_check_package() now loads Rd macros (#42) + 2.1 - Pre-filter script/style/img tags when checking html files because the huge embedded binary blogs produced by rmarkdown slow down the hunspell parser. diff --git a/R/check-files.R b/R/check-files.R index c6d8dd4..526ea1c 100644 --- a/R/check-files.R +++ b/R/check-files.R @@ -86,10 +86,10 @@ spell_check_description_text <- function(file, dict){ } spell_check_file_rd <- function(rdfile, macros = NULL, dict) { - if (is.null(macros)) { - text <- tools::RdTextFilter(rdfile) + text <- if (!length(macros)) { + tools::RdTextFilter(rdfile) } else { - text <- tools::RdTextFilter(rdfile, macros = macros) + tools::RdTextFilter(rdfile, macros = macros) } Encoding(text) <- "UTF-8" spell_check_plain(text, dict = dict) diff --git a/R/spell-check.R b/R/spell-check.R index 0630c58..9274f43 100644 --- a/R/spell-check.R +++ b/R/spell-check.R @@ -54,10 +54,9 @@ 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)) - macros <- tools::loadPkgRdMacros(pkg$path) macros <- tools::loadRdMacros( file.path(R.home("share"), "Rd", "macros", "system.Rd"), - macros = macros + tools::loadPkgRdMacros(pkg$path) ) rd_lines <- lapply(rd_files, spell_check_file_rd, dict = dict, macros = macros)