From 9b6c5870b43aa4d26163f2e44a50c49fb7eced11 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Thu, 31 Mar 2011 15:47:54 -0400 Subject: [PATCH 1/2] Bug #1074: Changes required to the configuration to start building docs with matplotlib's plot_directive. Requires that matplotlib have the new "merged" plot_directive. --- doc/source/conf.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 4dfec91dba31..8a80b179e65c 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -21,7 +21,7 @@ extensions = ['sphinx.ext.autodoc', 'sphinx.ext.pngmath', 'numpydoc', 'sphinx.ext.intersphinx', 'sphinx.ext.coverage', 'sphinx.ext.doctest', 'sphinx.ext.autosummary', - 'plot_directive'] + 'matplotlib.sphinxext.plot_directive'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -251,8 +251,7 @@ 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 +265,4 @@ 'figure.subplot.top': 0.85, 'figure.subplot.wspace': 0.4, 'text.usetex': False, -}) +} From e3ce6b93632ba47e46974c364bce1e47aee22b10 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 1 Apr 2011 09:14:09 -0400 Subject: [PATCH 2/2] If a recent enough version of matplotlib's plot_directive is found, use it, otherwise use the local fork. --- doc/source/conf.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 8a80b179e65c..72083cc955e1 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -20,8 +20,24 @@ extensions = ['sphinx.ext.autodoc', 'sphinx.ext.pngmath', 'numpydoc', 'sphinx.ext.intersphinx', 'sphinx.ext.coverage', - 'sphinx.ext.doctest', 'sphinx.ext.autosummary', - 'matplotlib.sphinxext.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'] @@ -266,3 +282,7 @@ 'figure.subplot.wspace': 0.4, 'text.usetex': False, } + +if not use_matplotlib_plot_directive: + import matplotlib + matplotlib.rcParams.update(plot_rcparams)