Skip to content

Commit

Permalink
Mock imports when building docs
Browse files Browse the repository at this point in the history
  • Loading branch information
apriha committed Jul 13, 2024
1 parent 19249b2 commit f3381b0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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/
Expand Down

0 comments on commit f3381b0

Please sign in to comment.