[gi-docgen/hide-toc: 2/2] template: Add a toc to the enumeration template




commit eb3cadc0b75789c5499ce6b6e3c8d51ef9edaacd
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Thu Sep 2 14:03:26 2021 +0100

    template: Add a toc to the enumeration template
    
    Enumeration types may have a functions section, so we should add a table
    of contents.

 gidocgen/templates/basic/enum.html | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
---
diff --git a/gidocgen/templates/basic/enum.html b/gidocgen/templates/basic/enum.html
index 081dece..8c56170 100644
--- a/gidocgen/templates/basic/enum.html
+++ b/gidocgen/templates/basic/enum.html
@@ -39,6 +39,24 @@ SPDX-License-Identifier: Apache-2.0 OR GPL-3.0-or-later
 {{ sidebar_block(enum.type_funcs, enum.name, "Type functions", "func", "type_func") }}
 {% endblock %}
 
+{% macro navbar_block(elements, section_title, section_link) -%}
+{% if elements|length > 0 %}
+<li class="toc-list-item"><a href="{{ section_link }}"><span class="link-text">{{ section_title 
}}</span></a></li>
+{% endif %}
+{% endmacro %}
+
+{% block navbar %}
+<div id="toc" class="toc">
+  <nav aria-labelledby="toc-title">
+    <p id="toc-title">Content</p>
+    <ul class="toc-list">
+      <li class="toc-list-item"><a href="#description"><span class="link-text">Description</span></a></li>
+      {{ navbar_block(class.type_funcs, "Functions", "#type-functions") }}
+    </ul>
+  </nav>
+</div>
+{% endblock %}
+
 {% block content %}
 <section id="main" class="content">
   <header>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]