From 6b9fa90602d41cd51265e402c2009d1a03fe730d Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Tue, 4 Sep 2018 11:04:10 +1000 Subject: [PATCH] Improve warning details Currently, if you make a warning mistake in your inline YAML you get warning output like: Warning, treated as error: /home/.../zuul.d:728:Unexpected indentation. This doesn't give you any clue as to what was actually wrong. Rework adding the content so that we add the job/template name as the source. You'll now get something like: Warning, treated as error: Job "failing-job" included in /home/.../doc/source/jobs.rst:6:Unexpected indentation. which lets you know the job/template that is causing the error, and where the auto include was sourced from. Change-Id: I3144cb9bf689724d113c9b4b126f975f34f565c3 --- zuul_sphinx/zuul.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/zuul_sphinx/zuul.py b/zuul_sphinx/zuul.py index df3895d..29f1d84 100644 --- a/zuul_sphinx/zuul.py +++ b/zuul_sphinx/zuul.py @@ -480,15 +480,17 @@ class ZuulAutoJobsDirective(ZuulDirective): has_content = False def run(self): - lines = [] + env = self.state.document.settings.env names = set() for job in self.zuul_layout.jobs: name = job['name'] if name in names: continue - lines.extend(self.generate_zuul_job_content(name)) + lines = self.generate_zuul_job_content(name) + location = 'Job "%s" included in %s' % \ + (name, env.doc2path(env.docname)) + self.state_machine.insert_input(lines, location) names.add(name) - self.state_machine.insert_input(lines, self.zuul_layout_path) return [] class ZuulAutoProjectTemplateDirective(ZuulDirective): @@ -503,15 +505,17 @@ class ZuulAutoProjectTemplatesDirective(ZuulDirective): has_content = False def run(self): - lines = [] + env = self.state.document.settings.env names = set() for template in self.zuul_layout.project_templates: name = template.name if name in names: continue - lines.extend(self.generate_zuul_project_template_content(name)) + lines = self.generate_zuul_project_template_content(name) + location = 'Template "%s" included in %s' % \ + (name, env.doc2path(env.docname)) + self.state_machine.insert_input(lines, location) names.add(name) - self.state_machine.insert_input(lines, self.zuul_layout_path) return []