summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Wienand <iwienand@redhat.com>2019-03-06 11:11:46 +1100
committerIan Wienand <iwienand@redhat.com>2019-03-11 16:53:37 +1100
commit6a0034ebcabc86ec60f8fbb96303840e6b503a2e (patch)
tree2f675fc3700b1e6269cc8c06f19c280d34d5c58f
parent1a2258eb5c8635e2f16fe8574e81888fc78d6fc8 (diff)
Add type to role variablesHEAD0.4.0master
This brings this documentation into line with other values like attr where you can specify the type of the variable. The type output is added to each entry where appropriate, one minor change is that we need to be less strict on the type lookup for the hint suffix on sub-entries for types like "bool" The documentation/test-case is updated. Change-Id: Icc01ec6f04af97beeb085f6dbcf37b0d9dbed1fd
Notes
Notes (review): Code-Review+2: James E. Blair <corvus@inaugust.com> Code-Review+2: Jens Harbott (frickler) <j.harbott@x-ion.de> Workflow+1: Jens Harbott (frickler) <j.harbott@x-ion.de> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 12 Mar 2019 10:32:21 +0000 Reviewed-on: https://review.openstack.org/641168 Project: openstack-infra/zuul-sphinx Branch: refs/heads/master
-rw-r--r--doc/source/example-roles.rst15
-rw-r--r--zuul_sphinx/zuul.py8
2 files changed, 22 insertions, 1 deletions
diff --git a/doc/source/example-roles.rst b/doc/source/example-roles.rst
index b32022e..afa9539 100644
--- a/doc/source/example-roles.rst
+++ b/doc/source/example-roles.rst
@@ -25,6 +25,21 @@ Roles
25 25
26 This is an item in a list. 26 This is an item in a list.
27 27
28 .. rolevar:: dict
29 :type: dict
30
31 This variable is a dict.
32
33 .. rolevar:: key
34
35 This is a key which should be assigned a value.
36
37 .. rolevar:: flag-value
38 :type: bool
39 :default: False
40
41 A variable which should be assigned a True/False value.
42
28This is an (Ansible) role (Sphinx) role: :role:`example` 43This is an (Ansible) role (Sphinx) role: :role:`example`
29 44
30This is an (Ansible) role variable (Sphinx) role: :rolevar:`example.items.baz` 45This is an (Ansible) role variable (Sphinx) role: :rolevar:`example.items.baz`
diff --git a/zuul_sphinx/zuul.py b/zuul_sphinx/zuul.py
index 37a6bd3..32b5e0c 100644
--- a/zuul_sphinx/zuul.py
+++ b/zuul_sphinx/zuul.py
@@ -404,7 +404,7 @@ class ZuulVarDirective(ZuulObjectDescription):
404 } 404 }
405 405
406 def get_type_str(self): 406 def get_type_str(self):
407 if 'type' in self.options: 407 if 'type' in self.options and self.options['type'] in self.type_map:
408 return self.type_map[self.options['type']] 408 return self.type_map[self.options['type']]
409 return '' 409 return ''
410 410
@@ -443,6 +443,12 @@ class ZuulVarDirective(ZuulObjectDescription):
443 line += nodes.literal(self.options['default'], 443 line += nodes.literal(self.options['default'],
444 self.options['default']) 444 self.options['default'])
445 signode += line 445 signode += line
446 if 'type' in self.options:
447 line = addnodes.desc_signature_line()
448 line += addnodes.desc_type('Type: ', 'Type: ')
449 line += nodes.emphasis(self.options['type'],
450 self.options['type'])
451 signode += line
446 return sig 452 return sig
447 453
448 454