link: Create a link to a different book

View source: R/link.R

linkR Documentation

Create a link to a different book

Description

From another Rmarkdown file, create a link to a section or figure of a rebook-configured book.

Usage

link(id, package, type = NULL, prefix = NULL, df = NULL, error = TRUE)

Arguments

id

String containing an identifier for a section or figure.

package

String containing the name of the package containing the target book.

type

String containing the type of the link, e.g., "Section" or "Figure", to be added to the link text. This is automatically determined if not provided. If NA, the type is not added to the link text.

prefix

String specifying the prefix to use on type. This is automatically determined from package's chosen prefix or, if that is not provided, using the package name itself. If NA, no prefix is added. Only used if type is not NA.

df

A data.frame containing all links for package. Only used for testing.

error

Logical scalar indicating whether an error should be raised if the link cannot be found.

Details

We expect that the target book is set up as a Bioconductor package with a configure file that runs configureBook. This function will then retrieve install-time information from that package to create necessary hyperlinks to the Bioconductor-hosted book content.

Value

String containing a markdown-formatted link to the relevant part of the target book. If the link cannot be constructed and error=FALSE, a NULL is instead returned.

Author(s)

Aaron Lun

See Also

configureBook, which should be run by the authors of package.

scrapeReferences, to generate a df for testing.

Examples

# Only using 'df=' here because 'testpackage' doesn't actually exist.
link("fig:xxx", package="testpackage", 
    df=data.frame(id='fig:xxx', file='whee.html', text='3.1'))

link("fig:xxx", package="testpackage", type=NA,
    df=data.frame(id='fig:xxx', file='whee.html', text='3.1'))

link("fig:xxx", package="testpackage", prefix=NA,
    df=data.frame(id='fig:xxx', file='whee.html', text='3.1'))

LTLA/rebook documentation built on June 5, 2023, 6:24 p.m.