"""Sphinx configuration for pyvergeos documentation."""

import os
import sys

# Add pyvergeos to path for autodoc
sys.path.insert(0, os.path.abspath(".."))

from pyvergeos import __version__

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

project = "pyvergeos"
copyright = "2024-2026, Verge.io"
author = "Verge.io"
version = __version__
release = __version__

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

extensions = [
    "sphinx.ext.autodoc",
    "sphinx.ext.napoleon",
    "sphinx.ext.viewcode",
    "sphinx.ext.intersphinx",
    "sphinx.ext.autosummary",
]

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# Suppress duplicate object description warnings (classes re-exported via __init__.py)
# These are benign - property names like 'key' appear in multiple resource classes
nitpicky = False


# Filter out duplicate object warnings from inherited properties
def setup(app):
    """Suppress duplicate object warnings."""
    import logging

    class DuplicateObjectFilter(logging.Filter):
        def filter(self, record):
            return "duplicate object description" not in record.getMessage()

    logging.getLogger("sphinx").addFilter(DuplicateObjectFilter())


# -- Options for autodoc -----------------------------------------------------

autodoc_default_options = {
    "members": True,
    "member-order": "bysource",
    "special-members": "__init__",
    "undoc-members": False,
    "exclude-members": "__weakref__",
    "show-inheritance": True,
}

autodoc_typehints = "description"
autodoc_class_signature = "separated"

# Napoleon settings for Google-style docstrings
napoleon_google_docstring = True
napoleon_numpy_docstring = False
napoleon_include_init_with_doc = True
napoleon_include_private_with_doc = False
napoleon_include_special_with_doc = True
napoleon_use_admonition_for_examples = True
napoleon_use_admonition_for_notes = True
napoleon_use_admonition_for_references = True
napoleon_use_ivar = False
napoleon_use_param = True
napoleon_use_rtype = True
napoleon_type_aliases = None

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

html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]

html_theme_options = {
    "logo_only": False,
    "prev_next_buttons_location": "bottom",
    "style_external_links": True,
    "collapse_navigation": False,
    "sticky_navigation": True,
    "navigation_depth": 4,
    "includehidden": True,
    "titles_only": False,
}

# -- Options for intersphinx -------------------------------------------------

intersphinx_mapping = {
    "python": ("https://docs.python.org/3", None),
    "requests": ("https://requests.readthedocs.io/en/latest/", None),
}

# -- Autosummary settings ----------------------------------------------------

autosummary_generate = True
