From 6dc7ca0234638436f3decfb85990613e69f7809f Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 12 Jan 2016 10:50:02 +0900 Subject: [PATCH] Fix line numbers were not shown on warnings in LaTeX and texinfo builder --- CHANGES | 1 + sphinx/util/nodes.py | 8 ++++++-- tests/test_build_latex.py | 6 +++--- tests/test_build_texinfo.py | 8 ++++---- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index ea325dc56..051423a52 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ Release 1.3.5 (in development) Bugs fixed ---------- +* Fix line numbers was not shown on warnings in LaTeX and texinfo builders Release 1.3.4 (released Jan 12, 2016) ===================================== diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py index d35f45265..aa4a9462b 100644 --- a/sphinx/util/nodes.py +++ b/sphinx/util/nodes.py @@ -292,9 +292,13 @@ def set_role_source_info(inliner, lineno, node): node.source, node.line = inliner.reporter.get_source_and_line(lineno) -# monkey-patch Element.copy to copy the rawsource +# monkey-patch Element.copy to copy the rawsource and line def _new_copy(self): - return self.__class__(self.rawsource, **self.attributes) + newnode = self.__class__(self.rawsource, **self.attributes) + if isinstance(self, nodes.Element): + newnode.source = self.source + newnode.line = self.line + return newnode nodes.Element.copy = _new_copy diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index ac843c897..c8026ba54 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -24,9 +24,9 @@ from test_build_html import ENV_WARNINGS LATEX_WARNINGS = ENV_WARNINGS + """\ -None:None: WARNING: unknown option: &option -None:None: WARNING: citation not found: missing -None:None: WARNING: no matching candidate for image URI u'foo.\\*' +%(root)s/markup.txt:158: WARNING: unknown option: &option +None:60: WARNING: citation not found: missing +%(root)s/images.txt:20: WARNING: no matching candidate for image URI u'foo.\\*' WARNING: invalid pair index entry u'' WARNING: invalid pair index entry u'keyword; ' """ diff --git a/tests/test_build_texinfo.py b/tests/test_build_texinfo.py index 5137cfbac..51b0b57dd 100644 --- a/tests/test_build_texinfo.py +++ b/tests/test_build_texinfo.py @@ -23,10 +23,10 @@ from test_build_html import ENV_WARNINGS TEXINFO_WARNINGS = ENV_WARNINGS + """\ -None:None: WARNING: unknown option: &option -None:None: WARNING: citation not found: missing -None:None: WARNING: no matching candidate for image URI u'foo.\\*' -None:None: WARNING: no matching candidate for image URI u'svgimg.\\*' +%(root)s/markup.txt:158: WARNING: unknown option: &option +None:60: WARNING: citation not found: missing +%(root)s/images.txt:20: WARNING: no matching candidate for image URI u'foo.\\*' +%(root)s/images.txt:29: WARNING: no matching candidate for image URI u'svgimg.\\*' """ if PY3: