From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Markus Armbruster" <armbru@redhat.com>,
"Joel Stanley" <joel@jms.id.au>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Leonardo Bras" <leobras@redhat.com>,
"Halil Pasic" <pasic@linux.ibm.com>,
qemu-block@nongnu.org, "Eduardo Habkost" <eduardo@habkost.net>,
"Vladimir Sementsov-Ogievskiy" <v.sementsov-og@mail.ru>,
"Cleber Rosa" <crosa@redhat.com>,
qemu-arm@nongnu.org, "Fabiano Rosas" <farosas@suse.de>,
"Hanna Reitz" <hreitz@redhat.com>,
qemu-s390x@nongnu.org,
"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
"John Snow" <jsnow@redhat.com>, "Cédric Le Goater" <clg@kaod.org>,
"Michael Roth" <michael.roth@amd.com>,
"Aurelien Jarno" <aurelien@aurel32.net>,
"Andrew Jeffery" <andrew@aj.id.au>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Beraldo Leal" <bleal@redhat.com>,
"Eric Farman" <farman@linux.ibm.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Ani Sinha" <anisinha@redhat.com>,
"Juan Quintela" <quintela@redhat.com>,
"Eric Blake" <eblake@redhat.com>,
"Vladimir Sementsov-Ogievskiy" <vsementsov@yandex-team.ru>,
"Thomas Huth" <thuth@redhat.com>, "Kevin Wolf" <kwolf@redhat.com>,
"Peter Xu" <peterx@redhat.com>
Subject: [PULL 6/6] docs: remove Sphinx 1.x compatibility code
Date: Mon, 15 Jul 2024 13:32:41 -0400 [thread overview]
Message-ID: <20240715173241.572048-7-jsnow@redhat.com> (raw)
In-Reply-To: <20240715173241.572048-1-jsnow@redhat.com>
In general, the Use_SSI workaround is no longer needed, and neither is
the pre-1.6 logging shim for kerneldoc.
Signed-off-by: John Snow <jsnow@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-id: 20240703175235.239004-3-jsnow@redhat.com
[rebased on top of origin/master. --js]
Signed-off-by: John Snow <jsnow@redhat.com>
---
docs/sphinx/hxtool.py | 21 ++++-----------------
docs/sphinx/kerneldoc.py | 38 ++++++++++++--------------------------
docs/sphinx/kernellog.py | 28 ----------------------------
docs/sphinx/qapidoc.py | 33 +++------------------------------
4 files changed, 19 insertions(+), 101 deletions(-)
delete mode 100644 docs/sphinx/kernellog.py
diff --git a/docs/sphinx/hxtool.py b/docs/sphinx/hxtool.py
index 3729084a36c..a84723be19e 100644
--- a/docs/sphinx/hxtool.py
+++ b/docs/sphinx/hxtool.py
@@ -24,16 +24,10 @@
from docutils.statemachine import ViewList
from docutils.parsers.rst import directives, Directive
from sphinx.errors import ExtensionError
+from sphinx.util.docutils import switch_source_input
from sphinx.util.nodes import nested_parse_with_titles
import sphinx
-# Sphinx up to 1.6 uses AutodocReporter; 1.7 and later
-# use switch_source_input. Check borrowed from kerneldoc.py.
-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'
@@ -185,16 +179,9 @@ def run(self):
# of title_styles and section_level that kerneldoc.py does,
# because nested_parse_with_titles() does that for us.
def do_parse(self, result, node):
- if Use_SSI:
- with switch_source_input(self.state, result):
- nested_parse_with_titles(self.state, result, node)
- else:
- save = self.state.memo.reporter
- self.state.memo.reporter = AutodocReporter(result, self.state.memo.reporter)
- try:
- nested_parse_with_titles(self.state, result, node)
- finally:
- self.state.memo.reporter = save
+ with switch_source_input(self.state, result):
+ nested_parse_with_titles(self.state, result, node)
+
def setup(app):
""" Register hxtool-doc directive with Sphinx"""
diff --git a/docs/sphinx/kerneldoc.py b/docs/sphinx/kerneldoc.py
index 72c403a7379..3aa972f2e89 100644
--- a/docs/sphinx/kerneldoc.py
+++ b/docs/sphinx/kerneldoc.py
@@ -38,20 +38,14 @@
from docutils.statemachine import ViewList
from docutils.parsers.rst import directives, Directive
-#
-# AutodocReporter is only good up to Sphinx 1.7
-#
import sphinx
+from sphinx.util import logging
+from sphinx.util.docutils import switch_source_input
-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
-
-import kernellog
__version__ = '1.0'
+logger = logging.getLogger('kerneldoc')
+
class KernelDocDirective(Directive):
"""Extract kernel-doc comments from the specified file"""
@@ -111,8 +105,7 @@ def run(self):
cmd += [filename]
try:
- kernellog.verbose(env.app,
- 'calling kernel-doc \'%s\'' % (" ".join(cmd)))
+ logger.verbose('calling kernel-doc \'%s\'' % (" ".join(cmd)))
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
@@ -122,8 +115,10 @@ def run(self):
if p.returncode != 0:
sys.stderr.write(err)
- kernellog.warn(env.app,
- 'kernel-doc \'%s\' failed with return code %d' % (" ".join(cmd), p.returncode))
+ logger.warning(
+ 'kernel-doc \'%s\' failed with return code %d' %
+ (" ".join(cmd), p.returncode)
+ )
return [nodes.error(None, nodes.paragraph(text = "kernel-doc missing"))]
elif env.config.kerneldoc_verbosity > 0:
sys.stderr.write(err)
@@ -149,22 +144,13 @@ def run(self):
return node.children
except Exception as e: # pylint: disable=W0703
- kernellog.warn(env.app, 'kernel-doc \'%s\' processing failed with: %s' %
+ logger.warning('kernel-doc \'%s\' processing failed with: %s' %
(" ".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
+ with switch_source_input(self.state, result):
+ self.state.nested_parse(result, 0, node, match_titles=1)
def setup(app):
diff --git a/docs/sphinx/kernellog.py b/docs/sphinx/kernellog.py
deleted file mode 100644
index af924f51a7d..00000000000
--- a/docs/sphinx/kernellog.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Sphinx has deprecated its older logging interface, but the replacement
-# only goes back to 1.6. So here's a wrapper layer to keep around for
-# as long as we support 1.4.
-#
-import sphinx
-
-if sphinx.__version__[:3] >= '1.6':
- UseLogging = True
- from sphinx.util import logging
- logger = logging.getLogger('kerneldoc')
-else:
- UseLogging = False
-
-def warn(app, message):
- if UseLogging:
- logger.warning(message)
- else:
- app.warn(message)
-
-def verbose(app, message):
- if UseLogging:
- logger.verbose(message)
- else:
- app.verbose(message)
-
-
diff --git a/docs/sphinx/qapidoc.py b/docs/sphinx/qapidoc.py
index 2b06750a3cd..62b39833ca0 100644
--- a/docs/sphinx/qapidoc.py
+++ b/docs/sphinx/qapidoc.py
@@ -35,22 +35,11 @@
from qapi.gen import QAPISchemaVisitor
from qapi.schema import QAPISchema
-import sphinx
from sphinx.errors import ExtensionError
+from sphinx.util.docutils import switch_source_input
from sphinx.util.nodes import nested_parse_with_titles
-# Sphinx up to 1.6 uses AutodocReporter; 1.7 and later
-# use switch_source_input. Check borrowed from kerneldoc.py.
-USE_SSI = sphinx.__version__[:3] >= "1.7"
-if USE_SSI:
- from sphinx.util.docutils import switch_source_input
-else:
- from sphinx.ext.autodoc import ( # pylint: disable=no-name-in-module
- AutodocReporter,
- )
-
-
__version__ = "1.0"
@@ -539,24 +528,8 @@ def do_parse(self, rstlist, node):
subheadings (titles) without confusing the rendering of
anything else.
"""
- # This is from kerneldoc.py -- it works around an API change in
- # Sphinx between 1.6 and 1.7. Unlike kerneldoc.py, we use
- # sphinx.util.nodes.nested_parse_with_titles() rather than the
- # plain self.state.nested_parse(), and so we can drop the saving
- # of title_styles and section_level that kerneldoc.py does,
- # because nested_parse_with_titles() does that for us.
- if USE_SSI:
- with switch_source_input(self.state, rstlist):
- nested_parse_with_titles(self.state, rstlist, node)
- else:
- save = self.state.memo.reporter
- self.state.memo.reporter = AutodocReporter(
- rstlist, self.state.memo.reporter
- )
- try:
- nested_parse_with_titles(self.state, rstlist, node)
- finally:
- self.state.memo.reporter = save
+ with switch_source_input(self.state, rstlist):
+ nested_parse_with_titles(self.state, rstlist, node)
def setup(app):
--
2.45.0
next prev parent reply other threads:[~2024-07-15 17:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-15 17:32 [PULL 0/6] Python patches John Snow
2024-07-15 17:32 ` [PULL 1/6] python: linter changes for pylint 3.x John Snow
2024-07-15 17:32 ` [PULL 2/6] python: Do not use pylint 3.2.4 with python 3.8 John Snow
2024-07-15 17:32 ` [PULL 3/6] iotests: Change imports for Python 3.13 John Snow
2024-07-15 17:32 ` [PULL 4/6] python: enable testing for 3.13 John Snow
2024-07-15 17:32 ` [PULL 5/6] Python: bump minimum sphinx version to 3.4.3 John Snow
2024-07-15 17:32 ` John Snow [this message]
2024-07-15 23:39 ` [PULL 0/6] Python patches Richard Henderson
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=20240715173241.572048-7-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=andrew@aj.id.au \
--cc=anisinha@redhat.com \
--cc=armbru@redhat.com \
--cc=aurelien@aurel32.net \
--cc=bleal@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=clg@kaod.org \
--cc=crosa@redhat.com \
--cc=eblake@redhat.com \
--cc=eduardo@habkost.net \
--cc=farman@linux.ibm.com \
--cc=farosas@suse.de \
--cc=hreitz@redhat.com \
--cc=joel@jms.id.au \
--cc=kwolf@redhat.com \
--cc=leobras@redhat.com \
--cc=michael.roth@amd.com \
--cc=mst@redhat.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=quintela@redhat.com \
--cc=thuth@redhat.com \
--cc=v.sementsov-og@mail.ru \
--cc=vsementsov@yandex-team.ru \
--cc=wainersm@redhat.com \
/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).