Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #4551 Changed mock docks to use sphinx #4569

Merged
merged 14 commits into from Nov 1, 2018
8 changes: 5 additions & 3 deletions docs/faq.rst
Expand Up @@ -70,9 +70,9 @@ I get import errors on libraries that depend on C modules
.. note::
Another use case for this is when you have a module with a C extension.

This happens because our build system doesn't have the dependencies for building your project. This happens with things like libevent and mysql, and other python things that depend on C libraries. We can't support installing random C binaries on our system, so there is another way to fix these imports.
This happens because our build system doesn't have the dependencies for building your project. This happens with things like ``libevent``, ``mysql``, and other python packages that depend on C libraries. We can't support installing random C binaries on our system, so there is another way to fix these imports.

You can mock out the imports for these modules in your ``conf.py`` with the following snippet::
With Sphinx you can use the built-in `autodoc_mock_imports`_ for mocking. Alternatively you can use the mock library by putting the following snippet in your ``conf.py``::

import sys
from unittest.mock import MagicMock
Expand All @@ -85,7 +85,7 @@ You can mock out the imports for these modules in your ``conf.py`` with the foll
MOCK_MODULES = ['pygtk', 'gtk', 'gobject', 'argparse', 'numpy', 'pandas']
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)

Of course, replacing `MOCK_MODULES` with the modules that you want to mock out.
You need to replace ``MOCK_MODULES`` with the modules that you want to mock out.

.. Tip:: The library ``unittest.mock`` was introduced on python 3.3. On earlier versions install the ``mock`` library
from PyPI with (ie ``pip install mock``) and replace the above import::
Expand All @@ -94,6 +94,8 @@ Of course, replacing `MOCK_MODULES` with the modules that you want to mock out.

If such libraries are installed via ``setup.py``, you also will need to remove all the C-dependent libraries from your ``install_requires`` in the RTD environment.

.. _autodoc_mock_imports: http://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#confval-autodoc_mock_imports

`Client Error 401` when building documentation
----------------------------------------------

Expand Down