ocaml-cff#
Citation File Format (CFF) codec for OCaml.
A library for parsing and generating CITATION.cff files following the
CFF 1.2.0 specification.
CFF is a human- and machine-readable format for software and dataset citation metadata.
Features#
- Full CFF 1.2.0 specification support
- SPDX license expression parsing via
spdx_licenses - Lenient parsing (accepts unknown fields, preserves non-SPDX licenses for round-tripping)
- Multiple I/O backends:
cff.unix- Unix file I/O usingIn_channel/Out_channelcff.eio- Eio-based async I/O
Installation#
opam install cff
Usage#
Reading a CITATION.cff file#
(* Using cff.unix *)
match Cff_unix.of_file "CITATION.cff" with
| Ok cff ->
Printf.printf "Title: %s\n" (Cff.title cff);
Printf.printf "Authors: %d\n" (List.length (Cff.authors cff))
| Error msg ->
Printf.eprintf "Error: %s\n" msg
Creating a CFF record programmatically#
let author = Cff.Author.person
~family_names:"Smith"
~given_names:"Jane"
~orcid:"https://orcid.org/0000-0001-2345-6789"
() in
let cff = Cff.make
~title:"My Research Software"
~authors:[author]
~version:"1.0.0"
~doi:"10.5281/zenodo.1234567"
~license:(`Spdx (Spdx_licenses.parse_exn "MIT"))
()
Writing a CITATION.cff file#
match Cff_unix.to_file "CITATION.cff" cff with
| Ok () -> print_endline "Written successfully"
| Error msg -> Printf.eprintf "Error: %s\n" msg
License#
ISC License. See LICENSE.md.