How to properly document a S3 method of a generic from a different package, using Roxygen?

前端 未结 3 1073
半阙折子戏
半阙折子戏 2020-12-05 01:43

I am writing a package that defines a new class, surveyor, and a print method for this, i.e. print.surveyor. My code works fine and I use roxygen

3条回答
  •  被撕碎了的回忆
    2020-12-05 02:20

    @export only works if the generic is loaded. If the generic is in another package you need to import the generic. With current roxygen this is solved with a block like

    #' @importFrom tibble data_frame
    #' @export
    tibble::data_frame
    

    taken from dplyr/R/reexport-tibble.r . In this example, the data_frame method is imported from the tibble package, and tibble::data_frame is exported. Such re-exported objects are then documented in a reexports.Rd file that - needless to say - satisfies R CMD check.

提交回复
热议问题