Skip to content

Commit 5b9a3af

Browse files
Remove matplotlib from autodoc mock imports and add custom mock for rcParams assignment
1 parent 52dc832 commit 5b9a3af

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

docs/conf.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def add_line(self, line: str, source: str, *lineno: int) -> None:
3737
# Mock imports for Sphinx documentation generation
3838
autodoc_mock_imports = [
3939
# Heavy / optional scientific stack
40-
'numpy', 'pandas', 'scipy', 'torch', 'transformers', 'sklearn', 'matplotlib', 'networkx',
40+
'numpy', 'pandas', 'scipy', 'torch', 'transformers', 'sklearn', 'networkx',
4141
# Embedding / NLP helper libs
4242
'sentence_transformers', 'simpleneighbors', 'syllables',
4343
# LangChain ecosystem
@@ -51,6 +51,21 @@ def add_line(self, line: str, source: str, *lineno: int) -> None:
5151
'tqdm', 'print_color', 'jinja2', 'graphviz', 'PIL', 'tenacity', 'joblib'
5252
]
5353

54+
# Custom mock for matplotlib to handle rcParams assignment
55+
from unittest.mock import MagicMock
56+
57+
class MockRcParams(dict):
58+
"""Mock rcParams that behaves like a dict and supports item assignment."""
59+
def __setitem__(self, key, value):
60+
super().__setitem__(key, value)
61+
62+
class MockMatplotlib(MagicMock):
63+
"""Mock matplotlib with properly configured rcParams."""
64+
rcParams = MockRcParams()
65+
66+
sys.modules['matplotlib'] = MockMatplotlib()
67+
sys.modules['matplotlib.pyplot'] = MagicMock()
68+
5469
# -- Project version ---------------------------------------------------------
5570

5671
_version_re__ = r"__version__\s*=\s*['\"]([^'\"]+)['\"]"

0 commit comments

Comments
 (0)