Skip to content

Commit 7ca1bd3

Browse files
Daniel Camporadpgeorge
Daniel Campora
authored andcommitted
docs: Generate a separate docs build for each port.
Using Damien's approach where conf.py and topindex.html are shared by all ports.
1 parent 031278f commit 7ca1bd3

32 files changed

+94
-42
lines changed

docs/conf.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134

135135
# The name of an image file (relative to this directory) to place at the top
136136
# of the sidebar.
137-
#html_logo = '../logo/trans-logo.png'
137+
#html_logo = '../../logo/trans-logo.png'
138138

139139
# The name of an image file (within the static path) to use as favicon of the
140140
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
@@ -277,3 +277,23 @@
277277

278278
# Example configuration for intersphinx: refer to the Python standard library.
279279
intersphinx_mapping = {'http://docs.python.org/': None}
280+
281+
282+
# Work out the port to generate the docs for
283+
from collections import OrderedDict
284+
micropy_port = os.getenv('MICROPY_PORT') or 'pyboard'
285+
tags.add('port_' + micropy_port)
286+
ports = OrderedDict((
287+
("unix", "unix"),
288+
("pyboard", "the pyboard"),
289+
("wipy", "the WiPy"),
290+
("esp8266", "esp8266"),
291+
))
292+
293+
# The members of the html_context dict are available inside topindex.html
294+
url_prefix = os.getenv('MICROPY_URL_PREFIX') or '/'
295+
html_context = {
296+
'port':micropy_port,
297+
'port_name':ports[micropy_port],
298+
'all_ports':[(n, url_prefix + p) for p, n in ports.items()],
299+
}

docs/contents.rst

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
Micro Python documentation contents
22
===================================
33

4-
.. toctree::
5-
6-
quickref.rst
7-
general.rst
8-
tutorial/index.rst
9-
library/index.rst
10-
hardware/index.rst
11-
license.rst
4+
.. only:: port_pyboard
5+
6+
.. toctree::
7+
8+
pyboard/quickref.rst
9+
pyboard/general.rst
10+
pyboard/tutorial/index.rst
11+
library/index.rst
12+
pyboard/hardware/index.rst
13+
license.rst
14+
15+
.. only:: port_esp8266
16+
17+
.. toctree::
18+
19+
library/index.rst
20+
license.rst

docs/index.rst

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
Micro Python documentation and references
22
=========================================
33

4-
.. toctree::
5-
6-
quickref.rst
7-
general.rst
8-
tutorial/index.rst
9-
library/index.rst
10-
hardware/index.rst
11-
license.rst
12-
contents.rst
4+
.. only:: port_pyboard
5+
6+
.. toctree::
7+
8+
pyboard/quickref.rst
9+
pyboard/general.rst
10+
pyboard/tutorial/index.rst
11+
library/index.rst
12+
pyboard/hardware/index.rst
13+
license.rst
14+
contents.rst
15+
16+
.. only:: port_esp8266
17+
18+
.. toctree::
19+
20+
library/index.rst
21+
license.rst
22+
contents.rst
1323

1424
Indices and tables
1525
==================
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/topindex.html

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,53 @@ <h1>Micro Python documentation</h1>
88
v{{ release|e }}{% if last_updated %}, {{ _('last updated') }} {{ last_updated|e }}{% endif %}.
99
</p>
1010

11+
<p>
12+
MicroPython runs on a variety of systems and each has their own specific
13+
documentation. You are currently viewing the documentation for
14+
<strong>{{ port_name }}</strong>.
15+
</p>
16+
17+
<!--p>
18+
Documentation for other systems are available:
19+
{% for p in all_ports %}
20+
<a href="{{ p[1] }}">{{ p[0] }}</a>{% if not loop.last %}, {% endif %}
21+
{% endfor %}.
22+
</p-->
23+
1124
<p><strong>Documentation for Micro Python and the pyboard:</strong></p>
1225

1326
<table class="contentstable"><tr>
1427
<td width="40%" style="padding-left:2em;">
15-
<p class="biglink">
16-
<a class="biglink" href="{{ pathto("quickref") }}">Quick reference for the pyboard</a><br/>
17-
<span class="linkdescr">pinout for the pyboard and snippets of useful code</span>
18-
</p>
19-
<p class="biglink">
20-
<a class="biglink" href="{{ pathto("general") }}">General information about the pyboard</a><br/>
21-
<span class="linkdescr">read this first for a quick overview</span>
22-
</p>
23-
<p class="biglink">
24-
<a class="biglink" href="{{ pathto("tutorial/index") }}">Tutorials and code examples</a><br/>
25-
<span class="linkdescr">start here</span>
26-
</p>
28+
{% if port == "pyboard" %}
29+
<p class="biglink">
30+
<a class="biglink" href="{{ pathto(port + "/quickref") }}">Quick reference for {{ port_name }}</a><br/>
31+
<span class="linkdescr">pinout for {{ port_name }} and snippets of useful code</span>
32+
</p>
33+
<p class="biglink">
34+
<a class="biglink" href="{{ pathto(port + "/general") }}">General information about {{ port_name }}</a><br/>
35+
<span class="linkdescr">read this first for a quick overview</span>
36+
</p>
37+
<p class="biglink">
38+
<a class="biglink" href="{{ pathto(port + "/tutorial/index") }}">Tutorials and code examples</a><br/>
39+
<span class="linkdescr">start here</span>
40+
</p>
41+
{% endif %}
2742
<p class="biglink">
2843
<a class="biglink" href="{{ pathto("library/index") }}">Library Reference</a><br/>
2944
<span class="linkdescr">Micro Python libraries, including the <a href="{{ pathto("library/pyb") }}">pyb module</a></span>
3045
</p>
3146
</td>
3247
<td width="40%" style="padding-left:2em;">
33-
<p class="biglink">
34-
<a class="biglink" href="{{ pathto("hardware/index") }}">The pyboard hardware</a><br/>
35-
<span class="linkdescr">schematics, dimensions and component datasheets</span>
36-
</p>
37-
<p class="biglink">
38-
<a class="biglink" href="http://micropython.org/resources/Micro-Python-Windows-setup.pdf">Guide for pyboard on Windows (PDF)</a><br/>
39-
<span class="linkdescr">including DFU programming</span>
40-
</p>
48+
{% if port == "pyboard" %}
49+
<p class="biglink">
50+
<a class="biglink" href="{{ pathto(port + "/hardware/index") }}">The {{ port }} hardware</a><br/>
51+
<span class="linkdescr">schematics, dimensions and component datasheets</span>
52+
</p>
53+
<p class="biglink">
54+
<a class="biglink" href="http://micropython.org/resources/Micro-Python-Windows-setup.pdf">Guide for {{ port_name }} on Windows (PDF)</a><br/>
55+
<span class="linkdescr">including DFU programming</span>
56+
</p>
57+
{% endif %}
4158
<p class="biglink">
4259
<a class="biglink" href="{{ pathto("license") }}">License</a><br/>
4360
<span class="linkdescr">Micro Python license information</span>
@@ -62,10 +79,6 @@ <h1>Micro Python documentation</h1>
6279
<a class="biglink" href="{{ pathto("contents") }}">Table of contents</a><br/>
6380
<span class="linkdescr">a list of all sections and subsections</span>
6481
</p>
65-
<p class="biglink">
66-
<a class="biglink" href="{{ pathto("search") }}">Search page</a><br/>
67-
<span class="linkdescr">search this documentation</span>
68-
</p>
6982
</td></tr>
7083
</table>
7184

0 commit comments

Comments
 (0)