Reputation: 13162
I'm working on theming my documentation, and I'm trying to get sphinx to add a class to the <ul>
elements of the Table of Contents. Unfortunately, it looks like the HTML is generated just the same as any other list.
Is there a way to add a class to the TOC?
The class that I want to add (fyi) is nav nav-tabs nav-stacked
; I'm using a bootstrap theme.
Update: my current hack is to override localtoc.html
template to have
{{ toc|replace("<ul>", "<ul class='nav nav-tabs nav-stacked'>") }}
but it feels ugly...
Upvotes: 3
Views: 1150
Reputation: 3405
The TOCs are converted to HTML separately and then inserted into the document, without letting you control it. Checkout the render_partial
method of sphinx.builds.html.StandaloneHTMLBuilder
.
Your hack is the easiest method, the other option is to subclass StandaloneHTMLBuilder
and override render_partial
to control the docutils' HTMLWriter
.
Upvotes: 1