Rd_help2txt | R Documentation |
Extract selected help sections as text.
Rd_help2txt(x, topic, pkgname = "", help_type = "text",
verbose = FALSE, try.all.packages = FALSE,
keep_section = TRUE, omit_sec_header = FALSE)
x |
the help object. Its class may be "Rd", string or "help_files_with_topic". |
topic |
passed on to |
pkgname |
passed on to |
help_type |
passed on to |
verbose |
passed on to |
try.all.packages |
passed on to |
keep_section |
the section to keep. If it is a
character vector of length at least one, the sections listed in it
(plus |
omit_sec_header |
whether to omit or not the section header |
Basically, this function calls Rd_fun
to get an Rd object
containing the required help sections, then converts them to text with
tools::Rd2txt
. At this point however unwanted sections may be
present since tools::Rd2txt
requires \title
and \name
.
If \title
is not an element of keep_section
, it should be
dropped. Other header information is dropped if omit_sec_header
= TRUE
. The way this is done is crude and based on inspection. It
would be better done using the Rd object but then I might need to,
effectively reprogram Rd2txt
.
FIXME: The above was done for version R-2.10 (I think), see if a more
modular version is available in current versions of R.
Also, it is tested only with help_type="text"
.
FIXME: Arguments whose description is marked "passed on to
Rd_fun
" could be replaced by a "..." argument.
A character vector containing the text of the selected help sections.
In R-2.12.0 the function tools::Rd2txt
acquired a fragment
argument. So, tools::Rd2txt
now works with fragments and can be
used directly in many cases.
Georgi N. Boshnakov
# 1st arg is the name of a function
Rd_help2txt("data.frame",keep_section="\\arguments")
Rd_help2txt("seq",keep_section="\\examples")
Rd_help2txt("seq",keep_section="\\examples",omit_sec_header=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.