[gi-docgen/derived-implements: 5/5] generate: Display the list of descendants of a class




commit b6870f4ec867e54226ad3e46b69b44064af98e12
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Mon Oct 18 13:16:52 2021 +0100

    generate: Display the list of descendants of a class
    
    We show the list of direct descendants, collapsed by default as it could
    be arbitrarily long.
    
    Fixes: #105

 gidocgen/gdgenerate.py              |  8 ++++++++
 gidocgen/templates/basic/class.html | 13 +++++++++++++
 2 files changed, 21 insertions(+)
---
diff --git a/gidocgen/gdgenerate.py b/gidocgen/gdgenerate.py
index 2db23ad..6c84777 100644
--- a/gidocgen/gdgenerate.py
+++ b/gidocgen/gdgenerate.py
@@ -1281,6 +1281,14 @@ class TemplateClass:
             for ancestor_type in cls.ancestors:
                 self.ancestors.append(gen_index_ancestor(ancestor_type, namespace, config, md))
 
+        if cls.descendants:
+            self.descendants = []
+            for descendant in cls.descendants:
+                self.descendants.append({
+                    'name': descendant.name,
+                    'ctype': descendant.ctype,
+                })
+
         self.class_name = cls.type_struct
 
         self.instance_struct = None
diff --git a/gidocgen/templates/basic/class.html b/gidocgen/templates/basic/class.html
index 01cd4b7..435f6e0 100644
--- a/gidocgen/templates/basic/class.html
+++ b/gidocgen/templates/basic/class.html
@@ -162,6 +162,19 @@ SPDX-License-Identifier: Apache-2.0 OR GPL-3.0-or-later
     </div>
     {% endif %}
 
+    {% if class.descendants %}
+    <div class="descendants toggle-wrapper default-hide">
+      <h4 id="descendants">Descendants <a href="#descendants" class="anchor"></a></h4>
+      <div class="docblock">
+        <ul>
+        {%- for cls in class.descendants %}
+          <li class="class"><a href="class.{{ cls.name }}.html" title="{{ cls.name }}">{{ cls.ctype 
}}</a></li>
+        {% endfor -%}
+        </ul>
+      </div>
+    </div>
+    {% endif %}
+
     {% if class.interfaces %}
     <div class="toggle-wrapper implements">
       <h4 id="implements">


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