On Tue, Dec 16, 2008 at 9:48 AM, John Hunter <jdh2...@gmail.com> wrote:

> On Mon, Dec 15, 2008 at 10:02 AM, Darren Dale <dsdal...@gmail.com> wrote:
>
> > You're right, the error does not occur with sphinx-0.5. It looks like the
> > API for registering nodes has changed as of 0.5. The development branch
> of
> > sphinx was throwing errors when it got to latex, so I had a look and came
> up
> > with some changes that work with both version 0.5 and the development
> > branch. The changes are not compatible with sphinx-0.4.2, but it looks
> like
> > we are requiring version 0.5 or later now anyway. If this is the case,
> I'll
> > go ahead and commit the changes. Here is the diff, please let me know if
> I
> > should commit or if I should hold off:
>
> I am getting errors trying to apply this patch on the 0.98.5 branch.
> Could you send a fresh diff against the HEAD of that branch, and
> attach it rather than paste it.
>

 Here is the diff. I think I wasn't clear though, this diff is intended to
be compatible with sphinx-0.5 and later, it is not compatible with earlier
versions. I can build the documentation using sphinx-0.5 with or without
this patch, but the patch will be needed for future versions of sphinx,
including the sphinx development branch.

I never did get to the bottom of the error building our docs with
sphinx-0.4.2. I think it was an entirely different issue.
Index: doc/sphinxext/inheritance_diagram.py
===================================================================
--- doc/sphinxext/inheritance_diagram.py        (revision 6626)
+++ doc/sphinxext/inheritance_diagram.py        (working copy)
@@ -39,8 +39,6 @@
     from md5 import md5
 
 from docutils.nodes import Body, Element
-from docutils.writers.html4css1 import HTMLTranslator
-from sphinx.latexwriter import LaTeXTranslator
 from docutils.parsers.rst import directives
 from sphinx.roles import xfileref_role
 
@@ -409,12 +407,9 @@
                                   inheritance_diagram_directive)
 
 def setup(app):
-    app.add_node(inheritance_diagram)
-
-    HTMLTranslator.visit_inheritance_diagram = \
-        visit_inheritance_diagram(html_output_graph)
-    HTMLTranslator.depart_inheritance_diagram = do_nothing
-
-    LaTeXTranslator.visit_inheritance_diagram = \
-        visit_inheritance_diagram(latex_output_graph)
-    LaTeXTranslator.depart_inheritance_diagram = do_nothing
+    app.add_node(inheritance_diagram,
+                 html=(visit_inheritance_diagram(html_output_graph),
+                       do_nothing))
+    app.add_node(inheritance_diagram,
+                 latex=(visit_inheritance_diagram(latex_output_graph),
+                        do_nothing))
Index: doc/sphinxext/mathmpl.py
===================================================================
--- doc/sphinxext/mathmpl.py    (revision 6626)
+++ doc/sphinxext/mathmpl.py    (working copy)
@@ -6,8 +6,6 @@
 
 from docutils import nodes
 from docutils.parsers.rst import directives
-from docutils.writers.html4css1 import HTMLTranslator
-from sphinx.latexwriter import LaTeXTranslator
 import warnings
 
 # Define LaTeX math node:
@@ -69,8 +67,6 @@
         self.body.append(latex2html(node, source))
     def depart_latex_math_html(self, node):
             pass
-    HTMLTranslator.visit_latex_math = visit_latex_math_html
-    HTMLTranslator.depart_latex_math = depart_latex_math_html
 
     # Add visit/depart methods to LaTeX-Translator:
     def visit_latex_math_latex(self, node):
@@ -83,9 +79,14 @@
                               '\\end{equation}'])
     def depart_latex_math_latex(self, node):
             pass
-    LaTeXTranslator.visit_latex_math = visit_latex_math_latex
-    LaTeXTranslator.depart_latex_math = depart_latex_math_latex
 
+    app.add_node(latex_math, html=(visit_latex_math_html,
+                                   depart_latex_math_html))
+    app.add_node(latex_math, latex=(visit_latex_math_latex,
+                                    depart_latex_math_latex))
+    app.add_role('math', math_role)
+
+
 from matplotlib import rcParams
 from matplotlib.mathtext import MathTextParser
 rcParams['mathtext.fontset'] = 'cm'
Index: doc/sphinxext/only_directives.py
===================================================================
--- doc/sphinxext/only_directives.py    (revision 6626)
+++ doc/sphinxext/only_directives.py    (working copy)
@@ -4,8 +4,6 @@
 #
 
 from docutils.nodes import Body, Element
-from docutils.writers.html4css1 import HTMLTranslator
-from sphinx.latexwriter import LaTeXTranslator
 from docutils.parsers.rst import directives
 
 class html_only(Body, Element):
@@ -63,9 +61,6 @@
     directives.register_directive('latexonly', LatexOnlyDirective)
 
 def setup(app):
-    app.add_node(html_only)
-    app.add_node(latex_only)
-
     # Add visit/depart methods to HTML-Translator:
     def visit_perform(self, node):
         pass
@@ -76,12 +71,7 @@
     def depart_ignore(self, node):
         node.children = []
 
-    HTMLTranslator.visit_html_only = visit_perform
-    HTMLTranslator.depart_html_only = depart_perform
-    HTMLTranslator.visit_latex_only = visit_ignore
-    HTMLTranslator.depart_latex_only = depart_ignore
-
-    LaTeXTranslator.visit_html_only = visit_ignore
-    LaTeXTranslator.depart_html_only = depart_ignore
-    LaTeXTranslator.visit_latex_only = visit_perform
-    LaTeXTranslator.depart_latex_only = depart_perform
+    app.add_node(html_only, html=(visit_perform, depart_perform))
+    app.add_node(html_only, latex=(visit_ignore, depart_ignore))
+    app.add_node(latex_only, latex=(visit_perform, depart_perform))
+    app.add_node(latex_only, html=(visit_ignore, depart_ignore))
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to