# 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

# -- Path setup --------------------------------------------------------------

# 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.
import importlib
import inspect
import os
import re
import sys
from datetime import date

sys.path.insert(0, os.path.abspath("../../"))
sys.path.append(os.path.abspath('./_ext'))


# -- Project information -----------------------------------------------------

project = "Standard Evaluator"
copyright = f"None"
author = "Joerg Gablonsky, Jeff Musiak, Ranald M Engelbeck, Eduardo Ocampo, Sean Wakayama"

# Version information

from pkg_resources import parse_version
from standard_evaluator import version

version_text = version.__version__
v = parse_version(version_text)

# The short X.Y version
version = v.base_version

# The full version, including alpha / beta / rc tags
release = version_text


# -- General configuration ---------------------------------------------------


def setup(app):
    pass


# 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.duration',
    "sphinx.ext.doctest",
    "sphinx.ext.autodoc",
    "sphinx.ext.autosummary",
    "sphinx.ext.napoleon",
    "sphinx.ext.mathjax",
    "autodocsumm",
    # Adding the ability to use Mermaid diagrams
    "sphinxcontrib.mermaid",
    # Custom directive to print options and known solution
    # Adds :print-options: and :known-solution: options to autoclass
    'format-class',
    "myst_nb",
    # This is needed to prevent a weird lexer unknown error when converting
    # jupyter notebooks to html
    'IPython.sphinxext.ipython_console_highlighting',
]

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

# 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", "Thumbs.db", ".DS_Store"]

# Place documentation generated by automodule and autoclass in the order they
# are in the source file.
autodoc_member_order = "bysource"

# Make it so that classes will not look like funtions
# ie.
#   class ClassName
# instead of
#   class ClassName(arg1, arg2, arg3)
autodoc_class_signature = "separated"

# Parameter types will only be in the description. Thus making things cleaner
autodoc_typehints = "description"

autodoc_default_options = {
    "autosummary": True,
    "autosummary-sections": "Attributes ;; Methods",
    "members": True,
    "special-members": True,
    "show-inheritance": True,
    "exclude-members": "__weakref__",
}

# Jupyter notebook cell executation time limit. Use None for no time limit
nb_execution_timeout = 600

# Hides class names from table of contents and sidebar
# When True it will look like:
#   - Python Evaluator
#       - PyEvaluator
#   - Executable Evaluator
#       - ExecutableEvaluator
#
# When False it will look like:
#   - Python Evaluator
#   - Executable Evaluator
toc_object_entries = False


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

# Options for RTD theme
# https://sphinx-rtd-theme.readthedocs.io/en/stable/configuring.html
html_theme_options = {
    'prev_next_buttons_location': '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".
html_static_path = ["_static"]

# Location of custom css files. Must be relative to html_static_path
html_css_files = [
    "css/class_doc.css",
    'css/general.css',
]

# Location of custom js files. Must be relative to html_static_path
html_js_files = [
    'js/require.min.js',
    'js/custom.js',
]

# Latex Support

katex_options = r"""{
    delimiters: [
        {left: '$$', right: '$$', display: true},
        {left: '$', right: '$', display: false},
        {left: '\\(', right: '\\)', display: false},
        {left: '\\[', right: '\\]', display: true}
    ],
}"""

# Mermaid options
mermaid_d3_zoom = True

# Myst-NB options

jupyter_execute_notebooks = "cache"
execution_in_temp = False
jupyter_cache = os.path.join(os.path.dirname(__file__), ".cache")
if not os.path.exists(jupyter_cache):
    os.mkdir(jupyter_cache)

myst_enable_extensions = [
    "amsmath",
    "dollarmath",
    "replacements",
    "smartquotes",
    "strikethrough",
    "tasklist",
]

# tweaks for how we write LaTeX

# allow spaces around $ delimiters
myst_dmath_allow_space = True

# allow displaymath in a markdown 'inline' context.
myst_dmath_double_inline = True

# hide module names
add_module_names = False