From 35882ae4bf1ffec1fd2d93fb3c82522d131a08a2 Mon Sep 17 00:00:00 2001 From: olivroy Date: Fri, 7 Jun 2024 01:49:14 -0400 Subject: [PATCH] Revert unintended --- NEWS.md | 2 +- R/outline-criteria.R | 14 ++++++++------ README.md | 4 ++-- tests/testthat/test-outline-criteria.R | 2 ++ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/NEWS.md b/NEWS.md index 996d358..2b45b7b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # reuseme (development version) -* `proj_outline()` now detects [knitr notebooks](https://rmarkdown.rstudio.com/articles_report_from_r_script.html) that use the default options. Internally, the file is transformed into a md file by stripping roxygen comments, and is processed as such. +* `proj_outline()` now detects [knitr notebooks](https://rmarkdown.rstudio.com/articles_report_from_r_script.html) that use the default options. Internally, the file is transformed into a md file by stripping roxygen comments, and is processed as such. (#30) * `proj_outline()` no longer shows `complete_todo()` links for items in non-interactive sessions. `complete_todo()` links are now only shown when calling `file_outline()` on the active file. diff --git a/R/outline-criteria.R b/R/outline-criteria.R index 99ba7a3..6028c87 100644 --- a/R/outline-criteria.R +++ b/R/outline-criteria.R @@ -167,12 +167,14 @@ define_outline_criteria <- function(.data, print_todo) { x$content[x$is_notebook] <- sub("^#'\\s?", "", x$content[x$is_notebook]) x$is_md <- (x$is_md | x$is_roxygen_comment | x$is_notebook) & !x$is_news # treating news and other md files differently. x$is_roxygen_comment <- x$is_roxygen_comment & !x$is_notebook - x <- dplyr::mutate( - x, - # Remove any files that contain noRd roxy tag to avoid false positive (this limitation can be overcome if / when I use roxygen2 parser) - is_roxygen_comment = is_roxygen_comment & !any(startsWith(content, "#' @noRd")), - .by = file - ) + # TODO extract title in roxy comments (@title too.L) + # x <- dplyr::mutate( + # x, + # # Remove any files that contain noRd roxy tag to avoid false positive (this limitation can be overcome if / when I use roxygen2 parser) + # is_roxygen_comment = is_roxygen_comment & !any(startsWith(content, "#' @noRd")), + # .by = file + # ) + # x$is_object_title <- x$is_roxygen_comment & (x$line == 1 | dplyr::lag(x$ccontent, "Nothing") %in% c("", " ", " ") & dplyr::lead(x$ccontent) %in% c("#'", "#' ", "#' ")) } else { x$is_notebook <- FALSE } diff --git a/README.md b/README.md index 6c7986d..202eb94 100644 --- a/README.md +++ b/README.md @@ -167,7 +167,7 @@ bench::mark( #> # A tibble: 1 × 6 #> expression min median `itr/sec` mem_alloc `gc/sec` #> -#> 1 outline <- proj_outline() 503ms 503ms 1.99 22.5MB 3.98 +#> 1 outline <- proj_outline() 523ms 523ms 1.91 22.2MB 3.82 ```
@@ -218,6 +218,7 @@ outline #> #> ── `R/outline-criteria.R` #> `i` Add variable to outline data frame +#> `i` TODO extract title in roxy comments (@title too.L) #> `i` TODO strip is_cli_info in Package? only valid for EDA #> `i` FIXME try to detect all the chunk caption, but would have to figure out the end of it maybe lightparser. #> `i` it is 'R/outline.R' @@ -247,7 +248,6 @@ outline #> ── `R/todo.R` #> `i` TODO think about maybe using todo = clipr::read_clip() #> `i` TODO nice to have, but would need to extract duplicates -#> `i` TODO, WORK, FIXME) #> `i` Helpers #> #> ── `R/utils-proj.R` usethis adaptions utils diff --git a/tests/testthat/test-outline-criteria.R b/tests/testthat/test-outline-criteria.R index a836d09..02dce39 100644 --- a/tests/testthat/test-outline-criteria.R +++ b/tests/testthat/test-outline-criteria.R @@ -24,6 +24,8 @@ test_that("o_is_todo_fixme() works", { expect_false(o_is_todo_fixme(" expect_true(o_is_todo_fixme(\" # TODO this is important\"))")) # avoid finding comments. expect_false(o_is_todo_fixme("# another TODO item")) + expect_false(o_is_todo_fixme("#' TODO, WORK, FIXME)", is_roxygen_comment = T)) + }) test_that("o_is_work_item() works", {