From 2d69e4a6f98a0bc25135b34e38f8e41d1bd0e48d Mon Sep 17 00:00:00 2001 From: Tim Paine <3105306+timkpaine@users.noreply.github.com> Date: Tue, 8 Sep 2026 13:26:36 -0400 Subject: [PATCH] Fix page titles and the klink sidebar logo The
element for the version. Themes deriving from the basic layout rendered that
markup escaped into browser tabs, so keep html_title plain text.
Sphinx only assigns a document title when a page opens with a single top
level section, so a README leading with a logo or badges left the root page
titled "". Fall back to the configured project title.
Klink's theme.conf points at _static/logo.png by default and yardang ships
no such file, leaving a broken image in its sidebar.
Search coverage now follows BUNDLED_THEMES so a newly added theme cannot
silently miss it.
---
yardang/conf.py.j2 | 18 ++++++++++++++++--
yardang/tests/test_themes.py | 2 +-
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/yardang/conf.py.j2 b/yardang/conf.py.j2
index 496c7750..c1815074 100644
--- a/yardang/conf.py.j2
+++ b/yardang/conf.py.j2
@@ -34,7 +34,9 @@ copyright = """{{copyright}}"""
title = """{{title}}"""
version = "{{version}}"
release = "{{version}}"
-html_title = """{{title}} v{{version}}"""
+# Sphinx reuses this as the tag, so it has to stay plain text; markup
+# here shows up escaped in browser tabs and search results.
+html_title = """{{title}} v{{version}}"""
docs_host_root = "{{docs_root}}"
root = "{{root}}"
cname = "{{ cname or '' }}"
@@ -133,8 +135,11 @@ html_theme = "{{theme}}"
if html_theme == "klink":
import klink
html_theme_path = [klink.get_html_theme_path()]
- html_title = f"{title} v{version}"
html_theme_options = {{html_theme_options}}
+# klink's theme.conf points at _static/logo.png by default, which yardang does
+# not ship, so drop it unless a logo was configured explicitly.
+if html_theme == "klink":
+ html_theme_options.setdefault("logo", "")
html_static_path = {{html_static_path}}
html_extra_path = {{html_extra_path}}
html_css_files = [
@@ -414,6 +419,14 @@ def run_convert_github_admonitions_to_rst(app, filename, lines):
lines[i] = "\n".join(orig_line_splits)
+def run_title_fallback(app, pagename, templatename, context, doctree):
+ # Sphinx only takes a document title when the page opens with a single top
+ # level section, so a README that leads with a logo or badges leaves the
+ # root page reading "".
+ if context.get("title") in (None, "", "<no title>", ""):
+ context["title"] = title
+
+
def setup(app):
if {{previous_versions}}:
app.connect("builder-inited", run_create_previous_version_markdown)
@@ -423,3 +436,4 @@ def setup(app):
{% endif %}
app.connect("builder-inited", run_copycname)
app.connect("source-read", run_convert_github_admonitions_to_rst)
+ app.connect("html-page-context", run_title_fallback)
diff --git a/yardang/tests/test_themes.py b/yardang/tests/test_themes.py
index efa233bd..7593a611 100644
--- a/yardang/tests/test_themes.py
+++ b/yardang/tests/test_themes.py
@@ -46,7 +46,7 @@ def _conf(self, tmp_path, **kwargs):
finally:
os.chdir(original_cwd)
- @pytest.mark.parametrize("theme", ["furo", "shibuya", "sphinxawesome_theme", "fuma"])
+ @pytest.mark.parametrize("theme", BUNDLED_THEMES)
def test_searchlite_is_enabled_for_first_class_themes(self, tmp_path, theme):
assert "sphinx_searchlite" in self._conf(tmp_path, theme=theme)