diff --git a/doc/conf.py b/doc/conf.py index f1c120b5..d32c77f7 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -13,6 +13,120 @@ import sys, os +#Mocking uninstalled modules: https://read-the-docs.readthedocs.org/en/latest/faq.html + +#class Mock(object): + #__all__ = [] + #def __init__(self, *args, **kwargs): + #for key, value in kwargs.iteritems(): + #setattr(self, key, value) + + #def __call__(self, *args, **kwargs): + #return Mock() + + #__add__ = __mul__ = __getitem__ = __setitem__ = \ +#__delitem__ = __sub__ = __floordiv__ = __mod__ = __divmod__ = \ +#__pow__ = __lshift__ = __rshift__ = __and__ = __xor__ = __or__ = \ +#__rmul__ = __rsub__ = __rfloordiv__ = __rmod__ = __rdivmod__ = \ +#__rpow__ = __rlshift__ = __rrshift__ = __rand__ = __rxor__ = __ror__ = \ +#__imul__ = __isub__ = __ifloordiv__ = __imod__ = __idivmod__ = \ +#__ipow__ = __ilshift__ = __irshift__ = __iand__ = __ixor__ = __ior__ = \ +#__neg__ = __pos__ = __abs__ = __invert__ = __call__ + + #def __getattr__(self, name): + #if name in ('__file__', '__path__'): + #return '/dev/null' + #if name == 'sqrt': + #return math.sqrt + #elif name[0] != '_' and name[0] == name[0].upper(): + #return type(name, (), {}) + #else: + #return Mock(**vars(self)) + + #def __lt__(self, *args, **kwargs): + #return True + + #__nonzero__ = __le__ = __eq__ = __ne__ = __gt__ = __ge__ = __contains__ = \ +#__lt__ + + + #def __repr__(self): + ## Use _mock_repr to fake the __repr__ call + #res = getattr(self, "_mock_repr") + #return res if isinstance(res, str) else "Mock" + + #def __hash__(self): + #return 1 + + #__len__ = __int__ = __long__ = __index__ = __hash__ + + #def __oct__(self): + #return '01' + + #def __hex__(self): + #return '0x1' + + #def __float__(self): + #return 0.1 + + #def __complex__(self): + #return 1j + + +#MOCK_MODULES = [ + #'pylab', 'scipy', 'matplotlib', 'matplotlib.pyplot', 'pyfits', + #'scipy.constants.constants', 'matplotlib.cm', + #'matplotlib.image', 'matplotlib.colors', 'sunpy.cm', + #'pandas', 'pandas.io', 'pandas.io.parsers', + #'suds', 'matplotlib.ticker', 'matplotlib.colorbar', + #'matplotlib.dates', 'scipy.optimize', 'scipy.ndimage', + #'matplotlib.figure', 'scipy.ndimage.interpolation', 'bs4'] +#for mod_name in MOCK_MODULES: + #sys.modules[mod_name] = Mock() + + +#sys.modules['numpy'] = Mock(pi=math.pi, G=6.67364e-11, + #ndarray=type('ndarray', (), {}), + #dtype=lambda _: Mock(_mock_repr='np.dtype(\'float32\')')) +#sys.modules['scipy.constants'] = Mock(pi=math.pi, G=6.67364e-11) + +############################################################################## +## +## Mock out imports with C dependencies because ReadTheDocs can't build them. +#class Mock(object): + #def __init__(self, *args, **kwargs): + #pass + + #def __call__(self, *args, **kwargs): + #return Mock() + + #@classmethod + #def __getattr__(cls, name): + #if name in ('__file__', '__path__'): + #return '/dev/null' + #elif name[0] == name[0].upper(): + #mockType = type(name, (), {}) + #mockType.__module__ = __name__ + #return mockType + #else: + #return Mock() + +import mock + +MOCK_MODULES = ['pylab', 'matplotlib']#'matplotlib', 'matplotlib.color', 'matplotlib.pyplot', 'pylab' ] +for mod_name in MOCK_MODULES: + sys.modules[mod_name] = mock.Mock() + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('..')) + +# If your extensions are in another directory, add it here. If the directory +# is relative to the documentation root, use os.path.abspath to make it +# absolute, like shown here. +#sys.path.append(os.path.abspath('.')) + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. @@ -33,7 +147,9 @@ on_rtd = os.environ.get('READTHEDOCS', None) == 'True' if on_rtd: sys.path.append("../GPy") os.system("pwd") + #os.system("cd ..") os.system("sphinx-apidoc -f -o . ../GPy") + #os.system("cd ./docs") # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -294,3 +410,18 @@ epub_copyright = u'2013, Author' # Allow duplicate toc entries. #epub_tocdup = True + +############################################################################# +# +# Include constructors in all the docs +# Got this method from: +# http://stackoverflow.com/questions/5599254/how-to-use-sphinxs-autodoc-to-document-a-classs-init-self-method +#def skip(app, what, name, obj, skip, options): + #if name == "__init__": + #return False + #return skip + +#def setup(app): + #app.connect("autodoc-skip-member", skip) + +