Skip to content

Commit 5b74bba

Browse files
committed
docs: Add versions.html template and support code for a version sidebar.
1 parent 4b6077b commit 5b74bba

File tree

2 files changed

+56
-7
lines changed

2 files changed

+56
-7
lines changed

docs/conf.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,28 @@
2626
micropy_port = os.getenv('MICROPY_PORT') or 'pyboard'
2727
tags.add('port_' + micropy_port)
2828
ports = OrderedDict((
29-
("unix", "unix"),
30-
("pyboard", "the pyboard"),
31-
("wipy", "the WiPy"),
32-
("esp8266", "esp8266"),
29+
('unix', ('unix', 'unix')),
30+
('pyboard', ('pyboard', 'the pyboard')),
31+
('wipy', ('WiPy', 'the WiPy')),
32+
('esp8266', ('ESP8266', 'the ESP8266')),
3333
))
3434

3535
# The members of the html_context dict are available inside topindex.html
36-
url_prefix = os.getenv('MICROPY_URL_PREFIX') or '/'
36+
micropy_version = os.getenv('MICROPY_VERSION') or 'latest'
37+
url_pattern = '%s/en/%%s/%%s' % (os.getenv('MICROPY_URL_PREFIX') or '/',)
3738
html_context = {
3839
'port':micropy_port,
39-
'port_name':ports[micropy_port],
40-
'all_ports':[(n, url_prefix + p) for p, n in ports.items()],
40+
'port_short_name':ports[micropy_port][0],
41+
'port_name':ports[micropy_port][1],
42+
'port_version':micropy_version,
43+
'all_ports':[
44+
(port_name[0], url_pattern % (micropy_version, port_id))
45+
for port_id, port_name in ports.items()
46+
],
47+
'all_versions':[
48+
(ver, url_pattern % (ver, micropy_port))
49+
for ver in ('v1.4', 'v1.4.1', 'v1.5', 'v1.6', 'latest')
50+
],
4151
}
4252

4353

docs/templates/versions.html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
2+
<span class="rst-current-version" data-toggle="rst-current-version">
3+
<span class="fa fa-book"> Ports and Versions</span>
4+
{{ port_short_name }} ({{ port_version }})
5+
<span class="fa fa-caret-down"></span>
6+
</span>
7+
<div class="rst-other-versions">
8+
<dl>
9+
<dt>Ports</dt>
10+
{% for slug, url in all_ports %}
11+
<dd><a href="{{ url }}">{{ slug }}</a></dd>
12+
{% endfor %}
13+
</dl>
14+
<dl>
15+
<dt>Versions</dt>
16+
{% for slug, url in all_versions %}
17+
<dd><a href="{{ url }}">{{ slug }}</a></dd>
18+
{% endfor %}
19+
</dl>
20+
<!--
21+
<dl>
22+
<dt>Downloads</dt>
23+
{% for type, url in downloads %}
24+
<dd><a href="{{ url }}">{{ type }}</a></dd>
25+
{% endfor %}
26+
</dl>
27+
-->
28+
<hr/>
29+
<dl>
30+
<dt>External links</dt>
31+
<dd>
32+
<a href="http://www.micropython.org">micropython.org</a>
33+
</dd>
34+
<dd>
35+
<a href="https://github.com/micropython/micropython">GitHub</a>
36+
</dd>
37+
</dl>
38+
</div>
39+
</div>

0 commit comments

Comments
 (0)