Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions yardang/conf.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ copyright = """{{copyright}}"""
title = """{{title}}"""
version = "{{version}}"
release = "{{version}}"
html_title = """{{title}} <code style='font-size: var(--font-size--small--4);color: var(--sd-color-primary);'>v{{version}}</code>"""
# Sphinx reuses this as the <title> 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 '' }}"
Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -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, "", "&lt;no title&gt;", "<no title>"):
context["title"] = title


def setup(app):
if {{previous_versions}}:
app.connect("builder-inited", run_create_previous_version_markdown)
Expand All @@ -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)
2 changes: 1 addition & 1 deletion yardang/tests/test_themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down