You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation for setClass explains that the function returns a class generator object, which can be invoked like new, but since it's an actual function it can be accessed via the :: operator, and therefore offers safety and convenience to users. BioConductor do something like this by defining their own constructor functions, but I see the return value of setClass as R's convenient, built-in version of that.
Unfortunately, though, roxygen2 doesn't allow you to export this generator function automatically. If you add an @export to the setClass statement, it only exports the class itself, via exportClass: R/my_class.R:
The NAMESPACE file that I actually want to be generated is
export(MyClass)
exportClasses(MyClass)
As a package developer, I would appreciate a new tag (say @exportConstructor), to do this automatically, or else some kind of workaround that allows me to generate the above NAMESPACE using Roxygen, instead of adding it manually.
The text was updated successfully, but these errors were encountered:
multimeric
changed the title
Export R4 class generator function
Export S4 class generator function
Apr 8, 2021
The documentation for
setClass
explains that the function returns a class generator object, which can be invoked likenew
, but since it's an actual function it can be accessed via the::
operator, and therefore offers safety and convenience to users. BioConductor do something like this by defining their own constructor functions, but I see the return value ofsetClass
as R's convenient, built-in version of that.Unfortunately, though, roxygen2 doesn't allow you to export this generator function automatically. If you add an
@export
to thesetClass
statement, it only exports the class itself, viaexportClass
:R/my_class.R
:NAMESPACE
:If try to later annotate an
@export
onto the return value, but separately from theexportClass
, Roxygen generates a blank export statement:R/my_class.R
:NAMESPACE
:The
NAMESPACE
file that I actually want to be generated isAs a package developer, I would appreciate a new tag (say
@exportConstructor
), to do this automatically, or else some kind of workaround that allows me to generate the aboveNAMESPACE
using Roxygen, instead of adding it manually.The text was updated successfully, but these errors were encountered: