doxtr-html-theme-aubergine 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- doxtr_html_theme_aubergine-0.1.0/LICENSE +21 -0
- doxtr_html_theme_aubergine-0.1.0/PKG-INFO +33 -0
- doxtr_html_theme_aubergine-0.1.0/README.md +7 -0
- doxtr_html_theme_aubergine-0.1.0/doxtr_html_theme_aubergine/__init__.py +131 -0
- doxtr_html_theme_aubergine-0.1.0/doxtr_html_theme_aubergine/layout.html +16 -0
- doxtr_html_theme_aubergine-0.1.0/doxtr_html_theme_aubergine/navigation.py +201 -0
- doxtr_html_theme_aubergine-0.1.0/doxtr_html_theme_aubergine/partials/header.html +167 -0
- doxtr_html_theme_aubergine-0.1.0/doxtr_html_theme_aubergine/partials/search_modal.html +48 -0
- doxtr_html_theme_aubergine-0.1.0/doxtr_html_theme_aubergine/search.html +29 -0
- doxtr_html_theme_aubergine-0.1.0/doxtr_html_theme_aubergine/search_index.py +301 -0
- doxtr_html_theme_aubergine-0.1.0/doxtr_html_theme_aubergine/static/doxtr-aubergine.css +377 -0
- doxtr_html_theme_aubergine-0.1.0/doxtr_html_theme_aubergine/static/doxtr-nav.js +364 -0
- doxtr_html_theme_aubergine-0.1.0/doxtr_html_theme_aubergine/static/doxtr-search.js +829 -0
- doxtr_html_theme_aubergine-0.1.0/doxtr_html_theme_aubergine/theme.conf +24 -0
- doxtr_html_theme_aubergine-0.1.0/doxtr_html_theme_aubergine.egg-info/PKG-INFO +33 -0
- doxtr_html_theme_aubergine-0.1.0/doxtr_html_theme_aubergine.egg-info/SOURCES.txt +21 -0
- doxtr_html_theme_aubergine-0.1.0/doxtr_html_theme_aubergine.egg-info/dependency_links.txt +1 -0
- doxtr_html_theme_aubergine-0.1.0/doxtr_html_theme_aubergine.egg-info/entry_points.txt +2 -0
- doxtr_html_theme_aubergine-0.1.0/doxtr_html_theme_aubergine.egg-info/requires.txt +4 -0
- doxtr_html_theme_aubergine-0.1.0/doxtr_html_theme_aubergine.egg-info/top_level.txt +1 -0
- doxtr_html_theme_aubergine-0.1.0/pyproject.toml +53 -0
- doxtr_html_theme_aubergine-0.1.0/setup.cfg +4 -0
- doxtr_html_theme_aubergine-0.1.0/tests/test_html_theme_aubergine.py +514 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Doxtr
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: doxtr-html-theme-aubergine
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Default Aubergine Sphinx HTML theme (black/blue/orange/violet, PyData-inspired reading layout, and smart positional DevonTHINK-like search).
|
|
5
|
+
Author: Jens Frey
|
|
6
|
+
Project-URL: Homepage, https://github.com/doxtr/doxtr-html-theme-aubergine
|
|
7
|
+
Project-URL: Repository, https://github.com/doxtr/doxtr-html-theme-aubergine
|
|
8
|
+
Project-URL: Issues, https://github.com/doxtr/doxtr-html-theme-aubergine/issues
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Framework :: Sphinx :: Extension
|
|
14
|
+
Classifier: Framework :: Sphinx :: Theme
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Topic :: Documentation :: Sphinx
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: doxtr-theme-core>=0.1.0
|
|
22
|
+
Requires-Dist: doxtr-html-theme-core>=0.1.0
|
|
23
|
+
Requires-Dist: doxtr-theme-aubergine>=0.1.0
|
|
24
|
+
Requires-Dist: Sphinx>=7.0
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# doxtr-html-theme-aubergine
|
|
28
|
+
|
|
29
|
+
Default Doxtr Sphinx HTML theme (`doxtr_aubergine`), inheriting `doxtr_core`:
|
|
30
|
+
|
|
31
|
+
- **Aubergine Design Language**: Deep black ink, cobalt blue, vibrant orange, and rich violet/aubergine in both light and dark modes (`--dd-*` tokens).
|
|
32
|
+
- **PyData-Inspired Reading & Navigation**: Sticky header with global navigation & instant search launcher, left section tree, crisp readable prose measure, and right section scrollspy outline.
|
|
33
|
+
- **Smart Full-Text Search**: Build-time positional inverted index (`_static/doxtr-search-index.json`) with German/diacritic & orthography folding (`konig` / `koenig` -> `könig`, `strasse` -> `Straße`, `cafe` -> `café`) and DevonTHINK query syntax (`NEAR/n`, `BEFORE/n`, `AFTER/n`, `AND`, `OR`, `NOT`, `-term`, `"exact phrase"`, `*`/`?` wildcards, `title:`/`heading:`/`section:` field prefixes, parentheses).
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# doxtr-html-theme-aubergine
|
|
2
|
+
|
|
3
|
+
Default Doxtr Sphinx HTML theme (`doxtr_aubergine`), inheriting `doxtr_core`:
|
|
4
|
+
|
|
5
|
+
- **Aubergine Design Language**: Deep black ink, cobalt blue, vibrant orange, and rich violet/aubergine in both light and dark modes (`--dd-*` tokens).
|
|
6
|
+
- **PyData-Inspired Reading & Navigation**: Sticky header with global navigation & instant search launcher, left section tree, crisp readable prose measure, and right section scrollspy outline.
|
|
7
|
+
- **Smart Full-Text Search**: Build-time positional inverted index (`_static/doxtr-search-index.json`) with German/diacritic & orthography folding (`konig` / `koenig` -> `könig`, `strasse` -> `Straße`, `cafe` -> `café`) and DevonTHINK query syntax (`NEAR/n`, `BEFORE/n`, `AFTER/n`, `AND`, `OR`, `NOT`, `-term`, `"exact phrase"`, `*`/`?` wildcards, `title:`/`heading:`/`section:` field prefixes, parentheses).
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"""Default Aubergine Sphinx HTML theme with PyData-style layout and smart search."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from docutils.utils import unescape
|
|
9
|
+
from sphinx.util import logging
|
|
10
|
+
|
|
11
|
+
from doxtr_theme_core import get_active_theme, register_renderer
|
|
12
|
+
|
|
13
|
+
from .navigation import extract_top_nav_items, get_top_nav_kind
|
|
14
|
+
from .search_index import SearchIndexBuilder, extract_article_html
|
|
15
|
+
|
|
16
|
+
__version__ = "0.1.0"
|
|
17
|
+
|
|
18
|
+
logger = logging.getLogger(__name__)
|
|
19
|
+
|
|
20
|
+
THEME_DIR = Path(__file__).resolve().parent
|
|
21
|
+
HTML_BUILDERS = frozenset({"html", "dirhtml", "singlehtml", "readthedocs"})
|
|
22
|
+
|
|
23
|
+
# Register immediately so setup_brand_theme("aubergine") resolves this HTML renderer.
|
|
24
|
+
register_renderer(
|
|
25
|
+
"html",
|
|
26
|
+
"aubergine",
|
|
27
|
+
"doxtr_html_theme_aubergine",
|
|
28
|
+
html_theme_name="doxtr_aubergine",
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _is_html_builder(app: Any) -> bool:
|
|
33
|
+
builder = getattr(app, "builder", None)
|
|
34
|
+
if builder is None:
|
|
35
|
+
return False
|
|
36
|
+
return (
|
|
37
|
+
getattr(builder, "format", None) == "html"
|
|
38
|
+
or getattr(builder, "name", "") in HTML_BUILDERS
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _get_collector(app: Any) -> SearchIndexBuilder:
|
|
43
|
+
collector = getattr(app, "_doxtr_search_collector", None)
|
|
44
|
+
if collector is None:
|
|
45
|
+
collector = SearchIndexBuilder()
|
|
46
|
+
app._doxtr_search_collector = collector
|
|
47
|
+
return collector
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _on_builder_inited(app: Any) -> None:
|
|
51
|
+
if not _is_html_builder(app):
|
|
52
|
+
return
|
|
53
|
+
app.add_js_file("doxtr-nav.js", priority=650)
|
|
54
|
+
app.add_js_file("doxtr-search-index.js", priority=750)
|
|
55
|
+
app.add_js_file("doxtr-search.js", priority=800)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _on_html_page_context(
|
|
59
|
+
app: Any,
|
|
60
|
+
pagename: str,
|
|
61
|
+
templatename: str,
|
|
62
|
+
context: dict[str, Any],
|
|
63
|
+
doctree: Any,
|
|
64
|
+
) -> None:
|
|
65
|
+
if not _is_html_builder(app):
|
|
66
|
+
return
|
|
67
|
+
context["doxtr_top_nav_kind"] = get_top_nav_kind(app.config)
|
|
68
|
+
context["doxtr_top_nav_items"] = extract_top_nav_items(app, pagename, context)
|
|
69
|
+
body = context.get("body") or ""
|
|
70
|
+
raw_title = context.get("title") or pagename
|
|
71
|
+
clean_title = unescape(str(raw_title))
|
|
72
|
+
if "<" in clean_title:
|
|
73
|
+
import re
|
|
74
|
+
|
|
75
|
+
clean_title = re.sub(r"<[^>]+>", "", clean_title)
|
|
76
|
+
_get_collector(app).add_html_page(pagename, clean_title, body)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _on_build_finished(app: Any, exception: Exception | None) -> None:
|
|
80
|
+
if exception is not None or not _is_html_builder(app):
|
|
81
|
+
return
|
|
82
|
+
try:
|
|
83
|
+
outdir = Path(app.outdir)
|
|
84
|
+
collector = _get_collector(app)
|
|
85
|
+
found_docs = set(getattr(getattr(app, "env", None), "found_docs", ()) or ())
|
|
86
|
+
# Drop removed pages if any
|
|
87
|
+
for cached_name in list(collector.pages):
|
|
88
|
+
if found_docs and cached_name not in found_docs:
|
|
89
|
+
del collector.pages[cached_name]
|
|
90
|
+
# Backfill unchanged pages during incremental builds directly from built HTML
|
|
91
|
+
for docname in sorted(found_docs):
|
|
92
|
+
if docname in collector.pages or docname in {"search", "genindex", "modindex"}:
|
|
93
|
+
continue
|
|
94
|
+
html_file = outdir / f"{docname}.html"
|
|
95
|
+
if html_file.is_file():
|
|
96
|
+
page_title, article_html = extract_article_html(
|
|
97
|
+
html_file.read_text(encoding="utf-8", errors="ignore")
|
|
98
|
+
)
|
|
99
|
+
collector.add_html_page(docname, unescape(page_title or docname), article_html)
|
|
100
|
+
|
|
101
|
+
static_dir = outdir / "_static"
|
|
102
|
+
collector.write_outputs(static_dir)
|
|
103
|
+
except Exception as exc: # pragma: no cover - defensive
|
|
104
|
+
logger.warning("[Doxtr HTML Aubergine] Could not write search index: %s", exc)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def setup(app: Any) -> dict[str, Any]:
|
|
108
|
+
"""Sphinx extension entry point for ``doxtr_html_theme_aubergine``."""
|
|
109
|
+
app.setup_extension("doxtr_html_theme_core")
|
|
110
|
+
|
|
111
|
+
# Apply Aubergine palette/fonts if registered and user hasn't picked another brand
|
|
112
|
+
try:
|
|
113
|
+
import doxtr_theme_aubergine # noqa: F401
|
|
114
|
+
except ImportError:
|
|
115
|
+
pass
|
|
116
|
+
active = get_active_theme(app.config)
|
|
117
|
+
if active.name == "core":
|
|
118
|
+
raw_cfg = getattr(app.config, "_raw_config", None) or {}
|
|
119
|
+
if not raw_cfg.get("doxtr_theme_brand"):
|
|
120
|
+
app.setup_extension("doxtr_theme_aubergine")
|
|
121
|
+
|
|
122
|
+
app.add_html_theme("doxtr_aubergine", str(THEME_DIR))
|
|
123
|
+
app.connect("builder-inited", _on_builder_inited)
|
|
124
|
+
app.connect("html-page-context", _on_html_page_context)
|
|
125
|
+
app.connect("build-finished", _on_build_finished)
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
"version": __version__,
|
|
129
|
+
"parallel_read_safe": True,
|
|
130
|
+
"parallel_write_safe": True,
|
|
131
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{%- extends "doxtr_html_theme_core/layout.html" -%}
|
|
2
|
+
|
|
3
|
+
{%- block header %}
|
|
4
|
+
{%- if theme_announcement_banner %}
|
|
5
|
+
<div class="doxtr-announcement" role="region" aria-label="Announcement">
|
|
6
|
+
<div class="doxtr-announcement-inner">{{ theme_announcement_banner }}</div>
|
|
7
|
+
</div>
|
|
8
|
+
{%- endif %}
|
|
9
|
+
<a class="doxtr-skip-link" href="#main-content">{{ theme_skip_link_label|default('Skip to main content')|e }}</a>
|
|
10
|
+
{% include "partials/header.html" %}
|
|
11
|
+
{%- endblock %}
|
|
12
|
+
|
|
13
|
+
{%- block content %}
|
|
14
|
+
{{ super() }}
|
|
15
|
+
{% include "partials/search_modal.html" %}
|
|
16
|
+
{%- endblock %}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"""Top-level Part / Chapter navigation extraction for the Aubergine HTML theme."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
from collections import deque
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from docutils import nodes
|
|
10
|
+
from sphinx import addnodes
|
|
11
|
+
|
|
12
|
+
_EXTERNAL_URI_RE = re.compile(r"^[a-zA-Z][a-zA-Z0-9+.-]*://")
|
|
13
|
+
_SPECIAL_DOCS = frozenset({"genindex", "modindex", "py-modindex"})
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def get_top_nav_kind(config: Any) -> str:
|
|
17
|
+
"""Return ``'part'`` when ``latex_toplevel_sectioning == 'part'``, else ``'chapter'``."""
|
|
18
|
+
sectioning = str(getattr(config, "latex_toplevel_sectioning", "") or "").strip().lower()
|
|
19
|
+
return "part" if sectioning == "part" else "chapter"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _clean_title(text: str) -> str:
|
|
23
|
+
return re.sub(r"\s+", " ", str(text or "")).strip()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _format_docname(docname: str) -> str:
|
|
27
|
+
leaf = docname.rsplit("/", 1)[-1]
|
|
28
|
+
if leaf in {"index", "guide", "basics", "extensions"} and "/" in docname:
|
|
29
|
+
leaf = docname.split("/")[-2]
|
|
30
|
+
return leaf.replace("-", " ").replace("_", " ").strip().title() or docname
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _get_doc_descendants(app: Any, env: Any) -> dict[str, set[str]]:
|
|
34
|
+
"""Return cached mapping of docname -> set of descendant docnames via ``toctree_includes``."""
|
|
35
|
+
includes: dict[str, list[str]] = getattr(env, "toctree_includes", None) or {}
|
|
36
|
+
cache_key = (id(env), len(includes))
|
|
37
|
+
cached = getattr(app, "_doxtr_nav_descendant_cache", None)
|
|
38
|
+
if cached is not None and cached[0] == cache_key:
|
|
39
|
+
return cached[1]
|
|
40
|
+
|
|
41
|
+
descendants: dict[str, set[str]] = {}
|
|
42
|
+
|
|
43
|
+
def _compute(start: str) -> set[str]:
|
|
44
|
+
if start in descendants:
|
|
45
|
+
return descendants[start]
|
|
46
|
+
seen: set[str] = set()
|
|
47
|
+
queue: deque[str] = deque(includes.get(start, ()))
|
|
48
|
+
while queue:
|
|
49
|
+
child = queue.popleft()
|
|
50
|
+
if child in seen or child == start:
|
|
51
|
+
continue
|
|
52
|
+
seen.add(child)
|
|
53
|
+
for grand in includes.get(child, ()):
|
|
54
|
+
if grand not in seen:
|
|
55
|
+
queue.append(grand)
|
|
56
|
+
descendants[start] = seen
|
|
57
|
+
return seen
|
|
58
|
+
|
|
59
|
+
for root_child in list(includes):
|
|
60
|
+
_compute(root_child)
|
|
61
|
+
|
|
62
|
+
app._doxtr_nav_descendant_cache = (cache_key, descendants)
|
|
63
|
+
return descendants
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _resolve_doc_href(pathto: Any, target: str) -> str:
|
|
67
|
+
if callable(pathto):
|
|
68
|
+
return str(pathto(target))
|
|
69
|
+
if target.endswith(".html"):
|
|
70
|
+
return target
|
|
71
|
+
return f"{target}.html"
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _extract_single_page_sections(
|
|
75
|
+
root_toc: nodes.Node,
|
|
76
|
+
root_doc: str,
|
|
77
|
+
pathto: Any,
|
|
78
|
+
) -> list[dict[str, Any]]:
|
|
79
|
+
"""Fallback for single-page sites with no ``toctree`` directive on ``root_doc``."""
|
|
80
|
+
outer_list = root_toc.next_node(nodes.bullet_list)
|
|
81
|
+
if outer_list is None:
|
|
82
|
+
return []
|
|
83
|
+
|
|
84
|
+
list_items = [child for child in outer_list.children if isinstance(child, nodes.list_item)]
|
|
85
|
+
candidate_items = list_items
|
|
86
|
+
if len(list_items) == 1:
|
|
87
|
+
nested = list_items[0].next_node(nodes.bullet_list)
|
|
88
|
+
if nested is not None:
|
|
89
|
+
candidate_items = [
|
|
90
|
+
child for child in nested.children if isinstance(child, nodes.list_item)
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
root_href = _resolve_doc_href(pathto, root_doc)
|
|
94
|
+
items: list[dict[str, Any]] = []
|
|
95
|
+
seen_hrefs: set[str] = set()
|
|
96
|
+
for li in candidate_items:
|
|
97
|
+
ref_node = li.next_node(nodes.reference)
|
|
98
|
+
if ref_node is None:
|
|
99
|
+
continue
|
|
100
|
+
anchor = str(ref_node.get("anchorname") or "").strip()
|
|
101
|
+
title = _clean_title(ref_node.astext())
|
|
102
|
+
if not anchor or not title:
|
|
103
|
+
continue
|
|
104
|
+
href = anchor if root_href in {"", "#"} else f"{root_href}{anchor}"
|
|
105
|
+
if href in seen_hrefs:
|
|
106
|
+
continue
|
|
107
|
+
seen_hrefs.add(href)
|
|
108
|
+
items.append(
|
|
109
|
+
{
|
|
110
|
+
"title": title,
|
|
111
|
+
"href": href,
|
|
112
|
+
"docname": f"{root_doc}{anchor}",
|
|
113
|
+
"active": False,
|
|
114
|
+
"current": False,
|
|
115
|
+
"external": False,
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
return items
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def extract_top_nav_items(
|
|
122
|
+
app: Any,
|
|
123
|
+
pagename: str,
|
|
124
|
+
context: dict[str, Any],
|
|
125
|
+
) -> list[dict[str, Any]]:
|
|
126
|
+
"""Extract ordered top-level Parts or Chapters from ``root_doc`` for the header nav."""
|
|
127
|
+
config = getattr(app, "config", None)
|
|
128
|
+
env = getattr(getattr(app, "builder", None), "env", None) or getattr(app, "env", None)
|
|
129
|
+
if config is None or env is None:
|
|
130
|
+
return []
|
|
131
|
+
|
|
132
|
+
root_doc = (
|
|
133
|
+
str(getattr(config, "root_doc", None) or getattr(config, "master_doc", None) or "index")
|
|
134
|
+
)
|
|
135
|
+
root_toc = getattr(env, "tocs", {}).get(root_doc)
|
|
136
|
+
if root_toc is None:
|
|
137
|
+
return []
|
|
138
|
+
|
|
139
|
+
pathto = context.get("pathto")
|
|
140
|
+
found_docs: set[str] = set(getattr(env, "found_docs", ()) or ())
|
|
141
|
+
titles: dict[str, nodes.Node] = getattr(env, "titles", None) or {}
|
|
142
|
+
descendants = _get_doc_descendants(app, env)
|
|
143
|
+
|
|
144
|
+
items: list[dict[str, Any]] = []
|
|
145
|
+
seen_refs: set[str] = set()
|
|
146
|
+
has_toctree_entries = False
|
|
147
|
+
|
|
148
|
+
for toctree_node in root_toc.findall(addnodes.toctree):
|
|
149
|
+
for explicit_title, ref in toctree_node.get("entries", ()) or ():
|
|
150
|
+
if not ref or ref in {"self", "search", root_doc}:
|
|
151
|
+
continue
|
|
152
|
+
has_toctree_entries = True
|
|
153
|
+
if ref in seen_refs:
|
|
154
|
+
continue
|
|
155
|
+
seen_refs.add(ref)
|
|
156
|
+
|
|
157
|
+
if _EXTERNAL_URI_RE.match(ref):
|
|
158
|
+
items.append(
|
|
159
|
+
{
|
|
160
|
+
"title": _clean_title(explicit_title) or ref,
|
|
161
|
+
"href": ref,
|
|
162
|
+
"docname": ref,
|
|
163
|
+
"active": False,
|
|
164
|
+
"current": False,
|
|
165
|
+
"external": True,
|
|
166
|
+
}
|
|
167
|
+
)
|
|
168
|
+
continue
|
|
169
|
+
|
|
170
|
+
base_doc, has_hash, anchor = ref.partition("#")
|
|
171
|
+
if found_docs and base_doc not in found_docs and base_doc not in _SPECIAL_DOCS:
|
|
172
|
+
continue
|
|
173
|
+
|
|
174
|
+
if explicit_title:
|
|
175
|
+
title = _clean_title(explicit_title)
|
|
176
|
+
elif base_doc in titles and titles[base_doc] is not None:
|
|
177
|
+
title = _clean_title(titles[base_doc].astext())
|
|
178
|
+
else:
|
|
179
|
+
title = _format_docname(base_doc)
|
|
180
|
+
|
|
181
|
+
href = _resolve_doc_href(pathto, base_doc)
|
|
182
|
+
if has_hash and anchor:
|
|
183
|
+
href = f"#{anchor}" if href in {"", "#"} else f"{href}#{anchor}"
|
|
184
|
+
|
|
185
|
+
is_current = pagename == base_doc and not has_hash
|
|
186
|
+
is_descendant = pagename in descendants.get(base_doc, ())
|
|
187
|
+
items.append(
|
|
188
|
+
{
|
|
189
|
+
"title": title,
|
|
190
|
+
"href": href,
|
|
191
|
+
"docname": ref,
|
|
192
|
+
"active": is_current or is_descendant,
|
|
193
|
+
"current": is_current,
|
|
194
|
+
"external": False,
|
|
195
|
+
}
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
if items or has_toctree_entries:
|
|
199
|
+
return items
|
|
200
|
+
|
|
201
|
+
return _extract_single_page_sections(root_toc, root_doc, pathto)
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
<header class="doxtr-header doxtr-aubergine-header">
|
|
2
|
+
<div class="doxtr-header-inner">
|
|
3
|
+
<div class="doxtr-header-start">
|
|
4
|
+
<button
|
|
5
|
+
type="button"
|
|
6
|
+
class="doxtr-icon-btn doxtr-menu-btn"
|
|
7
|
+
data-doxtr-open-drawer
|
|
8
|
+
aria-controls="doxtr-mobile-drawer"
|
|
9
|
+
aria-label="Open navigation menu"
|
|
10
|
+
>
|
|
11
|
+
<span aria-hidden="true">☰</span>
|
|
12
|
+
</button>
|
|
13
|
+
{%- if theme_show_nav|tobool and theme_show_sidebar_toggles|default(true)|tobool %}
|
|
14
|
+
<button
|
|
15
|
+
type="button"
|
|
16
|
+
class="doxtr-icon-btn doxtr-sidebar-toggle doxtr-sidebar-toggle-left"
|
|
17
|
+
data-doxtr-toggle-left-sidebar
|
|
18
|
+
aria-controls="doxtr-sidebar-left"
|
|
19
|
+
aria-expanded="true"
|
|
20
|
+
aria-label="Hide navigation sidebar"
|
|
21
|
+
title="Toggle navigation sidebar"
|
|
22
|
+
>
|
|
23
|
+
<svg width="18" height="18" viewBox="0 0 20 20" fill="none" aria-hidden="true">
|
|
24
|
+
<rect x="2.5" y="3.5" width="15" height="13" rx="2" stroke="currentColor" stroke-width="1.6"/>
|
|
25
|
+
<rect class="doxtr-panel-pane" x="3.3" y="4.3" width="4.4" height="11.4" rx="1"/>
|
|
26
|
+
<line x1="7.8" y1="3.5" x2="7.8" y2="16.5" stroke="currentColor" stroke-width="1.5"/>
|
|
27
|
+
</svg>
|
|
28
|
+
</button>
|
|
29
|
+
{%- endif %}
|
|
30
|
+
<a
|
|
31
|
+
class="doxtr-brand-link"
|
|
32
|
+
href="{{ pathto(root_doc)|e }}"
|
|
33
|
+
{%- if doxtr_full_title and doxtr_full_title != doxtr_header_title %} title="{{ doxtr_full_title|e }}"{% endif -%}
|
|
34
|
+
>
|
|
35
|
+
{%- if doxtr_logo_light_url %}
|
|
36
|
+
<img
|
|
37
|
+
class="doxtr-brand-logo"
|
|
38
|
+
src="{{ doxtr_logo_light_url|e }}"
|
|
39
|
+
alt="{{ doxtr_logo_alt|default(doxtr_header_title)|e }}"
|
|
40
|
+
{%- if doxtr_logo_dark_url %}
|
|
41
|
+
data-doxtr-light-src="{{ doxtr_logo_light_url|e }}"
|
|
42
|
+
data-doxtr-dark-src="{{ doxtr_logo_dark_url|e }}"
|
|
43
|
+
{%- endif %}
|
|
44
|
+
/>
|
|
45
|
+
{%- endif %}
|
|
46
|
+
<span class="doxtr-brand-name">{{ (doxtr_header_title or theme_brand_name or shorttitle)|e }}</span>
|
|
47
|
+
</a>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<nav
|
|
51
|
+
class="doxtr-top-links"
|
|
52
|
+
data-doxtr-top-nav
|
|
53
|
+
data-doxtr-nav-kind="{{ doxtr_top_nav_kind|default('chapter')|e }}"
|
|
54
|
+
aria-label="Top navigation"
|
|
55
|
+
>
|
|
56
|
+
<div class="doxtr-top-links-list" data-doxtr-top-nav-list>
|
|
57
|
+
<a
|
|
58
|
+
class="doxtr-top-nav-home{% if pagename == root_doc %} is-active{% endif %}"
|
|
59
|
+
href="{{ pathto(root_doc)|e }}"
|
|
60
|
+
{%- if pagename == root_doc %} aria-current="page"{% endif -%}
|
|
61
|
+
>Home</a>
|
|
62
|
+
{%- for item in doxtr_top_nav_items|default([]) %}
|
|
63
|
+
<a
|
|
64
|
+
class="doxtr-top-nav-item{% if item.active %} is-active{% endif %}"
|
|
65
|
+
data-doxtr-top-nav-item
|
|
66
|
+
href="{{ item.href|e }}"
|
|
67
|
+
{%- if item.external %} rel="noopener"{% endif -%}
|
|
68
|
+
{%- if item.current %} aria-current="page"{% elif item.active %} data-active="true"{% endif -%}
|
|
69
|
+
>{{ item.title|e }}</a>
|
|
70
|
+
{%- endfor %}
|
|
71
|
+
{%- if not theme_show_search_button|tobool %}
|
|
72
|
+
<a
|
|
73
|
+
class="doxtr-top-nav-item{% if pagename == 'search' %} is-active{% endif %}"
|
|
74
|
+
data-doxtr-top-nav-item
|
|
75
|
+
href="{{ pathto('search')|e }}"
|
|
76
|
+
{%- if pagename == 'search' %} aria-current="page"{% endif -%}
|
|
77
|
+
>Search</a>
|
|
78
|
+
{%- endif %}
|
|
79
|
+
</div>
|
|
80
|
+
<div class="doxtr-top-nav-more" data-doxtr-top-nav-more hidden>
|
|
81
|
+
<button
|
|
82
|
+
type="button"
|
|
83
|
+
class="doxtr-top-nav-more-btn"
|
|
84
|
+
data-doxtr-top-nav-more-btn
|
|
85
|
+
aria-expanded="false"
|
|
86
|
+
aria-haspopup="menu"
|
|
87
|
+
aria-controls="doxtr-top-nav-overflow-menu"
|
|
88
|
+
aria-label="More {{ 'parts' if doxtr_top_nav_kind == 'part' else 'chapters' }}"
|
|
89
|
+
>
|
|
90
|
+
<span>More</span>
|
|
91
|
+
<span class="doxtr-caret" aria-hidden="true">▾</span>
|
|
92
|
+
</button>
|
|
93
|
+
<div
|
|
94
|
+
id="doxtr-top-nav-overflow-menu"
|
|
95
|
+
class="doxtr-top-nav-dropdown"
|
|
96
|
+
data-doxtr-top-nav-dropdown
|
|
97
|
+
role="menu"
|
|
98
|
+
hidden
|
|
99
|
+
></div>
|
|
100
|
+
</div>
|
|
101
|
+
</nav>
|
|
102
|
+
|
|
103
|
+
<div class="doxtr-header-end">
|
|
104
|
+
{%- if theme_show_search_button|tobool %}
|
|
105
|
+
<button
|
|
106
|
+
type="button"
|
|
107
|
+
class="doxtr-search-trigger"
|
|
108
|
+
data-doxtr-open-search
|
|
109
|
+
aria-controls="doxtr-search-modal"
|
|
110
|
+
aria-keyshortcuts="/ Control+k"
|
|
111
|
+
aria-label="Open smart search"
|
|
112
|
+
>
|
|
113
|
+
<span class="doxtr-search-trigger-label">Search docs...</span>
|
|
114
|
+
<kbd class="doxtr-kbd">{{ theme_search_shortcut|default('/')|e }}</kbd>
|
|
115
|
+
</button>
|
|
116
|
+
{%- endif %}
|
|
117
|
+
{%- if theme_repo_url %}
|
|
118
|
+
<a class="doxtr-header-link" href="{{ theme_repo_url|e }}" rel="noopener">Repository</a>
|
|
119
|
+
{%- endif %}
|
|
120
|
+
{%- if theme_show_full_width_toggle|default(true)|tobool %}
|
|
121
|
+
<button
|
|
122
|
+
type="button"
|
|
123
|
+
class="doxtr-icon-btn doxtr-width-toggle"
|
|
124
|
+
data-doxtr-width-toggle
|
|
125
|
+
aria-pressed="false"
|
|
126
|
+
aria-label="Switch to full screen width"
|
|
127
|
+
title="Toggle full screen width"
|
|
128
|
+
>
|
|
129
|
+
<svg class="doxtr-icon-expand" width="18" height="18" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
130
|
+
<path d="M2.5 4v12M17.5 4v12M7.5 7 4.5 10l3 3M12.5 7l3 3-3 3M4.5 10h11"/>
|
|
131
|
+
</svg>
|
|
132
|
+
<svg class="doxtr-icon-compress" width="18" height="18" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
133
|
+
<path d="M2.5 4v12M17.5 4v12M5 7l3 3-3 3M15 7l-3 3 3 3M2.5 10h5.5M12 10h5.5"/>
|
|
134
|
+
</svg>
|
|
135
|
+
</button>
|
|
136
|
+
{%- endif %}
|
|
137
|
+
{%- if theme_color_scheme_toggle|tobool %}
|
|
138
|
+
<button
|
|
139
|
+
type="button"
|
|
140
|
+
class="doxtr-icon-btn doxtr-theme-toggle"
|
|
141
|
+
data-doxtr-theme-toggle
|
|
142
|
+
aria-label="Toggle color theme"
|
|
143
|
+
title="Toggle light / dark theme"
|
|
144
|
+
>
|
|
145
|
+
<span data-doxtr-theme-icon aria-hidden="true">◐</span>
|
|
146
|
+
</button>
|
|
147
|
+
{%- endif %}
|
|
148
|
+
{%- if theme_show_toc|tobool and display_toc and theme_show_sidebar_toggles|default(true)|tobool %}
|
|
149
|
+
<button
|
|
150
|
+
type="button"
|
|
151
|
+
class="doxtr-icon-btn doxtr-sidebar-toggle doxtr-sidebar-toggle-right"
|
|
152
|
+
data-doxtr-toggle-right-sidebar
|
|
153
|
+
aria-controls="doxtr-sidebar-right"
|
|
154
|
+
aria-expanded="true"
|
|
155
|
+
aria-label="Hide on-this-page sidebar"
|
|
156
|
+
title="Toggle on-this-page sidebar"
|
|
157
|
+
>
|
|
158
|
+
<svg width="18" height="18" viewBox="0 0 20 20" fill="none" aria-hidden="true">
|
|
159
|
+
<rect x="2.5" y="3.5" width="15" height="13" rx="2" stroke="currentColor" stroke-width="1.6"/>
|
|
160
|
+
<rect class="doxtr-panel-pane" x="12.3" y="4.3" width="4.4" height="11.4" rx="1"/>
|
|
161
|
+
<line x1="12.2" y1="3.5" x2="12.2" y2="16.5" stroke="currentColor" stroke-width="1.5"/>
|
|
162
|
+
</svg>
|
|
163
|
+
</button>
|
|
164
|
+
{%- endif %}
|
|
165
|
+
</div>
|
|
166
|
+
</div>
|
|
167
|
+
</header>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<dialog
|
|
2
|
+
class="doxtr-search-modal"
|
|
3
|
+
id="doxtr-search-modal"
|
|
4
|
+
closedby="any"
|
|
5
|
+
aria-labelledby="doxtr-search-modal-title"
|
|
6
|
+
>
|
|
7
|
+
<div class="doxtr-search-dialog-card" data-doxtr-search-card>
|
|
8
|
+
<div class="doxtr-search-dialog-head">
|
|
9
|
+
<h2 id="doxtr-search-modal-title" class="doxtr-search-dialog-title">Smart Search</h2>
|
|
10
|
+
<button
|
|
11
|
+
type="button"
|
|
12
|
+
class="doxtr-icon-btn"
|
|
13
|
+
data-doxtr-close-search
|
|
14
|
+
aria-label="Close search dialog"
|
|
15
|
+
>
|
|
16
|
+
<span aria-hidden="true">✕</span>
|
|
17
|
+
</button>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<form class="doxtr-search-form" data-doxtr-search-form="modal" role="search">
|
|
21
|
+
<label class="doxtr-sr-only" for="doxtr-search-modal-input">Search documentation</label>
|
|
22
|
+
<input
|
|
23
|
+
id="doxtr-search-modal-input"
|
|
24
|
+
class="doxtr-search-input"
|
|
25
|
+
type="search"
|
|
26
|
+
name="q"
|
|
27
|
+
autocomplete="off"
|
|
28
|
+
placeholder="konig, beer NEAR/5 Germany, title:theming, "dark mode"..."
|
|
29
|
+
data-doxtr-search-input="modal"
|
|
30
|
+
/>
|
|
31
|
+
<button type="submit" class="doxtr-btn doxtr-btn-primary" tabindex="-1">Search</button>
|
|
32
|
+
</form>
|
|
33
|
+
|
|
34
|
+
<div class="doxtr-search-syntax" aria-label="Supported query syntax">
|
|
35
|
+
<code>konig ↔ könig</code>
|
|
36
|
+
<code>NEAR/n</code>
|
|
37
|
+
<code>BEFORE/n</code>
|
|
38
|
+
<code>AFTER/n</code>
|
|
39
|
+
<code>AND / OR / NOT</code>
|
|
40
|
+
<code>"phrase"</code>
|
|
41
|
+
<code>title:</code>
|
|
42
|
+
<code>heading:</code>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<p class="doxtr-search-stats" role="status" data-doxtr-search-stats="modal"></p>
|
|
46
|
+
<ol class="doxtr-search-results" data-doxtr-search-results="modal"></ol>
|
|
47
|
+
</div>
|
|
48
|
+
</dialog>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{%- extends "layout.html" -%}
|
|
2
|
+
|
|
3
|
+
{%- block body %}
|
|
4
|
+
<section class="doxtr-search-page" aria-labelledby="doxtr-search-page-title">
|
|
5
|
+
<h1 id="doxtr-search-page-title">Smart Documentation Search</h1>
|
|
6
|
+
<p class="doxtr-search-help">
|
|
7
|
+
Supports German/diacritic folding (<code>konig</code> / <code>koenig</code> → <code>könig</code>,
|
|
8
|
+
<code>strasse</code> → <code>Straße</code>), proximity (<code>beer NEAR/5 Germany</code>,
|
|
9
|
+
<code>BEFORE/3</code>, <code>AFTER/3</code>), boolean operators (<code>AND</code>, <code>OR</code>,
|
|
10
|
+
<code>NOT</code>, <code>-term</code>), exact phrases (<code>"..."</code>), wildcards (<code>*</code>, <code>?</code>),
|
|
11
|
+
and field prefixes (<code>title:</code>, <code>heading:</code>).
|
|
12
|
+
</p>
|
|
13
|
+
<form class="doxtr-search-form" data-doxtr-search-form="page" role="search">
|
|
14
|
+
<label class="doxtr-sr-only" for="doxtr-search-page-input">Search documentation</label>
|
|
15
|
+
<input
|
|
16
|
+
id="doxtr-search-page-input"
|
|
17
|
+
class="doxtr-search-input"
|
|
18
|
+
type="search"
|
|
19
|
+
name="q"
|
|
20
|
+
autocomplete="off"
|
|
21
|
+
placeholder="Try: beer NEAR/5 Germany, konig, "dark mode", title:theming..."
|
|
22
|
+
data-doxtr-search-input="page"
|
|
23
|
+
/>
|
|
24
|
+
<button type="submit" class="doxtr-btn doxtr-btn-primary" tabindex="-1">Search</button>
|
|
25
|
+
</form>
|
|
26
|
+
<p class="doxtr-search-stats" role="status" data-doxtr-search-stats="page"></p>
|
|
27
|
+
<ol class="doxtr-search-results" data-doxtr-search-results="page"></ol>
|
|
28
|
+
</section>
|
|
29
|
+
{%- endblock %}
|