Make the sidebar a little nicer

This commit is contained in:
Kovid Goyal 2018-05-30 13:43:48 +05:30
parent bf8dfa5ee3
commit 0c5c6fcbbe
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
5 changed files with 48 additions and 0 deletions

View File

@ -64,3 +64,21 @@ body div.document {
outline: 0;
}
div.sphinxsidebar {
font-size: inherit;
line-height: inherit;
}
#sidebartoc li {
margin-top: 0.75ex;
margin-bottom: 0.75ex;
}
#sidebartoc ul {
list-style: none !important;
}
#sidebartoc a[href]:hover {
color: red;
}

6
docs/_templates/localtoc.html vendored Normal file
View File

@ -0,0 +1,6 @@
{%- if display_toc %}
<div>&nbsp;</div>
<div id="sidebartoc">
{{ toc }}
</div>
{%- endif %}

View File

@ -234,6 +234,26 @@ def commit_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
return [node], []
def create_toc(app, pagename):
toctree = app.env.get_toc_for(pagename, app.builder)
if toctree is not None:
subtree = toctree[toctree.first_child_matching_class(nodes.list_item)]
bl = subtree.first_child_matching_class(nodes.bullet_list)
if bl is None:
return # Empty ToC
subtree = subtree[bl]
# for li in subtree.traverse(nodes.list_item):
# modify_li(li)
# subtree['ids'] = [ID]
return app.builder.render_partial(subtree)['fragment']
def add_html_context(app, pagename, templatename, context, *args):
if 'toc' in context:
context['toc'] = create_toc(app, pagename) or context['toc']
def setup(app):
app.add_role('iss', issue_role)
app.add_role('commit', commit_role)
app.connect('html-page-context', add_html_context)

View File

@ -1,3 +1,5 @@
:tocdepth: 3
The terminal graphics protocol
==================================

View File

@ -1,3 +1,5 @@
:tocdepth: 2
==========================================================
kitty - the fast, featureful, GPU based, terminal emulator
==========================================================