doc2Rd
yourself, because pre.install
and patch.install
do it for you when you are building a package; the entire documentation of package help( glm, help_type="text")
and try making one yourself. Don't bother with indentation, except in item lists as per MORE.DETAILS below. See fixr
and its new.doc
argument for how to set up an empty template.doc2Rd( text, file=NULL, append=, warnings.on=TRUE, Rd.version=, def.valids=NULL, check.legality=TRUE)
doc
attribute that is a c.v. of d..!is.null(file)
; should output be appended rather than overwriting?doc2Rd
is being called from pre.install
, this will be set to all documented objects in your package. Cross-links to functions in other packaRd.version
is 2 or more, then the output Rd will be run thru parse_Rd
and a try-error
will be returned if that fails; normal return otherwise. Not applicable if Rd.version
is 1.class
of "cat" so it prints nicely on the screen.doc
attributes can be displayed by the replacement help
in mvbutils
(see dochelp
) without any further ado. This is very useful while developing code before the package-creation stage, and you can write such documentation any way you want. When you want to generate a package, doc2Rd
will convert pretty much anything into a legal Rd file. However, if you can follow a very few rules, using doc2Rd
will actually give nice-looking authentic R{} help. For this to work, your documentation basically needs to look like a plain-text help file, as displayed by help( ..., pager=T)
(pre-2.10) or help(..., help_type="text")
(post-2.10).
Rather than wading through this help file to work out how to write plain-text help, just have a look at a couple of R{}'s help screens in the pager (i.e. not HTML help) and try making one yourself. You can also use help2flatdoc
to convert an existing plain-text help file. Also check the file "sample.fun.rrr" in the "demostuff" subdirectory of this package (see Examples). If something doesn't work, delve more deeply...pre.install
pre.install
.
To check the results: "RCMD Rd2dvi --pdf XXX.Rd" and "RCMD Rdconv -t=html XXX.Rd" and/or "-t=txt" (though patch.installed
will allow to check the HTML version immediately).
To convert existing Rd documentation: help2flatdoc
.
If you want to tinker with the underlying mechanisms: flatdoc
, write.sourceable.function
## Needs a function with the right kind of "doc" attr
## Look at file "demostuff/sample.fun.rrr"
sample.fun <- source.mvb( system.file( file.path( 'demostuff', 'sample.fun.rrr'), package='mvbutils'))
cat( '***Original plain-text doco:***\n')
print( as.cat( attr( sample.fun, 'doc'))) # unescaped, ie what you'd actually edit
cat( '\n***Rd output:***\n')
sample.fun.Rd <- doc2Rd( sample.fun)
print( sample.fun.Rd) # already "cat" class
Run the code above in your browser using DataLab