From 6c1d6d96073154c284e5c75419f63394189d344f 2012-08-08 15:24:17 From: Bussonnier Matthias Date: 2012-08-08 15:24:17 Subject: [PATCH] Merge pull request #2263 from Carreau/rtfd Allow docs to build on http://readthedocs.org/ --- diff --git a/docs/source/conf.py b/docs/source/conf.py index 0eec195..d2e37b0 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 + tags.add('rtd') + 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'] diff --git a/docs/source/development/ipython_directive.txt b/docs/source/development/ipython_directive.txt index ca6c4da..8ebb554 100644 --- a/docs/source/development/ipython_directive.txt +++ b/docs/source/development/ipython_directive.txt @@ -1,7 +1,7 @@ .. _ipython_directive: ======================== -Ipython Sphinx Directive +IPython Sphinx Directive ======================== The ipython directive is a stateful ipython shell for embedding in diff --git a/docs/source/index.txt b/docs/source/index.txt index c344faa..c97d512 100644 --- a/docs/source/index.txt +++ b/docs/source/index.txt @@ -7,7 +7,13 @@ IPython Documentation :Release: |release| :Date: |today| -Welcome to the official IPython documentation. +.. only:: not rtd + + Welcome to the official IPython documentation. + +.. only:: rtd + + This is a partial copy of IPython documentation, please visit `IPython official documentation `_. Contents ========