# Copyright 2020-2022 David Robillard <d@drobilla.net>
# SPDX-License-Identifier: ISC

# Project information

project = "@SERD_TITLE@"
copyright = "2022-2023, David Robillard"
author = "David Robillard"
release = "@SERD_VERSION@"
version = "@SERD_VERSION@"
desc = "A lightweight library for working with RDF"

# General configuration

exclude_patterns = ["xml"]
language = "en"
nitpicky = True
pygments_style = "friendly"

try:
    import sphinx_lv2_theme

    have_lv2_theme = True
except ModuleNotFoundError:
    have_lv2_theme = False

# Ignore everything opaque or external for nitpicky mode
_opaque = [
    "FILE",
    "SerdCaretImpl",
    "SerdCursorImpl",
    "SerdEnvImpl",
    "SerdModelImpl",
    "SerdNodeImpl",
    "SerdNodesImpl",
    "SerdReaderImpl",
    "SerdSinkImpl",
    "SerdStatementImpl",
    "SerdWorldImpl",
    "SerdWriterImpl",
    "ZixAllocator",
    "ZixStringView",
    "int16_t",
    "int32_t",
    "int64_t",
    "int8_t",
    "size_t",
    "uint16_t",
    "uint32_t",
    "uint64_t",
    "uint8_t",
    "va_list",
]

_c_nitpick_ignore = map(lambda x: ("c:identifier", x), _opaque)
_cpp_nitpick_ignore = map(lambda x: ("cpp:identifier", x), _opaque)
nitpick_ignore = (
    list(_c_nitpick_ignore)
    + list(_cpp_nitpick_ignore)
    + [
        ("cpp:identifier", "detail"),
        ("cpp:identifier", "serd"),
        ("cpp:identifier", "serd::detail"),
    ]
)

# HTML output

html_copy_source = False
html_secnumber_suffix = " "
html_short_title = "@SERD_TITLE@"
html_static_path = ["@SERD_STATIC_PATH@"]

html_theme_options = {
    "description": desc,
    "logo": "serd.svg",
    "logo_name": True,
    "logo_width": "8em",
}

if tags.has("singlehtml"):
    html_sidebars = {"**": ["globaltoc.html"]}
    html_theme_options.update(
        {
            "globaltoc_collapse": False,
            "globaltoc_maxdepth": 3,
            "nosidebar": False,
            "page_width": "80em",
        }
    )
else:
    html_theme_options.update(
        {
            "globaltoc_collapse": True,
            "globaltoc_maxdepth": 1,
            "nosidebar": True,
            "page_width": "60em",
        }
    )

if have_lv2_theme:
    html_theme = "sphinx_lv2_theme"

    html_theme_options.update(
        {
            "show_footer_version": True,
            "show_logo_version": True,
        }
    )

    if tags.has("singlehtml"):
        html_theme_options.update(
            {
                "body_max_width": "64em",
                "body_min_width": "64em",
                "nosidebar": False,
                "sidebar_width": "12em",
            }
        )

    else:
        html_theme_options.update(
            {
                "body_max_width": "60em",
                "body_min_width": "40em",
            }
        )

else:
    html_theme = "alabaster"

    if tags.has("singlehtml"):
        html_theme_options = {
            "body_max_width": "58em",
            "body_min_width": "40em",
            "sidebar_width": "16em",
        }

    else:
        html_theme_options = {
            "body_max_width": "60em",
            "body_min_width": "40em",
            "nosidebar": True,
            "show_relbars": True,
        }

# EPub output

epub_show_urls = "no"
epub_cover = ("../_static/serd.svg", "")
epub_description = "Serd, a lightweight library for working with RDF"
epub_title = "Serd @SERD_VERSION@ Documentation"
epub_basename = "Serd-@SERD_VERSION@"
epub_css_files = ["epubstyle.css"]