Skip to content

Commit

Permalink
Merge pull request #4569 from anubhavsinha98/master
Browse files Browse the repository at this point in the history
Issue #4551 Changed mock docks to use sphinx
  • Loading branch information
ericholscher authored Nov 1, 2018
2 parents a2eee02 + 96aba32 commit cb215c2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions docs/faq.rst
Original file line number Diff line number Diff line change
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

0 comments on commit cb215c2

Please sign in to comment.