diff --git a/docs/source/conf.py b/docs/source/conf.py index 0eec195..bd7d0ac 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -17,6 +17,33 @@ import sys, os +ON_RTD = os.environ.get('READTHEDOCS', None) == 'True' + +if ON_RTD: + # Mock the presence of matplotlib, which we don't have on RTD + # see + # http://read-the-docs.readthedocs.org/en/latest/faq.html + + class Mock(object): + def __init__(self, *args, **kwargs): + pass + + def __call__(self, *args, **kwargs): + return Mock() + + @classmethod + def __getattr__(self, name): + if name in ('__file__', '__path__'): + return '/dev/null' + elif name[0] == name[0].upper(): + return type(name, (), {}) + else: + return Mock() + + MOCK_MODULES = ['matplotlib', 'matplotlib.sphinxext', 'numpy'] + for mod_name in MOCK_MODULES: + sys.modules[mod_name] = Mock() + # If your extensions are in another directory, add it here. If the directory # is relative to the documentation root, use os.path.abspath to make it # absolute, like shown here. @@ -48,6 +75,11 @@ extensions = [ 'github', # for easy GitHub links ] +if ON_RTD: + # Remove extensions not currently supported on RTD + extensions.remove('matplotlib.sphinxext.only_directives') + extensions.remove('ipython_directive') + # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates']