-
Notifications
You must be signed in to change notification settings - Fork 233
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
Failures in a file included with @includeRmd
will nuke the NAMESPACE
#1254
Comments
This does not happen to me, am I doing this right?
|
If you change the So then you can add I committed all the changes that roxygen2 made, which was probably confusing |
Got it. Two workarounds, that are IMO better than
|
Just want to clarify that the errors are unexpected, i.e. I would never set |
Maybe the Or maybe we should have some way to roll back to the previous namespace if the whole process fails? And maybe we also need something in |
Possible duplicate of #1144 |
@DavisVaughan do you happen to have an example where after the fixing the problem you can't redocument? In https://github.com/DavisVaughan/testfailingroxygen2, if I comment out the error, I can still rebuild the package. roxygen2 currently does two passes to solve the a boostrapping problem. Imagine if we didn't have the pre-processing step and wrote this code: #' @importFrom foo someS3generic
#' @export
someS3generic.character <- function(x) 3 The first time we run it, we can't tell that Or imagine that But maybe the pre-processing step could somehow preserve all the existing lines that aren't imports? |
This approach seems promising: parsed <- parse("NAMESPACE", keep.source = TRUE)
is_import <- function(x) is_call(x, c("import", "importFrom", "importClassesFrom", "importMethodsFrom"))
unlist(lapply(attr(parsed, "srcref")[!vapply(parsed, is_import, logical(1))], as.character)) |
Yea, I think the super broken state is related to S3 methods. I have created an updated
|
Now preserves all non-import directives. Fixes #1254
Ah of course, because you're using an exported function that's no longer exported. |
Now preserves all non-import directives. Fixes #1254
If you include a file with
@includeRmd
that fails duringroxygenise()
, then your NAMESPACE will be (mostly) nuked, which often puts you in a state where you can't evenroxygenise()
again to fix it. You end up having to revert the changes made to the NAMESPACE manually, fix the Rmd (or whatever made it fail), and then redocument. (This has bitten the tidymodels team, and me in vctrs quite a few times)I have a somewhat minimal example here, where this commit changed an Rmd to make it fail, I redocumented, and now the exported function
fn()
is no longer part of NAMESPACEDavisVaughan/testfailingroxygen2@ad6f49f
The way this occurs is:
roclet_preprocess()
has a namespace method that inserts partial information into the NAMESPACE file. It seems to insert information about imports only.roclet_process()
will then run, and the Rd method for that is where the Rmd is rendered and subsequently fails.roclet_output()
never gets to run, which is where the NAMESPACE is finalized, so we end up with the broken partial NAMESPACE thatroclet_preprocess()
wrote.I see two potential solutions:
roxy_tag_rd.roxy_tag_includeRmd()
couldtryCatch()
thermarkdown::render()
call? Or maybe pass something torender()
to make it not fail.roclet_preprocess.roclet_namespace()
exists. It seems like the process and output methods for roclet_namespace will basically do the same thing, just withimport_only = FALSE
. If the preprocess method wasn't run, it seems like we wouldn't get into that problematic state from above because we would never write a partial NAMESPACE to disk. I'm probably missing something thoughroxygen2/R/namespace.R
Lines 34 to 63 in 6c1e42f
The text was updated successfully, but these errors were encountered: