Browse Source

Add example and type options to attributes

As described; this is used in the nodepool configuration
documentation.

Change-Id: Iad188fd69818762cc9bad927beaff55749e0385c
Ian Wienand 7 months ago
parent
commit
0210c9df03
2 changed files with 16 additions and 0 deletions
  1. 2
    0
      doc/source/examples.rst
  2. 14
    0
      zuul_sphinx/zuul.py

+ 2
- 0
doc/source/examples.rst View File

@@ -11,6 +11,8 @@ Configuration Attributes
11 11
 
12 12
    .. attr:: foo
13 13
       :default: bar
14
+      :example: sample_value_for_example_attr
15
+      :type: str
14 16
 
15 17
       A sub attribute.
16 18
 

+ 14
- 0
zuul_sphinx/zuul.py View File

@@ -328,6 +328,8 @@ class ZuulAttrDirective(ZuulObjectDescription):
328 328
         'required': lambda x: x,
329 329
         'default': lambda x: x,
330 330
         'noindex': lambda x: x,
331
+        'example': lambda x: x,
332
+        'type': lambda x: x,
331 333
     }
332 334
 
333 335
     def before_content(self):
@@ -361,6 +363,18 @@ class ZuulAttrDirective(ZuulObjectDescription):
361 363
             line += nodes.literal(self.options['default'],
362 364
                                   self.options['default'])
363 365
             signode += line
366
+        if 'example' in self.options:
367
+            line = addnodes.desc_signature_line()
368
+            line += addnodes.desc_type('Example: ', 'Example: ')
369
+            line += nodes.literal(self.options['example'],
370
+                                  self.options['example'])
371
+            signode += line
372
+        if 'type' in self.options:
373
+            line = addnodes.desc_signature_line()
374
+            line += addnodes.desc_type('Type: ', 'Type: ')
375
+            line += nodes.emphasis(self.options['type'],
376
+                                   self.options['type'])
377
+            signode += line
364 378
         return sig
365 379
 
366 380
 

Loading…
Cancel
Save