Instead of creating lots of individual templates, one can create a single template that uses javascript to populate extra entries on the table of contents at load time.
I can use viblo's script from Toc/list with all classes generated by automodule in sphinx docs that dynamically generates lists of Classes
, Functions
, and Variables
.
My _templates/localtoc.html
then becomes:
<h3><a href="{{ pathto(master_doc) }}">{{ _('Table Of Contents') }}</a></h3>
{%- if display_toc %}
{{ toc }}
{%- endif %}
<div class="custom-index container">
<script type="text/javascript" src={{ pathto(master_doc)[:-10] + '_static/pymunk.js' }}></script>
</div>