diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-09-12 18:54:36 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-09-12 19:22:55 +0900 |
commit | fc2ca413ece79c083d52a86df982b33e61847327 (patch) | |
tree | 4e5fb3401fcc35ed834d7bd350e8eb35b2b82760 /sphinx/directives/other.py | |
parent | ba2439a105e5a68a44dd3f839e86332889cce451 (diff) | |
download | sphinx-git-fc2ca413ece79c083d52a86df982b33e61847327.tar.gz |
refactor: Use logger.warning() instead of reporter.warning()
Diffstat (limited to 'sphinx/directives/other.py')
-rw-r--r-- | sphinx/directives/other.py | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py index e131fe820..78890b14c 100644 --- a/sphinx/directives/other.py +++ b/sphinx/directives/other.py @@ -19,7 +19,7 @@ from docutils.parsers.rst.directives.misc import Include as BaseInclude from sphinx import addnodes from sphinx.domains.changeset import VersionChange # NOQA # for compatibility from sphinx.locale import _ -from sphinx.util import docname_join, url_re +from sphinx.util import docname_join, logging, url_re from sphinx.util.docutils import SphinxDirective from sphinx.util.matching import Matcher, patfilter from sphinx.util.nodes import explicit_title_re @@ -30,6 +30,7 @@ if TYPE_CHECKING: glob_re = re.compile(r'.*[*?\[].*') +logger = logging.getLogger(__name__) def int_or_nothing(argument: str) -> int: @@ -106,9 +107,8 @@ class TocTree(SphinxDirective): toctree['entries'].append((None, docname)) toctree['includefiles'].append(docname) if not docnames: - ret.append(self.state.document.reporter.warning( - 'toctree glob pattern %r didn\'t match any documents' - % entry, line=self.lineno)) + logger.warning('toctree glob pattern %r didn\'t match any documents', + entry, location=toctree) else: if explicit: ref = explicit.group(2) @@ -132,16 +132,14 @@ class TocTree(SphinxDirective): else: message = 'toctree contains reference to nonexisting document %r' - ret.append(self.state.document.reporter.warning(message % docname, - line=self.lineno)) + logger.warning(message, docname, location=toctree) self.env.note_reread() else: if docname in all_docnames: all_docnames.remove(docname) else: - message = 'duplicated entry found in toctree: %s' - ret.append(self.state.document.reporter.warning(message % docname, - line=self.lineno)) + logger.warning('duplicated entry found in toctree: %s', docname, + location=toctree) toctree['entries'].append((title, docname)) toctree['includefiles'].append(docname) @@ -250,8 +248,9 @@ class Acks(SphinxDirective): self.state.nested_parse(self.content, self.content_offset, node) if len(node.children) != 1 or not isinstance(node.children[0], nodes.bullet_list): - reporter = self.state.document.reporter - return [reporter.warning('.. acks content is not a list', line=self.lineno)] + logger.warning('.. acks content is not a list', + location=(self.env.docname, self.lineno)) + return [] return [node] @@ -274,8 +273,9 @@ class HList(SphinxDirective): self.state.nested_parse(self.content, self.content_offset, node) if len(node.children) != 1 or not isinstance(node.children[0], nodes.bullet_list): - reporter = self.state.document.reporter - return [reporter.warning('.. hlist content is not a list', line=self.lineno)] + logger.warning('.. hlist content is not a list', + location=(self.env.docname, self.lineno)) + return [] fulllist = node.children[0] # create a hlist node where the items are distributed npercol, nmore = divmod(len(fulllist), ncolumns) |