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))