@@ -34,7 +34,9 @@ copyright = """{{copyright}}"""
3434title = """{{title}}"""
3535version = "{{version}}"
3636release = "{{version}}"
37- html_title = """{{title}} <code style =' font-size : var (--font-size--small--4 );color : var (--sd-color-primary );' >v{{version}}</code >"""
37+ # Sphinx reuses this as the <title > tag, so it has to stay plain text; markup
38+ # here shows up escaped in browser tabs and search results.
39+ html_title = """{{title}} v{{version}}"""
3840docs_host_root = "{{docs_root}}"
3941root = "{{root}}"
4042cname = "{{ cname or '' }}"
@@ -133,8 +135,11 @@ html_theme = "{{theme}}"
133135if html_theme == "klink":
134136 import klink
135137 html_theme_path = [klink.get_html_theme_path()]
136- html_title = f"{title} v{version}"
137138html_theme_options = {{html_theme_options}}
139+ # klink's theme.conf points at _static/logo.png by default, which yardang does
140+ # not ship, so drop it unless a logo was configured explicitly.
141+ if html_theme == "klink":
142+ html_theme_options.setdefault("logo", "")
138143html_static_path = {{html_static_path}}
139144html_extra_path = {{html_extra_path}}
140145html_css_files = [
@@ -414,6 +419,14 @@ def run_convert_github_admonitions_to_rst(app, filename, lines):
414419 lines[i] = "\n".join(orig_line_splits)
415420
416421
422+ def run_title_fallback(app, pagename, templatename, context, doctree):
423+ # Sphinx only takes a document title when the page opens with a single top
424+ # level section, so a README that leads with a logo or badges leaves the
425+ # root page reading "<no title >".
426+ if context.get("title") in (None, "", "< ; no title> ; ", "<no title >"):
427+ context["title"] = title
428+
429+
417430def setup(app):
418431 if {{previous_versions}}:
419432 app.connect("builder-inited", run_create_previous_version_markdown)
@@ -423,3 +436,4 @@ def setup(app):
423436 {% endif %}
424437 app.connect("builder-inited", run_copycname)
425438 app.connect("source-read", run_convert_github_admonitions_to_rst)
439+ app.connect("html-page-context", run_title_fallback)
0 commit comments