[PATCH] Mock non-standard modules so we can generate API docs on readthedocs.

David Lehman dlehman at redhat.com
Thu Jul 17 20:44:14 UTC 2014


---
 doc/conf.py | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/doc/conf.py b/doc/conf.py
index 4b16a97..05594fd 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -289,3 +289,32 @@ epub_copyright = u'2013, David Lehman'
 
 # Example configuration for intersphinx: refer to the Python standard library.
 intersphinx_mapping = {'https://docs.python.org/2': None}
+
+class Mock(object):
+
+    __all__ = []
+
+    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()
+
+    @classmethod
+    def __getitem__(cls, key):
+	return cls.__getattr__(key)
+
+MOCK_MODULES = ['parted', 'block', 'pycryptsetup', 'pykickstart', 'pykickstart.constants', '_ped']
+for mod_name in MOCK_MODULES:
+    sys.modules[mod_name] = Mock()
-- 
1.9.3



More information about the anaconda-patches mailing list