How to properly document S4 class slots using Roxygen2?

后端 未结 3 1699
予麋鹿
予麋鹿 2020-12-04 07:04

For documenting classes with roxygen(2), specifying a title and description/details appears to be the same as for functions, methods, data, etc. However, slots and inheritan

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-04 07:41

    The solution provided by Full Decent is OK if you go for documenting slots in the Rd files itself. When using roxygen2, you can use the tag @section to do basically the same with \describe. An example:

    #' The EXAMPLE class
    #'
    #' This class contains an example. This line goes into the description
    #'
    #' This line and the next ones go into the details.
    #' This line thus appears in the details as well.
    #'
    #'@section Slots: 
    #'  \describe{
    #'    \item{\code{slot1}:}{Matrix of class \code{"numeric"}, containing data from slot1}
    #'    \item{\code{slot2}:}{Object of class \code{"character"}, containing data that needs to go in slot2.}
    #'  }
    #'
    #' @note You can still add notes
    #' @name EXAMPLE 
    #' @rdname EXAMPLE
    #' @aliases EXAMPLE-class
    #' @exportClass EXAMPLE
    #' @author Joris Meys
    

提交回复
热议问题