Skip to content

Commit

Permalink
refactor: Use logger.warning() instead of reporter.warning()
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Sep 12, 2021
1 parent ba2439a commit fc2ca41
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions sphinx/directives/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
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
Expand All @@ -30,6 +30,7 @@


glob_re = re.compile(r'.*[*?\[].*')
logger = logging.getLogger(__name__)


def int_or_nothing(argument: str) -> int:
Expand Down Expand Up @@ -106,9 +107,8 @@ def parse_content(self, toctree: addnodes.toctree) -> List[Node]:
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)
Expand All @@ -132,16 +132,14 @@ def parse_content(self, toctree: addnodes.toctree) -> List[Node]:
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)
Expand Down Expand Up @@ -250,8 +248,9 @@ def run(self) -> List[Node]:
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]


Expand All @@ -274,8 +273,9 @@ def run(self) -> List[Node]:
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)
Expand Down

0 comments on commit fc2ca41

Please sign in to comment.