Skip to content

Commit b6201aa

Browse files
committed
#53 another experiment mocking package dependencies
1 parent 279e9d6 commit b6201aa

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

.isort.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[settings]
2-
known_third_party = arviz,matplotlib,numpy,pandas,patsy,pymc,scipy,seaborn,setuptools,sklearn,statsmodels,xarray
2+
known_third_party = arviz,matplotlib,mock,numpy,pandas,patsy,pymc,scipy,seaborn,setuptools,sklearn,statsmodels,xarray

docs/conf.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,30 @@
1414

1515
sys.path.insert(0, os.path.abspath("../"))
1616

17-
# manually import package dependencies in an attempt to make autodoc work
18-
import arviz
19-
import matplotlib
20-
import numpy
21-
import pandas
22-
import patsy
23-
import pymc
24-
import scipy
25-
import seaborn
26-
import sklearn
27-
import xarray
17+
18+
# Need to mock the package dependencies in order for autodoc to work when docs are remotely built on readthedocs
19+
from mock import Mock as MagicMock
20+
21+
22+
class Mock(MagicMock):
23+
@classmethod
24+
def __getattr__(cls, name):
25+
return MagicMock()
26+
27+
28+
MOCK_MODULES = [
29+
"arviz",
30+
"matplotlib",
31+
"numpy",
32+
"pandas",
33+
"patsy",
34+
"pymc",
35+
"scipy",
36+
"seaborn",
37+
"sklearn",
38+
"xarray",
39+
]
40+
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
2841

2942
# -- Project information -----------------------------------------------------
3043
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

requirements-docs.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
ipykernel
22
linkify-it-py
3+
mock
34
myst_parser
45
nbsphinx
56
pathlib

0 commit comments

Comments
 (0)