-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add parsable-roxygen hook #563
Add parsable-roxygen hook #563
Conversation
Sorry @owenjonesuob for the delay. Here's my review:
Can you tell me when a warning would be issued? Depending on that, maybe a flag
What speaks against it? Is it slower? I guess it requires the package to be loadable with #' Initiate a pre-commit config file
#'
#' @param verbose way. `r 1+++++`
my_fun <- function(...) NULL But |
Co-authored-by: Lorenz Walthert <[email protected]>
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
A big "sorry" from me too, for leaving this unanswered for so long - it's been a busy few weeks!
Apologies, I should have explained this better. When we call
If there is a problem with the parsing, we will get an error in Step 1, before we even look at the roxygen comments! Hence the need to capture such an error, in the same way as Then assuming we make it to Step 2: if there are any problems with roxygen comments, these are reported via In other words, messages - not warnings, that was a mistake from me! - indicate some problem with the roxygen comments. I've fixed that logic in 4043ada.
Yep I think those were the drawbacks I had identified (but not communicated, sorry!) - especially the requirement for dependencies to be available, in certain cases. I'll explain one of those cases in a moment... The default in If the file contains only "object declarations" - e.g. of functions or data objects, like in a For a concrete example, consider the Appsilon/rhino-showcase Shiny app. It's built using the Rhino framework, which makes heavy use of box modules (see their docs). There is plenty of functionality which might benefit from roxygen documentation (not that it has any right now!) - see for example https://github.com/Appsilon/rhino-showcase/blob/ae366f522d3adf0571fb7c45aaa8e8d29d0937e0/app/logic/update_map.R But box modules often begin with one or more I wonder whether we could have the best of both worlds, if we expose an
I can implement something like that if you think it's a suitable idea! |
I've pushed a proof-of-concept for a Re this comment in
As far as I can tell, this is how those inline chunks get evaluated: https://github.com/r-lib/roxygen2/blob/c03a6711eea3f7dc16e55f0ab0babac9ff40d9ea/R/markdown.R#L134-L140 That's called at the point where chunks are actually being processed; so I'd suggest checking the content of inline code is out of scope for this hook? |
Thanks for all your comments. I added some suggestions to the PR, please have a look. I am preparing a new CRAN release but I suggest to not include this hook there, as I am not clear on the
Bottom line, probably we want |
Co-authored-by: Lorenz Walthert <[email protected]>
Many thanks for your detailed thoughts and suggestions! After some consideration, for now I have opted for a variation of your second proposal above:
|
Ok, works for me too. To be honest, I don't think
|
FWIW you can always override |
Can you please fix the one test in R cmd check that fails, then I can merge this... |
Oops sorry 🤦 tests have now been adjusted to match the updated functionality! I happen to be working on a different computer today, with an older version of roxygen2, which helped me to catch one other problem... quoting myself from a few comments ago:
In fact, problems were reported via warnings (not messages!) prior to roxygen2 v7.3.0 (changed by r-lib/roxygen2#1548, I think). So I've added a minimum version requirement for roxygen2 >= 7.3.0, similar to the ones used in a couple of other hooks! |
Thanks, since we use |
Thanks again for the collaboration. I added an issue for extending |
As discussed in #562.
Things to note:
roxygen2::parse_file()
does actually parse the file, I think we have to allow this hook to fail in two ways:parsable-R
roxygen2::parse_file(..., env = NULL)
- unless you can think of some reason why we would need to evaluate?Closes #562.