File: fix-term.py-for-latest-docutils.patch

package info (click to toggle)
watcher 15.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,216 kB
  • sloc: python: 52,260; xml: 323; sh: 299; makefile: 78
file content (38 lines) | stat: -rw-r--r-- 1,760 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Description: Fix term.py for latest docutils
 The WatcherTerm.run() method where self.result (a ViewList) was being passed
 to nested_parse, but the source information was not properly set up.
Author: Thomas Goirand <zigo@debian.org>
Bug-Debian: https://bugs.debian.org/1118332
Forwarded: https://review.opendev.org/c/openstack/watcher/+/964762
Last-Update: 2025-10-24

Index: watcher/doc/ext/term.py
===================================================================
--- watcher.orig/doc/ext/term.py
+++ watcher/doc/ext/term.py
@@ -37,11 +37,22 @@ class BaseWatcherDirective(rst.Directive
 
     def add_line(self, line, *lineno):
         """Append one line of generated reST to the output."""
-        self.result.append(line, rst.directives.unchanged, *lineno)
+        # Provide a proper source string to avoid issues with newer docutils
+        # Try to get the actual source file, fallback to class name
+        source = getattr(self.state.document, 'current_source', None)
+        if source is None:
+            source = f'<watcher-{self.__class__.__name__.lower()}>'
+
+        # Handle lineno properly - use the first arg from *lineno if provided, otherwise use self.lineno
+        actual_lineno = lineno[0] if lineno else getattr(self, "lineno", 0)
+
+        # For newer docutils, ensure source is always a string
+        self.result.append(line, source, actual_lineno)
 
     def add_textblock(self, textblock):
-        for line in textblock.splitlines():
-            self.add_line(line)
+        base_lineno = getattr(self, "lineno", 0)
+        for i, line in enumerate(textblock.splitlines()):
+            self.add_line(line, base_lineno + i)
 
     def add_object_docstring(self, obj):
         obj_raw_docstring = obj.__doc__ or ""