-
Notifications
You must be signed in to change notification settings - Fork 235
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
assignment of an object of class “call” is not valid for @‘.Data’ in an object of class “MethodDefinition”; is(value, "function") is not TRUE #847
Comments
If I convert this into the simplest possible reprex, it seems to work ok: library(roxygen2)
roc_proc_text(namespace_roclet(), "
setClass('Foo')
#' @export
setMethod('subset', 'Foo', function(x, ...) {
10
})
")
#> [1] "exportMethods(subset)" Can you please have a go at making this more realistic to reveal your problem? This process will either reveal what you're doing wrong, or where the problem with roxygen2 lines. |
Thanks @hadley for replying. Genuinely appreciated. To be honest, I'm still a little bit confused whether it's even necessary to write both S3 and S4 methods in this kind of scenario. Lastly I don't want to waste too much of anyone's time, as I will point out that there is effort to develop a similar package in a "tidy" style by the Bioconductor core team here: https://github.com/Kayla-Morrell/BiocSet Again, this was all mostly to teach myself good practice in terms of package development. I'm mostly self taught and I didn't know where to turn to learn this particular S3/S4 point. |
You should not need to write S3 and S4 methods. All I'm looking for is a reprex in the style above, the demonstrates the problem that you are seeing. |
Here we go:
Seems to be due to function defined within other functions. Bad practice? I know I've picked that up from somewhere, I just can't find from where right now 😅 |
(sorry, I didn't mean to close the issue - accidental keyboard shortcut did that) |
Ah, it looks like you’re copying something that S4 does automatically in some cases. I don’t think there’s any need for it here, so you should remove it, and I’ll also make a better error message here. |
Thanks for the feedback. E.g. For my own record in the S4Vectors package The source code below
is automatically turned by S4 into the following code:
I clearly used the latter as template for writing my own source code. |
Looks like the code never did what it was supposed to (i.e. automatically extracting the S4 generated |
Hi all,
I have been stumbling into the same issue for a while now, when documenting packages that include S4 methods named like primitives of the
base
package. I have a kind of workaround (described further below), but I would like to learn if and what is the proper way of dealing with this kind of situation.The issue is that Roxygen crashes with the following message. As a result, the
NAMESPACE
file is left with onlyimport*
directives, but none of theexport*
directives.This crash happens when I document functions like
subset
orc
like this:I've tried the following too:
My current workaround is to define both an S3 an S4 functions, and to document the S3 only, like this:
Can anyone spot what I'm doing wrong?
The package source code is hosted here: https://github.com/kevinrue/unisets if anyone is willing to open a PR showing me the fix.
Thank you in advance!
The text was updated successfully, but these errors were encountered: