Skip to content

Commit

Permalink
mock C extensions in doc/conf.py for readthedocs.org
Browse files Browse the repository at this point in the history
  • Loading branch information
ambv committed May 17, 2013
1 parent 14350ab commit 19e1b9b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,32 @@

# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False

class CExtMock(object):
"""Required for autodoc on readthedocs.org where you cannot build C extensions."""
def __init__(self, *args, **kwargs):
pass

def __call__(self, *args, **kwargs):
return CExtMock()

@classmethod
def __getattr__(cls, name):
if name in ('__file__', '__path__'):
return '/dev/null'
else:
return CExtMock()

try:
import lxml # flake8: noqa
except ImportError:
sys.modules['lxml'] = CExtMock()
sys.modules['lxml.etree'] = CExtMock()
print("warning: lxml modules mocked.")

try:
import genshi # flake8: noqa
except ImportError:
sys.modules['genshi'] = CExtMock()
sys.modules['genshi.core'] = CExtMock()
print("warning: genshi modules mocked.")

0 comments on commit 19e1b9b

Please sign in to comment.