Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exclude_files.txt feature #29

Merged
merged 5 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading