convertExamples {wyz.code.rdoc}R Documentation

Convert Examples

Description

Generate example section content from R code.

Usage

convertExamples(examples_l, captureOutput_b_1n = TRUE,
                mode_s_1n = c(NA, "donttest", "dontrun", "dontshow")[1])

Arguments

examples_l

An unconstrained list of functions

captureOutput_b_1n

a length-1 or N boolean vector

mode_s_1n

An length-1 or N vector of string values taken amongst valid values. See examples below.

Author(s)

Fabien Gelineau <neonira@gmail.com>

Maintainer: Fabien Gelineau <neonira@gmail.com>

Examples

someComputation <- function(numberAsString_s_1) {
  suppressWarnings(sum(as.integer(strsplit(numberAsString_s_1, '')[[1]]), na.rm = TRUE))
}

examples <- list(
  function() {
    someComputation("145")
  },
  function() {
    someComputation("1547215")
  },
  function() {
    someComputation(NA_character_)
  },
  function() {
    invisible(someComputation("0x145ABC"))
  }
)

cat(convertExamples(examples, TRUE , c(NA_character_, 'donttest', 'dontrun', 'dontshow')))
# ------- example 1 -------
# someComputation("145")
# 10

# \\donttest{
# ------- example 2 -------
someComputation("1547215")
# 25
# }
# \\dontrun{
# ------- example 3 -------
# someComputation(NA)
# 0
# }
# \dontshow{
# ------- example 4 -------
#invisible(someComputation("0x145ABC"))
# }"


[Package wyz.code.rdoc version 1.1.19 Index]