Skip to content

Commit 9ee7ff2

Browse files
committed
Mock grpcio when generating docs.
1 parent 488b600 commit 9ee7ff2

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎docs/conf.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# serve to show the default.
1313

1414
from email import message_from_string
15+
import mock
1516
import os
1617
from pkg_resources import get_distribution
1718
import sys
@@ -23,6 +24,20 @@
2324
ON_READ_THE_DOCS = os.environ.get('READTHEDOCS', None) == 'True'
2425
LOCAL_READ_THE_DOCS = os.environ.get('LOCAL_RTD', None) == 'True'
2526

27+
28+
# See
29+
# (https://read-the-docs.readthedocs.io/en/latest/faq.html#\
30+
# i-get-import-errors-on-libraries-that-depend-on-c-modules)
31+
32+
class Mock(mock.Mock):
33+
34+
@classmethod
35+
def __getattr__(cls, name):
36+
return Mock()
37+
38+
39+
MOCK_MODULES = ('grpcio')
40+
2641
# If extensions (or modules to document with autodoc) are in another directory,
2742
# add these directories to sys.path here. If the directory is relative to the
2843
# documentation root, use os.path.abspath to make it absolute, like shown here.

‎tox.ini‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ commands =
8282
sphinx-build -W -b html -d docs/_build/doctrees docs docs/_build/html
8383
python {toxinidir}/scripts/verify_included_modules.py
8484
deps =
85+
mock
8586
Sphinx
8687
sphinx_rtd_theme
8788
passenv = {[testenv:system-tests]passenv} SPHINX_RELEASE READTHEDOCS LOCAL_RTD

0 commit comments

Comments
 (0)