source_decoratees: Read and Parse Decoratees from a File

Description Usage Arguments Details Examples

View source: R/source-decoratees.R

Description

Given a file, source_decoratees reads and parses decorated functions (decoratees) into the calling environment.

Usage

1

Arguments

file

A character string specifying a file path.

Details

Malformed decoratees are ignored and a message will alert the user a function has been skipped. However, an error is raised if a decorator is undefined.

If you are working within RStudio the "Source Active File Decoratees" addin effectively allows you to bind source_decoratees to a keyboard shorcut. The addin is found under Tools > Addins.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# source example files
source_decoratees(tinsel_example('attributes.R'))
source_decoratees(tinsel_example('tags.R'))

# the important thing is to look at the contents
# of the example files, note the use of the special
# "#." comment
writeLines(readLines(tinsel_example('attributes.R')))
writeLines(readLines(tinsel_example('tags.R')))

# the decorator functions are not sourced,
exists('attribute')  # FALSE
exists('html_wrap')  # FALSE

# only decorated functions are sourced
print(selector1)
selector1(mtcars, 'mpg')

# format with bold tags
html_bold('make this bold')

# format with paragraph tags
html_paragraph("I'll make my report as if I told a story...")

nteetor/tinsel documentation built on May 24, 2019, 9:56 a.m.