Package 'felp'

Title: Functional Help for Functions, Objects, and Packages
Description: Enhance R help system by fuzzy search and preview interface, pseudo-postfix operators, and more. The `?.` pseudo-postfix operator and the `?` prefix operator displays documents and contents (source or structure) of objects simultaneously to help understanding the objects. The `?p` pseudo-postfix operator displays package documents, and is shorter than help(package = foo).
Authors: Atsushi Yasumoto [aut, cph, cre]
Maintainer: Atsushi Yasumoto <[email protected]>
License: MIT + file LICENSE
Version: 0.6.0
Built: 2024-11-07 02:41:00 UTC
Source: https://github.com/atusy/felp

Help Index


Functional help with ⁠?⁠ operator

Description

Displays help and structure of an object, or help of a package. Two syntax sugars are added to enhance ⁠utils::?⁠. One is object?. which works as if ?object. Another is package?p which works as if help(package = package)

Usage

`?`(e1, e2)

Arguments

e1

A topic of document. Refer to topic argument described in utils::`?`.

e2

. and p have special meanings as documented above. Otherwise, e2 is same as type argument of utils::`?`.

Examples

# Identical to help(identity); print(identity)
?identity
identity?.  # The same

# Identical to help(iris); str(iris)
?iris
iris?.  # The same

# Identical to help(package = stats)
stats?p

A dummy data for felp

Description

A dummy data for felp

Usage

dummy

Format

An object of class list of length 2.


Functional help which displays structure of an object in addition to help

Description

Structure of object is returned by str(). For a function, its source is returned instead of str().

Usage

felp(topic, package = NULL, ...)

Arguments

topic

usually, a name or character string specifying the topic for which help is sought. A character string (enclosed in explicit single or double quotes) is always taken as naming a topic.

If the value of topic is a length-one character vector the topic is taken to be the value of the only element. Otherwise topic must be a name or a reserved word (if syntactically valid) or character string.

See ‘Details’ for what happens if this is omitted.

package

a name or character vector giving the packages to look into for documentation, or NULL. By default, all packages whose namespaces are loaded are used. To avoid a name being deparsed use e.g. (pkg_ref) (see the examples).

...

Arguments passed on to utils::help

lib.loc

a character vector of directory names of R libraries, or NULL. The default value of NULL corresponds to all libraries currently known. If the default is used, the loaded packages are searched before the libraries. This is not used for HTML help (see ‘Details’).

verbose

logical; if TRUE, the file name is reported.

try.all.packages

logical; see Note.

help_type

character string: the type of help required. Possible values are "text", "html" and "pdf". Case is ignored, and partial matching is allowed.

Examples

# Identical to help(identity); print(identity)
felp(identity)

# Identical to help(iris); str(iris)
felp(iris)

# Identical to help(package = stats)
felp(package = stats)

Fuzzily Search Help and View the Selection

Description

Users no longer have to remember the exact name to find help, vignettes, and demo. A shiny gadget helps you to find a topic fuzzily. Click radio buttons to switch preview contents. Click "Done" or "Cancel" to close the widget. When background = FALSE, the "Done" button will also hook help, vignette, or demo, accordingly.

Usage

fuzzyhelp(
  query = "",
  method = getOption("fuzzyhelp.method", "fzf"),
  background = getOption("fuzzyhelp.background", TRUE),
  viewer = shiny::paneViewer()
)

Arguments

query

An initial query to search for the help system.

method

A fuzzy match method to use. Choices are "fzf" and "lv" (levenstein). The method "lv" is faster but can be less accurate. The default value can be tweaked by options(fuzzyhelp.method = "lv").

background

Whether to run a shiny gadget in a background process. The default value is TRUE and can be changed by option(fuzzyhelp.background = FALSE).

viewer

Specify where the gadget should be displayed–viewer pane, dialog window, or external browser–by passing in a call to one of the viewer() functions.

Value

If the background argument is TRUE, then the return value inherits from callr::r_bg(). Otherwise, NULL is returned.

Note

The default fuzzy match algorithm is a simplified version of https://github.com/junegunn/fzf. The implementation in this package excludes bonuses from relationship with matched characters and their previous characters.

Examples

if (FALSE) {
  fuzzyhelp()
}