r - Is there anyway to document S4 class and its constructor separately using Roxygen2 -


i trying design s4 class own initialization method , separately document them roxygen2. assuming class defined as:

#' classa #' @name classa-class #' @rdname classa-class ######## @aliases null #' @exportclass classa classa <- setclass(class = "classa", slots = list(member = "any")) 

with initialization method:

#' constructor #' @name classa #' @rdname classa #' @export classa setmethod("initialize", "classa", function(.object, x) {              .object@member = x              return(.object)          }) 

after compiling package roxygen2. got 2 .rd files 3 page:

  • classa-class: classa
  • classa: classa
  • classa: constructor

both class?classa , ?classa show classa-class page. want hope class?classa lead classa-class: classa while ?classa lead classa: constructor.

so, question how separate class documentation , constructor documentation roxygen2? thank help.

(i understand roxygen2 put aliases class name s4 class default. when set @aliases null, the classa-class: classa help page disappeared!! left the classa: constructor)

the reasons both files show under class documentation setclass uses class name alias class in documentation. in addition, method generic initialize defined classa specifies @rdname classa points classa-method.

here 2 solutions:

first, can simplify roxygen2 header codes , behaviour want, need use @name call initialize method other classa.

#' \code{classa} class definition #' #' @slot member description of slot here classa <- setclass(class = "classa", slots = list(member = "any"))      #' constructor \link{classa-class} #'  #' constructor. #' @name initializeclassa #' @export setmethod("initialize", "classa", function(.object, x) {     .object@member = x     return(.object) }) 

that gives classa-class page ?classa , ?"classa-class" constructor, whatever name used after @rdname, e.g. ?initializeclassa, if that's want.

second, recommend not use initialize @ all, instead create new instances of classa using new("classa", membervalue). can define prototype in class definition assign default values of member if want, and/or validator functions. need separate page constructor?


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -