summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Wienand <iwienand@redhat.com>2018-08-20 13:21:32 +1000
committerIan Wienand <iwienand@redhat.com>2018-08-20 14:42:17 +1000
commit06eadf8e730ee3c9833541aa3e70988d87100e45 (patch)
tree088d2c9e4346be48b84f1bc6997580105a21606c
parent44012c032bd53fd92543aa374cb974dc33eafc88 (diff)
Add config option to find other roles0.2.3
Add a new option to provide an additional list of directories to look for roles to document. Additionally, allow the 'roles/' top-level directory to not exist. Needed-By: https://review.openstack.org/593478 Change-Id: I997c8bbece4917fe041aa9fd3dde13ee532fa2a6
Notes
Notes (review): Code-Review+2: James E. Blair <corvus@inaugust.com> Code-Review+2: Monty Taylor <mordred@inaugust.com> Workflow+1: Monty Taylor <mordred@inaugust.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 21 Aug 2018 21:30:14 +0000 Reviewed-on: https://review.openstack.org/593477 Project: openstack-infra/zuul-sphinx Branch: refs/heads/master
-rw-r--r--README.rst8
-rw-r--r--zuul_sphinx/zuul.py19
2 files changed, 21 insertions, 6 deletions
diff --git a/README.rst b/README.rst
index bb250f8..814cfde 100644
--- a/README.rst
+++ b/README.rst
@@ -2,3 +2,11 @@ Zuul Sphinx
2=========== 2===========
3 3
4A Sphinx extension for documenting Zuul jobs. 4A Sphinx extension for documenting Zuul jobs.
5
6Config options
7--------------
8
9``zuul_role_path``
10 (str list)
11 List of extra paths to examine for role documentation (other than
12 ``roles/``)
diff --git a/zuul_sphinx/zuul.py b/zuul_sphinx/zuul.py
index 7e8463a..df3895d 100644
--- a/zuul_sphinx/zuul.py
+++ b/zuul_sphinx/zuul.py
@@ -164,14 +164,20 @@ class ZuulDirective(Directive):
164 return lines 164 return lines
165 165
166 def find_zuul_roles(self): 166 def find_zuul_roles(self):
167 root = os.path.dirname(self.zuul_layout_path)
168 roledir = os.path.join(root, 'roles')
169 env = self.state.document.settings.env 167 env = self.state.document.settings.env
168 _root = os.path.dirname(self.zuul_layout_path)
169 root_roledir = os.path.join(_root, 'roles')
170 role_dirs = []
171 if os.path.isdir(root_roledir):
172 role_dirs = [root_roledir,]
173 if env.config.zuul_role_paths:
174 role_dirs.extend(env.config.zuul_role_paths)
170 roles = env.domaindata['zuul']['role_paths'] 175 roles = env.domaindata['zuul']['role_paths']
171 for p in os.listdir(roledir): 176 for d in role_dirs:
172 role_readme = os.path.join(roledir, p, 'README.rst') 177 for p in os.listdir(d):
173 if os.path.exists(role_readme): 178 role_readme = os.path.join(d, p, 'README.rst')
174 roles[p] = role_readme 179 if os.path.exists(role_readme):
180 roles[p] = role_readme
175 181
176 @property 182 @property
177 def zuul_role_paths(self): 183 def zuul_role_paths(self):
@@ -613,4 +619,5 @@ class ZuulDomain(Domain):
613 619
614 620
615def setup(app): 621def setup(app):
622 app.add_config_value('zuul_role_paths', [], 'html')
616 app.add_domain(ZuulDomain) 623 app.add_domain(ZuulDomain)