Commits

Nozomu Kaneko committed aca95ed

use ``nodes.inline`` with a "translatable" attr instead

Comments (0)

Files changed (3)

sphinx/environment.py

             node['entries'] = new_entries
 
 
-class DocFields(Transform):
+class RemoveTranslatableInline(Transform):
     """
-    Remove nested paragraphs generated by docfields.
+    Remove inline nodes used for translation as placeholders.
     """
     default_priority = 999
 
         builder = env.app.builder
         if isinstance(builder, MessageCatalogBuilder):
             return
-        for field_list in self.document.traverse(nodes.field_list):
-            for field_body in field_list.traverse(nodes.field_body):
-                for par in field_list.traverse(nodes.paragraph):
-                    if not ('removable' in par and
-                            isinstance(par.parent, nodes.paragraph)):
-                        continue
-                    par.parent.remove(par)
-                    par.parent += par.children
+        for inline in self.document.traverse(nodes.inline):
+            if 'translatable' in inline:
+                inline.parent.remove(inline)
+                inline.parent += inline.children
 
 
 class SphinxStandaloneReader(standalone.Reader):
     Add our own transforms.
     """
     transforms = [Locale, CitationReferences, DefaultSubstitutions,
-                  MoveModuleTargets, HandleCodeBlocks, SortIds, DocFields]
+                  MoveModuleTargets, HandleCodeBlocks, SortIds,
+                  RemoveTranslatableInline]
 
     def get_transforms(self):
         return standalone.Reader.get_transforms(self) + self.transforms

sphinx/util/docfields.py

                                                [nodes.Text(argtype)]
                     fieldarg = argname
 
-            translatable_content = nodes.paragraph(fieldbody.rawsource,
-                                                   removable=True)
+            translatable_content = nodes.inline(fieldbody.rawsource,
+                                                translatable=True)
             translatable_content.source = fieldbody.parent.source
             translatable_content.line = fieldbody.parent.line
             translatable_content += content

sphinx/util/nodes.py

 
         if not node.source:
             continue # built-in message
-        if isinstance(node, IGNORED_NODES):
+        if isinstance(node, IGNORED_NODES) and 'translatable' not in node:
             continue
         # <field_name>orphan</field_name>
         # XXX ignore all metadata (== docinfo)