From 857e1917ec45413c45dc76682fc0c1b88cd60fc6 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Thu, 31 Mar 2011 15:47:54 -0400 Subject: 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) --- doc/source/conf.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'doc/source/conf.py') 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) -- cgit v1.2.1