Merge branch '1.8' into 5498_typehints_for_partial

This commit is contained in:
Takeshi KOMIYA 2018-10-15 00:46:43 +09:00 committed by GitHub
commit 24af3d9eee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 23 deletions

View File

@ -21,6 +21,8 @@ Bugs fixed
* #3704: latex: wrong ``\label`` positioning for figures with a legend
* #5496: C++, fix assertion when a symbol is declared more than twice.
* #5493: gettext: crashed with broken template
* #5495: csv-table directive with file option in included file is broken (refs:
#4821)
* #5498: autodoc: unable to find type hints for a ``functools.partial``
Testing

View File

@ -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 += ' <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
return BaseInclude.run(self)
def setup(app):