From 50c4a9066f985d0888252e169573a2127275e2e9 Mon Sep 17 00:00:00 2001 From: cansavvy Date: Thu, 29 Feb 2024 07:59:33 -0500 Subject: [PATCH 1/4] Add exclude_files.txt --- .gitignore | 11 +++++++++++ resources/exclude_files.txt | 1 + scripts/spell-check.R | 13 +++++++++++++ scripts/url-check.R | 13 +++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 .gitignore create mode 100644 resources/exclude_files.txt 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..a1892e3 --- /dev/null +++ b/resources/exclude_files.txt @@ -0,0 +1 @@ +CONTRIBUTING.md diff --git a/scripts/spell-check.R b/scripts/spell-check.R index d85c108..6b75ea1 100644 --- a/scripts/spell-check.R +++ b/scripts/spell-check.R @@ -27,12 +27,25 @@ if (!dir.exists('check_reports')) { dict_file <- file.path(root_dir, 'resources', 'dictionary.txt') dictionary <- readLines(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 <- "" +} + # Make it alphabetical and only unique entries writeLines(unique(sort(dictionary)), dict_file) # Only declare `.Rmd` files but not the ones in the style-sets directory files <- list.files(pattern = 'md$', recursive = TRUE, full.names = TRUE) +# Exclude files lists in the exclude_file +files <- setdiff(files, file.path(root_dir, exclude_file)) + # Get quiz file names quiz_files <- list.files(file.path(root_dir, "quizzes"), pattern = '\\.md$', full.names = TRUE) diff --git a/scripts/url-check.R b/scripts/url-check.R index c662b07..839603c 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,9 +28,19 @@ 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) +# Exclude files lists in the exclude_file +files <- setdiff(files, file.path(root_dir, exclude_file)) + test_url <- function(url) { if (url %in% ignore_urls) { From e052a4a872bc8fc5e7c86697dafa8c7300bf7a37 Mon Sep 17 00:00:00 2001 From: cansavvy Date: Fri, 1 Mar 2024 07:52:20 -0500 Subject: [PATCH 2/4] Get rid of About.Rmd exclusion --- scripts/spell-check.R | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/spell-check.R b/scripts/spell-check.R index 6b75ea1..c61c565 100644 --- a/scripts/spell-check.R +++ b/scripts/spell-check.R @@ -52,14 +52,13 @@ quiz_files <- list.files(file.path(root_dir, "quizzes"), pattern = '\\.md$', ful # Put into one list files <- c(files, quiz_files) -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() %>% From 7c2912311ceea4891e5f3e9df0c2eb9fb591f5cd Mon Sep 17 00:00:00 2001 From: cansavvy Date: Fri, 1 Mar 2024 08:10:08 -0500 Subject: [PATCH 3/4] Make it so exclude_files accepts regex --- resources/exclude_files.txt | 3 ++- scripts/spell-check.R | 14 +------------- scripts/url-check.R | 7 +++---- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/resources/exclude_files.txt b/resources/exclude_files.txt index a1892e3..7e32026 100644 --- a/resources/exclude_files.txt +++ b/resources/exclude_files.txt @@ -1 +1,2 @@ -CONTRIBUTING.md +About.Rmd +docs/* diff --git a/scripts/spell-check.R b/scripts/spell-check.R index c61c565..522f628 100644 --- a/scripts/spell-check.R +++ b/scripts/spell-check.R @@ -37,22 +37,10 @@ if (file.exists(exclude_file)) { exclude_file <- "" } -# Make it alphabetical and only unique entries -writeLines(unique(sort(dictionary)), dict_file) - # Only declare `.Rmd` files but not the ones in the style-sets directory files <- list.files(pattern = 'md$', recursive = TRUE, full.names = TRUE) -# Exclude files lists in the exclude_file -files <- setdiff(files, file.path(root_dir, exclude_file)) - -# 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) - -files <- grep("style-sets", files, ignore.case = TRUE, invert = TRUE, value = TRUE) +if( exclude_file[1] != "") files <- grep(paste0(exclude_file, collapse = "|"), files, invert = TRUE, value = TRUE) tryCatch( expr = { diff --git a/scripts/url-check.R b/scripts/url-check.R index 839603c..113c1a8 100644 --- a/scripts/url-check.R +++ b/scripts/url-check.R @@ -34,12 +34,11 @@ if (file.exists(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) -# Exclude files lists in the exclude_file -files <- setdiff(files, file.path(root_dir, exclude_file)) +if( exclude_file[1] != "") files <- grep(paste0(exclude_file, collapse = "|"), files, invert = TRUE, value = TRUE) test_url <- function(url) { From 6fa12ead2868130b04d7184b8f9f167fe48ddde1 Mon Sep 17 00:00:00 2001 From: cansavvy Date: Fri, 1 Mar 2024 08:11:12 -0500 Subject: [PATCH 4/4] Make standard exclude_files.txt --- resources/exclude_files.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/exclude_files.txt b/resources/exclude_files.txt index 7e32026..cc77fee 100644 --- a/resources/exclude_files.txt +++ b/resources/exclude_files.txt @@ -1,2 +1,4 @@ About.Rmd docs/* +style-sets/* +manuscript/*