-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjinja2glue.py
More file actions
55 lines (46 loc) · 1.54 KB
/
jinja2glue.py
File metadata and controls
55 lines (46 loc) · 1.54 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""Glue code for the jinja2 templating engine."""
from __future__ import annotations
import os
from os import path
from pprint import pformat
from typing import TYPE_CHECKING, Any
from jinja2 import BaseLoader, FileSystemLoader, TemplateNotFound
from jinja2.sandbox import SandboxedEnvironment
from jinja2.utils import open_if_exists, pass_context
from sphinx.application import TemplateBridge
from sphinx.util import logging
from sphinx.util.osutil import _last_modified_time
if TYPE_CHECKING:
from collections.abc import Callable, Iterator
from jinja2.environment import Environment
from sphinx.builders import Builder
from sphinx.theming import Theme
def _todim(val: int | str) -> str:
"""
Make val a css dimension. In particular the following transformations
are performed:
- None -> 'initial' (default CSS value)
- 0 -> '0'
- ints and string representations of ints are interpreted as pixels.
Everything else is returned unchanged.
"""
pass
def accesskey(context: Any, key: str) -> str:
"""Helper to output each access key only once."""
pass
class idgen:
def __init__(self) -> None:
self.id = 0
def __next__(self) -> int:
self.id += 1
return self.id
next = __next__
class SphinxFileSystemLoader(FileSystemLoader):
"""
FileSystemLoader subclass that is not so strict about '..' entries in
template names.
"""
class BuiltinTemplateLoader(TemplateBridge, BaseLoader):
"""
Interfaces the rendering environment of jinja2 for use in Sphinx.
"""