Skip to content

Commit

Permalink
docs: mocking glfw imports on RTD builds [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
swistakm committed Nov 17, 2016
1 parent 27326a1 commit e10f99a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/requirements-docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ PyOpenGL
glfw
pypandoc
git-lfs
mock
19 changes: 19 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@
import os
import sys

try:
import glfw

except ImportError:
glfw = None

if glfw is None:
try:
from unittest.mock import MagicMock
except ImportError:
from mock import MagicMock

class Mock(MagicMock):
@classmethod
def __getattr__(cls, name):
return Mock()

MOCK_MODULES = ['glfw']
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)

sys.path.insert(0, os.path.dirname(__file__))

Expand Down

0 comments on commit e10f99a

Please sign in to comment.