| as_bibentry {cffr} | R Documentation |
Create bibentry objects from several sources
Description
This function creates bibentry objects from different metadata sources
(cff objects, DESCRIPTION files, etc.). The inverse transformation
(bibentry object to cff_ref_lst) can be done with the corresponding
as_cff.bibentry() method.
With toBibtex() it is possible to convert cff objects
to BibTeX markup on the fly, see Examples.
Usage
as_bibentry(x, ...)
## Default S3 method:
as_bibentry(x, ...)
## S3 method for class 'character'
as_bibentry(x, ..., what = c("preferred", "references", "all"))
## S3 method for class ''NULL''
as_bibentry(x, ...)
## S3 method for class 'list'
as_bibentry(x, ...)
## S3 method for class 'cff'
as_bibentry(x, ..., what = c("preferred", "references", "all"))
## S3 method for class 'cff_ref_lst'
as_bibentry(x, ...)
## S3 method for class 'cff_ref'
as_bibentry(x, ...)
Arguments
x |
The source that would be used for generating
the
|
... |
Additional arguments to be passed to or from methods. |
what |
Fields to extract from a full
See |
Details
A R bibentry object is the representation of a BibTeX entry. These
objects can be converted to BibTeX markup with toBibtex(), that creates an
object of class Bibtex and can be printed and exported as a valid BibTeX
entry.
as_bibtex() tries to map the information of the source x into a cff] object and performs a mapping of the metadata to BibTeX, according to vignette("bibtex_cff", "cffr")'.
Value
as_bibentry() returns a bibentry object with one or more entries.
References
Patashnik, Oren. "BIBTEXTING" February 1988. https://osl.ugr.es/CTAN/biblio/bibtex/base/btxdoc.pdf.
Haines, R., & The Ruby Citation File Format Developers. (2021). Ruby CFF Library (Version 0.9.0) (Computer software). doi:10.5281/zenodo.1184077.
Hernangomez D (2022). "BibTeX and CFF, a potential crosswalk." The cffr package, Vignettes. doi:10.21105/joss.03900, https://docs.ropensci.org/cffr/articles/bibtex_cff.html.
See Also
utils::bibentry() to understand more about the bibentry class.
-
vignette("crosswalk", package = "cffr")provides details on how the metadata of a package is mapped to produce acffobject. -
vignette("bibtex_cff", "cffr")provides detailed information about the internal mapping performed betweencffobjects and BibTeX markup ( bothcffto BibTeX and BibTeX tocff).
Other related functions:
Other functions for working with BibTeX format:
cff_read(),
cff_read_bib_text(),
cff_write_bib(),
encoded_utf_to_latex()
Coercing between R classes with S3 Methods:
as_cff(),
as_cff_person(),
cff_class
Examples
# From a cff object ----
cff_object <- cff()
cff_object
# bibentry object
bib <- as_bibentry(cff_object)
class(bib)
bib
# Print as bibtex
toBibtex(bib)
# Thanks to the S3 Method we can also do
toBibtex(cff_object)
# Other sources ----
# From a CITATION.cff
path <- system.file("examples/CITATION_complete.cff", package = "cffr")
cff_file <- as_bibentry(path)
cff_file
# For an installed package with options
installed_package <- as_bibentry("jsonvalidate", what = "all")
installed_package
# Use a DESCRIPTION file
path2 <- system.file("examples/DESCRIPTION_gitlab", package = "cffr")
desc_file <- as_bibentry(path2)
toBibtex(desc_file)