import datetime

import intake_thredds

# 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.viewcode',
    'sphinx.ext.autosummary',
    'sphinx.ext.doctest',
    'sphinx.ext.intersphinx',
    'sphinx.ext.extlinks',
    'sphinx.ext.intersphinx',
    'IPython.sphinxext.ipython_console_highlighting',
    'IPython.sphinxext.ipython_directive',
    'sphinx.ext.napoleon',
    'myst_nb',
    'sphinx_copybutton',
    'sphinx_design',
]

autodoc_member_order = 'groupwise'
autodoc_typehints = 'description'
autodoc_typehints_description_target = 'documented'
# Napoleon configurations

napoleon_google_docstring = False
napoleon_numpy_docstring = True
napoleon_use_param = True
napoleon_use_rtype = True
napoleon_preprocess_types = False

numpydoc_show_class_members = False
numpydoc_validation_checks = {'all'}

myst_enable_extensions = ['colon_fence', 'dollarmath', 'amsmath', 'deflist', 'html_image']

myst_url_schemes = ['http', 'https', 'mailto']
myst_heading_anchors = 2

# sphinx-copybutton configurations
copybutton_prompt_text = r'>>> |\.\.\. |\$ |In \[\d*\]: | {2,5}\.\.\.: | {5,8}: '
copybutton_prompt_is_regexp = True

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

# Autosummary pages will be generated by sphinx-autogen instead of sphinx-build
autosummary_generate = []


# Enable notebook execution
jupyter_execute_notebooks = 'cache'
execution_timeout = 600
execution_allow_errors = True

# The suffix of source filenames.
source_suffix = ['.rst', '.md']

# The encoding of source files.
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'

# General information about the project.
current_year = datetime.datetime.now().year
project = 'intake-thredds'
author = 'intake-thredds Developers'
copyright = f'2019-{current_year}, {author}'


# The short X.Y version.
version = intake_thredds.__version__.split('+')[0]
# The full version, including alpha/beta/rc tags.
release = intake_thredds.__version__


# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
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 = 'furo'

html_static_path = ['_static']

html_context = {
    'github_user': 'intake',
    'github_repo': 'intake-thredds',
    'github_version': 'main',
    'doc_path': 'docs',
}
html_theme_options = {'sidebar_hide_name': True, 'light_logo': '', 'dark_logo': ''}
html_last_updated_fmt = '%b %d, %Y'


# The name of an image file (within the static path) to use as favicon of the
# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
# html_favicon = None

# 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".


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


# -- Options for LaTeX output --------------------------------------------------

latex_elements = {
    # The paper size ('letterpaper' or 'a4paper').
    # 'papersize': 'letterpaper',
    # The font size ('10pt', '11pt' or '12pt').
    # 'pointsize': '10pt',
    # Additional stuff for the LaTeX preamble.
    # 'preamble': '',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
    ('index', 'intake-thredds.tex', 'intake-thredds Documentation', author, 'manual')
]
# latex_domain_indices = True


# -- Options for manual page output --------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [('index', 'intake-thredds', 'intake-thredds Documentation', [author], 1)]

# If true, show URL addresses after external links.
# man_show_urls = False


# -- Options for Texinfo output ------------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
    (
        'index',
        'intake-thredds',
        'intake-thredds Documentation',
        author,
        'intake-thredds',
        'One line description of project.',
        'Miscellaneous',
    )
]


# If true, do not generate a @detailmenu in the "Top" node's menu.
# texinfo_no_detailmenu = False
ipython_execlines = ['import intake', 'import intake_thredds', 'import xarray']


intersphinx_mapping = {
    'python': ('https://docs.python.org/3/', None),
    'xarray': ('http://xarray.pydata.org/en/stable/', None),
    'siphon': ('https://unidata.github.io/siphon/latest/', None),
    'intake': ('https://intake.readthedocs.io/en/latest/', None),
}
