Closed
Description
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
:
#' Create an instance of MyClass
#'
#' @returns An instance of MyClass
#'
#' @export
MyClass <- 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() {}
)
)
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
Metadata
Metadata
Assignees
Labels
No labels