convertExamples: Convert Examples

Description Usage Arguments Author(s) Examples

View source: R/convertExamples.R

Description

Generate example section content from R code.

Usage

1
2
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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"))
# }"

wyz.code.rdoc documentation built on Oct. 6, 2021, 9:07 a.m.