-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
It is customary to provide sample code within R's native documentation which is executable at package build time. This is helpful to package users looking for a quick demo for functions in packages, but also to developers wanting to demonstrate packages work as expected.
Repositories such as CRAN require this to be present, although their current automated package checks pass when a vignette exists.
To avoid delays for future submissions, and to streamline the path for Dash component developers, we should introduce functionality which allows for easy inlining of function examples.
The dash-info.yaml file is a logical avenue to implement this feature. If this file exists, and if it contains examples, we should insert them at the end of the corresponding .Rd file, e.g.
r_examples:
- name: df_to_list
dontrun: TRUE
code: |
# first, create data frame
df <- read.csv(url(
'https://raw.githubusercontent.com/plotly/datasets/master/solar.csv'
),
check.names=FALSE,
stringsAsFactors=FALSE
)
# then convert to list-of-lists format for use in dashTable
# the following snippet below will print as JSON
# see the help for dashDataTable to see an actual app example
dashDataTable(
id = 'table',
columns = lapply(colnames(df), function(x) {
list(name = x, id = x)
}),
data = df_to_list(df)
)
...should generate the following .Rd markup:
\examples{
\dontrun{
# first, create data frame
df <- read.csv(url(
'https://raw.githubusercontent.com/plotly/datasets/master/solar.csv'
),
check.names=FALSE,
stringsAsFactors=FALSE
)
# then convert to list-of-lists format for use in dashTable
# the following snippet below will print as JSON
# see the help for dashDataTable to see an actual app example
dashDataTable(
id = 'table',
columns = lapply(colnames(df), function(x) {
list(name = x, id = x)
}),
data = df_to_list(df)
)}
}