Skip to content

S4 generic functions are not exported unless a method is also defined #246

Closed

Description

@jankowtf

Seems like @export in a S4 generic for which no method is defined will be ignored/not properly handled (leads to an empty export() in the NAMESPACE file).

An illustration can be found at this stackoverflow post.

Best regards and thanks for the great work with roxygen/roxygen2!
Janko

Activity

  1. jankowtf commented on May 6, 2014

    @jankowtf
    Author

    I looked around in the code a bit and found this:

    # Functions that take complete partitum and return NAMESPACE lines
    ns_export <- function(tag, part) {
      if (!is.null.string(tag)) return(export(tag))
      # FIXME: check for empty exports (i.e. no name)
    
      default_export(part$object, part)
    }
    

    This gave me the idea to try @export <tag> and @exportPattern <pattern>. Both works (i.e. the export works), but there will still be an export() line in the NAMESPACE file.

  2. fmichonneau commented on May 6, 2014

    @fmichonneau
    Contributor

    I see this behavior even when methods are defined.

  3. jlehtoma commented on May 8, 2014

    @jlehtoma

    I confirm @fmichonneau 's observation. The S4 generic is not exported even if a method is defined, at least when the method definition is in a separate file (foo-methods.R) than the generic definition (AllGenerics.R).

  4. hadley commented on May 8, 2014

    @hadley
    Member

    Looks like I'm missing a default_export method for s4generic

  5. jlehtoma commented on May 8, 2014

    @jlehtoma

    Thanks @hadley , fixed it for me.

  6. jankowtf commented on May 11, 2014

    @jankowtf
    Author

    Dito!

  7. added a commit that references this issue on Aug 26, 2014
    730a995
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions