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