blob: 6a7256e266746c3aa95d1a64cb4b89a6494be8f7 [file] [log] [blame]
James E. Blair32df6d82017-08-03 14:20:04 -07001Documentation
2=============
3
4This is a brief style guide for Zuul documentation.
5
6ReStructuredText Conventions
7----------------------------
8
9Code Blocks
10~~~~~~~~~~~
11
12When showing a YAML example, use the ``.. code-block:: yaml``
13directive so that the sample appears as a code block with the correct
14syntax highlighting.
15
16Literal Values
17~~~~~~~~~~~~~~
18
19Filenames and literal values (such as when we instruct a user to type
20a specific string into a configuration file) should use the RST
21````literal```` syntax.
22
James E. Blair97940192017-08-03 14:47:47 -070023YAML supports boolean values expressed with or without an initial
24capital letter. In examples and documentation, use ``true`` and
25``false`` in lowercase type because the resulting YAML is easier for
26users to type and read.
27
James E. Blair32df6d82017-08-03 14:20:04 -070028Terminology
29~~~~~~~~~~~
30
31Zuul employs some specialized terminology. To help users become
32acquainted with it, we employ a glossary. Observe the following:
33
34* Specialized terms should have entries in the glossary.
35
36* If the term is being defined in the text, don't link to the glossary
37 (that would be redundant), but do emphasize it with ``*italics*``
38 the first time it appears in that definition. Subsequent uses
39 within the same subsection should be in regular type.
40
41* If it's being used (but not defined) in the text, link the first
42 usage within a subsection to the glossary using the ``:term:`` role,
43 but subsequent uses should be in regular type.
44
45* Be cognizant of how readers may jump to link targets within the
46 text, so be liberal in considering that once you cross a link
47 target, you may be in a new "subsection" for the above guideline.
48
49
50Zuul Sphinx Directives
51----------------------
52
53The following extra Sphinx directives are available in the ``zuul``
54domain. The ``zuul`` domain is configured as the default domain, so the
55``zuul:`` prefix may be omitted.
56
57zuul:attr::
58~~~~~~~~~~~
59
60This should be used when documenting Zuul configuration attributes.
61Zuul configuration is heavily hierarchical, and this directive
62facilitates documenting these by emphasising the hierarchy as
63appropriate. It will annotate each configuration attribute with a
64nice header with its own unique hyperlink target. It displays the
65entire hierarchy of the attribute, but emphasises the last portion
66(i.e., the field being documented).
67
68To use the hierarchical features, simply nest with indendtation in the
69normal RST manner.
70
71It supports the ``required`` and ``default`` options and will annotate
72the header appropriately. Example:
73
74.. code-block:: rst
75
76 .. attr:: foo
77
78 Some text about ``foo``.
79
80 .. attr:: bar
81 :required:
82 :default: 42
83
84 Text about ``foo.bar``.
85
86.. attr:: foo
87 :noindex:
88
89 Some text about ``foo``.
90
91 .. attr:: bar
92 :noindex:
93 :required:
94 :default: 42
95
96 Text about ``foo.bar``.
97
98zuul:value::
99~~~~~~~~~~~~
100
101Similar to zuul:attr, but used when documenting a literal value of an
102attribute.
103
104.. code-block:: rst
105
106 .. attr:: foo
107
108 Some text about foo. It supports the following values:
109
110 .. value:: bar
111
112 One of the supported values for ``foo`` is ``bar``.
113
114 .. value:: baz
115
116 Another supported values for ``foo`` is ``baz``.
117
118.. attr:: foo
119 :noindex:
120
121 Some text about foo. It supports the following values:
122
123 .. value:: bar
124 :noindex:
125
126 One of the supported values for ``foo`` is ``bar``.
127
128 .. value:: baz
129 :noindex:
130
131 Another supported values for ``foo`` is ``baz``.
132
133zuul:var::
134~~~~~~~~~~
135
136Also similar to zuul:attr, but used when documenting an Ansible
137variable which is available to a job's playbook. In these cases, it's
138often necessary to indicate the variable may be an element of a list
139or dictionary, so this directive supports a ``type`` option. It also
140supports the ``hidden`` option so that complex data structure
141definitions may continue across sections. To use this, set the hidden
142option on a ``zuul:var::`` directive with the root of the data
143structure as the name. Example:
144
145.. code-block:: rst
146
147 .. var:: foo
148
149 Foo is a dictionary with the following keys:
150
151 .. var:: items
152 :type: list
153
154 Items is a list of dictionaries with the following keys:
155
156 .. var:: bar
157
158 Text about bar
159
160 Section Boundary
161
162 .. var:: foo
163 :hidden:
164
165 .. var:: baz
166
167 Text about baz
168
169.. End of code block; start example
170
171.. var:: foo
172 :noindex:
173
174 Foo is a dictionary with the following keys:
175
176 .. var:: items
177 :noindex:
178 :type: list
179
180 Items is a list of dictionaries with the following keys:
181
182 .. var:: bar
183 :noindex:
184
185 Text about bar
186
187Section Boundary
188
189.. var:: foo
190 :noindex:
191 :hidden:
192
193 .. var:: baz
194 :noindex:
195
196 Text about baz
197
198.. End of example
199
200Zuul Sphinx Roles
201-----------------
202
203The following extra Sphinx roles are available. Use these within the
204text when referring to attributes, values, and variables defined with
205the directives above. Use these roles for the first appearance of an
206object within a subsection, but use the ````literal```` role in
207subsequent uses.
208
209:zuul:attr:
210~~~~~~~~~~~
211
212This creates a reference to the named attribute. Provide the fully
213qualified name (e.g., ``:attr:`pipeline.manager```)
214
215:zuul:value:
216~~~~~~~~~~~~
217
218This creates a reference to the named value. Provide the fully
219qualified name (e.g., ``:attr:`pipeline.manager.dependent```)
220
221:zuul:var:
222~~~~~~~~~~
223
224This creates a reference to the named variable. Provide the fully
225qualified name (e.g., ``:var:`zuul.executor.name```)