From f3381b0bf3d93c604f0135e056d2bd6811ab4a59 Mon Sep 17 00:00:00 2001 From: Andrew Riha Date: Fri, 12 Jul 2024 21:47:20 -0700 Subject: [PATCH] Mock imports when building docs --- docs/conf.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index ab6120f..c121253 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -19,6 +19,7 @@ # import os import sys +from unittest.mock import MagicMock # http://docs.readthedocs.io/en/latest/faq.html#i-get-import-errors-on-libraries-that-depend-on-c-modules autodoc_mock_imports = [ @@ -31,6 +32,17 @@ sys.path.insert(0, os.path.abspath("../")) + +class Mock(MagicMock): + @classmethod + def __getattr__(cls, name): + return MagicMock() + + +# Apply the mock for each module +for mod_name in autodoc_mock_imports: + sys.modules[mod_name] = Mock() + import lineage # https://samnicholls.net/2016/06/15/how-to-sphinx-readthedocs/