diff --git a/docs/conf.py b/docs/conf.py index 6b2dcd872739..3fb5f3fbf800 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,6 +12,7 @@ # serve to show the default. from email import message_from_string +import mock import os from pkg_resources import get_distribution import sys @@ -23,6 +24,20 @@ ON_READ_THE_DOCS = os.environ.get('READTHEDOCS', None) == 'True' LOCAL_READ_THE_DOCS = os.environ.get('LOCAL_RTD', None) == 'True' + +# See +# (https://read-the-docs.readthedocs.io/en/latest/faq.html#\ +# i-get-import-errors-on-libraries-that-depend-on-c-modules) + +class Mock(mock.Mock): + + @classmethod + def __getattr__(cls, name): + return Mock() + + +MOCK_MODULES = ('grpcio') + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. diff --git a/tox.ini b/tox.ini index 1936e43c354c..2ef040f8bca5 100644 --- a/tox.ini +++ b/tox.ini @@ -82,6 +82,7 @@ commands = sphinx-build -W -b html -d docs/_build/doctrees docs docs/_build/html python {toxinidir}/scripts/verify_included_modules.py deps = + mock Sphinx sphinx_rtd_theme passenv = {[testenv:system-tests]passenv} SPHINX_RELEASE READTHEDOCS LOCAL_RTD