Skip to content

Commit

Permalink
Doc build fix
Browse files Browse the repository at this point in the history
Unfortnately, readthedocs currently doesn't support plot_directive
  • Loading branch information
r9y9 committed Sep 6, 2015
1 parent f998f2d commit e89a2df
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
1 change: 0 additions & 1 deletion .requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ cython >= 0.19.0
six
numpydoc
seaborn
matplotlib == 1.1.1
40 changes: 24 additions & 16 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))

ON_RTD = os.environ.get('READTHEDOCS', None) == 'True'

# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
Expand All @@ -39,31 +41,37 @@
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'numpydoc',
'matplotlib.sphinxext.plot_directive',
]

if ON_RTD:
# Remove extensions not currently supported on RTD
extensions.remove('matplotlib.sphinxext.plot_directive')

autosummary_generate = True
numpydoc_show_class_members = False

# Most of plotting settings are copy and pasted from librosa
# https://github.com/bmcfee/librosa

# Determine if the matplotlib has a recent enough version of the
# plot_directive.
try:
from matplotlib.sphinxext import plot_directive
except ImportError:
use_matplotlib_plot_directive = False
else:
if not ON_RTD:
# Determine if the matplotlib has a recent enough version of the
# plot_directive.
try:
print("plot_directive.__version__:", plot_directive.__version__)
use_matplotlib_plot_directive = (plot_directive.__version__ >= 2)
except AttributeError:
from matplotlib.sphinxext import plot_directive
except ImportError:
use_matplotlib_plot_directive = False

if use_matplotlib_plot_directive:
extensions.append('matplotlib.sphinxext.plot_directive')
else:
raise RuntimeError("You need a recent enough version of matplotlib")
else:
try:
print("plot_directive.__version__:", plot_directive.__version__)
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:
raise RuntimeError("You need a recent enough version of matplotlib")

#------------------------------------------------------------------------------
# Plot
Expand Down Expand Up @@ -97,7 +105,7 @@
'text.usetex': False,
}

if not use_matplotlib_plot_directive:
if not ON_RTD:
import matplotlib
matplotlib.rcParams.update(plot_rcparams)

Expand Down

0 comments on commit e89a2df

Please sign in to comment.