On Sat, Dec 13, 2008 at 10:32 AM, John Hunter <jdh2...@gmail.com> wrote:

> On Sat, Dec 13, 2008 at 9:22 AM, Darren Dale <dsdal...@gmail.com> wrote:
>
> >> I haven't been able to get to the root of this problem, but an
> "svn-clean"
> >> in the doc directory always fixes it for me.
> >
> > I tried that but the problem persists. I have sphinx-0.4.2 installed, are
> > you using the same version?
>
>
(John suggested in a private email to try upgrading to sphinx-0.5.)

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:

$ svn diff sphinxext/
Index: sphinxext/inheritance_diagram.py
===================================================================
--- sphinxext/inheritance_diagram.py    (revision 6612)
+++ 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: sphinxext/mathmpl.py
===================================================================
--- sphinxext/mathmpl.py        (revision 6612)
+++ 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: sphinxext/only_directives.py
===================================================================
--- sphinxext/only_directives.py        (revision 6612)
+++ 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