OCaml library for JSONfeed parsing and creation
1(** Author information for JSON Feed items and feeds. 2 3 An author object provides information about the creator of a feed or item. 4 According to the JSON Feed 1.1 specification, at least one field must be 5 present when an author object is included. 6 7 @see <https://www.jsonfeed.org/version/1.1/> JSON Feed Specification *) 8 9 10(** The type representing an author. *) 11type t 12 13 14(** {1 Construction} *) 15 16(** [create ?name ?url ?avatar ()] creates an author object. 17 18 At least one of the optional parameters must be provided, otherwise 19 the function will raise [Invalid_argument]. 20 21 @param name The author's name 22 @param url URL of the author's website or profile 23 @param avatar URL of the author's avatar image (should be square, 512x512 or larger) 24 25 {b Examples:} 26 {[ 27 let author = Author.create ~name:"Jane Doe" () 28 let author = Author.create ~name:"Jane Doe" ~url:"https://janedoe.com" () 29 let author = Author.create 30 ~name:"Jane Doe" 31 ~url:"https://janedoe.com" 32 ~avatar:"https://janedoe.com/avatar.png" () 33 ]} *) 34val create : ?name:string -> ?url:string -> ?avatar:string -> unit -> t 35 36 37(** {1 Accessors} *) 38 39(** [name t] returns the author's name, if set. *) 40val name : t -> string option 41 42(** [url t] returns the author's URL, if set. *) 43val url : t -> string option 44 45(** [avatar t] returns the author's avatar URL, if set. *) 46val avatar : t -> string option 47 48 49(** {1 Predicates} *) 50 51(** [is_valid t] checks if the author has at least one field set. 52 53 This should always return [true] for authors created via {!create}, 54 but may be useful when parsing from external sources. *) 55val is_valid : t -> bool 56 57 58(** {1 Comparison} *) 59 60(** [equal a b] tests equality between two authors. *) 61val equal : t -> t -> bool 62 63 64(** {1 Pretty Printing} *) 65 66(** [pp ppf t] pretty prints an author to the formatter. 67 68 The output is human-readable and suitable for debugging. 69 70 {b Example output:} 71 {v Jane Doe <https://janedoe.com> v} *) 72val pp : Format.formatter -> t -> unit