Skip to content

Commit 1d31c6f

Browse files
committed
dt-bindings: writing-schema: Add details on YAML text blocks
The YAML format has a couple of different forms for multi-line text blocks which control allowed characters and handling of line-breaks. Getting this wrong is a common review issue. Either a literal block is used when there's no formatting needed or a folded/literal block is not used when there is formatting to maintain. Add some descriptions of the different forms to point folks to in reviews. Reviewed-by: Conor Dooley <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rob Herring (Arm) <[email protected]>
1 parent 29bf311 commit 1d31c6f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Documentation/devicetree/bindings/writing-schema.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,36 @@ description
4343
or device does, standards the device conforms to, and links to datasheets for
4444
more information.
4545

46+
The YAML format has several options for defining the formatting of the text
47+
block. The options are controlled with indicator characters following the key
48+
(e.g. "description: \|"). The minimum formatting needed for a block should be
49+
used. The formatting controls can not only affect whether the YAML can be
50+
parsed correctly, but are important when the text blocks are rendered to
51+
another form. The options are as follows.
52+
53+
The default without any indicators is flowed, plain scalar style where single
54+
line breaks and leading whitespace are stripped. Paragraphs are delimited by
55+
blank lines (i.e. double line break). This style cannot contain ": " in it as
56+
it will be interpretted as a key. Any " #" sequence will be interpretted as
57+
a comment. There's other restrictions on characters as well. Most
58+
restrictions are on what the first character can be.
59+
60+
The second style is folded which is indicated by ">" character. In addition
61+
to maintaining line breaks on double line breaks, the folded style also
62+
maintains leading whitespace beyond indentation of the first line. The line
63+
breaks on indented lines are also maintained.
64+
65+
The third style is literal which is indicated by "\|" character. The literal
66+
style maintains all line breaks and whitespace (beyond indentation of the
67+
first line).
68+
69+
The above is not a complete description of YAML text blocks. More details on
70+
multi-line YAML text blocks can be found online:
71+
72+
https://yaml-multiline.info/
73+
74+
https://www.yaml.info/learn/quote.html
75+
4676
select
4777
Optional. A json-schema used to match nodes for applying the
4878
schema. By default, without 'select', nodes are matched against their possible

0 commit comments

Comments
 (0)