diff --git a/docs/conf.py b/docs/conf.py index 4f189350..79630685 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -13,12 +13,24 @@ # serve to show the default. import sys import os +from unittest.mock import MagicMock # 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. sys.path.insert(0, os.path.abspath('..')) +# Mock packages that cannot be installed on rtd +on_rtd = os.environ.get('READTHEDOCS') == 'True' +if on_rtd: + class Mock(MagicMock): + @classmethod + def __getattr__(cls, name): + return MagicMock() + + MOCK_MODULES = ['ldap'] + sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) + # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. diff --git a/docs/requirements.txt b/docs/requirements.txt index 5503d6a7..0362eadf 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -28,7 +28,7 @@ tabulate==0.7.7 pem==17.1.0 raven[flask]==6.1.0 jinja2==2.9.6 -pyldap==2.4.37 # required by ldap auth provider +# pyldap==2.4.37 # cannot be installed on rtd - required by ldap auth provider paramiko==2.2.1 # required for lemur_linuxdst plugin sphinx sphinxcontrib-httpdomain