diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3da8ec4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +# ignore nonsense files +.DS_Store +.Rhistory +.local +.rstudio +.bash_history +.RData +.httr-oauth +docker/git_token.txt +.Rproj.user +docs/* diff --git a/resources/exclude_files.txt b/resources/exclude_files.txt new file mode 100644 index 0000000..cc77fee --- /dev/null +++ b/resources/exclude_files.txt @@ -0,0 +1,4 @@ +About.Rmd +docs/* +style-sets/* +manuscript/* diff --git a/scripts/spell-check.R b/scripts/spell-check.R index d85c108..522f628 100644 --- a/scripts/spell-check.R +++ b/scripts/spell-check.R @@ -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() %>% diff --git a/scripts/url-check.R b/scripts/url-check.R index c662b07..113c1a8 100644 --- a/scripts/url-check.R +++ b/scripts/url-check.R @@ -18,6 +18,9 @@ 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) @@ -25,8 +28,17 @@ if (file.exists(ignore_urls_file)) { 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) {