File: ext_html_template_vars.py

package info (click to toggle)
streamlink 8.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,564 kB
  • sloc: python: 51,188; sh: 184; makefile: 152
file content (27 lines) | stat: -rw-r--r-- 572 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
26
27
from __future__ import annotations

from typing import TYPE_CHECKING, Any


if TYPE_CHECKING:
    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)