diff --git a/doc/source/conf.py b/doc/source/conf.py index 5d7a6fc4..975de3eb 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -26,9 +26,26 @@ sys.path.append(os.path.join(curpath, '..', 'ext')) # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.pngmath', 'numpydoc', - 'sphinx.ext.autosummary', 'plot_directive', 'plot2rst', + 'sphinx.ext.autosummary', 'plot2rst', 'sphinx.ext.intersphinx'] +# 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']