Learn R Programming

ascribe (version 0.2.0)

cite_usage: Cite package and function use in a project

Description

Builds citations from scan_usage() results. Package collections supply their own citation records and package-citation policy.

Usage

cite_usage(
  usage,
  package_citations = new.env(parent = emptyenv(), hash = TRUE),
  function_citations = new.env(parent = emptyenv(), hash = TRUE),
  package_citation = utils::citation,
  always_cite = character(),
  format = c("bibtex", "bibentry")
)

Value

A BibTeX character vector or a bibentry object.

Arguments

usage

Results returned by scan_usage().

package_citations

An environment of package citation entries. Missing packages use package_citation.

function_citations

An environment of function citation entries, keyed by "pkg::function".

package_citation

A function that accepts a package name and returns its citation entries. Defaults to utils::citation().

always_cite

Character vector of packages to cite in addition to the packages found by the scan.

format

One of "bibtex" or "bibentry".

Examples

Run this code
path <- tempfile(fileext = ".R")
writeLines("cli::cli_alert_info('hi'); fastmatch::fmatch(1, 1:5)", path)
universe <- build_universe_data(c("cli", "fastmatch"))
usage <- scan_usage(path, universe)
cite_usage(usage)
unlink(path)

Run the code above in your browser using DataLab