Skip to content

Commit 8a2dc00

Browse files
emcdMuse Spark 1.3
andcommitted
Render floating alias rows in website index.
Drive Current Releases from track versions with generic alias hrefs instead of hardcoded stable/development labels. Co-Authored-By: Muse Spark 1.3 <noreply@opencode.ai>
1 parent ece3429 commit 8a2dc00

2 files changed

Lines changed: 28 additions & 16 deletions

File tree

‎data/templates/website.html.jinja‎

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<body>
2626
<h1>Available Releases</h1>
2727

28-
{% if stable_dev_versions %}
28+
{% if track_versions %}
2929
<h2>Current Releases</h2>
3030
<table>
3131
<thead>
@@ -36,27 +36,19 @@
3636
</tr>
3737
</thead>
3838
<tbody>
39-
{% for version_label, attributes in stable_dev_versions.items() %}
39+
{% for alias, version in track_versions.items() %}
4040
<tr>
41-
<td>{{ version_label }}</td>
41+
<td>{{ alias }} ({{ version }})</td>
4242
<td>
43-
{% if 'sphinx-html' in attributes %}
44-
{% if version_label.startswith('stable') %}
45-
<a href="stable/sphinx-html/index.html">Docs</a>
46-
{% elif version_label.startswith('development') %}
47-
<a href="development/sphinx-html/index.html">Docs</a>
48-
{% endif %}
43+
{% if 'sphinx-html' in versions[version] %}
44+
<a href="{{ alias }}/sphinx-html/index.html">Docs</a>
4945
{% else %}
5046
N/A
5147
{% endif %}
5248
</td>
5349
<td>
54-
{% if 'coverage-pytest' in attributes %}
55-
{% if version_label.startswith('stable') %}
56-
<a href="stable/coverage-pytest/index.html">Coverage</a>
57-
{% elif version_label.startswith('development') %}
58-
<a href="development/coverage-pytest/index.html">Coverage</a>
59-
{% endif %}
50+
{% if 'coverage-pytest' in versions[version] %}
51+
<a href="{{ alias }}/coverage-pytest/index.html">Coverage</a>
6052
{% else %}
6153
N/A
6254
{% endif %}
@@ -65,7 +57,7 @@
6557
{% endfor %}
6658
</tbody>
6759
</table>
68-
60+
6961
<h2>All Releases</h2>
7062
{% endif %}
7163

‎tests/test_000_emcdproj/test_202_publication.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,3 +846,23 @@ def test_112_bare_label_stable_alias(
846846
( locations_tmpdir.website / 'versions.json' ).read_text( ) )
847847
assert versions[ 'track_versions' ][ 'stable' ] == '1.0'
848848
assert versions[ 'stable_version' ] == '1.0'
849+
850+
851+
def test_113_index_renders_alias_rows( website ):
852+
''' Real index template renders floating alias lines with targets. '''
853+
from jinja2 import Environment, FileSystemLoader
854+
from pathlib import Path
855+
templates = (
856+
Path( __file__ ).parent.parent.parent
857+
/ 'data' / 'templates' )
858+
environment = Environment(
859+
loader = FileSystemLoader( templates ), autoescape = True )
860+
template = environment.get_template( 'website.html.jinja' )
861+
html = template.render(
862+
versions = { '1.0': ( 'sphinx-html', ), '1.1': ( 'sphinx-html', ) },
863+
latest_version = '1.1',
864+
track_versions = { 'v1': '1.1' },
865+
stable_dev_versions = { },
866+
stable_version = None )
867+
assert 'v1 (1.1)' in html
868+
assert 'v1/sphinx-html/index.html' in html

0 commit comments

Comments
 (0)