forked from
anil.recoil.org/monopam-myspace
My aggregated monorepo of OCaml code, automaintained
1(*---------------------------------------------------------------------------
2 Copyright (c) 2026 The ocaml-cff programmers. All rights reserved.
3 SPDX-License-Identifier: ISC
4 ---------------------------------------------------------------------------*)
5
6(** Unix file I/O for CFF.
7
8 This module provides YAML parsing and serialization for CFF using
9 standard Unix file operations ({!In_channel}, {!Out_channel}).
10
11 {1 Example}
12
13 {[
14 match Cff_unix.of_file "CITATION.cff" with
15 | Ok cff ->
16 Printf.printf "Title: %s\n" (Cff.title cff);
17 Printf.printf "Version: %s\n"
18 (Option.value ~default:"unspecified" (Cff.version cff))
19 | Error msg ->
20 Printf.eprintf "Parse error: %s\n" msg
21 ]}
22
23 {1 Functions} *)
24
25(** [of_yaml_string s] parses a CFF from YAML string [s].
26
27 Returns [Ok cff] on success or [Error msg] with a descriptive error
28 message on failure. *)
29val of_yaml_string : string -> (Cff.t, string) result
30
31(** [to_yaml_string cff] serializes [cff] to a YAML string.
32
33 The output uses YAML block style for readability. *)
34val to_yaml_string : Cff.t -> (string, string) result
35
36(** [of_file path] reads and parses a [CITATION.cff] file.
37
38 Returns [Ok cff] on success or [Error msg] if the file cannot be
39 read or contains invalid CFF data. *)
40val of_file : string -> (Cff.t, string) result
41
42(** [to_file path cff] writes [cff] to a file at [path].
43
44 Creates or overwrites the file. Returns [Error msg] on I/O failure. *)
45val to_file : string -> Cff.t -> (unit, string) result