[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29054] trunk/blender/source/blender/ python/doc/sphinx_html_compact.diff: Correct sphinx patch.
Alex Sytnik
the.smerch at gmail.com
Fri May 28 22:53:06 CEST 2010
Revision: 29054
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29054
Author: smerch
Date: 2010-05-28 22:53:06 +0200 (Fri, 28 May 2010)
Log Message:
-----------
Correct sphinx patch.
Added Paths:
-----------
trunk/blender/source/blender/python/doc/sphinx_html_compact.diff
Added: trunk/blender/source/blender/python/doc/sphinx_html_compact.diff
===================================================================
--- trunk/blender/source/blender/python/doc/sphinx_html_compact.diff (rev 0)
+++ trunk/blender/source/blender/python/doc/sphinx_html_compact.diff 2010-05-28 20:53:06 UTC (rev 29054)
@@ -0,0 +1,58 @@
+--- /home/sashka/Sphinx-0.6.5-py2.6.egg_FILES/sphinx/writers/html.py 2010-01-02 00:43:38.000000000 +0200
++++ /home/sashka/egg/lib/python2.6/site-packages/Sphinx-0.6.5-py2.6.egg/sphinx/writers/html.py 2010-05-27 02:24:33.203418028 +0300
+@@ -16,6 +16,7 @@
+ from docutils import nodes
+ from docutils.writers.html4css1 import Writer, HTMLTranslator as BaseTranslator
+
++from sphinx import addnodes
+ from sphinx.locale import admonitionlabels, versionlabels
+ from sphinx.util.smartypants import sphinx_smarty_pants
+
+@@ -271,6 +272,47 @@
+ def depart_centered(self, node):
+ self.body.append('</strong></p>')
+
++ def should_be_compact_paragraph(self, node):
++ """
++ Determine if the <p> tags around paragraph ``node`` can be omitted.
++ """
++ if (isinstance(node.parent, nodes.document) or
++ isinstance(node.parent, nodes.compound) or
++ isinstance(node.parent, addnodes.desc_content)):
++ # Never compact paragraphs in document or compound.
++ # or desc_content items either.
++ return 0
++ for key, value in node.attlist():
++ if (node.is_not_default(key) and
++ not (key == 'classes' and value in
++ ([], ['first'], ['last'], ['first', 'last']))):
++ # Attribute which needs to survive.
++ return 0
++ first = isinstance(node.parent[0], nodes.label) # skip label
++ for child in node.parent.children[first:]:
++ # only first paragraph can be compact
++ if isinstance(child, nodes.Invisible):
++ continue
++ if child is node:
++ break
++ return 0
++ parent_length = len([n for n in node.parent if not isinstance(
++ n, (nodes.Invisible, nodes.label))])
++ if ( self.compact_simple
++ or self.compact_field_list
++ or self.compact_p and parent_length == 1):
++ return 1
++ return 0
++
++ def visit_paragraph(self, node):
++ if self.should_be_compact_paragraph(node):
++ self.context.append('')
++ else:
++ self.body.append(self.starttag(node, 'p', ''))
++ self.context.append('</p>\n')
++ def depart_paragraph(self, node):
++ self.body.append(self.context.pop())
++
+ def visit_compact_paragraph(self, node):
+ pass
+ def depart_compact_paragraph(self, node):
More information about the Bf-blender-cvs
mailing list