Fix Sphinx 2 new API for Fedora 31+

This commit is contained in:
Frédéric Pierret (fepitre) 2019-11-22 11:28:11 +01:00
parent b4177cf7d2
commit be1c193e3c
No known key found for this signature in database
GPG Key ID: 484010B5CDC576E2

View File

@ -41,12 +41,17 @@ import sphinx
import sphinx.errors import sphinx.errors
import sphinx.locale import sphinx.locale
import sphinx.util.docfields import sphinx.util.docfields
from sphinx.util import logging
import qubes.tools import qubes.tools
SUBCOMMANDS_TITLE = 'COMMANDS' SUBCOMMANDS_TITLE = 'COMMANDS'
OPTIONS_TITLE = 'OPTIONS' OPTIONS_TITLE = 'OPTIONS'
try:
log = logging.getLogger(__name__)
except AttributeError:
log = None
class GithubTicket: class GithubTicket:
# pylint: disable=too-few-public-methods # pylint: disable=too-few-public-methods
@ -338,7 +343,13 @@ class ManpageCheckVisitor(docutils.nodes.SparseNodeVisitor):
try: try:
parser = qubes.tools.get_parser_for_command(command) parser = qubes.tools.get_parser_for_command(command)
except ImportError: 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 self.parser = None
return return
except AttributeError: except AttributeError:
@ -394,7 +405,13 @@ def check_man_args(app, doctree, docname):
if os.path.basename(dirname) != 'manpages': if os.path.basename(dirname) != 'manpages':
return 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)) doctree.walk(ManpageCheckVisitor(app, command, doctree))