Skip to content

Commit

Permalink
Merge pull request #29 from jhudsl/cansavvy/exclude_files
Browse files Browse the repository at this point in the history
  • Loading branch information
cansavvy authored Mar 1, 2024
2 parents a0ec32d + 6fa12ea commit b7e56c1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 13 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ignore nonsense files
.DS_Store
.Rhistory
.local
.rstudio
.bash_history
.RData
.httr-oauth
docker/git_token.txt
.Rproj.user
docs/*
4 changes: 4 additions & 0 deletions resources/exclude_files.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
About.Rmd
docs/*
style-sets/*
manuscript/*
24 changes: 12 additions & 12 deletions scripts/spell-check.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,26 @@ if (!dir.exists('check_reports')) {
dict_file <- file.path(root_dir, 'resources', 'dictionary.txt')
dictionary <- readLines(dict_file)

# Make it alphabetical and only unique entries
writeLines(unique(sort(dictionary)), dict_file)
# Declare exclude_files.txt
exclude_file <- file.path(root_dir, 'resources', 'exclude_files.txt')

# Read in exclude_files.txt if it exists
if (file.exists(exclude_file)) {
exclude_file <- readLines(exclude_file)
} else {
exclude_file <- ""
}

# Only declare `.Rmd` files but not the ones in the style-sets directory
files <- list.files(pattern = 'md$', recursive = TRUE, full.names = TRUE)

# Get quiz file names
quiz_files <- list.files(file.path(root_dir, "quizzes"), pattern = '\\.md$', full.names = TRUE)

# Put into one list
files <- c(files, quiz_files)
if( exclude_file[1] != "") files <- grep(paste0(exclude_file, collapse = "|"), files, invert = TRUE, value = TRUE)

files <- grep("About.Rmd", files, ignore.case = TRUE, invert = TRUE, value = TRUE)
files <- grep("style-sets", files, ignore.case = TRUE, invert = TRUE, value = TRUE)

tryCatch(
tryCatch(
expr = {
# Run spell check
sp_errors <- spelling::spell_check_files(files, ignore = dictionary)

if (nrow(sp_errors) > 0) {
sp_errors <- sp_errors %>%
data.frame() %>%
Expand Down
14 changes: 13 additions & 1 deletion scripts/url-check.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,27 @@ if (!dir.exists('check_reports')) {
# Declare ignore_urls file
ignore_urls_file <- file.path(root_dir, 'resources', 'ignore-urls.txt')

# Declare exclude_files.txt
exclude_file <- file.path(root_dir, 'resources', 'exclude_files.txt')

# Read in ignore urls file if it exists
if (file.exists(ignore_urls_file)) {
ignore_urls <- readLines(ignore_urls_file)
} else {
ignore_urls <- ""
}

# Read in ignore urls file if it exists
if (file.exists(exclude_file)) {
exclude_file <- readLines(exclude_file)
} else {
exclude_file <- ""
}

# Only declare `.md` files but not the ones in the style-sets directory
files <- list.files(path = root_dir, pattern = 'md$', full.names = TRUE)
files <- list.files(path = root_dir, pattern = 'md$', full.names = TRUE, recursive = TRUE)

if( exclude_file[1] != "") files <- grep(paste0(exclude_file, collapse = "|"), files, invert = TRUE, value = TRUE)

test_url <- function(url) {

Expand Down

0 comments on commit b7e56c1

Please sign in to comment.