Skip to main content

parse_vocabulary

Function parse_vocabulary 

Source
pub fn parse_vocabulary(value: &Value) -> Option<VocabularyDoc>
Expand description

Parse a vocabulary document from its top-level value: a vocabulary: { field, values } marker plus a terms: mapping, each entry either a bare key (a live term with no metadata) or a { label?, description?, retired? } mapping. Returns None when value carries no vocabulary marker — i.e. it is not a vocabulary document.

This is the shared file-format half of a controlled vocabulary: Term and validate_enum already say how to check a value; this says how to load the term set a document declares, so two independent embedders (a frontmatter engine, a batch renderer) can point at the same vocabulary document without either depending on the other.

Key lookup is Value::get, so a duplicated key resolves last-wins, the same way fig itself reads one. A duplicated term is not a lookup and yields two Terms with the same value, in declaration order.