Documentation (informal help)
dochelp(topic)
will be invoked by the replacement help
if conventional help
fails to find documentation for topic topic
. If topic
is an object with a doc
attribute (or failing that if <<topic>>
or <<topic>>.doc
is a character vector), then the attribute (or the character object) will be formatted and displayed by the pager or browser. dochelp
is not usually called directly.
# Not usually called directly # If it is, then normal usage is: dochelp( topic) dochelp( topic, doc, help_type=c( "text", "html")) # Set options( mvb_help_type="text") if the browser gives you grief
topic |
(character) name of the object to look for help on, or name of "...doc" character object– e.g. either |
doc |
(character or list)– normally not set, but deduced by default from |
help_type |
as per |
The doc
argument defaults to the doc
attribute of get("topic")
. The only reason to supply a non-default argument would be to use dochelp
as a pager; this might have some value, since dochelp
does reformat character vectors to fit nicely in the system pager window, one paragraph per element, using strwrap
. Elements starting with a "%" symbol are not displayed.
To work with dochelp
, a doc
attribute should be either:
a character vector, of length >=1. New elements get line breaks in the pager. Or:
a length-one list, containing the name of another object with a doc
attribute. dochelp
will then use the doc
attribute of that object instead. This referencing can be iterated.
If the documentation is very informal, start it with a blank line to prevent find.documented( ..., doctype="Rd")
from finding it.
With help_type="text"
, the doco will be re-formatted to fit the pager; each paragraph should be a single element in the character vector. Elements starting with a % will be dropped (but may still be useful for doc2Rd
).
flatdoc
offers an easy way to incorporate plain-text (flat-format) documentation– formal or informal– in the same text file as a function definition, allowing easy maintenance. The closer you get to the displayed appearance of formal R-style help, the nicer the results will look in a browser (assuming help_type="html"
), but the main thing is to just write some documentation– the perfect is the enemy of the good in this case!
Mark Bravington
flatdoc
, doc2Rd
, find.documented
, strwrap
# myfun <- structure( function() 1, doc="Here is some informal documentation for myfun\n") dochelp( "myfun") help( "myfun") # calls dochelp
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.