File: ext_html_template_vars.py

package info (click to toggle)
streamlink 7.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 5,428 kB
  • sloc: python: 49,104; sh: 184; makefile: 145
file content (25 lines) | stat: -rw-r--r-- 530 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from __future__ import annotations

from typing import Any

from sphinx.addnodes import document
from sphinx.application import Sphinx


_CONFIG_VAR = "html_template_vars"


def update_context(
    app: Sphinx,
    pagename: str,
    templatename: str,
    context: dict[str, Any],
    doctree: document,
) -> None:
    for k, v in getattr(app.config, _CONFIG_VAR).items():
        context[k] = v


def setup(app: Sphinx) -> None:
    app.add_config_value(_CONFIG_VAR, {}, "")
    app.connect("html-page-context", update_context)