2

In my package, I'm extending an S3 method as_bar from the package pcp_pack, as applied on an object foo from my package foo_pack.

The ROxygen2 documentation is the following:

#' Implementation of as_bar for foo objects
#'
#' @param x same as foo_pack::as_bar
#' @param y new argument
#' @param z also new argument
#' @param ... unused, for S3 compatibility
#'
#' @name as_bar
#' @rdname as_bar
#' @export
#'
#' @examples
as_bar.foo = function(x, y, z, ...){
    #...
}

However, this function is quite independent and it can work without the original package. But for the function to work without having to run library(pcp_pack), I had to re-export the generic method (I copied the re-exporting syntax from dplyr magrittr reexport), so R know that it should call a method:

#' @importFrom pcp_pack as_bar
#' @export
pcp_pack::as_bar

This works perfectly, and as_bar works on foo objects as well as on other objects.

However, the documentation is not perfect, and running library(foo_pack);?as_bar gives two results:

  • man of pcp_pack::as_bar, with no mention of as_bar.foo in the usage
  • man of foo_pack::as_bar, with as_bar.foo in the usage but nothing else

Running library(pcp_pack) beforehand does not change anything.

How can I get a unified version of ?as_bar, with all usages from all loaded packages, whichever they are?

EDITS

Dan Chaltiel
  • 7,811
  • 5
  • 47
  • 92

0 Answers0