Browse files

Added mock class to mock C modules for doc builds.

  • Loading branch information...
1 parent e7a500c commit b0faa60be6bbe9bb212f9c2c56393f14d1743f89 @xzased committed May 2, 2012
Showing with 21 additions and 0 deletions.
  1. +21 −0 docs/conf.py
View
21 docs/conf.py
@@ -187,6 +187,27 @@
u'Ruben Quinones', 'manual'),
]
+# Mock the existence of C modules (for readthedocs.org documentation builds).
+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 = ['libparted']
+for mod_name in MOCK_MODULES:
+ sys.modules[mod_name] = Mock()
+
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None

0 comments on commit b0faa60

Please sign in to comment.