Skip to content

Commit

Permalink
Merge pull request #2263 from Carreau/rtfd
Browse files Browse the repository at this point in the history
Allow docs to build on http://readthedocs.org/
  • Loading branch information
Carreau committed Aug 8, 2012
2 parents 0b8dc09 + 0d7d010 commit 6c1d6d9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
32 changes: 32 additions & 0 deletions docs/source/conf.py
Expand Up @@ -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.
Expand Down Expand Up @@ -48,6 +75,11 @@
'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']

Expand Down
2 changes: 1 addition & 1 deletion 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
Expand Down
8 changes: 7 additions & 1 deletion docs/source/index.txt
Expand Up @@ -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 <http://ipython.org/documentation.html>`_.

Contents
========
Expand Down

0 comments on commit 6c1d6d9

Please sign in to comment.