Readme in staticdocs

staticdocs is a Hadley Wickham package that can create sleek web pages for a package. I used it with great success (although I still did not understand how to add examples without errors), but every time I have to manually reformat the readme part of the created file index.html. This seems silly, because from ggplot2 staticdocs is used , that there is a way to configure readme in the index file inside inst/staticdocs/.

Hadley has not documented the package so well (staticdocs) at this time, and I'm not sure how to change the readme entry / argument list in the index file. Does anyone have any guidance on what the format should look like for this; that is, the format of what the record should look like?

+5
source share
1 answer

Until Hadley and his team can develop staticdocs and its documentation, here is my work, found in a very rough package :

#' Change read.me File
#'
#' Alter the read.me file with a preset.
#' 
#' @param path Path to the index.html file.
#' @param readme Path to the readme file.
#' @param file The path/file name to output.
readme_statdoc <- function(path, readme, file = NULL) {
    if (length(path) > 1) {
        x <- path
    } else {
        x <- suppressWarnings(readLines(path))
    }
    y <- suppressWarnings(readLines(readme))
    start <- which(grepl("<h1></h1>", x))
    end <- which(grepl("<h2>Help topics</h2>", x))
    x <- c(x[1:start], "", y, "", x[end:length(x)])
    if (!is.null(file)) {
        cat(paste(x, collapse="\n"), file = file)
    }
    return(x)
}

Basically you create an external document to be inserted into the read me part. I used this in qdap and you can see how I use it when creating a staticdoc website through this script .

+1
source

All Articles