Skip to content

Commit

Permalink
Add Sphinx settings suitable for readthedocs.org
Browse files Browse the repository at this point in the history
  • Loading branch information
sawcordwell committed Mar 26, 2015
1 parent ea2cf20 commit e830b2d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 12 deletions.
8 changes: 3 additions & 5 deletions README.rst
Expand Up @@ -155,7 +155,9 @@ optimal policy.
Documentation
-------------
Documentation is available as docstrings in the module code.
Documentation is available at http://pymdptoolbox.readthedocs.org/

as docstrings in the module code.
If you use `IPython <http://ipython.scipy.org>`_ to work with the toolbox,
then you can view the docstrings by using a question mark ``?``. For example:

Expand All @@ -167,10 +169,6 @@ then you can view the docstrings by using a question mark ``?``. For example:
mdptoolbox.mdp.ValueIteration?<ENTER>
will display the relevant documentation.
Once the Sphinx document geneator has been set up correctly then the
documentation will be available at http://sawcordwell.github.io/pymdptoolbox/.

.. TODO and as html in the doc folder.

Contribute
----------
Expand Down
42 changes: 35 additions & 7 deletions docs/conf.py
Expand Up @@ -17,6 +17,24 @@
import os
import shlex

on_rtd = os.environ.get('READTHEDOCS', None) == 'True'

# When on read the docs stub out the modules that cannot be loaded
if on_rtd:
try:
from unittest.mock import MagicMock
except ImportError:
from mock import MagicMock


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

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

# 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.
Expand All @@ -31,14 +49,24 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
'sphinx.ext.autodoc'
]

if on_rtd:
extensions.extend([
'sphinx.ext.mathjax',
'sphinxcontrib.napoleon',
'sphinx.ext.viewcode',
])
else:
extensions.extend([
'sphinx.ext.doctest',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinxcontrib.napoleon',
'sphinx.ext.viewcode',
])

# Napoleon settings
napoleon_google_docstrings = False
napoleon_use_param = True
Expand Down Expand Up @@ -120,7 +148,7 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'alabaster'
html_theme = 'default'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
@@ -0,0 +1 @@
sphinxcontrib-napoleon==0.3.1

0 comments on commit e830b2d

Please sign in to comment.