3 https://yaml.org/[YAML] is a human-readable data serialization format,
4 like https://www.json.org/json-en.html[JSON].
6 In fact, YAML is a superset of JSON: you can also write a barectf
9 YAML has many features which are outside the scope of the barectf
10 documentation. This page is a simple introduction to the
11 https://yaml.org/spec/1.2/spec.html[YAML{nbsp}1.2] language.
13 YAML uses indentation for scoping, much like Python.
15 The root of a YAML document is a <<mapping,mapping>>.
20 A YAML mapping is an unordered list of key-value pairs.
22 Within a mapping, `:` delimits the value from the key.
24 .A YAML mapping with four entries.
28 Castonguay: Huguette Delisle
29 Létourneau: Gaétan Delisle
30 Robitaille: Serge Paquette
31 Gonthier-Hyndman: Micheline Paquette
35 .A YAML mapping with a nested mapping.
39 title: C'est comme ça que je t'aime
42 release-date: 6 March 2020
44 Castonguay: Huguette Delisle
45 Létourneau: Gaétan Delisle
46 Robitaille: Serge Paquette
47 Gonthier-Hyndman: Micheline Paquette
51 You can also write a mapping on a single line, delimiting key-value
52 pairs with `,`, beginning with `{` and ending with `}`:
54 .A single-line YAML mapping with four entries.
58 {Marilyn: Huguette, François: Gaétan, Karine: Micheline, Patrice: Serge}
62 .A YAML mapping with a nested single-line mapping.
66 title: C'est comme ça que je t'aime
69 release-date: 6 March 2020
70 cast: {Marilyn: Huguette, François: Gaétan, Karine: Micheline, Patrice: Serge}
74 Although the keys of a mapping can be any value, barectf only uses
77 Each key of a given mapping must be unique.
82 A YAML sequence is an ordered list of values.
84 Each item begins with `-`.
86 .A YAML sequence with four items.
97 .A YAML sequence. The third item is a <<mapping,mapping>>.
101 - Le poète des temps gris
104 album: Toutte est temporaire
110 You can also write a sequence on a single line, delimiting items
111 with a comma (`,`), beginning with `[` and ending with `]`:
113 .A single-line YAML sequence with four items.
117 [Corvette Express, Québec Deli, Boulangerie Fanfare, Marché Méli-Mélo]
121 .A single-line YAML sequence. The third item is a single-line <<mapping,mapping>>.
125 [Le poète des temps gris, Aidez-moi, {name: Granby, year: 2014}, La patente]
130 == Null, boolean, integer, and string values
132 The basic YAML scalar values which are of interest to write a barectf
136 `null`, `Null`, `NULL`, `+~+`, or nothing.
138 In a barectf YAML configuration, a null value always means to use the
142 `true`, `True`, `TRUE`, `false`, `False`, or `FALSE`.
147 ** `+[-+]?[0-9]++` (decimal)
148 ** `+0o[0-7]++` (octal)
149 ** `+0x[0-9a-fA-F]++` (hexadecimal)
152 Examples: `23`, `0x45fc1`, `-17`, `0o644`.
155 Double-quoted or single-quoted sequence of characters, or unquoted
156 sequence of characters when it doesn't match the form of another
161 ** `+"Whoever is happy will make others happy too."+`
162 ** `+'Life is either a daring adventure or nothing at all.'+`
163 ** `+Only a life lived for others is a life worthwhile.+`
165 .A YAML mapping with null, boolean, integer, and string values.
170 booleans: [true, false]
171 integers: [23, 0x45fc1, -17, 0o644]
173 - "Whoever is happy will make others happy too."
174 - 'Life is either a daring adventure or nothing at all.'
175 - Only a life lived for others is a life worthwhile
181 A YAML comment starts with `+#+` and ends at the end of the line.
183 .A YAML mapping with comments.
187 title: C'est comme ça que je t'aime
189 # This is actually a Québec production.
193 release-date: 6 March 2020
195 Castonguay: Huguette Delisle
196 Létourneau: Gaétan Delisle # also cowrote Série noire
197 Robitaille: Serge Paquette
198 Gonthier-Hyndman: Micheline Paquette
205 Any YAML value has a tag to indicate its meaning.
207 If you don't write any tag, it's implicit from the value's form.
209 .A YAML value with a tag.
211 The second `true` value below is actually a string instead of a boolean
212 because it has an explicit YAML string tag:
217 actually a string: !<tag:yaml.org,2002:str> true
221 In the example above, `tag:yaml.org,2002:str` is the standard YAML tag
224 barectf requires that the configuration file's root <<mapping,mapping>>
225 be tagged with `tag:barectf.org,2020/3/config` to identify the whole
226 mapping as a barectf configuration object.
228 You can tag the root mapping by tagging the YAML document itself:
230 .A tagged YAML document.
234 --- !<tag:barectf.org,2020/3/config>