Add example and type options to attributes

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

Change-Id: Iad188fd69818762cc9bad927beaff55749e0385c
This commit is contained in:
Ian Wienand 2018-09-21 15:54:53 +10:00
parent 0165692e62
commit 0210c9df03
2 changed files with 16 additions and 0 deletions

View File

@ -11,6 +11,8 @@ Configuration Attributes
.. attr:: foo
:default: bar
:example: sample_value_for_example_attr
:type: str
A sub attribute.

View File

@ -328,6 +328,8 @@ class ZuulAttrDirective(ZuulObjectDescription):
'required': lambda x: x,
'default': lambda x: x,
'noindex': lambda x: x,
'example': lambda x: x,
'type': lambda x: x,
}
def before_content(self):
@ -361,6 +363,18 @@ class ZuulAttrDirective(ZuulObjectDescription):
line += nodes.literal(self.options['default'],
self.options['default'])
signode += line
if 'example' in self.options:
line = addnodes.desc_signature_line()
line += addnodes.desc_type('Example: ', 'Example: ')
line += nodes.literal(self.options['example'],
self.options['example'])
signode += line
if 'type' in self.options:
line = addnodes.desc_signature_line()
line += addnodes.desc_type('Type: ', 'Type: ')
line += nodes.emphasis(self.options['type'],
self.options['type'])
signode += line
return sig