Skip to content

Commit 19e1b9b

Browse files
committed
mock C extensions in doc/conf.py for readthedocs.org
1 parent 14350ab commit 19e1b9b

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

doc/conf.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,32 @@
249249

250250
# If true, do not generate a @detailmenu in the "Top" node's menu.
251251
#texinfo_no_detailmenu = False
252+
253+
class CExtMock(object):
254+
"""Required for autodoc on readthedocs.org where you cannot build C extensions."""
255+
def __init__(self, *args, **kwargs):
256+
pass
257+
258+
def __call__(self, *args, **kwargs):
259+
return CExtMock()
260+
261+
@classmethod
262+
def __getattr__(cls, name):
263+
if name in ('__file__', '__path__'):
264+
return '/dev/null'
265+
else:
266+
return CExtMock()
267+
268+
try:
269+
import lxml # flake8: noqa
270+
except ImportError:
271+
sys.modules['lxml'] = CExtMock()
272+
sys.modules['lxml.etree'] = CExtMock()
273+
print("warning: lxml modules mocked.")
274+
275+
try:
276+
import genshi # flake8: noqa
277+
except ImportError:
278+
sys.modules['genshi'] = CExtMock()
279+
sys.modules['genshi.core'] = CExtMock()
280+
print("warning: genshi modules mocked.")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy