Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

list available examples when calling runExample() without arguments #4

Open
nuest opened this issue Nov 12, 2014 · 1 comment
Open

Comments

@nuest
Copy link
Contributor

nuest commented Nov 12, 2014

To replicate:

library(sensorweby)
?runExample
runExample()
runExample("not-there") # lists the existing shiny examples instead of the sensorweby examples
@nuest nuest changed the title list available examples when calling runExample() withour arguments list available examples when calling runExample() without arguments Nov 12, 2014
@autermann
Copy link
Member

we can reuse this snippet:

listExamples <- function(package, blacklist = NULL) {
    dir <- paste(find.package(package), 'examples', sep='/')
    dirs <- list.dirs(dir, recursive=FALSE)
    if (!is.null(blacklist)) {
        dirs <- Reduce(intersect, lapply(blacklist, function(x) 
            dirs[!grepl(x, dirs, fixed=TRUE)]), dirs)    
    }
    examples <-  substr(dirs,  nchar(dir) + 2, nchar(dirs))
    htmltools::tag('ul', lapply(examples, function(x) 
        htmltools::tag('li', tagList(htmltools::a(href = paste(package, x, sep="/"), htmltools::code(x))))))
}

listExamples("sensorweby", blacklist = "iframe")

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants