From c4a3e15ff0ad2fee8f650b7eb8f372f295f11784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Verg=C3=A9?= Date: Sun, 3 Sep 2017 15:55:57 +0200 Subject: [PATCH] docs(readthedocs): Fix builds on yamllint.readthedocs.io Documentation builds on readthedocs.io partly fail because some modules imported by yammlint cannot be imported in Sphinx automodule. This commit fixes that using the tip at [1]. Closes #66 [1]: http://docs.readthedocs.io/en/latest/faq.html#i-get-import-errors-on-libraries-that-depend-on-c-modules --- docs/conf.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index 26668da..8225094 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -4,6 +4,7 @@ import sys import os +from unittest.mock import MagicMock sys.path.insert(0, os.path.abspath('..')) # noqa @@ -40,3 +41,15 @@ htmlhelp_basename = 'yamllintdoc' man_pages = [ ('index', 'yamllint', '', [u'Adrien Vergé'], 1) ] + +# -- Build with sphinx automodule without needing to install third-party libs + + +class Mock(MagicMock): + @classmethod + def __getattr__(cls, name): + return MagicMock() + + +MOCK_MODULES = ['pathspec', 'yaml'] +sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)