summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakayuki Shimizukawa <shimizukawa+bitbucket@gmail.com>2013-11-13 00:19:21 +0900
committerTakayuki Shimizukawa <shimizukawa+bitbucket@gmail.com>2013-11-13 00:19:21 +0900
commitaa4f7e224d21bfc5328afde206e49811db29a3f8 (patch)
tree27f2f952f49242337cc879430c4f15106364fed5
parenta56b65634bf3fe57af58e781674ef0be339be2fe (diff)
parentf8ee72d5d9ff38c6dd852efe9747c728eb3a92bc (diff)
downloadsphinx-aa4f7e224d21bfc5328afde206e49811db29a3f8.tar.gz
Merged in mschlenker/cs-sphinx/fix-nested-figure-caption-i18n (pull request #190)
I18n does not always extract figure captions for figures nested inside other blocks
-rw-r--r--sphinx/util/nodes.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py
index a8395f60..9d303188 100644
--- a/sphinx/util/nodes.py
+++ b/sphinx/util/nodes.py
@@ -41,6 +41,23 @@ IGNORED_NODES = (
nodes.doctest_block,
#XXX there are probably more
)
+
+def find_source_node(node):
+ if node.source:
+ return node.source
+
+ current = node
+ while 1:
+ parent = current.parent
+ if parent.source:
+ return parent.source
+ else:
+ current = parent
+
+ if not current:
+ break
+ return None
+
def extract_messages(doctree):
"""Extract translatable messages from a document tree."""
for node in doctree.traverse(nodes.TextElement):
@@ -58,8 +75,8 @@ def extract_messages(doctree):
# this issue was filed to Docutils tracker:
# sf.net/tracker/?func=detail&aid=3599485&group_id=38414&atid=422032
# sourceforge.net/p/docutils/patches/108/
- if isinstance(node, (nodes.caption, nodes.title)) and not node.source:
- node.source = node.parent.source
+ if isinstance(node, (nodes.caption, nodes.title, nodes.rubric)) and not node.source:
+ node.source = find_source_node(node)
node.line = 0 #need fix docutils to get `node.line`
if not node.source: