From be1c193e3c292e57f1bf260d43dca377d8f1a9e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Pierret=20=28fepitre=29?= Date: Fri, 22 Nov 2019 11:28:11 +0100 Subject: [PATCH] Fix Sphinx 2 new API for Fedora 31+ --- qubes/dochelpers.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/qubes/dochelpers.py b/qubes/dochelpers.py index ee674322..7d8becb1 100644 --- a/qubes/dochelpers.py +++ b/qubes/dochelpers.py @@ -41,12 +41,17 @@ import sphinx import sphinx.errors import sphinx.locale import sphinx.util.docfields +from sphinx.util import logging import qubes.tools SUBCOMMANDS_TITLE = 'COMMANDS' OPTIONS_TITLE = 'OPTIONS' +try: + log = logging.getLogger(__name__) +except AttributeError: + log = None class GithubTicket: # pylint: disable=too-few-public-methods @@ -338,7 +343,13 @@ class ManpageCheckVisitor(docutils.nodes.SparseNodeVisitor): try: parser = qubes.tools.get_parser_for_command(command) except ImportError: - app.warn('cannot import module for command') + msg = 'cannot import module for command' + if log: + log.warning(msg) + else: + # Handle legacy + app.warn(msg) + self.parser = None return except AttributeError: @@ -394,7 +405,13 @@ def check_man_args(app, doctree, docname): if os.path.basename(dirname) != 'manpages': return - app.info('Checking arguments for {!r}'.format(command)) + msg = 'Checking arguments for {!r}'.format(command) + if log: + log.info(msg) + else: + # Handle legacy + app.info(msg) + doctree.walk(ManpageCheckVisitor(app, command, doctree))