Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Sep 24, 2024
1 parent f622ba7 commit dda4e1d
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion R/files-conflicts.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ check_referenced_files <- function(path = ".", quiet = FALSE) {
# FIXME in Rbuilignore, change `^_pkgdown\.yml$` to `_pkgdown.yml` to make sure it works
path <- fs::dir_ls(path = path, recurse = TRUE, regexp = "\\.(R|md|ya?ml|builignore)$", all = TRUE, type = "file")
# FIXME Support _pkgdown when you want it. will likely require adjustments, not worth the effort for now.
path <- fs::path_filter(path = path, regexp = "_files|tests/testthat|_book|_freeze|_site|.github|_pkgdown", invert = TRUE) # need to do this in 2 places
path <- fs::path_filter(path = path, regexp = "_files|tests/testthat|_book|_freeze|_site|.github|_pkgdown|\\.revealjs\\.md$|\\.html\\.md$", invert = TRUE) # need to do this in 2 places
} else if (fs::path_ext(path) %in% c("R", "yml", "yaml", "Rmd", "md", "qmd", "Rmarkdown", "gitignore", "Rbuildignore")) {
path <- path
} else {
Expand Down
2 changes: 1 addition & 1 deletion R/outline-criteria.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ o_is_tab_plot_title <- function(x) {
sep = "|"
)

stringr::str_detect(x, "(?<!(_|:|\"|abbr\\s))title = [\"'](?![\"'])[^\"]{5,}") &
stringr::str_detect(x, "(?<!(_|:|\"|abbr\\s))title = (md\\(|html\\()?[\"'](?![\"'])[^\"]{5,}") &
!grepl("[", x, fixed = TRUE) &
!grepl(generic_title_regex, x) &
!stringr::str_ends(x, "\\(|\"\",?|'',?|\\(") &
Expand Down
5 changes: 5 additions & 0 deletions R/outline.R
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ exclude_example_files <- function(path) {
"vignettes/.+\\.R$", # generated files
"vignette-dump|renv/",
"RcppExports.R",
"revealjs.md$",
"html.md$",
"_book/",
"_freeze/",
"_site/",
"malformed", # likely for tests
"pkgdown/assets",
sep = "|"
Expand Down
2 changes: 1 addition & 1 deletion R/rename.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ rename_files2 <- function(old,
regex_friendly <- paste0("to {.val ", regex_friendly, "}")
# avoid searching in generated files and tests/testthat files
files_to_look_into <- fs::dir_ls(regexp = "ya?ml$|md$|R$|gitignore|Rbuildignore", type = "file", recurse = TRUE, all = TRUE)
files_to_look_into <- fs::path_filter(files_to_look_into, regexp = "_files|tests/testthat|_book/|_freeze/|renv/|.github/|.git/", invert = TRUE) # need to do elsewhere too
files_to_look_into <- fs::path_filter(files_to_look_into, regexp = "_files|tests/testthat|_book/|_site/|_freeze/|renv/|.github/|.git/", invert = TRUE) # need to do elsewhere too
n_file_names_conflicts <- solve_file_name_conflict(
files = files_to_look_into,
regex = regexp_to_search_for_in_files,
Expand Down
1 change: 0 additions & 1 deletion TODO.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
# TODO [delete] generated files
# TODO [check_referenced_files] doesn't check for {.file R/file.R}
# TODO browse_pkg should open by default if no vignettes are found, because there is not much to do in the R-session.
# TODO exclude _files from `proj_list()`
# TODO rename_files should be less noisy about project name file
# TODO add_to_tricks(). when detecting TRICK like complete todo, but not remove line. requires a scheme. moves the item to tricks.md at the correct place. (copy to clipboard is probably enough)
# TODO use vapply() instead of purrr::map
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/_snaps/outline.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-- `my-analysis.R` Analyse my {streets}
Output
`i` **A table title**
`i` A section
`i` TODO Create a new version
`i` Read my streets (<https://https://en.wikipedia.org/wiki/Street_art>) data
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-outline-criteria.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ test_that("o_is_generic_test() works", {

test_that("o_is_tab_plot_title() works", {
expect_true(o_is_tab_plot_title("title = 'A great'"))
expect_true(o_is_tab_plot_title("title = md('A great')"))

expect_false(o_is_tab_plot_title("tab_header()"))
expect_false(o_is_tab_plot_title("```{r tab_header}"))
expect_false(o_is_tab_plot_title("fwd_title = 'Family'"))
Expand Down

0 comments on commit dda4e1d

Please sign in to comment.