Commits

Nozomu Kaneko committed ad579c3

use `paragraph` nodes instead of `translatable` nodes.

  • Participants
  • Parent commits 1f0e285

Comments (0)

Files changed (2)

sphinx/environment.py

             node.children = patch.children
 
 
+class DocFields(Transform):
+    """
+    Remove nested paragraphs generated by docfields.
+    """
+    default_priority = 999
+
+    def apply(self):
+        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
+
+
 class SphinxStandaloneReader(standalone.Reader):
     """
     Add our own transforms.
     """
     transforms = [Locale, CitationReferences, DefaultSubstitutions,
-                  MoveModuleTargets, HandleCodeBlocks, SortIds]
+                  MoveModuleTargets, HandleCodeBlocks, SortIds, DocFields]
 
     def get_transforms(self):
         return standalone.Reader.get_transforms(self) + self.transforms

sphinx/util/docfields.py

             fieldname += nodes.Text(' ')
             fieldname += self.make_xref(self.rolename, domain,
                                         fieldarg, nodes.Text)
-        par = nodes.paragraph()
-        par += content
-        fieldbody = nodes.field_body('', par)
+        fieldbody = nodes.field_body('', nodes.paragraph('', '', content))
         return nodes.field('', fieldname, fieldbody)
 
 
                                                [nodes.Text(argtype)]
                     fieldarg = argname
 
-            translatable_content = addnodes.translatable(fieldbody.rawsource)
+            translatable_content = nodes.paragraph(fieldbody.rawsource,
+                                                   removable=True)
             translatable_content.source = fieldbody.parent.source
             translatable_content.line = fieldbody.parent.line
             translatable_content += content