mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Revert "Improve warning messages during including (refs: #4818)"
This reverts commit a4dbb6e657
.
This commit is contained in:
parent
9158363adc
commit
7249df80a3
@ -8,7 +8,6 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from contextlib import contextmanager
|
|
||||||
|
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
from docutils.parsers.rst import directives
|
from docutils.parsers.rst import directives
|
||||||
@ -381,7 +380,6 @@ class Include(BaseInclude, SphinxDirective):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# type: () -> List[nodes.Node]
|
# type: () -> List[nodes.Node]
|
||||||
current_filename = self.env.doc2path(self.env.docname)
|
|
||||||
if self.arguments[0].startswith('<') and \
|
if self.arguments[0].startswith('<') and \
|
||||||
self.arguments[0].endswith('>'):
|
self.arguments[0].endswith('>'):
|
||||||
# docutils "standard" includes, do not do path processing
|
# docutils "standard" includes, do not do path processing
|
||||||
@ -389,29 +387,9 @@ class Include(BaseInclude, SphinxDirective):
|
|||||||
rel_filename, filename = self.env.relfn2path(self.arguments[0])
|
rel_filename, filename = self.env.relfn2path(self.arguments[0])
|
||||||
self.arguments[0] = filename
|
self.arguments[0] = filename
|
||||||
self.env.note_included(filename)
|
self.env.note_included(filename)
|
||||||
with patched_warnings(self, current_filename):
|
|
||||||
return BaseInclude.run(self)
|
return BaseInclude.run(self)
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
|
||||||
def patched_warnings(directive, parent_filename):
|
|
||||||
# type: (BaseInclude, unicode) -> Generator[None, None, None]
|
|
||||||
"""Add includee filename to the warnings during inclusion."""
|
|
||||||
try:
|
|
||||||
original = directive.state_machine.insert_input
|
|
||||||
|
|
||||||
def insert_input(input_lines, source):
|
|
||||||
# type: (Any, unicode) -> None
|
|
||||||
source += ' <included from %s>' % parent_filename
|
|
||||||
original(input_lines, source)
|
|
||||||
|
|
||||||
# patch insert_input() temporarily
|
|
||||||
directive.state_machine.insert_input = insert_input
|
|
||||||
yield
|
|
||||||
finally:
|
|
||||||
directive.state_machine.insert_input = original
|
|
||||||
|
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
# type: (Sphinx) -> Dict[unicode, Any]
|
# type: (Sphinx) -> Dict[unicode, Any]
|
||||||
directives.register_directive('toctree', TocTree)
|
directives.register_directive('toctree', TocTree)
|
||||||
|
Loading…
Reference in New Issue
Block a user