Skip to content

Commit e5bb71e

Browse files
committed
Merge branch 'main' of github.com:python-project-templates/yardang
2 parents 7b287c5 + 41cf60b commit e5bb71e

4 files changed

Lines changed: 29 additions & 5 deletions

File tree

‎docs/src/configuration.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ yardang preview
282282
```
283283

284284
This renders the documentation into `docs/html/_previews/<theme>/` for each
285-
bundled theme (`furo`, `sphinxawesome_theme`, `shibuya`, `fuma`). Themes whose
285+
bundled theme (`furo`, `sphinxawesome_theme`, `shibuya`, `fuma`, `klink`). Themes whose
286286
package is not installed are skipped. Restrict the set with `--themes`:
287287

288288
```bash
@@ -303,6 +303,7 @@ each theme is browsable live at a suburl of the published site:
303303
- [`/_previews/sphinxawesome_theme/`](https://yardang.python-templates.dev/_previews/sphinxawesome_theme/)
304304
- [`/_previews/shibuya/`](https://yardang.python-templates.dev/_previews/shibuya/)
305305
- [`/_previews/fuma/`](https://yardang.python-templates.dev/_previews/fuma/)
306+
- [`/_previews/klink/`](https://yardang.python-templates.dev/_previews/klink/)
306307

307308
## `source-dir`
308309

‎docs/src/home.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</div>
77

88
[![GitHub](https://img.shields.io/badge/repo-github-181717?logo=github&logoColor=white)](https://github.com/python-project-templates/yardang)
9-
[![Build Status](https://github.com/python-project-templates/yardang/actions/workflows/build.yml/badge.svg?branch=main&event=push)](https://github.com/python-project-templates/yardang/actions/workflows/build.yml)
9+
[![Build Status](https://github.com/python-project-templates/yardang/actions/workflows/build.yaml/badge.svg?branch=main&event=push)](https://github.com/python-project-templates/yardang/actions/workflows/build.yaml)
1010
[![codecov](https://codecov.io/gh/python-project-templates/yardang/branch/main/graph/badge.svg)](https://codecov.io/gh/python-project-templates/yardang)
1111
[![License](https://img.shields.io/github/license/python-project-templates/yardang)](https://github.com/python-project-templates/yardang)
1212
[![PyPI](https://img.shields.io/pypi/v/yardang.svg)](https://pypi.python.org/pypi/yardang)

‎yardang/conf.py.j2‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ copyright = """{{copyright}}"""
3434
title = """{{title}}"""
3535
version = "{{version}}"
3636
release = "{{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}}"""
3840
docs_host_root = "{{docs_root}}"
3941
root = "{{root}}"
4042
cname = "{{ cname or '' }}"
@@ -133,8 +135,11 @@ html_theme = "{{theme}}"
133135
if html_theme == "klink":
134136
import klink
135137
html_theme_path = [klink.get_html_theme_path()]
136-
html_title = f"{title} v{version}"
137138
html_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", "")
138143
html_static_path = {{html_static_path}}
139144
html_extra_path = {{html_extra_path}}
140145
html_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, "", "&lt;no title&gt;", "<no title>"):
427+
context["title"] = title
428+
429+
417430
def 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)

‎yardang/tests/test_themes.py‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ def test_other_themes_are_unchanged(self):
3232
assert build_module.theme_module("furo") == "furo"
3333

3434

35+
class TestDocumentedThemes:
36+
"""The theme lists in the docs are maintained by hand, so they drift."""
37+
38+
@pytest.mark.parametrize("theme", BUNDLED_THEMES)
39+
def test_theme_has_a_preview_link(self, theme):
40+
docs = Path(__file__).parents[2] / "docs" / "src" / "configuration.md"
41+
assert f"/_previews/{theme}/" in docs.read_text()
42+
43+
3544
class TestSearchIntegration:
3645
"""Search is theme-independent, so it is wired for every first-class theme."""
3746

@@ -46,7 +55,7 @@ def _conf(self, tmp_path, **kwargs):
4655
finally:
4756
os.chdir(original_cwd)
4857

49-
@pytest.mark.parametrize("theme", ["furo", "shibuya", "sphinxawesome_theme", "fuma"])
58+
@pytest.mark.parametrize("theme", BUNDLED_THEMES)
5059
def test_searchlite_is_enabled_for_first_class_themes(self, tmp_path, theme):
5160
assert "sphinx_searchlite" in self._conf(tmp_path, theme=theme)
5261

0 commit comments

Comments
 (0)