[Rd] RFC: allow packages to advertise vignettes on Windows

Seth Falcon sfalcon at fhcrc.org
Tue May 15 01:15:31 CEST 2007


Hello,

The vignette concept, which started in Bioconductor, seems to be
catching on.  They are supported by R CMD build/check and documented
in the Writing R Extensions manual.  I think vignettes are a fantastic
way to introduce new users to a package.  However, getting new users
to realize that a vignette is available can be challenging.

For some time now, we have had a function in Biobase that creates a
"Vignettes" menu item in the R Windows GUI and gives packages a
mechanism to register their vignettes so that they appear on this
menu.  I would like to see this functionality included in R so that
there can be a standard mechanism that doesn't depend on Biobase of
registering a package's vignettes with one of the R GUIs (currently
only Windows is supported, but I imagine the OS X GUI could also
implement this).

Below is the implementation we have been using.  Is there an R-core
member I can interest in pushing this along?  I'm willing to submit a
patch with documentation, etc.

+ seth

addVigs2WinMenu <- function(pkgName) {
    if ((.Platform$OS.type == "windows") && (.Platform$GUI == "Rgui")
        && interactive()) {
        vigFile <- system.file("Meta", "vignette.rds", package=pkgName)
        if (!file.exists(vigFile)) {
            warning(sprintf("%s contains no vignette, nothing is added to the menu bar", pkgName))
        } else {
            vigMtrx <- .readRDS(vigFile)
            vigs <- file.path(.find.package(pkgName), "doc", vigMtrx[,"PDF"])
            names(vigs) <- vigMtrx[,"Title"]

            if (!"Vignettes" %in% winMenuNames())
              winMenuAdd("Vignettes")
            pkgMenu <- paste("Vignettes", pkgName, sep="/")
            winMenuAdd(pkgMenu)
            for (i in vigs) {
                item <- sub(".pdf", "", basename(i))
                winMenuAddItem(pkgMenu, item, paste("shell.exec(\"", as.character(i), "\")", sep = ""))
            }
        } ## else
        ans <- TRUE
    } else {
        ans <- FALSE
    }
    ans
}




-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org



More information about the R-devel mailing list