From 7249df80a3da8e3aa141c77e7ad48c6a9c9e95e7 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 14 Oct 2018 12:58:00 +0900 Subject: [PATCH] Revert "Improve warning messages during including (refs: #4818)" This reverts commit a4dbb6e657bf86e5940e352a2935d1b3264d74e2. --- sphinx/directives/other.py | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py index a1e39de77..3776536b8 100644 --- a/sphinx/directives/other.py +++ b/sphinx/directives/other.py @@ -8,7 +8,6 @@ """ import re -from contextlib import contextmanager from docutils import nodes from docutils.parsers.rst import directives @@ -381,7 +380,6 @@ class Include(BaseInclude, SphinxDirective): def run(self): # type: () -> List[nodes.Node] - current_filename = self.env.doc2path(self.env.docname) if self.arguments[0].startswith('<') and \ self.arguments[0].endswith('>'): # docutils "standard" includes, do not do path processing @@ -389,27 +387,7 @@ class Include(BaseInclude, SphinxDirective): rel_filename, filename = self.env.relfn2path(self.arguments[0]) self.arguments[0] = filename self.env.note_included(filename) - with patched_warnings(self, current_filename): - 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 += ' ' % 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 + return BaseInclude.run(self) def setup(app):