roxygen2 icon indicating copy to clipboard operation
roxygen2 copied to clipboard

roxygen2 should return info about what's changed, or otherwise get a helper for this

Open MichaelChirico opened this issue 2 years ago • 3 comments

I'm trying to set up a GitHub Actions to ding us whenever we forget to roxygenize() some change. This happens with some frequency when a change to docs is made during review.

My current approach (https://github.com/r-lib/lintr/pull/2460/commits/85ed38a57f5aaad64fec1519973a4a77adefe79e) is a bit long-winded: (1) check the content of man/ doesn't change after roxygenize(), then loop over the files and check that the content hasn't changed.

OTOH, it seems from the output of roxygenize() that it is already doing this sort of comparison under the hood -- hence "Writing 'any_is_na_linter.Rd'" in the roxygenize() output:

image

However, AFAICT this info is lost after being emitted to the terminal. If it were part of the roxygenize() output, I could save some headache maintaining the similar script, as well as being more confident the two classifiers would always agree without trying to call roxygen2:::same_contents() myself.

MichaelChirico avatar Dec 17 '23 15:12 MichaelChirico

The other possible approach here would be to parse the .Rd files, extract the source files, and then compare timestamps between source and destination. It's not 100% perfect if you're running dynamic code, but I bet it would get you a long way.

hadley avatar Jun 08 '24 13:06 hadley

Not sure I see 100% what you mean, but here's the essence of our current approach:

https://github.com/r-lib/lintr/blob/1f5e46992c7f5590f6d28e17e212a861f12312f0/.dev/roxygen_test.R#L14-L16

normalize_rd <- function(rd_file) as.character(parse_Rd(rd_file))

rd_equal <- function(f1, f2) isTRUE(all.equal(normalize_rd(f1), normalize_rd(f2)))

MichaelChirico avatar Jun 13 '24 06:06 MichaelChirico

I meant you could look at https://github.com/r-lib/lintr/blob/1f5e46992c7f5590f6d28e17e212a861f12312f0/man/Linter.Rd#L2, and then see if utils.R was newer than linter.Rd.

hadley avatar Jun 13 '24 12:06 hadley