Skip to content

Commit

Permalink
Merge branch 'main' into roxy-parse
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy authored Aug 8, 2024
2 parents 322e5d0 + 86cfda0 commit caa185c
Show file tree
Hide file tree
Showing 16 changed files with 99 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
branches: [main, master]

name: R-CMD-check
name: R-CMD-check.yaml

permissions: read-all

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
types: [published]
workflow_dispatch:

name: pkgdown
name: pkgdown.yaml

permissions: read-all

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
branches: [main, master]

name: test-coverage
name: test-coverage.yaml

permissions: read-all

Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: reuseme
Title: Collections of Utility Functions to Work Across Projects
Version: 0.0.2.9005
Version: 0.0.2.9006
Authors@R:
person("Olivier", "Roy", , "olivierroy71@hotmail.com", role = c("aut", "cre"))
Description: Allows you to browse current projects, rename files safely,
Expand Down Expand Up @@ -45,4 +45,4 @@ Suggests:
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ that will passed on to `proj_list()`

* `file_outline()` result is now a simpler data frame. The cli links are now created in the print method. (which makes more sense for truncation)

* `use_todo("global::todo")` no longer works out of the box. You need to set `options(reuseme.global_todo = fs::path("Documents"))` explicitly (in .Rprofile) for example to make sure
reuseme can write in a directory.

## Fixes

* `rename_files2()` now looks in `.Rbuildignore` to see if some files should be replaced.
Expand Down Expand Up @@ -51,6 +54,8 @@ that will passed on to `proj_list()`

* Package versions in NEWS.md are now normalized to yield better results.

* `active_rs_doc()` returns the relative path if in RStudio project.

# reuseme 0.0.2

* `complete_todo()` no longer deletes the full line. It only deletes what it says it deletes (#27).
Expand Down
8 changes: 8 additions & 0 deletions R/open.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ active_rs_doc <- function() {
cli::cli_abort("Either RStudio is not available or you are trying to map an unsaved file")
})
path <- fs::path_expand_r(path)
active_proj <- proj_get2()
if (is.null(active_proj)) {
return(invisible(path))
}
if (isTRUE(fs::path_has_parent(path, active_proj))) {
path <- fs::path_rel(path)
}
path
# likely not hapenning on RStudio >= 2023.06.2
}

