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 "<no title>". + if context.get("title") in (None, "", "<no title>", "<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)