Browse Source

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
Ian Wienand 7 months ago
parent
commit
6b9fa90602
1 changed files with 10 additions and 6 deletions
  1. 10
    6
      zuul_sphinx/zuul.py

+ 10
- 6
zuul_sphinx/zuul.py View File

@@ -480,15 +480,17 @@ class ZuulAutoJobsDirective(ZuulDirective):
480 480
     has_content = False
481 481
 
482 482
     def run(self):
483
-        lines = []
483
+        env = self.state.document.settings.env
484 484
         names = set()
485 485
         for job in self.zuul_layout.jobs:
486 486
             name = job['name']
487 487
             if name in names:
488 488
                 continue
489
-            lines.extend(self.generate_zuul_job_content(name))
489
+            lines = self.generate_zuul_job_content(name)
490
+            location = 'Job "%s" included in %s' % \
491
+                (name, env.doc2path(env.docname))
492
+            self.state_machine.insert_input(lines, location)
490 493
             names.add(name)
491
-        self.state_machine.insert_input(lines, self.zuul_layout_path)
492 494
         return []
493 495
 
494 496
 class ZuulAutoProjectTemplateDirective(ZuulDirective):
@@ -503,15 +505,17 @@ class ZuulAutoProjectTemplatesDirective(ZuulDirective):
503 505
     has_content = False
504 506
 
505 507
     def run(self):
506
-        lines = []
508
+        env = self.state.document.settings.env
507 509
         names = set()
508 510
         for template in self.zuul_layout.project_templates:
509 511
             name = template.name
510 512
             if name in names:
511 513
                 continue
512
-            lines.extend(self.generate_zuul_project_template_content(name))
514
+            lines = self.generate_zuul_project_template_content(name)
515
+            location = 'Template "%s" included in %s' % \
516
+                (name, env.doc2path(env.docname))
517
+            self.state_machine.insert_input(lines, location)
513 518
             names.add(name)
514
-        self.state_machine.insert_input(lines, self.zuul_layout_path)
515 519
         return []
516 520
 
517 521
 

Loading…
Cancel
Save