diff mbox series

[5.1,56/85] doc: Cope with the deprecation of AutoReporter

Message ID 20190607153855.717899507@linuxfoundation.org
State Superseded
Headers show
Series None | expand

Commit Message

Greg Kroah-Hartman June 7, 2019, 3:39 p.m. UTC
From: Jonathan Corbet <corbet@lwn.net>


commit 2404dad1f67f8917e30fc22a85e0dbcc85b99955 upstream.

AutoReporter is going away; recent versions of sphinx emit a warning like:

  Documentation/sphinx/kerneldoc.py:125:
      RemovedInSphinx20Warning: AutodocReporter is now deprecated.
      Use sphinx.util.docutils.switch_source_input() instead.

Make the switch.  But switch_source_input() only showed up in 1.7, so we
have to do ugly version checks to keep things working in older versions.

Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


---
 Documentation/sphinx/kerneldoc.py |   34 ++++++++++++++++++++++++++--------
 1 file changed, 26 insertions(+), 8 deletions(-)

Comments

Jiri Slaby June 10, 2019, 7:56 a.m. UTC | #1
On 10. 06. 19, 9:48, Greg Kroah-Hartman wrote:
>> [  103s] Running Sphinx v1.8.5

> 

> Hm, 2.1 here:

> 	Running Sphinx v2.1.0

> perhaps Tumbleweed needs to update?  :)


Heh, it was submitted 3 days ago :):
  https://build.opensuse.org/request/show/708276
(And is blocked by a failing sphinx-test AFAICT.)

> Anyway, this should not be breaking, if Jon doesn't have any ideas, I'll

> just drop these changes.


OK. In the meantime, I have reverted the commit in Kernel:stable for the
time being.

thanks,
-- 
js
suse labs
Jonathan Corbet June 10, 2019, 12:33 p.m. UTC | #2
On Mon, 10 Jun 2019 09:48:40 +0200
Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:

> Hm, 2.1 here:

> 	Running Sphinx v2.1.0

> perhaps Tumbleweed needs to update?  :)


Heh...trying 2.1 is still on my list of things to do ... :)

> Anyway, this should not be breaking, if Jon doesn't have any ideas, I'll

> just drop these changes.


The fix for that is 551bd3368a7b (drm/i915: Maintain consistent
documentation subsection ordering) which was also marked for stable.  Jiri,
do you somehow not have that one?

Thanks,

jon
Jiri Slaby June 11, 2019, 8:50 a.m. UTC | #3
On 10. 06. 19, 16:39, Greg Kroah-Hartman wrote:
>>>> The fix for that is 551bd3368a7b (drm/i915: Maintain consistent

>>>> documentation subsection ordering) which was also marked for stable.  Jiri,

>>>> do you somehow not have that one?

>>>

>>> It's part of this series, which is probably why it works for me.  Don't

>>> know why it doesn't work for Jiri, unless he is cherry-picking things?

>>>

>>

>> Actualliy it is not.

>>

>> This patch Jiri responded to / points out to break stuff is part of 5.1.8,

>> but the fix in in review queue for 5.1.9 :

>>

>> https://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git/diff/queue-5.1/drm-i915-maintain-consistent-documentation-subsection-ordering.patch?id=29167bff7a1c0d79dda104c44c262b0bc4cd6644

> 

> Ah, that makes more sense, and is why my build works for me :)

> 

> Jiri, wait a few days and this will get fixed...


No problem. I just pushed this one and 5.1.9 will dispose it later.

thanks,
-- 
js
suse labs
diff mbox series

Patch

--- a/Documentation/sphinx/kerneldoc.py
+++ b/Documentation/sphinx/kerneldoc.py
@@ -37,7 +37,17 @@  import glob
 from docutils import nodes, statemachine
 from docutils.statemachine import ViewList
 from docutils.parsers.rst import directives, Directive
-from sphinx.ext.autodoc import AutodocReporter
+
+#
+# AutodocReporter is only good up to Sphinx 1.7
+#
+import sphinx
+
+Use_SSI = sphinx.__version__[:3] >= '1.7'
+if Use_SSI:
+    from sphinx.util.docutils import switch_source_input
+else:
+    from sphinx.ext.autodoc import AutodocReporter
 
 __version__  = '1.0'
 
@@ -121,13 +131,7 @@  class KernelDocDirective(Directive):
                     lineoffset += 1
 
             node = nodes.section()
-            buf = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter
-            self.state.memo.reporter = AutodocReporter(result, self.state.memo.reporter)
-            self.state.memo.title_styles, self.state.memo.section_level = [], 0
-            try:
-                self.state.nested_parse(result, 0, node, match_titles=1)
-            finally:
-                self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = buf
+            self.do_parse(result, node)
 
             return node.children
 
@@ -136,6 +140,20 @@  class KernelDocDirective(Directive):
                          (" ".join(cmd), str(e)))
             return [nodes.error(None, nodes.paragraph(text = "kernel-doc missing"))]
 
+    def do_parse(self, result, node):
+        if Use_SSI:
+            with switch_source_input(self.state, result):
+                self.state.nested_parse(result, 0, node, match_titles=1)
+        else:
+            save = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter
+            self.state.memo.reporter = AutodocReporter(result, self.state.memo.reporter)
+            self.state.memo.title_styles, self.state.memo.section_level = [], 0
+            try:
+                self.state.nested_parse(result, 0, node, match_titles=1)
+            finally:
+                self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = save
+
+
 def setup(app):
     app.add_config_value('kerneldoc_bin', None, 'env')
     app.add_config_value('kerneldoc_srctree', None, 'env')