Description Usage Arguments Details See Also Examples
Works like write
for functions without flat documentation (i.e. without a "doc" attribute). If a "doc" attribute exists, the file is written in a form allowing it to be edited and then read back in with "source.mvb"; the "doc" attribute is given as free-form text following the function definition. If applied to a non-function with a "source" attribute, just the source attribute is printed; the idea is that this could be read back by source
(or source.mvb
), probably in the course of FF
after fixr
, to regenerate the non-function object.
1 2 | write.sourceable.function( x, con, append=FALSE, print.name=FALSE,
doc.special=TRUE, xn=NULL)
|
x |
function or other object, or the name thereof, that is to be written. If |
con |
a connection or filename |
append |
if "con" is not already open, should it be appended to rather than overwritten? |
print.name |
should output start with |
doc.special |
TRUE if |
xn |
(string) can set this to be the name of the function if |
If x
is unquoted and print.name=TRUE
, the name is obtained from deparse( substitute( x))
. If x
is a character string, the name is x
itself and the function printed is get(x)
.
The real criterion for an attribute to be output in flatdoc
-style, is not whether the attribute is called doc
, but rather whether it is a character-mode object of class docattr
. You can use this to force flatdoc
-style output of several doc
-like attributes.
The default EOF line for an attribute is <<end of doc>>, but this will be adjusted if it appears in the attribute itself.
source.mvb
, readLines.mvb
, flatdoc
, the file "demostuff/original.dochelp.rrr", the demo in "flatdoc.demo.r"
1 2 3 4 5 6 7 8 9 10 11 12 13 | ## Not run:
write.sourceable.function( write.sourceable.function, "wsf.r")
# To dump all functions and their documentation in a workspace into a single sourceable file:
cat( "", file="allfuns.r")
sapply( find.funs(), write.sourceable.function, file="allfuns.r", append=TRUE, print.name=TRUE)
# A non-function
scrunge <- c( 1:7, 11)
attr( scrunge, "source") <- c( "# Another way:", "c( 1:4, c( 5:7, 11))")
scrunge # [1] 1 2 3 4 5 6 7 11
write.sourceable.function( scrunge, stdout()) # source
fixr( scrunge) # source
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.