linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Linux Doc Mailing List <linux-doc@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Mauro Carvalho Chehab" <mchehab+huawei@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 14/33] docs: kernel_abi.py: make it compatible with Sphinx 1.7+
Date: Wed, 28 Oct 2020 15:23:12 +0100	[thread overview]
Message-ID: <b51e7b564b8d8403ea537dba67c82db40b420257.1603893146.git.mchehab+huawei@kernel.org> (raw)
In-Reply-To: <cover.1603893146.git.mchehab+huawei@kernel.org>

From: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

The same way kerneldoc.py needed changes to work with newer
Sphinx, this script needs the same changes.

While here, reorganize the include order to match kerneldoc.py.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 Documentation/sphinx/kernel_abi.py | 39 +++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/Documentation/sphinx/kernel_abi.py b/Documentation/sphinx/kernel_abi.py
index fe69c213716d..8601a3b75a28 100644
--- a/Documentation/sphinx/kernel_abi.py
+++ b/Documentation/sphinx/kernel_abi.py
@@ -33,18 +33,27 @@ u"""
 """
 
 import codecs
-import sys
 import os
-from os import path
 import subprocess
+import sys
 
-from sphinx.ext.autodoc import AutodocReporter
+from os import path
 
-from docutils import nodes
-from docutils.parsers.rst import Directive, directives
+from docutils import nodes, statemachine
 from docutils.statemachine import ViewList
+from docutils.parsers.rst import directives, Directive
 from docutils.utils.error_reporting import ErrorString
 
+#
+# 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'
 
@@ -142,11 +151,17 @@ class KernelCmd(Directive):
             content.append(l, fname, c)
 
         buf  = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter
-        self.state.memo.title_styles  = []
-        self.state.memo.section_level = 0
-        self.state.memo.reporter      = AutodocReporter(content, self.state.memo.reporter)
-        try:
-            self.state.nested_parse(content, 0, node, match_titles=1)
-        finally:
-            self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = buf
+
+        if Use_SSI:
+            with switch_source_input(self.state, content):
+                self.state.nested_parse(content, 0, node, match_titles=1)
+        else:
+            self.state.memo.title_styles  = []
+            self.state.memo.section_level = 0
+            self.state.memo.reporter      = AutodocReporter(content, self.state.memo.reporter)
+            try:
+                self.state.nested_parse(content, 0, node, match_titles=1)
+            finally:
+                self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = buf
+
         return node.children
-- 
2.26.2


  parent reply	other threads:[~2020-10-29  0:34 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-28 14:22 [PATCH 00/33] ABI: add it to the documentation build system Mauro Carvalho Chehab
2020-10-28 14:22 ` [PATCH 01/33] scripts: get_abi.pl: change script to allow parsing in ReST mode Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 02/33] scripts: get_abi.pl: fix parsing on " Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 03/33] scripts: get_abi.pl: Allow optionally record from where a line came from Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 04/33] scripts: get_abi.pl: improve its parser to better catch up indentation Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 05/33] scripts: get_abi.pl: cleanup ABI cross-reference logic Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 06/33] scripts: get_abi.pl: detect duplicated ABI definitions Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 07/33] scripts: get_abi.pl: output users in ReST format Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 08/33] scripts: get_abi.pl: prevent duplicated file names Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 09/33] scripts: get_abi.pl: use bold font for ABI definitions Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 10/33] scripts: get_abi.pl: auto-generate cross references Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 11/33] docs: kernellog.py: add support for info() Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 12/33] docs: kernel_abi.py: add a script to parse ABI documentation Mauro Carvalho Chehab
2020-10-28 16:21   ` Jonathan Corbet
2020-10-28 17:02     ` Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 13/33] docs: kernel_abi.py: fix UTF-8 support Mauro Carvalho Chehab
2020-10-28 14:23 ` Mauro Carvalho Chehab [this message]
2020-10-28 14:23 ` [PATCH 15/33] docs: kernel_abi.py: use --enable-lineno for get_abi.pl Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 16/33] docs: kernel_abi.py: Handle with a lazy Sphinx parser Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 17/33] docs: add ABI documentation to the admin-guide book Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 18/33] docs: ABI: README: specify that files should be ReST compatible Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 19/33] docs: ABI: stable: make files " Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 20/33] docs: ABI: testing: make the files compatible with ReST output Mauro Carvalho Chehab
2020-10-28 17:44   ` Richard Cochran
2020-10-29  7:21     ` Mauro Carvalho Chehab
2020-10-29 14:49   ` Jonathan Cameron
2020-10-30  7:11     ` Mauro Carvalho Chehab
2020-11-02 15:06   ` Gautham R Shenoy
2020-10-28 14:23 ` [PATCH 21/33] docs: ABI: make it parse ABI/stable as ReST-compatible files Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 22/33] docs: ABI: create a 2-depth index for ABI Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 23/33] docs: ABI: don't escape ReST-incompatible chars from obsolete and removed Mauro Carvalho Chehab
2020-11-05 13:56   ` Linus Walleij
2020-10-28 14:23 ` [PATCH 24/33] docs: abi-testing.rst: enable --rst-sources when building docs Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 25/33] docs: Kconfig/Makefile: add a check for broken ABI files Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 26/33] docs: ABI: convert testing/configfs-acpi to ReST Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 27/33] docs: ABI: fix syntax to be parsed using ReST notation Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 28/33] docs: ABI: vdso: use the right format for ABI Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 29/33] docs: ABI: sysfs-bus-nvdimm: " Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 30/33] docs: ABI: cleanup several ABI documents Mauro Carvalho Chehab
2020-10-29 14:42   ` Jonathan Cameron
2020-10-29 15:29     ` kajoljain
2020-10-29 16:14       ` Oded Gabbay
2020-10-29 14:54   ` Tom Rix
2020-10-30  6:33   ` Vaibhav Jain
2020-10-30  7:52   ` Jinpu Wang
2020-11-03 15:24   ` Bjorn Andersson
2020-10-28 14:23 ` [PATCH 31/33] docs: ABI: change read/write attributes Mauro Carvalho Chehab
2020-10-28 14:23 ` [PATCH 32/33] docs: ABI: stable: remove a duplicated documentation Mauro Carvalho Chehab
2020-10-28 14:57   ` Wei Liu
2020-10-28 14:23 ` [PATCH 33/33] docs: ABI: unify /sys/class/leds/<led>/max_brightness documentation Mauro Carvalho Chehab
2020-10-29 17:16   ` Pavel Machek
2020-10-29 22:11   ` Jacek Anaszewski
2020-10-28 14:39 ` [PATCH 00/33] ABI: add it to the documentation build system Greg Kroah-Hartman
2020-10-28 15:10   ` Mauro Carvalho Chehab
2020-10-28 14:43 ` Greg Kroah-Hartman
2020-10-28 16:22   ` Jonathan Corbet
2020-10-28 16:54     ` Greg Kroah-Hartman
2020-10-29  9:07   ` Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b51e7b564b8d8403ea537dba67c82db40b420257.1603893146.git.mchehab+huawei@kernel.org \
    --to=mchehab+huawei@kernel.org \
    --cc=corbet@lwn.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab+samsung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).