# -*- coding: utf-8 -*-
#
# YATSM documentation build configuration file, created by
# sphinx-quickstart on Tue Nov  4 18:26:04 2014.

import sys
import os

import sphinx

try:
    from unittest import mock
    from unittest.mock import MagicMock
except:
    import mock
    from mock import MagicMock
mock.FILTER_DIR = False


MOCK_MODULES = [
    'glmnet',
    'matplotlib', 'matplotlib.cm', 'matplotlib.pyplot', 'matplotlib.style',
    'numpy', 'numpy.lib', 'numpy.lib.recfunctions', 'numpy.ma',
    'numba',
    'osgeo',
    'pandas',
    'patsy',
    'rpy2', 'rpy2.robjects', 'rpy2.robjects.numpy2ri',
    'rpy2.robjects.packages',
    'scipy', 'scipy.stats',
    'sklearn', 'sklearn.cross_validation', 'sklearn.ensemble',
    'sklearn.linear_model',
    'sklearn.externals', 'sklearn.externals.joblib',
    'statsmodels', 'statsmodels.api',
    'yatsm.accel', 'yatsm._cyprep',
    'yatsm.classifiers', 'yatsm.classifiers.diagnostics',
]
for mod_name in MOCK_MODULES:
    sys.modules[mod_name] = MagicMock()

# 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.
d = os.path.dirname
sys.path.insert(0, d(d(os.path.abspath(__file__))))
sys.path.insert(0, os.path.join(d(d(os.path.abspath(__file__))), 'scripts'))

# -- General configuration ------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
    'sphinx.ext.autosummary',
    'sphinx.ext.autodoc',
    'sphinx.ext.extlinks',
    'sphinx.ext.graphviz',
    'sphinx.ext.intersphinx',
    'sphinx.ext.mathjax',
    'sphinx.ext.viewcode',
    'sphinx.ext.todo',
    'sphinxcontrib.bibtex'
]
extlinks = {
    'issue': ('https://github.com/ceholden/yatsm/issues/%s', 'issue ')
}
intersphinx_mapping = {
    'sklearn': ('http://scikit-learn.org/stable', None),
    'python': ('https://docs.python.org/3/', None)
}
todo_include_todos = True


# Napoleon extension moving to sphinx.ext.napoleon as of sphinx 1.3
sphinx_version = sphinx.version_info
if sphinx_version[0] >= 1 and sphinx_version[1] >= 3:
    extensions.append('sphinx.ext.napoleon')
else:
    extensions.append('sphinxcontrib.napoleon')

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix of source filenames.
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = u'YATSM'
copyright = u'2014 - 2016, Chris Holden'

import yatsm  # noqa
version = yatsm.__version__
release = yatsm.__version__
html_last_updated_fmt = '%c'

exclude_patterns = ['_build']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []

# -- Options for HTML output ----------------------------------------------

# on_rtd is whether we are on readthedocs.org, this line of code grabbed from
# docs.readthedocs.org
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
if not on_rtd:  # only import and set the theme if we're building docs locally
    import sphinx_rtd_theme
    html_theme = 'sphinx_rtd_theme'
    html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

html_context = dict(
    display_github=True,
    github_user="ceholden",
    github_repo="yatsm",
    github_version="master",
    conf_py_path="/docs/",
    source_suffix=".rst",
)

# html_theme_options = { }

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
# html_extra_path = []

# Custom sidebar templates, maps document names to template names.
# html_sidebars = {}

# Additional templates that should be rendered to pages, maps page names to
# template names.
# html_additional_pages = {}

# If true, links to the reST sources are added to the pages.
html_show_sourcelink = False

# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it.  The value of this option must be the
# base URL from which the finished HTML is served.
# html_use_opensearch = ''

@@ -642,16 +642,33 @@
 'scipy',
+ 'scipy.ndimage',
  'scipy.
@@ -742,36 +742,8 @@
 e',%0A
-    'sklearn.linear_model',%0A
     
@@ -801,45 +801,52 @@
   's
-tats
+klearn.linear_
 model
-s
 ', 's
-tatsmodels.api
+klearn.utils
 ',%0A    '
 yats
@@ -845,36 +845,38 @@
    '
-y
+st
 atsm
-.acc
+od
 el
+s
 ', '
-y
+st
 atsm
-._cyprep
+odels.api
 ',%0A 
@@ -889,54 +889,16 @@
 tsm.
-classifiers', 'yatsm.classifiers.diagnostics',
+_cyprep'
 %0A%5D%0Af
@@ -3865,19 +3865,8 @@
 s%22.%0A
-html_static
 _pat
@@ -3871,17 +3871,16 @@
 ath = %5B'
-_
 static'%5D

Remove unneeded mocks