[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/master] Mock C-extensions out for doc building.
commit 4cdf880516388c93086ff6e60e4e9f4c761005db
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date: Tue Nov 26 12:39:15 2013 +0000
Mock C-extensions out for doc building.
---
doc/sphinx/source/conf.py | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/doc/sphinx/source/conf.py b/doc/sphinx/source/conf.py
index 686a055..49d5305 100644
--- a/doc/sphinx/source/conf.py
+++ b/doc/sphinx/source/conf.py
@@ -42,6 +42,33 @@ import bridgedb.test
import bridgedb.Tests
import bridgedb.Util
+
+class Mock(object):
+ """Used to fake the presence of Python C-extensions for documentation
+ building. See
+ http://docs.readthedocs.org/en/latest/faq.html#i-get-import-errors-on-libraries-that-depend-on-c-modules
+ """
+ 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()
+
+MOCK_MODULES = ['pygpgme']
+for mod_name in MOCK_MODULES:
+ sys.modules[mod_name] = Mock()
+
# -- Autodoc settings ----------------------------------------------------------
autodoc_member_order = 'bysource'
autodoc_default_flags = ['members',
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits