cff_write: Write a 'CITATION.cff' file

View source: R/cff-write.R

cff_writeR Documentation

Write a CITATION.cff file

Description

cff_write() is the primary workflow for package development.

This function writes a CITATION.cff file for a given package. It wraps cff_create() to create the cff object, then writes it to a YAML-formatted file in one command.

Usage

cff_write(
  x,
  outfile = "CITATION.cff",
  keys = list(),
  cff_version = "1.2.0",
  gh_keywords = TRUE,
  r_citation = FALSE,
  dependencies = TRUE,
  validate = TRUE,
  verbose = TRUE,
  authors_roles = c("aut", "cre"),
  encoding = "UTF-8"
)

Arguments

x

The source used to generate the cff object. It can be:

  • A missing value, which retrieves the DESCRIPTION file from your in-development R package.

  • An existing cff object.

  • The name of an installed package ("jsonlite").

  • A path to a DESCRIPTION file ("./DESCRIPTION").

outfile

The name and path of the CITATION.cff to be created. Relative paths are resolved from the current working directory, independently of the source specified in x.

keys

A list of additional keys to add to the cff object. See cff_modify().

cff_version

The Citation File Format schema version used for the generated metadata.

gh_keywords

A logical value. If TRUE and the package is hosted on GitHub, add the repository topics as keywords.

r_citation

A logical value. If TRUE, the R package citation (inst/CITATION) is created or updated relative to the current working directory. No backup copy is created. For more control, use cff_write_citation().

dependencies

A logical value. If TRUE, add the package dependencies to the references CFF key.

validate

A logical value. If TRUE, validate the new file with cff_validate().

verbose

A logical value. If TRUE, the function displays informative messages.

authors_roles

Roles to be considered as authors of the package when generating the CITATION.cff file. See Details.

encoding

The name of the encoding to be assumed. Default is "UTF-8", but it can be any other value accepted by base::iconv(), such as "ASCII//TRANSLIT".

Details

For details of authors_roles, see cff_create().

The x argument identifies the metadata source. It does not determine the output directory. This allows you to create a CITATION.cff from a package or file located outside the current working directory.

When creating and writing a CITATION.cff for a package in the current working directory, this function adds the pattern "^CITATION\.cff$" to the local .Rbuildignore file.

Value

Invisibly returns the generated cff object. This function is called primarily for its side effect of writing a CITATION.cff file.

See Also

Citation File Format schema guide.

Core cffr workflow: cff(), cff_create(), cff_modify(), cff_validate()

Write citation metadata files: cff_write_bib()

Examples


tmpfile <- tempfile(fileext = ".cff")
cff_obj <- cff_write("jsonlite", outfile = tmpfile)

cff_obj

# Force cleanup.
file.remove(tmpfile)


cffr documentation built on Aug. 24, 2026, 5:11 p.m.