Title: | Colourised R Documentation |
---|---|
Description: | Extends tools::Rd2txt() by adding customisable text and colour formatting to R documentation contents. If used from a terminal, output will be displayed via file.show() otherwise contents will be printed in sections. Also provides stand-in replacements for ?() and help(). |
Authors: | Matthew de Queljoe [aut, cre] |
Maintainer: | Matthew de Queljoe <[email protected]> |
License: | GPL-3 |
Version: | 0.1.0.9000 |
Built: | 2024-11-02 03:57:02 UTC |
Source: | https://github.com/mdequeljoe/rdoc |
Refer to colourised R docs as terminal output. Provides a replacement for
help
. A number of common (substantive) section accessors are also
provided.
rdoc(topic, package = NULL, lib.loc = NULL) rdoc_usage(topic, package = NULL, lib.loc = NULL) rdoc_arguments(topic, package = NULL, lib.loc = NULL) rdoc_details(topic, package = NULL, lib.loc = NULL) rdoc_examples(topic, package = NULL, lib.loc = NULL)
rdoc(topic, package = NULL, lib.loc = NULL) rdoc_usage(topic, package = NULL, lib.loc = NULL) rdoc_arguments(topic, package = NULL, lib.loc = NULL) rdoc_details(topic, package = NULL, lib.loc = NULL) rdoc_examples(topic, package = NULL, lib.loc = NULL)
topic |
|
package |
|
lib.loc |
|
The manner in which content is outputted depends on where it is
being used. If used from a terminal the contents will be outputted via
file.show
. Otherwise the output will be printed interactively by
sections unless this has been disabled via options(rdoc.by_section =
FALSE)
. When printing by section pressing the <enter> keypress will show
the next section. Any other keypress will exit the interaction without
printing any remaining sections. Color support is checked via
crayon::has_color()
. Customising rdoc output is possible via
'options', see rdoc_options
for more details.
library(rdoc) rdoc("rdoc") rdoc_examples("min") rdoc_usage(substr)
library(rdoc) rdoc("rdoc") rdoc_examples("min") rdoc_usage(substr)
Rdoc uses the following options()
to set output:
'rdoc.by_section': logical, output interactively printed by sections for console sessions. Sections will be printed with the <enter> keypress. Any other keypress will exit the interaction without printing the remaining sections. Default is TRUE.
'rdoc.header': logical, whether package header is included in the output. Default is TRUE.
'rdoc.text_formats': see rdoc_text_formats
'rdoc.style': see rdoc_style
'rdoc.item_bullet': Symbol to use for itemized lists. Default is
paste0(cli::symbol$circle, " ")
Refer to colourised R docs as terminal output. Provides a
replacement for ?
. Meant primarily for use as an
override in use_rdoc()
rdoc_question(type, topic)
rdoc_question(type, topic)
type |
the special type of documentation to use for this topic;
for example, if the type is |
topic |
Usually, a name or character string specifying the topic for which help is sought. Alternatively, a function call to ask for documentation on a
corresponding S4 method: see the section on S4 method documentation.
The calls |
The manner in which content is outputted depends on where it is
being used. If used from a terminal the contents will be outputted via
file.show
. Otherwise the output will be printed interactively by
sections unless this has been disabled via options(rdoc.by_section =
FALSE)
. When printing by section pressing the <enter> keypress will show
the next section. Any other keypress will exit the interaction without
printing any remaining sections. Color support is checked via
crayon::has_color()
. Customising rdoc output is possible via
'options', see rdoc_options
for more details.
rdoc::rdoc_question('lapply')
rdoc::rdoc_question('lapply')
Refer directly to .Rd file contents as terminal output.
rdoc_rd(path)
rdoc_rd(path)
path |
character(1), the path to an .Rd file |
The manner in which content is outputted depends on where it is
being used. If used from a terminal the contents will be outputted via
file.show
. Otherwise the output will be printed interactively by
sections unless this has been disabled via options(rdoc.by_section =
FALSE)
. When printing by section pressing the <enter> keypress will show
the next section. Any other keypress will exit the interaction without
printing any remaining sections. Color support is checked via
crayon::has_color()
. Customising rdoc output is possible via
'options', see rdoc_options
for more details.
d <- system.file('extdata/rdoc_test.Rd', package = "rdoc") rdoc::rdoc_rd(d)
d <- system.file('extdata/rdoc_test.Rd', package = "rdoc") rdoc::rdoc_rd(d)
Set Rd output formatting styles to be supplied to options(rdoc.style =
rdoc_style())
rdoc_style(title = crayon::bold, section_titles = crayon::underline, arguments = NULL, code_style = prettycode::default_style())
rdoc_style(title = crayon::bold, section_titles = crayon::underline, arguments = NULL, code_style = prettycode::default_style())
title |
topic title. |
section_titles |
section titles |
arguments |
argument parameters. |
code_style |
code sections (e.g. examples) and inline code
styles to be passed on to |
all inputs should be functions or NULL
with the exception of
code_style
which should be a list of functions.
A list
options(rdoc.style = rdoc::rdoc_style(arguments = crayon::italic))
options(rdoc.style = rdoc::rdoc_style(arguments = crayon::italic))
Access the underlying rdoc text lines
rdoc_text(topic, package = NULL, lib.loc = NULL)
rdoc_text(topic, package = NULL, lib.loc = NULL)
topic |
|
package |
|
lib.loc |
|
character
txt <- rdoc::rdoc_text('min')
txt <- rdoc::rdoc_text('min')
Set Rd text format defaults to be supplied to options(rdoc.text_formats
= rdoc_text_formats())
rdoc_text_formats(r_logo = crayon::combine_styles("bold", "blue"), pkg = function(x) paste0("{", x, "}"), inline_code = prettycode::default_style(), italic = crayon::italic, bold = crayon::bold, table = list(float = "center", border_style = "single", align = "left"), email = crayon::underline, url = crayon::underline, href = crayon::underline, link = function(x) x)
rdoc_text_formats(r_logo = crayon::combine_styles("bold", "blue"), pkg = function(x) paste0("{", x, "}"), inline_code = prettycode::default_style(), italic = crayon::italic, bold = crayon::bold, table = list(float = "center", border_style = "single", align = "left"), email = crayon::underline, url = crayon::underline, href = crayon::underline, link = function(x) x)
r_logo |
R symbol |
pkg |
pkg references |
inline_code |
inline code, options to pass to the |
italic |
italic font |
bold |
bold font |
table |
tabular, options to pass to |
email |
email formats |
url |
url references |
href |
href |
link |
links |
The input will generally be a function, unless otherwise indicated
above. Functions must take and return a character vector. If set as
NULL
, the relevant text will be displayed using the defaults of
tools::Rd2txt
or the calling function it is passed to. Note that
href and link formatting refer to the source reference which will otherwise
be excluded by tools::Rd2txt
.
rdoc replacements for ?
and help
use_rdoc() rm_rdoc()
use_rdoc() rm_rdoc()
Calling use_rdoc()
will override utils::`?`
with rdoc_question
and utils::help
with rdoc
. As a convenience, use_rdoc()
loads utils first.
This ensures that if use_rdoc()
is set in an .Rprofile the replacements will stay ahead of
utils in the search path after startup is finished.
These replacements can be unset by calling rm_rdoc()
(note that no detachment will
occur for utils here).
rdoc::use_rdoc() ?help rdoc::rm_rdoc() ?help
rdoc::use_rdoc() ?help rdoc::rm_rdoc() ?help