From a13edb86318b21e224cf1365fc9c5edb05df18dc Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sun, 20 Nov 2016 17:32:05 +0900 Subject: [PATCH 1/7] refs #3093: gettext build broken on substituted images. --- CHANGES | 1 + sphinx/transforms.py | 4 ++-- sphinx/util/nodes.py | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 49b0ca941..ef2997d10 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,7 @@ Bugs fixed * #3074: ``add_source_parser()`` crashes in debug mode * #3135: ``sphinx.ext.autodoc`` crashes with plain Callable * #3150: Fix query word splitter in JavaScript. It behaves as same as Python's regular expression. +* #3093: gettext build broken on substituted images. Release 1.4.8 (released Oct 1, 2016) ==================================== diff --git a/sphinx/transforms.py b/sphinx/transforms.py index cb4a5779b..ba15ae614 100644 --- a/sphinx/transforms.py +++ b/sphinx/transforms.py @@ -166,7 +166,7 @@ class ApplySourceWorkaround(Transform): def apply(self): for n in self.document.traverse(): - if isinstance(n, nodes.TextElement): + if isinstance(n, (nodes.TextElement, nodes.image)): apply_source_workaround(n) @@ -192,7 +192,7 @@ class ExtraTranslatableNodes(Transform): """ make nodes translatable """ - default_priority = 10 + default_priority = 9 def apply(self): targets = self.document.settings.env.config.gettext_additional_targets diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py index e4a2fd73b..e51ad2972 100644 --- a/sphinx/util/nodes.py +++ b/sphinx/util/nodes.py @@ -46,6 +46,8 @@ def apply_source_workaround(node): node.source = definition_list_item.source node.line = definition_list_item.line - 1 node.rawsource = node.astext() # set 'classifier1' (or 'classifier2') + if isinstance(node, nodes.image) and node.source is None: + node.source, node.line = node.parent.source, node.parent.line if isinstance(node, nodes.term): # strip classifier from rawsource of term for classifier in reversed(node.parent.traverse(nodes.classifier)): From 76eb8ab56d49c6fbe28e03934fdd60ad92459452 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sun, 20 Nov 2016 17:44:10 +0900 Subject: [PATCH 2/7] * #3093: gettext build broken on image node under ``note`` directive. --- CHANGES | 1 + sphinx/util/nodes.py | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index ef2997d10..0ae8cb26d 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,7 @@ Bugs fixed * #3135: ``sphinx.ext.autodoc`` crashes with plain Callable * #3150: Fix query word splitter in JavaScript. It behaves as same as Python's regular expression. * #3093: gettext build broken on substituted images. +* #3093: gettext build broken on image node under ``note`` directive. Release 1.4.8 (released Oct 1, 2016) ==================================== diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py index e51ad2972..b3f7efa8e 100644 --- a/sphinx/util/nodes.py +++ b/sphinx/util/nodes.py @@ -71,6 +71,7 @@ def apply_source_workaround(node): nodes.title, nodes.rubric, nodes.line, + nodes.image, ))): node.source = find_source_node(node) node.line = 0 # need fix docutils to get `node.line` From 3566352bdbd21a2f6668d5f3da815ed6f8de3f50 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sun, 20 Nov 2016 17:48:07 +0900 Subject: [PATCH 3/7] refs #3093: add tests --- tests/roots/test-intl/conf.py | 2 +- tests/roots/test-intl/figure.txt | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/roots/test-intl/conf.py b/tests/roots/test-intl/conf.py index aafd9ba79..e465e75dc 100644 --- a/tests/roots/test-intl/conf.py +++ b/tests/roots/test-intl/conf.py @@ -6,5 +6,5 @@ keep_warnings = True templates_path = ['_templates'] html_additional_pages = {'index': 'index.html'} release = version = '2013.120' -gettext_additional_targets = ['index'] +gettext_additional_targets = ['index', 'image'] exclude_patterns = ['_build'] diff --git a/tests/roots/test-intl/figure.txt b/tests/roots/test-intl/figure.txt index b639a4ac1..e6ebfd7ce 100644 --- a/tests/roots/test-intl/figure.txt +++ b/tests/roots/test-intl/figure.txt @@ -34,3 +34,20 @@ image url and alt .. figure:: img.png :alt: img + +image on substitution +--------------------- + +.. |sub image| image:: i18n.png + +image under note +----------------- + +.. note:: + + .. image:: i18n.png + :alt: i18n + + .. figure:: img.png + :alt: img + From 3c89ddd99f7d703a975272040dfbfead85db500b Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sun, 20 Nov 2016 17:55:28 +0900 Subject: [PATCH 4/7] refs #3093: revert non-related changed line --- sphinx/transforms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/transforms.py b/sphinx/transforms.py index ba15ae614..3281541c0 100644 --- a/sphinx/transforms.py +++ b/sphinx/transforms.py @@ -192,7 +192,7 @@ class ExtraTranslatableNodes(Transform): """ make nodes translatable """ - default_priority = 9 + default_priority = 10 def apply(self): targets = self.document.settings.env.config.gettext_additional_targets From e712401dd1b3df2ae2e839f7c467c6393244dc04 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sun, 20 Nov 2016 18:00:23 +0900 Subject: [PATCH 5/7] #3093: fix test --- tests/roots/test-intl/conf.py | 2 +- tests/roots/test-intl/figure.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/roots/test-intl/conf.py b/tests/roots/test-intl/conf.py index e465e75dc..aafd9ba79 100644 --- a/tests/roots/test-intl/conf.py +++ b/tests/roots/test-intl/conf.py @@ -6,5 +6,5 @@ keep_warnings = True templates_path = ['_templates'] html_additional_pages = {'index': 'index.html'} release = version = '2013.120' -gettext_additional_targets = ['index', 'image'] +gettext_additional_targets = ['index'] exclude_patterns = ['_build'] diff --git a/tests/roots/test-intl/figure.txt b/tests/roots/test-intl/figure.txt index e6ebfd7ce..633e12ee8 100644 --- a/tests/roots/test-intl/figure.txt +++ b/tests/roots/test-intl/figure.txt @@ -46,8 +46,8 @@ image under note .. note:: .. image:: i18n.png - :alt: i18n + :alt: i18n under note .. figure:: img.png - :alt: img + :alt: img under note From 6b0d3e7400ab7b50ce840a8eec9507d15cf74b14 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sun, 20 Nov 2016 18:17:16 +0900 Subject: [PATCH 6/7] #3093: fix test again --- tests/roots/test-intl/figure.po | 7 +++++++ tests/test_intl.py | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/tests/roots/test-intl/figure.po b/tests/roots/test-intl/figure.po index cbd9c8837..449b15e3f 100644 --- a/tests/roots/test-intl/figure.po +++ b/tests/roots/test-intl/figure.po @@ -50,3 +50,10 @@ msgid "" msgstr "" ".. image:: img.png\n" " :alt: I18N -> IMG" + +msgid "image on substitution" +msgstr "IMAGE ON SUBSTITUTION" + +msgid "image under note" +msgstr "IMAGE UNDER NOTE" + diff --git a/tests/test_intl.py b/tests/test_intl.py index b31f1678b..e1c0784d8 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -261,6 +261,18 @@ def test_text_builder(app, status, warning): u"[image: i18n][image]\n" u"\n" u" [image: img][image]\n" + u"\n" + u"\n" + u"IMAGE ON SUBSTITUTION\n" + u"=====================\n" + u"\n" + u"\n" + u"IMAGE UNDER NOTE\n" + u"================\n" + u"\n" + u"Note: [image: i18n under note][image]\n" + u"\n" + u" [image: img under note][image]\n" ) yield assert_equal, result, expect From 8f79c11b04c6ea675ead6a019013e1d208efec97 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sun, 20 Nov 2016 18:35:12 +0900 Subject: [PATCH 7/7] #3093: fix test again --- tests/test_intl.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/test_intl.py b/tests/test_intl.py index e1c0784d8..4fac62c21 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -261,18 +261,18 @@ def test_text_builder(app, status, warning): u"[image: i18n][image]\n" u"\n" u" [image: img][image]\n" - u"\n" - u"\n" - u"IMAGE ON SUBSTITUTION\n" - u"=====================\n" - u"\n" - u"\n" - u"IMAGE UNDER NOTE\n" - u"================\n" - u"\n" - u"Note: [image: i18n under note][image]\n" - u"\n" - u" [image: img under note][image]\n" + u"\n" + u"\n" + u"IMAGE ON SUBSTITUTION\n" + u"=====================\n" + u"\n" + u"\n" + u"IMAGE UNDER NOTE\n" + u"================\n" + u"\n" + u"Note: [image: i18n under note][image]\n" + u"\n" + u" [image: img under note][image]\n" ) yield assert_equal, result, expect