# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import datetime
import os
import subprocess
import sys

import sphinx_autosummary_accessors

import xskillscore

print('python exec:', sys.executable)
print('sys.path:', sys.path)

if 'conda' in sys.executable:
    print('conda environment:')
    subprocess.run(['conda', 'list'])
else:
    print('pip environment:')
    subprocess.run(['pip', 'list'])

print('xskillscore: %s, %s' % (xskillscore.__version__, xskillscore.__file__))


# -- 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.autodoc',
    'sphinx.ext.autosummary',
    'sphinx.ext.intersphinx',
    'sphinx.ext.extlinks',
    'sphinx.ext.mathjax',
    'sphinx.ext.napoleon',
    'IPython.sphinxext.ipython_directive',
    'IPython.sphinxext.ipython_console_highlighting',
    'nbsphinx',
    'sphinx_autosummary_accessors',
]

extlinks = {
    'issue': ('https://github.com/raybellwaves/xskillscore/issues/%s', 'GH#'),
    'pr': ('https://github.com/raybellwaves/xskillscore/pull/%s', 'GH#'),
}

nbsphinx_timeout = 60
nbsphinx_execute = 'always'

autosummary_generate = True
autodoc_typehints = 'none'

napoleon_use_param = True
napoleon_use_rtype = True

numpydoc_class_members_toctree = True
numpydoc_show_class_members = False

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

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

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = 'xskillscore'
copyright = '2018-%s, xskillscore Developers' % datetime.datetime.now().year

# The full version, including alpha/beta/rc tags
version = xskillscore.__version__

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
# today = ''
# Else, today_fmt is used as the format for a strftime call.
today_fmt = '%Y-%m-%d'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['build', '**.ipynb_checkpoints', 'Thumbs.db', '.DS_Store']

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


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

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

# Can add below once we have a logo.
# html_logo = 'images/esmtools-logo.png'
# html_theme_options = {'logo_only': True, 'style_nav_header_background': '#fcfcfc'}

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
html_last_updated_fmt = today_fmt

# Output file base name for HTML help builder.
htmlhelp_basename = 'xskillscoredoc'

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
    'cftime': ('https://unidata.github.io/cftime', None),
    'dask': ('https://docs.dask.org/en/latest', None),
    'numpy': ('https://numpy.org/doc/stable', None),
    'python': ('https://docs.python.org/3/', None),
    'pandas': ('https://pandas.pydata.org/pandas-docs/stable', None),
    'scipy': ('https://docs.scipy.org/doc/scipy/reference', None),
    'sklearn': ('https://scikit-learn.org/stable', None),
    'xarray': ('https://xarray.pydata.org/en/stable', None),
}
