|
From: <lee...@us...> - 2009-10-12 23:27:38
|
Revision: 7880
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7880&view=rev
Author: leejjoon
Date: 2009-10-12 23:02:27 +0000 (Mon, 12 Oct 2009)
Log Message:
-----------
fix plot_directive.py that generated incorrect links for some cases
Modified Paths:
--------------
branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py
Modified: branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py
===================================================================
--- branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py 2009-10-12 16:30:14 UTC (rev 7879)
+++ branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py 2009-10-12 23:02:27 UTC (rev 7880)
@@ -260,12 +260,10 @@
# the temporary directory, and then sphinx moves the file to
# build/html/_images for us later.
rstdir, rstfile = os.path.split(state_machine.document.attributes['source'])
- reldir = rstdir[len(setup.confdir)+1:]
- relparts = [p for p in os.path.split(reldir) if p.strip()]
- nparts = len(relparts)
outdir = os.path.join('plot_directive', basedir)
- linkdir = ('../' * nparts) + outdir
-
+ reldir = relpath(setup.confdir, rstdir)
+ linkdir = os.path.join(reldir, outdir)
+
# tmpdir is where we build all the output files. This way the
# plots won't have to be redone when generating latex after html.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-10-19 09:02:16
|
Revision: 7893
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7893&view=rev
Author: leejjoon
Date: 2009-10-19 09:02:08 +0000 (Mon, 19 Oct 2009)
Log Message:
-----------
fix a bug in plot_directive
Modified Paths:
--------------
branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py
Modified: branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py
===================================================================
--- branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py 2009-10-19 06:50:44 UTC (rev 7892)
+++ branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py 2009-10-19 09:02:08 UTC (rev 7893)
@@ -81,7 +81,10 @@
i+=1
rel_list = [os.pardir] * (len(base_list)-i) + target_list[i:]
- return os.path.join(*rel_list)
+ if rel_list:
+ return os.path.join(*rel_list)
+ else:
+ return ""
def write_char(s):
sys.stdout.write(s)
@@ -263,7 +266,7 @@
outdir = os.path.join('plot_directive', basedir)
reldir = relpath(setup.confdir, rstdir)
linkdir = os.path.join(reldir, outdir)
-
+
# tmpdir is where we build all the output files. This way the
# plots won't have to be redone when generating latex after html.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2009-11-18 16:19:28
|
Revision: 7972
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7972&view=rev
Author: mdboom
Date: 2009-11-18 16:19:21 +0000 (Wed, 18 Nov 2009)
Log Message:
-----------
Fix plot directive so it handles source files in various encodings.
Modified Paths:
--------------
branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py
Modified: branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py
===================================================================
--- branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py 2009-11-16 23:53:13 UTC (rev 7971)
+++ branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py 2009-11-18 16:19:21 UTC (rev 7972)
@@ -36,7 +36,7 @@
sphinx_version = sphinx.__version__.split(".")
# The split is necessary for sphinx beta versions where the string is
# '6b1'
-sphinx_version = tuple([int(re.split('[a-z]', x)[0])
+sphinx_version = tuple([int(re.split('[a-z]', x)[0])
for x in sphinx_version[:2]])
import matplotlib
@@ -96,7 +96,8 @@
'scale': directives.nonnegative_int,
'align': align,
'class': directives.class_option,
- 'include-source': directives.flag }
+ 'include-source': directives.flag,
+ 'encoding': directives.encoding}
template = """
.. htmlonly::
@@ -294,8 +295,15 @@
if options.has_key('include-source'):
if content is None:
- content = open(reference, 'r').read()
- lines = ['::', ''] + [' %s'%row.rstrip() for row in content.split('\n')]
+ lines = [
+ '.. include:: %s' % os.path.join(setup.app.builder.srcdir, reference),
+ ' :literal:']
+ if options.has_key('encoding'):
+ lines.append(' :encoding: %s' % options['encoding'])
+ del options['encoding']
+ else:
+ lines = ['::', ''] + [' %s'%row.rstrip() for row in content.split('\n')]
+ lines.append('')
del options['include-source']
else:
lines = []
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2009-12-01 19:01:53
|
Revision: 7998
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7998&view=rev
Author: mdboom
Date: 2009-12-01 19:01:45 +0000 (Tue, 01 Dec 2009)
Log Message:
-----------
[2906157] Let sphinx reference matplotlib-created plots (backport)
Modified Paths:
--------------
branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py
Modified: branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py
===================================================================
--- branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py 2009-12-01 18:58:49 UTC (rev 7997)
+++ branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py 2009-12-01 19:01:45 UTC (rev 7998)
@@ -276,8 +276,8 @@
# treated as relative to the root of the documentation tree. We need
# to support both methods here.
tmpdir = os.path.join('build', outdir)
+ tmpdir = os.path.abspath(tmpdir)
if sphinx_version < (0, 6):
- tmpdir = os.path.abspath(tmpdir)
prefix = ''
else:
prefix = '/'
@@ -343,6 +343,36 @@
return []
+def mark_plot_labels(app, document):
+ """
+ To make plots referenceable, we need to move the reference from
+ the "htmlonly" (or "latexonly") node to the actual figure node
+ itself.
+ """
+ for name, explicit in document.nametypes.iteritems():
+ if not explicit:
+ continue
+ labelid = document.nameids[name]
+ if labelid is None:
+ continue
+ node = document.ids[labelid]
+ if node.tagname in ('html_only', 'latex_only'):
+ for n in node:
+ if n.tagname == 'figure':
+ sectname = name
+ for c in n:
+ if c.tagname == 'caption':
+ sectname = c.astext()
+ break
+
+ node['ids'].remove(labelid)
+ node['names'].remove(name)
+ n['ids'].append(labelid)
+ n['names'].append(name)
+ document.settings.env.labels[name] = \
+ document.settings.env.docname, labelid, sectname
+ break
+
def setup(app):
setup.app = app
setup.config = app.config
@@ -354,3 +384,4 @@
['png', 'hires.png', 'pdf'],
True)
+ app.connect('doctree-read', mark_plot_labels)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|