r-lib / devtools

Tools to make an R developer's life easier
https://devtools.r-lib.org
Other
2.37k stars 753 forks source link

FR: Integrate a function that gets all NEWS items for a particular function? #2441

Closed etiennebacher closed 1 year ago

etiennebacher commented 2 years ago

Is your feature request related to a problem? Please describe.

When we work on a package, it would be useful to know if using a particular function will break backwards compatibility. For example, I might want to keep support for R >= 3.5, but if I use list2DF() in my package (that was introduced in R 4.0.0), it will no longer work with R between 3.5 and 4.0. I could go and manually check the changelog of R to find when this function was introduced, but it takes some time and the info is not necessarily so easy to find.

I took the example of a base R function, but this problem might also appear with dependencies on other packages. For instance, dplyr::relocate() was introduced in 1.0.0, so if I use this function my package will have to depend on dplyr >= 1.0.0 (you already know that, it's just to set up the context).

Similarly, it could be useful to know when the behavior of a particular function changed (gained/lost args, etc.), not just when it was introduced.

Describe the solution you'd like

I would like to have a function whose input is a function name (and potentially a package name), and that outputs a list of NEWS items that are related to this function. Those items would be categorized by version, so that we can quickly see when a function was introduced/modified.

Describe alternatives you've considered

I don't think there's a function to do that already, which is why I asked first on StackOverflow but it didn't give any solutions.

Therefore, I made a function like this, and put it in a single-function package, {getnews} (temporary name). It works like this:

library(getnews)

getnews("paste0")
#> VERSION 2.15.0 
#>  =========== 
#> 
#>  New function paste0(), an efficient version of paste(*,
#> sep=""), to be used in many places for more concise (and
#> slightly more efficient) code. 
#> 
#> 
#> VERSION 4.0.1 
#>  =========== 
#> 
#>  paste() and paste0() gain a new optional argument recycle0.
#> When set to true, zero-length arguments are recycled leading to
#> character(0) after the sep-concatenation, i.e., to the empty
#> string "" if collapse is a string and to the zero-length value
#> character(0) when collapse = NULL.
#> 
#> A package whose code uses this should depend on R (>= 4.0.1).

getnews("adist")
#> VERSION 2.14.0 
#>  =========== 
#> 
#>  New function adist() in package utils for computing ‘edit’
#> (generalized Levenshtein) distances between strings.

getnews("relocate", "dplyr")
#> VERSION 1.0.0 
#>  =========== 
#>  New relocate() verb makes it easy to move columns around within a
#>     data frame (#4598).
#> 
#>   
#> 
#> VERSION 1.0.3 
#>  =========== 
#>  relocate() can rename columns it relocates (#5569).
#> 
#> 

Created on 2022-07-09 by the reprex package (v2.0.1)

Additional context

I find it counterproductive to have a separate package for this function since there's already a great ecosystem for package development, so would you accept integrating this function in devtools or one of its "sub-packages"? Of course, I'm ok to modify the function, its design, etc. if necessary.

I don't know if this feature request belongs in this repo but since this repo contains "Tools to make an R developer's life easier", it seemed quite appropriate to me.

jennybc commented 1 year ago

I don't foresee us adding this to devtools.

FWIW it reminds me of the problem space explored by these other tools for monitoring function signatures over time: