Skip to content

Commit e07e72f

Browse files
committed
progress
1 parent 4f1bed5 commit e07e72f

File tree

3 files changed

+62
-6
lines changed

3 files changed

+62
-6
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
S3method(print,summary_spellcheck)
44
export(get_wordlist)
5+
export(spell_check_bookdown)
56
export(spell_check_files)
67
export(spell_check_package)
78
export(spell_check_setup)

R/spell-check-bookdown.R

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ spell_check_bookdown <- function(path = ".", lang = NULL, use_wordlist = TRUE){
5252
author <- if(length(pkg[['authors@r']])){
5353
parse_r_field(pkg[['authors@r']])
5454
} else {
55-
strsplit(pkg[['author']], " ", fixed = TRUE)[[1]]
55+
if ("author" %in% names(pkg)) {
56+
strsplit(pkg[['author']], " ", fixed = TRUE)[[1]]
57+
} else{
58+
author <- NULL
59+
}
5660
}
5761

5862
meta <- c(pkg$package, author)
@@ -65,23 +69,28 @@ spell_check_bookdown <- function(path = ".", lang = NULL, use_wordlist = TRUE){
6569
dict <- hunspell::dictionary(lang, add_words = sort(ignore))
6670

6771
# Where to check for rmd/md files
68-
bookdown_files <- list.files(file.path(pkg$path), pattern = "\\.r?md$",
72+
bookdown_files <- list.files(file.path(path), pattern = "\\.rmd$",
6973
ignore.case = TRUE, full.names = TRUE, recursive = TRUE)
70-
root_files <- list.files(pkg$path, pattern = "(readme|news|changes|index).r?md",
74+
root_files <- list.files(file.path(path), pattern = "(readme|news|changes).r?md",
7175
ignore.case = TRUE, full.names = TRUE)
7276

7377
# Markdown files
74-
md_files <- normalizePath(c(root_files, bookdown_files))
75-
md_lines <- lapply(sort(md_files), spell_check_file_md, dict = dict)
78+
md_files <- sort(normalizePath(c(root_files, bookdown_files)))
79+
md_lines <- lapply(md_files, spell_check_file_md, dict = dict)
7680

7781
all_sources <- md_files
7882
all_lines <- md_lines
7983

8084
# Check 'DESCRIPTION' fields
8185
if (file.exists(file.path(path, "DESCRIPTION"))){
8286
pkg_fields <- c("title", "description")
87+
pkg <- as_package(path)
8388
pkg_lines <- lapply(pkg_fields, function(x){
84-
spell_check_file_text(textConnection(pkg[[x]]), dict = dict)
89+
if (x %in% names(pkg)) {
90+
spell_check_file_text(textConnection(pkg[[x]]), dict = dict)
91+
} else {
92+
spell_check_file_text(textConnection(""), dict = dict)
93+
}
8594
})
8695

8796
all_sources <- c(all_sources, pkg_fields)

man/spell_check_bookdown.Rd

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)