Skip to content

Commit b9c8633

Browse files
committed
Revert deletion of _Mock object and fix ReadTheDocs.
1 parent 7717a5f commit b9c8633

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,3 +370,5 @@
370370
'https://docs.python.org/2/': None,
371371
'https://docs.scipy.org/doc/numpy/': None,
372372
}
373+
374+
os.environ['READTHEDOCS'] = 'True'

tcod/libtcod.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,32 @@ def BKGND_ALPHA(a):
3232
def BKGND_ADDALPHA(a):
3333
return BKGND_ADDA | (int(a * 255) << 8)
3434

35-
if not _os.environ.get('READTHEDOCS'):
35+
class _Mock(object):
36+
"""Mock object needed for ReadTheDocs."""
37+
38+
CData = () # This gets passed to an isinstance call.
39+
40+
@staticmethod
41+
def def_extern():
42+
"""Pass def_extern call silently."""
43+
return lambda func: func
44+
45+
def __getattr__(self, attr):
46+
"""This object pretends to have everything."""
47+
return self
48+
49+
def __call__(self, *args, **kargs):
50+
"""Suppress any other calls"""
51+
return self
52+
53+
def __str__(self):
54+
"""Just have ? in case anything leaks as a parameter default."""
55+
return '?'
56+
57+
58+
if _os.environ.get('READTHEDOCS'):
59+
# Mock the lib and ffi objects needed to compile docs for readthedocs.io
3660
# Allows an import without building the cffi module first.
61+
lib = ffi = _Mock()
62+
else:
3763
from tcod._libtcod import lib, ffi

tcod/map.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
from tcod.libtcod import lib, ffi
3939
import tcod._internal
40+
import tcod.constants
4041

4142

4243
class Map(object):
@@ -98,7 +99,8 @@ def fov(self):
9899
return buffer.T if self._order == 'F' else buffer
99100

100101
def compute_fov(self, x, y, radius=0, light_walls=True,
101-
algorithm=lib.FOV_RESTRICTIVE):
102+
algorithm=tcod.constants.FOV_RESTRICTIVE):
103+
# type (int, int, int, bool, int) -> None
102104
"""Compute a field-of-view on the current instance.
103105
104106
Args:

0 commit comments

Comments
 (0)