Skip to content

Commit 3aa07ed

Browse files
committed
Docs: Add module mocks
1 parent e54e78a commit 3aa07ed

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

docs/conf.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,20 @@
2929
# Enviroment variable used to code to detect if modules are imported by sphinx
3030
os.environ['DOCS_BUILDING'] = "True"
3131

32+
# Mock modules
33+
class Mock(MagicMock):
34+
@classmethod
35+
def __getattr__(cls, name):
36+
return MagicMock()
37+
38+
MOCK_MODULES = ['glfw',]
39+
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
40+
3241
# Define a settings module
3342
os.environ['DEMOSYS_SETTINGS_MODULE'] = 'demosys.conf.default'
3443
import demosys
3544
demosys.setup()
3645

37-
3846
# Monkey patch sphinx to ignore: WARNING: nonlocal image URI
3947
def _warn_node(self, msg, node, **kwargs):
4048
if not msg.startswith('nonlocal image URI found:'):

0 commit comments

Comments
 (0)