Getting started with alttip

This vignette showcases altdoc styled with altdown’s pkgdown theme, with function hover previews and links from reftip.

library(alttip)

A plain call

Note

greet() and add() are ordinary functions. Hover either one, in a code block or in prose, and you get a tooltip.

greet("alttip")
[1] "Hello, alttip!"
add(2, 40)
[1] 42

An S3 method, called by name

animal() and speak.animal() share one Rd page and one \usage{} block. reftip narrows the tooltip to just this method, not the whole block.

rex <- animal("Rex", "woof")
speak.animal(rex)
Rex says woof!
TipTip

print.animal() works the same way; try hovering it.

<animal: Rex>

Known limitations

WarningGeneric dispatch

print() is a generic; which method runs depends on rex’s class at runtime. reftip doesn’t run code, so it doesn’t know which method it belongs to. Hence no preview is given.

print(rex)
<animal: Rex>
WarningR6 methods

Same story for $: nothing in counter$increment() says which class’s methods to look up, so it stays untouched too.

counter <- Counter$new()
counter$increment()
counter$increment(by = 2)
counter$value()
[1] 3
Important

This package is a toy, built only to demonstrate altdown and reftip together. Don’t expect real functionality here.