summaryrefslogtreecommitdiff
path: root/sphinx/util
diff options
context:
space:
mode:
authorRobert Lehmann <mail@robertlehmann.de>2011-07-06 08:52:07 +0200
committerRobert Lehmann <mail@robertlehmann.de>2011-07-06 08:52:07 +0200
commit09e2e6e04d81d325b9b985fdb2a4965ffde7a24c (patch)
tree3afc5e2877fce2b4075717e7fc898e01caf8d86a /sphinx/util
parentc10a6b351e4c2e3cda99a7b0904c79709f46cb0c (diff)
downloadsphinx-09e2e6e04d81d325b9b985fdb2a4965ffde7a24c.tar.gz
Move node filtering into extract_messages.
Diffstat (limited to 'sphinx/util')
-rw-r--r--sphinx/util/nodes.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py
index a241f574..682ea77b 100644
--- a/sphinx/util/nodes.py
+++ b/sphinx/util/nodes.py
@@ -22,16 +22,25 @@ from sphinx.util.pycompat import class_types
explicit_title_re = re.compile(r'^(.+?)\s*(?<!\x00)<(.*?)>$', re.DOTALL)
caption_ref_re = explicit_title_re # b/w compat alias
-
+IGNORED_NODES = (
+ nodes.Invisible,
+ nodes.Inline,
+ nodes.literal_block,
+ nodes.doctest_block,
+ #XXX there are probably more
+)
def extract_messages(doctree):
"""Extract translatable messages from a document tree."""
for node in doctree.traverse(nodes.TextElement):
- if isinstance(node, (nodes.Invisible, nodes.Inline)):
+ if not node.source:
+ continue # built-in message
+ if isinstance(node, IGNORED_NODES):
continue
# <field_name>orphan</field_name>
# XXX ignore all metadata (== docinfo)
if isinstance(node, nodes.field_name) and node.children[0] == 'orphan':
continue
+
msg = node.rawsource.replace('\n', ' ').strip()
# XXX nodes rendering empty are likely a bug in sphinx.addnodes
if msg: