parseSourceFile <-
function # ^ Parse a R-source-code regarding annotated documentation
### ^ Annotation has to look like
### ^ myFun <-
### ^ function # ^ Compute something
### ^ ### ^ Optional multiline
### ^ ### ^ description
### ^ (
### ^ x # ^ argument x is something;
### ^ # ^ could also be multiline
### ^ ,y # ^ argument y is another something
### ^ )
### ^ {
### ^ doSomething(x,y)
### ^ } # ^ Returns this
(
f # ^ source-code-file
,p = '\\s*# \\^\\s*' # ^ general annotation pattern (default '# ^')
)
{
lns. <- readLines(f)
lns <-
strsplit(sub("\\s*(<-|=)\\s*\n*\\s*function", " = function",
paste(lns., collapse = "\n" )), "\n")[[1]]
cmts <- lns[grep(p, lns)]
parseFunction(cmts)
## TODO: iterate over functions
} # ^ Returns a 'FunctionDoc'
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.