summaryrefslogtreecommitdiff
path: root/doc/source/conf.py
diff options
context:
space:
mode:
authorMichael Droettboom <mdboom@gmail.com>2011-03-31 15:47:54 -0400
committerPauli Virtanen <pav@iki.fi>2011-04-02 13:49:27 +0200
commit857e1917ec45413c45dc76682fc0c1b88cd60fc6 (patch)
tree6cbdac2097032e580e83ae2800b9b6350e34ded9 /doc/source/conf.py
parent1dcf0c96df5e2f7b861c6054ead2ad7ebc77aa79 (diff)
downloadnumpy-857e1917ec45413c45dc76682fc0c1b88cd60fc6.tar.gz
DOC: Changes required to the configuration to start building docs with matplotlib's plot_directive. Requires that matplotlib have the new "merged" plot_directive. (#1074)
Diffstat (limited to 'doc/source/conf.py')
-rw-r--r--doc/source/conf.py29
1 files changed, 24 insertions, 5 deletions
diff --git a/doc/source/conf.py b/doc/source/conf.py
index 4dfec91db..72083cc95 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -20,8 +20,24 @@ sys.path.insert(0, os.path.abspath('../sphinxext'))
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.pngmath', 'numpydoc',
'sphinx.ext.intersphinx', 'sphinx.ext.coverage',
- 'sphinx.ext.doctest', 'sphinx.ext.autosummary',
- 'plot_directive']
+ 'sphinx.ext.doctest', 'sphinx.ext.autosummary']
+
+# Determine if the matplotlib has a recent enough version of the
+# plot_directive, otherwise use the local fork.
+try:
+ from matplotlib.sphinxext import plot_directive
+except ImportError:
+ use_matplotlib_plot_directive = False
+else:
+ try:
+ use_matplotlib_plot_directive = (plot_directive.__version__ >= 2)
+ except AttributeError:
+ use_matplotlib_plot_directive = False
+
+if use_matplotlib_plot_directive:
+ extensions.append('matplotlib.sphinxext.plot_directive')
+else:
+ extensions.append('plot_directive')
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -251,8 +267,7 @@ plot_formats = [('png', 100), 'pdf']
import math
phi = (math.sqrt(5) + 1)/2
-import matplotlib
-matplotlib.rcParams.update({
+plot_rcparams = {
'font.size': 8,
'axes.titlesize': 8,
'axes.labelsize': 8,
@@ -266,4 +281,8 @@ matplotlib.rcParams.update({
'figure.subplot.top': 0.85,
'figure.subplot.wspace': 0.4,
'text.usetex': False,
-})
+}
+
+if not use_matplotlib_plot_directive:
+ import matplotlib
+ matplotlib.rcParams.update(plot_rcparams)