Expand Down
22 changes: 16 additions & 6 deletions R/outdated-pkgs.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ outdated_pkgs <- function(type = c("binary", "source")) {
default_repo <- getOption("repos")[[1]]
default_repo <- sub("/$", "", default_repo)
default_repo <- sub("https://", "", default_repo, fixed = TRUE)
if (!grepl("packagemanager", default_repo)) {
# ppm is not well detected
access_repo <- tryCatch(curl::nslookup(default_repo),
error = function(e) {
FALSE
}
)
} else {
access_repo <- TRUE
}

access_repo <- tryCatch(curl::nslookup(default_repo),
error = function(e) {
FALSE
}
)
} else {
access_repo <- TRUE
}
Expand All @@ -46,7 +51,12 @@ outdated_pkgs <- function(type = c("binary", "source")) {
outdated_pkg_mat <- utils::old.packages(type = type, lib.loc = .libPaths()[1])

if (rlang::has_length(outdated_pkg_mat) && !is.null(getOption("reuseme.ignore_update"))) {
indices_to_discard <- which(rownames(outdated_pkg_mat) %in% getOption("reuseme.ignore_update"))
if (type == "source") {
# only disallow update when building from source.
indices_to_discard <- which(rownames(outdated_pkg_mat) %in% getOption("reuseme.ignore_update"))
} else {
indices_to_discard <- integer(0L)
}
if (rlang::has_length(indices_to_discard)) { # because matrix[-character(0), ] destroys |> the matrix?
outdated_pkg_mat <- outdated_pkg_mat[-indices_to_discard, , drop = FALSE]
}
Expand Down
2 changes: 1 addition & 1 deletion R/outline-criteria.R
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ define_outline_criteria <- function(.data, exclude_todos) {
is_object_title = FALSE,
tag = NA_character_,
topic = NA_character_,
is_cross_ref = stringr::str_detect(content, "docs_links?\\(.") & !stringr::str_detect(content, "@param|\\{\\."),
is_cross_ref = stringr::str_detect(content, "docs_(links|add.+)?\\(.") & !stringr::str_detect(content, "@param|\\{\\."),
is_function_def = grepl("<- function(", content, fixed = TRUE) & !stringr::str_starts(content, "\\s*#"),
is_tab_or_plot_title = o_is_tab_plot_title(content) & !is_section_title & !is_function_def,
)
Expand Down
4 changes: 2 additions & 2 deletions R/outline.R
Original file line number Diff line number Diff line change
Expand Up @@ -744,14 +744,14 @@ display_outline_element <- function(.data) {
y <- dplyr::mutate(
x,
has_title_el =
((line == 1 & !is_todo_fixme & !is_test_name & !is_snap_file) |
((line == 1 & !is_todo_fixme & !is_test_name & !is_snap_file & !is_cross_ref) |
(is_doc_title & !is_subtitle & !is_snap_file & !is_second_level_heading_or_more)) & !is_news,
.by = "file"
)
y <- withCallingHandlers(
dplyr::mutate(y,
title_el_line = ifelse(has_title_el, line[
(line == 1 & !is_todo_fixme & !is_test_name & !is_snap_file) |
(line == 1 & !is_todo_fixme & !is_test_name & !is_snap_file & !is_cross_ref) |
(is_doc_title & !is_subtitle & !is_snap_file & !is_second_level_heading_or_more)
][1], # take the first element to avoid problems (may be the reason why problems occur)
NA_integer_
Expand Down
2 changes: 1 addition & 1 deletion R/rename.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ rename_files2 <- function(old,
# Warn if some related files are found. If I have file.R and file.csv,
# this will warn if I rename file.R, but not file.csv
related_files <- fs::dir_ls(regexp = paste0(basename_remove_ext(old), "\\."), recurse = TRUE)
related_files <- fs::path_filter(related_files, "_snaps/|_book/|_files|_freeze|renv/", invert = TRUE)
related_files <- fs::path_filter(related_files, "_snaps/|_book/|_files|_freeze|renv/|\\~\\$", invert = TRUE)
related_files <- setdiff(related_files, old)

# remove project name from conflicts.
Expand Down
14 changes: 12 additions & 2 deletions R/todo.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
#' use `usethis::use_git_ignore("TODO.R")` if you don't want your `TODO.R` file
#'
#' to be included in git. If using in a package directory, use
#' `usethis::use_build_ignore("TODO.R")` to prevent a note in `R CMD CHECK`
#' `usethis::use_build_ignore("TODO.R")` to prevent a note in `R CMD CHECK`.
#'
#' If you want to write to a global TODO, use
#'
#' `options(reuseme.global_todo = fs::path("Documents"))` to write there.
#'
#' @param todo A character vector of lines to add to the TODO file. See details
#' for special handling.
Expand Down Expand Up @@ -219,7 +223,13 @@ compute_path_todo <- function(todo, proj) {

# Handle special global and all syntax for todo items.
if (proj %in% c("global", "all")) {
proj_path <- Sys.getenv("R_USER", Sys.getenv("HOME")) # ?base::path.expand
proj_path <- getOption("reuseme.global_todo")
if (is.null(proj_path)) {
cli::cli_abort(c(
"You must set a global option reuseme.global_todo to write to a global todo.",
i ="A good option for cross-platform is `options(reuseme.global_todo = fs::path_home(\"Documents\"))"
))
}
} else if (!is_active_proj) {
# in interactive session with options set
proj_path <- proj_list(proj)
Expand Down
3 changes: 1 addition & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ knitr::opts_chunk$set(
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/reuseme)](https://CRAN.R-project.org/package=reuseme)
[![R-CMD-check](https://github.com/olivroy/reuseme/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/olivroy/reuseme/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/olivroy/reuseme/branch/main/graph/badge.svg)](https://app.codecov.io/gh/olivroy/reuseme?branch=main)

[![Codecov test coverage](https://codecov.io/gh/olivroy/reuseme/graph/badge.svg)](https://app.codecov.io/gh/olivroy/reuseme)
<!-- badges: end -->

The goal of reuseme is to provide utility functions for project management across RStudio projects.
Expand Down
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](h
status](https://www.r-pkg.org/badges/version/reuseme)](https://CRAN.R-project.org/package=reuseme)
[![R-CMD-check](https://github.com/olivroy/reuseme/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/olivroy/reuseme/actions/workflows/R-CMD-check.yaml)
[![Codecov test
coverage](https://codecov.io/gh/olivroy/reuseme/branch/main/graph/badge.svg)](https://app.codecov.io/gh/olivroy/reuseme?branch=main)

coverage](https://codecov.io/gh/olivroy/reuseme/graph/badge.svg)](https://app.codecov.io/gh/olivroy/reuseme)
<!-- badges: end -->

The goal of reuseme is to provide utility functions for project
Expand Down Expand Up @@ -210,6 +209,7 @@ outline
#>
#> ── `R/files-conflicts.R`
#> `i` TODO insert in either proj_outline, or rename_file
#> `i` FIXME in Rbuilignore, change `^_pkgdown\.yml$` to `_pkgdown.yml` to make sure it works
#> `i` TODO probably needs a `detect_genuine_path()`
#> `i` Helpers
#> `i` TODO Add false positive references
Expand Down Expand Up @@ -254,6 +254,7 @@ outline
#> `i` Print interactive outline of file sections [outline]
#> `i` `file_outline()`
#> `i` File outline
#> `i` TODO expand this to apply to most generated files
#> `i` Print method
#> `i` TODO since April 2024, cli links work almost out of the box in VScode? microsoft/vscode#176812 (<https://github.com/microsoft/vscode/issues/176812>)
#> `i` Step: tweak outline look as they show
Expand Down Expand Up @@ -550,6 +551,38 @@ outline
#> ── `tests/testthat/test-todo.R`
#> `i` Marking TODO as done detects tags
#>
#> ── `TODO.R`
#> `i` TODO screenshot make the behaviour different when vignettes vs articles: vignettes should place it in man/figures, while articles could put it in vignettes/articles file.
#> `i` TODO screenshot RStudio addin to insert the code directly in the qmd doc. No longer needed with RStudio 2023.12
#> `i` TODO use_family() to edit .R file to add @family data frames tags to roxygen
#> `i` TODO mutate_identity redundant if the focus pillar PR was merged. r-lib/pillar#585 (<https://github.com/r-lib/pillar/issues/585>)
#> `i` TODO rename if many matches, separate those with the exact path.
#> `i` TODO outline make ggtitle work
#> `i` TODO outline show extra msg only for some, but in file outline, not in proj?
#> `i` TODO outline detect help calls and apply markup. `?fs::file_show` disregard finishing `.` (not followed by dot)
#> `i` TODO outline renable cli info.
#> `i` TODO escape_markup doesn't work with complex operation {x^2} for example. Maybe if detecting something complex, use cli_escape function. escape-complex-markyp branch created to try to address this.
#> `i` TODO outline avoid evaluating in current env.
#> `i` TODO wrap regexps in functions
#> `i` TODO outline remove examples from outline. Sometimes commented code is caught.
#> `i` TODO outline roxygen comments processing should be left to `roxygen2::parse_file()`
#> `i` TODO outline show key like `pak::pkg_deps_tree()` does.
#> `i` TODO outline roxygen function title
#> `i` TODO outline remove ggtext markup from plot title.
#> `i` FIXME outline comments are now interpreted as section
#> `i` TODO outline todos in qmd file inside html comment
#> `i` TODO reframe more than one issue. nw drive
#> `i` TODO delete generated files
#> `i` TODO [check_referenced_files] doesn't check for 'R/file.R'
#> `i` TODO browse_pkg should open by default if no vignettes are found, because there is not much to do in the R-session.
#> `i` TODO exclude _files from `proj_list()`
#> `i` TODO rename_files should be less noisy about project name file
#> `i` 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)
#> `i` TODO use vapply() instead of purrr::map
#> `i` TODO rename_files() should know about .covrignore too
#> `i` TODO withr::local_dir for proj_outline.
#> `i` TODO add warn_conflicts = 'none'
#>
#> ── `NEWS.md`
#> `i` reuseme (development version)
#>
Expand Down
4 changes: 4 additions & 0 deletions TODO.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@
# TODO [outline] family should be displayed differently..
# TODO [outline] find a way to make print bookmarks..
# TODO [outline] escape some content in headings see {.file tests/testthat/_outline/quarto-caps.md} for examples.
# TODO use vapply() instead of purrr::map
# TODO rename_files() should know about .covrignore too
# TODO withr::local_dir for proj_outline.
# TODO add warn_conflicts = 'none'
4 changes: 4 additions & 0 deletions man/filter_detect.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion man/use_todo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit caa185c

Please sign in to comment.