Skip to main content

Module yaml

Module yaml 

Source
Expand description

The semantic tree as YAML: one line per node with its role, quoted name, attributes in brackets and a value or text after a colon. Unnamed generics are hoisted away and owned subtrees print under their owner.

- dialog "Delete item?" [modal]:
  - heading "Delete item?" [level=2]
  - text: Water the beans will be removed.
  - button "Delete"
- textbox "New item": Sow the leeks

States print bare when true ([disabled]) and with a value otherwise ([expanded=false], [checked=mixed]); derived flags print only when set. A node with both a value and children carries the value as a first child - /value: ...

The output is always valid YAML: a key containing : or # is single-quoted, a value YAML would read differently is double-quoted with YAML’s escapes, and a key longer than YAML’s 1024-character limit for one-line keys is written as an explicit ? key entry. normalise folds those forms back into one line per entry for read and the template parser.

Structs§

YamlOptions
What write() includes.

Constants§

STATE_NAMES
Every state name, in the order the writer and the selector printer use.

Functions§

normalise
Puts each entry back on one line: a key YAML needed quoted or explicit is folded into the plain - key: value form the line grammar reads, and the second line of an explicit key becomes blank, so line numbers still match the source. read does this first, and so does the template parser in icedwright-check.
read
Reads YAML written by write() or by hand into a tree. Bounds are zero where the YAML has none, and states are taken as written rather than derived. Top-level window entries become windows; anything else is wrapped in one unnamed window, so writing that window gives back the same text.
write
Writes the subtree at root. A window root writes its content without a line of its own.