Permalink
Browse files

Mock out deps for RTD

  • Loading branch information...
1 parent af18a2a commit de00e9eb7dfdc439a20d277956f347820b339c04 @kvh committed Dec 18, 2012
Showing with 27 additions and 0 deletions.
  1. +27 −0 docs/source/conf.py
View
@@ -18,6 +18,33 @@
# 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'
+
+# mock out dependencies
+class Mock(object):
+ def __init__(self, *args, **kwargs):
+ pass
+
+ def __call__(self, *args, **kwargs):
+ return Mock()
+
+ @classmethod
+ def __getattr__(cls, name):
+ if name in ('__file__', '__path__'):
+ return '/dev/null'
+ elif name[0] == name[0].upper():
+ mockType = type(name, (), {})
+ mockType.__module__ = __name__
+ return mockType
+ else:
+ return Mock()
+
+if ON_RTD:
+ MOCK_MODULES = ['numpy', 'scipy', 'scipy.stats', 'pandas', 'sklearn']
+ for mod_name in MOCK_MODULES:
+ sys.modules[mod_name] = Mock()
+
+
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.

0 comments on commit de00e9e

Please sign in to comment.