add jinja extension; update shared-bindings/index.rst to use jinja

This commit is contained in:
sommersoft 2019-07-04 01:19:56 -05:00
parent f1256c0b35
commit 4342383d95
3 changed files with 44 additions and 42 deletions

17
conf.py
View File

@ -13,6 +13,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import json
import sys
import os
@ -26,6 +27,19 @@ sys.path.insert(0, os.path.abspath('.'))
master_doc = 'docs/index'
# Grab the JSON values to use while building the module support matrix
# in 'shared-bindings/index.rst'
shared_bindings_json = 'support_matrix.json'
if 'TRAVIS' in os.environ:
shared_bindings_json = os.path.join('$HOME', shared_bindings_json)
else:
shared_bindings_json = os.path.join('shared-bindings', shared_bindings_json)
with open(shared_bindings_json) as json_file:
modules_support_matrix = json.load(json_file)
html_context = {
'support_matrix': modules_support_matrix
}
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
@ -40,7 +54,8 @@ extensions = [
'sphinxcontrib.rsvgconverter',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage'
'sphinx.ext.coverage',
'rstjinja'
]
# Add any paths that contain templates here, relative to this directory.

24
docs/rstjinja.py Normal file
View File

@ -0,0 +1,24 @@
# Derived from code on Eric Holscher's blog, found at:
# https://www.ericholscher.com/blog/2016/jul/25/integrating-jinja-rst-sphinx/
def rstjinja(app, docname, source):
"""
Render our pages as a jinja template for fancy templating goodness.
"""
# Make sure we're outputting HTML
if app.builder.format != 'html':
return
# we only want our one jinja template to run through this func
if "shared-bindings/index" not in docname:
return
src = source[0]
print(docname)
rendered = app.builder.templates.render_string(
src, app.config.html_context
)
source[0] = rendered
def setup(app):
app.connect("source-read", rstjinja)

View File

@ -21,48 +21,11 @@ Modules
Support Matrix
---------------
NOTE 1: **All Supported** means the following ports are supported: SAMD21, SAMD21 Express,
SAMD51, SAMD51 Express, and ESP8266.
NOTE 2: **SAMD** and/or **SAMD Express** without additional numbers, means both SAMD21 & SAMD51 versions
are supported.
NOTE 3: The `pIRkey SAMD21 board <https://www.adafruit.com/product/3364>`_ is specialized and may not
have modules as listed below.
================= ==============================
Module Supported Ports
Module Not Available On
================= ==============================
`analogio` **All Supported**
`audiobusio` **SAMD/SAMD Express**
`audioio` **SAMD Express**
`binascii` **ESP8266**
`bitbangio` **SAMD Express, ESP8266**
`board` **All Supported**
`bleio` **nRF**
`busio` **All Supported**
`digitalio` **All Supported**
`frequencyio` **SAMD51**
`gamepad` **SAMD Express, nRF**
`hashlib` **ESP8266**
`i2cslave` **SAMD Express**
`math` **All Supported**
`microcontroller` **All Supported**
`multiterminal` **ESP8266**
`neopixel_write` **All Supported**
`nvm` **SAMD Express**
`os` **All Supported**
`pulseio` **SAMD/SAMD Express**
`ps2io` **SAMD/SAMD Express**
`random` **All Supported**
`rotaryio` **SAMD51, SAMD Express**
`storage` **All Supported**
`struct` **All Supported**
`supervisor` **SAMD/SAMD Express**
`time` **All Supported**
`touchio` **SAMD/SAMD Express**
`uheap` **Debug (All)**
`usb_hid` **SAMD/SAMD Express**
`_pixelbuf` **SAMD Express**
`_stage` **SAMD/SAMD Express**
{%- for key, value in support_matrix|dictsort %}
{{ value.name.ljust(18) }} {{ value.excluded|join(", ") }}{{ '\n'|e }}
{%- endfor %}
================= ==============================