James E. Blair | 32df6d8 | 2017-08-03 14:20:04 -0700 | [diff] [blame^] | 1 | Documentation |
| 2 | ============= |
| 3 | |
| 4 | This is a brief style guide for Zuul documentation. |
| 5 | |
| 6 | ReStructuredText Conventions |
| 7 | ---------------------------- |
| 8 | |
| 9 | Code Blocks |
| 10 | ~~~~~~~~~~~ |
| 11 | |
| 12 | When showing a YAML example, use the ``.. code-block:: yaml`` |
| 13 | directive so that the sample appears as a code block with the correct |
| 14 | syntax highlighting. |
| 15 | |
| 16 | Literal Values |
| 17 | ~~~~~~~~~~~~~~ |
| 18 | |
| 19 | Filenames and literal values (such as when we instruct a user to type |
| 20 | a specific string into a configuration file) should use the RST |
| 21 | ````literal```` syntax. |
| 22 | |
| 23 | Terminology |
| 24 | ~~~~~~~~~~~ |
| 25 | |
| 26 | Zuul employs some specialized terminology. To help users become |
| 27 | acquainted 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 | |
| 45 | Zuul Sphinx Directives |
| 46 | ---------------------- |
| 47 | |
| 48 | The following extra Sphinx directives are available in the ``zuul`` |
| 49 | domain. The ``zuul`` domain is configured as the default domain, so the |
| 50 | ``zuul:`` prefix may be omitted. |
| 51 | |
| 52 | zuul:attr:: |
| 53 | ~~~~~~~~~~~ |
| 54 | |
| 55 | This should be used when documenting Zuul configuration attributes. |
| 56 | Zuul configuration is heavily hierarchical, and this directive |
| 57 | facilitates documenting these by emphasising the hierarchy as |
| 58 | appropriate. It will annotate each configuration attribute with a |
| 59 | nice header with its own unique hyperlink target. It displays the |
| 60 | entire hierarchy of the attribute, but emphasises the last portion |
| 61 | (i.e., the field being documented). |
| 62 | |
| 63 | To use the hierarchical features, simply nest with indendtation in the |
| 64 | normal RST manner. |
| 65 | |
| 66 | It supports the ``required`` and ``default`` options and will annotate |
| 67 | the 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 | |
| 93 | zuul:value:: |
| 94 | ~~~~~~~~~~~~ |
| 95 | |
| 96 | Similar to zuul:attr, but used when documenting a literal value of an |
| 97 | attribute. |
| 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 | |
| 128 | zuul:var:: |
| 129 | ~~~~~~~~~~ |
| 130 | |
| 131 | Also similar to zuul:attr, but used when documenting an Ansible |
| 132 | variable which is available to a job's playbook. In these cases, it's |
| 133 | often necessary to indicate the variable may be an element of a list |
| 134 | or dictionary, so this directive supports a ``type`` option. It also |
| 135 | supports the ``hidden`` option so that complex data structure |
| 136 | definitions may continue across sections. To use this, set the hidden |
| 137 | option on a ``zuul:var::`` directive with the root of the data |
| 138 | structure 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 | |
| 182 | Section 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 | |
| 195 | Zuul Sphinx Roles |
| 196 | ----------------- |
| 197 | |
| 198 | The following extra Sphinx roles are available. Use these within the |
| 199 | text when referring to attributes, values, and variables defined with |
| 200 | the directives above. Use these roles for the first appearance of an |
| 201 | object within a subsection, but use the ````literal```` role in |
| 202 | subsequent uses. |
| 203 | |
| 204 | :zuul:attr: |
| 205 | ~~~~~~~~~~~ |
| 206 | |
| 207 | This creates a reference to the named attribute. Provide the fully |
| 208 | qualified name (e.g., ``:attr:`pipeline.manager```) |
| 209 | |
| 210 | :zuul:value: |
| 211 | ~~~~~~~~~~~~ |
| 212 | |
| 213 | This creates a reference to the named value. Provide the fully |
| 214 | qualified name (e.g., ``:attr:`pipeline.manager.dependent```) |
| 215 | |
| 216 | :zuul:var: |
| 217 | ~~~~~~~~~~ |
| 218 | |
| 219 | This creates a reference to the named variable. Provide the fully |
| 220 | qualified name (e.g., ``:var:`zuul.executor.name```) |