docs: Add versions.html template and support code for a version sidebar.
This commit is contained in:
parent
4b6077b3fe
commit
5b74bba3a3
24
docs/conf.py
24
docs/conf.py
@ -26,18 +26,28 @@ from collections import OrderedDict
|
||||
micropy_port = os.getenv('MICROPY_PORT') or 'pyboard'
|
||||
tags.add('port_' + micropy_port)
|
||||
ports = OrderedDict((
|
||||
("unix", "unix"),
|
||||
("pyboard", "the pyboard"),
|
||||
("wipy", "the WiPy"),
|
||||
("esp8266", "esp8266"),
|
||||
('unix', ('unix', 'unix')),
|
||||
('pyboard', ('pyboard', 'the pyboard')),
|
||||
('wipy', ('WiPy', 'the WiPy')),
|
||||
('esp8266', ('ESP8266', 'the ESP8266')),
|
||||
))
|
||||
|
||||
# The members of the html_context dict are available inside topindex.html
|
||||
url_prefix = os.getenv('MICROPY_URL_PREFIX') or '/'
|
||||
micropy_version = os.getenv('MICROPY_VERSION') or 'latest'
|
||||
url_pattern = '%s/en/%%s/%%s' % (os.getenv('MICROPY_URL_PREFIX') or '/',)
|
||||
html_context = {
|
||||
'port':micropy_port,
|
||||
'port_name':ports[micropy_port],
|
||||
'all_ports':[(n, url_prefix + p) for p, n in ports.items()],
|
||||
'port_short_name':ports[micropy_port][0],
|
||||
'port_name':ports[micropy_port][1],
|
||||
'port_version':micropy_version,
|
||||
'all_ports':[
|
||||
(port_name[0], url_pattern % (micropy_version, port_id))
|
||||
for port_id, port_name in ports.items()
|
||||
],
|
||||
'all_versions':[
|
||||
(ver, url_pattern % (ver, micropy_port))
|
||||
for ver in ('v1.4', 'v1.4.1', 'v1.5', 'v1.6', 'latest')
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
|
39
docs/templates/versions.html
vendored
Normal file
39
docs/templates/versions.html
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
|
||||
<span class="rst-current-version" data-toggle="rst-current-version">
|
||||
<span class="fa fa-book"> Ports and Versions</span>
|
||||
{{ port_short_name }} ({{ port_version }})
|
||||
<span class="fa fa-caret-down"></span>
|
||||
</span>
|
||||
<div class="rst-other-versions">
|
||||
<dl>
|
||||
<dt>Ports</dt>
|
||||
{% for slug, url in all_ports %}
|
||||
<dd><a href="{{ url }}">{{ slug }}</a></dd>
|
||||
{% endfor %}
|
||||
</dl>
|
||||
<dl>
|
||||
<dt>Versions</dt>
|
||||
{% for slug, url in all_versions %}
|
||||
<dd><a href="{{ url }}">{{ slug }}</a></dd>
|
||||
{% endfor %}
|
||||
</dl>
|
||||
<!--
|
||||
<dl>
|
||||
<dt>Downloads</dt>
|
||||
{% for type, url in downloads %}
|
||||
<dd><a href="{{ url }}">{{ type }}</a></dd>
|
||||
{% endfor %}
|
||||
</dl>
|
||||
-->
|
||||
<hr/>
|
||||
<dl>
|
||||
<dt>External links</dt>
|
||||
<dd>
|
||||
<a href="http://www.micropython.org">micropython.org</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="https://github.com/micropython/micropython">GitHub</a>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user