[gi-docgen/ebassi/sub-headings: 2/2] template: Improve the TOC sidebar of types
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gi-docgen/ebassi/sub-headings: 2/2] template: Improve the TOC sidebar of types
- Date: Sun, 30 Jan 2022 22:33:33 +0000 (UTC)
commit c97faeacc3b565b3345ebc8bed3a7211e11a7f4a
Author: Emmanuele Bassi <ebassi gnome org>
Date: Sun Jan 30 22:31:29 2022 +0000
template: Improve the TOC sidebar of types
Like we do for extra content files, we should generate a TOC of the
sub-headings inside the description of types: classes, interfaces, and
structured data. This way it's easier to navigate to sub-sections, and
to get their location for links.
gidocgen/templates/basic/class.html | 13 +++++++++++++
gidocgen/templates/basic/interface.html | 13 +++++++++++++
gidocgen/templates/basic/struct.html | 13 +++++++++++++
3 files changed, 39 insertions(+)
---
diff --git a/gidocgen/templates/basic/class.html b/gidocgen/templates/basic/class.html
index b74bdea..6d76282 100644
--- a/gidocgen/templates/basic/class.html
+++ b/gidocgen/templates/basic/class.html
@@ -57,6 +57,19 @@ SPDX-License-Identifier: Apache-2.0 OR GPL-3.0-or-later
<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>
+ {% if class.description_toc %}
+ <ul class="toc-list">
+ {% if class.description_toc|length == 1 %}
+ {% for header in class.description_toc[0].children %}
+ <li class="toc-list-item"><a href="#{{ header.id }}"><span class="link-text">{{ header.name
}}</span></a></li>
+ {% endfor %}
+ {% else %}
+ {% for header in class.description_toc %}
+ <li class="toc-list-item"><a href="#{{ header.id }}"><span class="link-text">{{ header.name
}}</span></a></li>
+ {% endfor %}
+ {% endif %}
+ </ul>
+ {% endif %}
{% if CONFIG.show_class_hierarchy and (class.ancestors or class.interfaces) %}
<li class="toc-list-item"><a href="#hierarchy"><span class="link-text">Hierarchy</span></a></li>
{% endif %}
diff --git a/gidocgen/templates/basic/interface.html b/gidocgen/templates/basic/interface.html
index ea6f994..4f64e51 100644
--- a/gidocgen/templates/basic/interface.html
+++ b/gidocgen/templates/basic/interface.html
@@ -56,6 +56,19 @@ SPDX-License-Identifier: Apache-2.0 OR GPL-3.0-or-later
<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>
+ {% if interface.description_toc %}
+ <ul class="toc-list">
+ {% if interface.description_toc|length == 1 %}
+ {% for header in interface.description_toc[0].children %}
+ <li class="toc-list-item"><a href="#{{ header.id }}"><span class="link-text">{{ header.name
}}</span></a></li>
+ {% endfor %}
+ {% else %}
+ {% for header in interface.description_toc %}
+ <li class="toc-list-item"><a href="#{{ header.id }}"><span class="link-text">{{ header.name
}}</span></a></li>
+ {% endfor %}
+ {% endif %}
+ </ul>
+ {% endif %}
{{ navbar_block(interface.type_funcs, "Functions", "#type-functions") }}
{{ navbar_block(interface.methods, "Methods", "#methods") }}
{{ navbar_block(interface.properties, "Properties", "#properties") }}
diff --git a/gidocgen/templates/basic/struct.html b/gidocgen/templates/basic/struct.html
index 0b0f27a..fb45616 100644
--- a/gidocgen/templates/basic/struct.html
+++ b/gidocgen/templates/basic/struct.html
@@ -53,6 +53,19 @@ SPDX-License-Identifier: Apache-2.0 OR GPL-3.0-or-later
<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>
+ {% if struct.description_toc %}
+ <ul class="toc-list">
+ {% if struct.description_toc|length == 1 %}
+ {% for header in struct.description_toc[0].children %}
+ <li class="toc-list-item"><a href="#{{ header.id }}"><span class="link-text">{{ header.name
}}</span></a></li>
+ {% endfor %}
+ {% else %}
+ {% for header in struct.description_toc %}
+ <li class="toc-list-item"><a href="#{{ header.id }}"><span class="link-text">{{ header.name
}}</span></a></li>
+ {% endfor %}
+ {% endif %}
+ </ul>
+ {% endif %}
{{ navbar_block(struct.ctors, "Constructors", "#constructors") }}
{{ navbar_block(struct.type_funcs, "Functions", "#type-functions") }}
{{ navbar_block(struct.methods, "Methods", "#methods") }}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]