You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When @examplesIf is used instead of @examples whilst documenting an R6 method, the example is treated as separate from the method (i.e. only documenting the class).
A simple class is created, with two documented methods: one which uses @examples and one which used @examplesIf:
#' Create an instance of MyClass#'#' @returns An instance of MyClass#'#' @exportMyClass<-R6::R6Class("MyClass",
public=list(
#' @description#' Create a new `MyClass` instance.initialize=function() {},
#' @description#' Do something.#'#' @examples#' MyClass$new()$foo()foo=function() {},
#' @description#' Do something else.#'#' @examplesIf TRUE#' MyClass$new()$bar()bar=function() {}
)
)
Method documentation can use the @description, @details, @param, @return and @examples tags. These are used to create a subsection for the method, within a separate ‘Methods’ section. All roxygen comment lines of a method documentation must appear after a tag.
It is a useful tag to have to protect against suggested packages that are used in examples not being installed.
Alternatively, support the \dontshow tag inside the R6 methods @examples so this can be achieved manually (it currently shows the \dontshow on the method definition)
When
@examplesIf
is used instead of@examples
whilst documenting an R6 method, the example is treated as separate from the method (i.e. only documenting the class).I've created a reproducible example here: https://github.com/ashbythorpe/roxygen2examples
A simple class is created, with two documented methods: one which uses
@examples
and one which used@examplesIf
:I would expect the two examples sections to be rendered in the same way. Instead, the following is produced:
https://ashbythorpe.github.io/roxygen2examples/reference/MyClass.html
https://github.com/ashbythorpe/roxygen2examples/blob/a94f2bbdb9ebf9e1a71b06e20d4aab52e767a823/man/MyClass.Rd
The text was updated successfully, but these errors were encountered: