Module B0_meta

Metadata.

Typed key-value dictionaries. Values of this type are used with various B0 definitions to specify metadata.

The module defines a few standard keys. The recommended way of formatting constant dictionaries is:

let meta =
  let open B0_meta in (* This can be omitted *)
  empty
  |> add authors ["The project programmers"]
  |> add homepage "https://example.org"
  |> tag B0_opam.Meta.tag

XXX. They used to be serializable, see if we don't want that again.

Keys

type 'a key

The type for keys whose lookup value is of type 'a.

module Key : sig ... end

Metadata keys

Metadata

type binding =
| B : 'a key * 'a -> binding

The type for metadata bindings.

val pp_binding : binding B00_std.Fmt.t

pp_binding formats a binding using B00_std.Fmt.field and the key's value print function.

type t

The type for metadata.

val empty : t

empty is the empty metadata.

val is_empty : t -> bool

is_empty m is true iff m is empty.

val mem : 'a key -> t -> bool

mem k m is true iff m has a binding for k.

val add : 'a key -> 'a -> t -> t

add k v m is m with k bound to v.

val tag : unit key -> t -> t

tag k m is add k () m.

val rem : 'a key -> t -> t

rem k m is m wihtout a binding for k.

val find : 'a key -> t -> 'a option

find k m is the binding of k in m (if any).

val find_binding : 'a key -> t -> binding option

find_binding k m is the binding for k in m (if any).

val find_binding_by_name : string -> t -> binding option

find_binding_by_name n m is the binding named n in m (if any).

val get : 'a key -> t -> 'a

get k m is the binding of k in m. Raises Invalid_argument if there is no such binding.

val get_binding : 'a key -> t -> binding

find_binding k m is the binding for k in m. Raises Invalid_argument if there is no such binding.

val get_binding_by_name : string -> t -> binding

get_binding_by_name n m is the binding named n in m. Raises Invalid_argument if there is no such binding.

val fold : (binding -> 'a -> 'a) -> t -> 'a -> 'a

fold f m acc folds f over the bindings of m starting with acc.

Formatting

val pp : t B00_std.Fmt.t

pp formats metadata using pp_bindings.

val pp_non_empty : t B00_std.Fmt.t

pp_non_empty is Fmt.cut followed by pp if metadata is non empty and Fmt.nop otherwise.

Standard keys

End-user information

val authors : string list key

authors describes a list of persons with authorship.

val description_tags : string list key

description_tags describes a list of classification tags used for documentation.

val description : string key

description is a long description for the entity.

val homepage : string key

issues is an URI to an issue tracker.

val issues : string key

issues is an URI to an issue tracker.

val licenses : string list key

licenses describes a list of licenses. Each license should be a SPDX license identifier.

val maintainers : string list key

maintainers describe a list of persons with maintainership.

val online_doc : string key

online_doc is an URI to online documentation.

val repo : string key

repo is an URI to a VCS system.

val synopsis : string key

synopsis is a one line synopsis for an entity.

Entity tags

val bench : unit key

bench tags benchmarking entities.

val build : unit key

build tags build system entities.

val dev : unit key

dev tags development entities.

val doc : unit key

doc tags documentation entities.

val exe : unit key

exe tags executable entities.

val test : unit key

test tags testing entities.

val lib : unit key

lib tags library entities.

Entity properties

val exe_name : string key

exe_name is an executable name without the platform specific executable extension.

val exe_path : B00_std.Fpath.t B00_std.Fut.t key

exe_path is an absolute path to a built executable in the unit.