# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

import os
from datetime import datetime

import motile
import tomli

with open("../../pyproject.toml", "rb") as fh:
    project = tomli.load(fh)["project"]

author_list = ", ".join([author["name"] for author in project["authors"]])

project = "motile"
copyright = f"{datetime.now().year}, {author_list}, Ana Cristina Pascual Ramos"
author = author_list
version = motile.__version__
release = motile.__version__

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
    "jupyter_sphinx",
    "sphinx.ext.autodoc",
    "sphinx.ext.napoleon",
    "sphinx_autodoc_typehints",
    "sphinx.ext.githubpages",
    "sphinx.ext.mathjax",
    "sphinx_rtd_theme",
    "sphinx_togglebutton",
    "sphinxcontrib.jquery",
    "sphinx.ext.intersphinx",
]

templates_path = ["_templates"]
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinx_rtd_theme"
html_logo = "img/motile.svg"
html_static_path = ["_static"]
html_css_files = ["css/custom.css"]
html_show_sourcelink = False

# Version switcher for versioned docs on GitHub Pages.
# The DOCS_VERSION env var is set by CI; defaults to the package version locally.
docs_version = os.environ.get("DOCS_VERSION", f"v{version}")
html_context = {
    "current_version": docs_version,
    "versions": [
        ("stable", "/motile/stable/"),
        ("main", "/motile/main/"),
    ],
}

togglebutton_hint = ""
togglebutton_hint_hide = ""

pygments_style = "lovelace"

# Napoleon settings
napoleon_google_docstring = True

intersphinx_mapping = {
    "python": ("https://docs.python.org/3", None),
    "networkx": ("https://networkx.org/documentation/stable/", None),
    "numpy": ("https://numpy.org/doc/stable/", None),
}
