import json
with open("../metadata.json", "r") as f:
    metadata = json.loads(f.read())

import subprocess
all_versions = ["master"] + (
    subprocess
        .check_output(["git", "tag"])
        .decode("ascii")
        .strip()
        .split()
)

project = metadata["project_name"]
author = metadata["authors"][0]
version = metadata["version"]
release = version
epub_copyright = "CC BY-SA 4.0"
nitpicky = True

extensions = [
    "sphinx.ext.extlinks",
    "sphinx.ext.graphviz",
    "sphinx.ext.todo",
]

graphviz_output_format = "svg"

todo_include_todos = True

templates_path = ["_templates"]
html_theme = "sphinx_rtd_theme"
html_theme_options = {
    "style_external_links": True
}

html_show_sphinx = False
html_show_copyright = False

extlinks = {
    "src": ("https://git.euandreh.xyz/$PROJECT/tree/%s", ""),
    "bug": ("https://$PROJECT.euandreh.xyz/tasks-and-bugs.html#%s", "bug "),
}

with open("i18n-pagenames.json", "r") as f:
    i18n_pagenames = json.loads(f.read())

html_context = {
    "all_versions": all_versions,
    "langs": metadata["langs"],
    "current_lang": metadata["current_lang"],
    "cgit_url_prefix": "https://git.euandreh.xyz/$PROJECT/tree/docs",
    "gitlab_url_prefix": "https://gitlab.com/EuAndreh/$PROJECT/-/blob/master/docs",
    "i18n_pagenames": i18n_pagenames
}

gettext_compact = False
