Skip to content

Commit

Permalink
Fixed #1855: make gettext generates broken po file for definition lis…
Browse files Browse the repository at this point in the history
…ts with classifier.
  • Loading branch information
shimizukawa committed Jul 25, 2015
1 parent 3cd7e14 commit d337576
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES
Expand Up @@ -39,7 +39,11 @@ Bugs fixed
* #1903: Fix strange id generation for glossary terms.
* #1796, On py3, automated .mo building cause UnicodeDecodeError
* Fix: ``make text`` will crush if a definition list item has more than 1 classifiers as:
* #1796: On py3, automated .mo building cause UnicodeDecodeError
* ``make text`` will crush if a definition list item has more than 1 classifiers as:
* Fixed #1855: make gettext generates broken po file for definition lists with classifier.
``term : classifier1 : classifier2``.
* #1855: make gettext generates broken po file for definition lists with classifier.


Release 1.3.1 (released Mar 17, 2015)
Expand Down
14 changes: 14 additions & 0 deletions sphinx/util/nodes.py
Expand Up @@ -36,6 +36,20 @@ def write(self, text):


def apply_source_workaround(node):
# workaround: nodes.term have wrong rawsource if classifier is specified.
# The behavior of docutils-0.11, 0.12 is:
# * when ``term text : classifier1 : classifier2`` is specified,
# * rawsource of term node will have: ``term text : classifier1 : classifier2``
# * rawsource of classifier node will be None
if isinstance(node, nodes.classifier) and not node.rawsource:
definition_list_item = node.parent
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.term):
# overwrite: ``term : classifier1 : classifier2`` -> ``term text``
node.rawsource = node.astext()

This comment has been minimized.

Copy link
@methane

methane Dec 30, 2015

Contributor

This breaks inline markup in term.

https://docs.python.org/2.7/library/datetime.html

Module :mod:`calendar`
   General calendar related functions.

In sphinx 1.3.1, Module :mod:calendar`` is extracted.
In sphinx 1.3.3, Module calendar is extracted.

This comment has been minimized.

Copy link
@shimizukawa

shimizukawa Dec 30, 2015

Author Member

Thanks! I'll take a look.

This comment has been minimized.

Copy link
@shimizukawa

shimizukawa Dec 30, 2015

Author Member

#2205 is filed.


if node.source and node.rawsource:
return

Expand Down
10 changes: 10 additions & 0 deletions tests/roots/test-intl/definition_terms.po
Expand Up @@ -30,3 +30,13 @@ msgstr "SOME OTHER TERM"

msgid "The corresponding definition #2"
msgstr "THE CORRESPONDING DEFINITION #2"

msgid "Some term with"
msgstr "SOME TERM WITH"

msgid "classifier1"
msgstr "CLASSIFIER1"

msgid "classifier2"
msgstr "CLASSIFIER2"

3 changes: 3 additions & 0 deletions tests/roots/test-intl/definition_terms.txt
Expand Up @@ -9,3 +9,6 @@ Some term
Some other term
The corresponding definition #2

Some term with : classifier1 : classifier2
The corresponding definition

5 changes: 4 additions & 1 deletion tests/test_intl.py
Expand Up @@ -183,7 +183,10 @@ def test_text_builder(app, status, warning):
u"\nSOME TERM"
u"\n THE CORRESPONDING DEFINITION\n"
u"\nSOME OTHER TERM"
u"\n THE CORRESPONDING DEFINITION #2\n")
u"\n THE CORRESPONDING DEFINITION #2\n"
u"\nSOME TERM WITH : CLASSIFIER1 : CLASSIFIER2"
u"\n THE CORRESPONDING DEFINITION\n"
)
yield assert_equal, result, expect

# --- glossary terms: regression test for #1090
Expand Down

0 comments on commit d337576

Please sign in to comment.