diff --git a/doc/source/examples.rst b/doc/source/examples.rst index ad175cb..3986fd8 100644 --- a/doc/source/examples.rst +++ b/doc/source/examples.rst @@ -11,6 +11,8 @@ Configuration Attributes .. attr:: foo :default: bar + :example: sample_value_for_example_attr + :type: str A sub attribute. diff --git a/zuul_sphinx/zuul.py b/zuul_sphinx/zuul.py index c9dbf01..a2e6381 100644 --- a/zuul_sphinx/zuul.py +++ b/zuul_sphinx/zuul.py @@ -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