PlumeQuarto {plume}R Documentation

PlumeQuarto class

Description

Class that pushes author metadata in the YAML header of Quarto files.

Super classes

plume::NameHandler -> plume::PlumeHandler -> plume::StatusSetter -> plume::StatusSetterPlumeQuarto -> PlumeQuarto

Methods

Public methods

Inherited methods

Method new()

Create a PlumeQuarto object.

Usage
PlumeQuarto$new(
  data,
  file,
  names = NULL,
  roles = credit_roles(),
  credit_roles = FALSE,
  initials_given_name = FALSE,
  by = NULL
)
Arguments
data

A data frame containing author-related data.

file

A .qmd file to insert author data into.

names

A vector of key-value pairs specifying custom names to use, where keys are default names and values their respective replacements.

roles

A vector of key-value pairs defining roles where keys identify columns and values describe the actual roles to use.

credit_roles

[Deprecated]

It is now recommended to use roles = credit_roles() to use the Contributor Roles Taxonomy.

initials_given_name

Should the initials of given names be used?

by

A character string defining the default variable used to assign specific metadata to authors in all ⁠set_*()⁠ methods. By default, uses authors' id.

Returns

A PlumeQuarto object.


Method to_yaml()

Push or update author information in a YAML header. The generated YAML complies with Quarto's author and affiliations schemas.

Usage
PlumeQuarto$to_yaml()
Details

If missing, to_yaml() pushes author information into a YAML header. If already existing, the function replaces old author and affiliations values with the ones provided in the input data.

Returns

The input file invisibly.


Method clone()

The objects of this class are cloneable with this method.

Usage
PlumeQuarto$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

# Create a simple temporary file with a YAML header
# containing a title
tmp_file <- tempfile(fileext = ".qmd")
readr::write_lines("---\ntitle: Encyclopédie\n---", tmp_file)

# View the temporary file
cat(readr::read_file(tmp_file))

# Create a PlumeQuarto instance using the temporary file
# you've just created
aut <- PlumeQuarto$new(
  encyclopedists,
  file = tmp_file
)

# And push author data to the YAML header
aut$to_yaml()

cat(readr::read_file(tmp_file))

# Pushing again with new data updates the YAML
# header accordingly
aut <- PlumeQuarto$new(
  dplyr::slice(encyclopedists, 2),
  file = tmp_file
)
aut$to_yaml()

cat(readr::read_file(tmp_file))

# Clean up the temporary file
unlink(tmp_file)

[Package plume version 0.2.4 Index]