Revision: 6950
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6950&view=rev
Author:   mdboom
Date:     2009-03-03 22:06:53 +0000 (Tue, 03 Mar 2009)

Log Message:
-----------
Add workaround for change in handling of absolute paths in image directive in 
recent Sphinx hg versions.

Modified Paths:
--------------
    branches/v0_98_5_maint/lib/matplotlib/sphinxext/plot_directive.py

Modified: branches/v0_98_5_maint/lib/matplotlib/sphinxext/plot_directive.py
===================================================================
--- branches/v0_98_5_maint/lib/matplotlib/sphinxext/plot_directive.py   
2009-03-03 15:06:54 UTC (rev 6949)
+++ branches/v0_98_5_maint/lib/matplotlib/sphinxext/plot_directive.py   
2009-03-03 22:06:53 UTC (rev 6950)
@@ -30,7 +30,11 @@
     from docutils.parsers.rst.directives.images import Image
     align = Image.align
 from docutils import nodes
+import sphinx
 
+sphinx_version = sphinx.__version__.split(".")
+sphinx_version = tuple([int(x) for x in sphinx_version[:2]])
+
 import matplotlib
 import matplotlib.cbook as cbook
 matplotlib.use('Agg')
@@ -92,11 +96,11 @@
 
    [%(links)s]
 
-   .. image:: %(tmpdir)s/%(outname)s.png
+   .. image:: %(prefix)s%(tmpdir)s/%(outname)s.png
    %(options)s
 
 .. latexonly::
-   .. image:: %(tmpdir)s/%(outname)s.pdf
+   .. image:: %(prefix)s%(tmpdir)s/%(outname)s.pdf
    %(options)s
 """
 
@@ -262,7 +266,17 @@
 
     # tmpdir is where we build all the output files.  This way the
     # plots won't have to be redone when generating latex after html.
-    tmpdir = os.path.abspath(os.path.join('build', outdir))
+
+    # Prior to Sphinx 0.6, absolute image paths were treated as
+    # relative to the root of the filesystem.  0.6 and after, they are
+    # treated as relative to the root of the documentation tree.  We need
+    # to support both methods here.
+    tmpdir = os.path.join('build', outdir)
+    if sphinx_version < (0, 6):
+        tmpdir = os.path.abspath(tmpdir)
+        prefix = ''
+    else:
+        prefix = '/'
     if not os.path.exists(tmpdir):
         cbook.mkdirs(tmpdir)
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to