A class and utility methods for reading, creating and holding CFF information.
Arguments
- path
The path to a
CITATION.cff
file.- ...
Named arguments to be used for creating a
cff
object. See Details.- x
a character string for the
as.cff
default method
Value
A cff
object. Under the hood, a cff
object is a regular list
object
with a special print()
method.
Details
This object can be manipulated using cff_create()
.
Note that this function reads CITATION.cff
files. If you want to
create cff
objects from DESCRIPTION files use cff_create()
.
If no additional ...
parameters are supplied (the default behavior),
a minimal valid cff
object is created. Valid parameters are those
specified on cff_schema_keys()
:
valid cff keys |
cff-version |
message |
type |
license |
title |
version |
doi |
abstract |
authors |
preferred-citation |
repository |
repository-artifact |
repository-code |
url |
date-released |
contact |
keywords |
references |
commit |
identifiers |
license-url |
See also
Other Core functions:
cff_create()
,
cff_validate()
,
cff_write()
Examples
# Blank cff
cff()
#> authors:
#> - family-names: Doe
#> given-names: John
#> cff-version: 1.2.0
#> message: If you use this software, please cite it using these metadata.
#> title: My Research Software
# From file
cff_read(system.file("examples/CITATION_basic.cff",
package = "cffr"
))
#> cff-version: 1.2.0
#> message: If you use this software in your research, please cite it as below.
#> title: cff-validator
#> abstract: Validate your repository's CITATION.cff file using R software
#> authors:
#> - family-names: Hernangómez
#> given-names: Diego
#> orcid: https://orcid.org/0000-0001-8457-4658
#> license: MIT
#> repository-code: https://github.com/dieghernan/cff-validator
#> references:
#> - title: Bootstrap Methods and Their Applications
#> authors:
#> - family-names: Davison
#> given-names: Anthony C.
#> - family-names: Hinkley
#> given-names: David V.
#> year: '1997'
#> publisher:
#> name: Cambridge University Press (Madrid)
#> translators:
#> name: Research Translators Ltd.
#> url: http://statwww.epfl.ch/davison/BMA/
#> type: proceedings
# Use custom params
test <- cff(
title = "Manipulating files",
keywords = c("A", "new", "list", "of", "keywords"),
authors = list(cff_parse_person("New author"))
)
test
#> title: Manipulating files
#> keywords:
#> - A
#> - new
#> - list
#> - of
#> - keywords
#> authors:
#> - family-names: author
#> given-names: New
# \donttest{
# Would fail
cff_validate(test)
#> ══ Validating cff ══════════════════════════════════════════════════════════════
#> ✖ Oops! This <cff> has the following errors:
#> * cff["cff-version"]: is required
#> * cff.message: is required
# Modify with cff_create
new <- cff_create(test, keys = list(
"cff-version" = "1.2.0",
message = "A blank file"
))
new
#> cff-version: 1.2.0
#> message: A blank file
#> title: Manipulating files
#> authors:
#> - family-names: author
#> given-names: New
#> keywords:
#> - A
#> - new
#> - list
#> - of
#> - keywords
# Would pass
cff_validate(new)
#> ══ Validating cff ══════════════════════════════════════════════════════════════
#> ✔ Congratulations! This <cff> is valid
# }
# Convert a list to "cff" object
cffobj <- as.cff(list(
"cff-version" = "1.2.0",
title = "Manipulating files"
))
class(cffobj)
#> [1] "cff"
# Nice display thanks to yaml package
cffobj
#> cff-version: 1.2.0
#> title: Manipulating files