[PATCH 1/7] docs: Remove XSLT table of contents generator

Peter Krempa posted 7 patches 1 year, 5 months ago
[PATCH 1/7] docs: Remove XSLT table of contents generator
Posted by Peter Krempa 1 year, 5 months ago
The only remaining page was 'hvsupport.html' which is generated by
'scripts/hvsupport.py'. The script already has all the data to generate
the table of contents internally so we can remove the whole complicated
template.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 docs/page.xsl        | 55 --------------------------------------------
 scripts/hvsupport.py | 10 +++++++-
 2 files changed, 9 insertions(+), 56 deletions(-)

diff --git a/docs/page.xsl b/docs/page.xsl
index 20b49d1afd..a93f24fb09 100644
--- a/docs/page.xsl
+++ b/docs/page.xsl
@@ -15,65 +15,10 @@
     </xsl:copy>
   </xsl:template>

-
-  <xsl:template match="html:ul[@id='toc']" mode="content">
-    <xsl:call-template name="toc"/>
-  </xsl:template>
-
   <xsl:template match="html:div[@id='include']" mode="content">
     <xsl:call-template name="include"/>
   </xsl:template>

-  <xsl:template name="toc">
-    <ul>
-      <xsl:for-each select="/html:html/html:body/html:h2[count(html:a) = 1]">
-        <xsl:variable name="thish2" select="."/>
-        <li>
-          <a href="#{html:a/@id}"><xsl:value-of select="html:a/text()"/></a>
-          <xsl:if test="count(./following-sibling::html:h3[preceding-sibling::html:h2[1] = $thish2 and count(html:a) = 1]) > 0">
-            <ul>
-              <xsl:for-each select="./following-sibling::html:h3[preceding-sibling::html:h2[1] = $thish2 and count(html:a) = 1]">
-                <xsl:variable name="thish3" select="."/>
-                <li>
-                  <a href="#{html:a/@id}"><xsl:value-of select="html:a/text()"/></a>
-                  <xsl:if test="count(./following-sibling::html:h4[preceding-sibling::html:h3[1] = $thish3 and count(html:a) = 1]) > 0">
-                    <ul>
-                      <xsl:for-each select="./following-sibling::html:h4[preceding-sibling::html:h3[1] = $thish3 and count(html:a) = 1]">
-                        <xsl:variable name="thish4" select="."/>
-                        <li>
-                          <a href="#{html:a/@id}"><xsl:value-of select="html:a/text()"/></a>
-                          <xsl:if test="count(./following-sibling::html:h5[preceding-sibling::html:h4[1] = $thish4 and count(html:a) = 1]) > 0">
-                            <ul>
-                              <xsl:for-each select="./following-sibling::html:h5[preceding-sibling::html:h4[1] = $thish4 and count(html:a) = 1]">
-                                <xsl:variable name="thish5" select="."/>
-                                <li>
-                                  <a href="#{html:a/@id}"><xsl:value-of select="html:a/text()"/></a>
-                                  <xsl:if test="count(./following-sibling::html:h6[preceding-sibling::html:h5[1] = $thish5 and count(html:a) = 1]) > 0">
-                                    <ul>
-                                      <xsl:for-each select="./following-sibling::html:h6[preceding-sibling::html:h5[1] = $thish5 and count(html:a) = 1]">
-                                        <li>
-                                          <a href="#{html:a/@id}"><xsl:value-of select="html:a/text()"/></a>
-                                        </li>
-                                      </xsl:for-each>
-                                    </ul>
-                                  </xsl:if>
-                                </li>
-                              </xsl:for-each>
-                            </ul>
-                          </xsl:if>
-                        </li>
-                      </xsl:for-each>
-                    </ul>
-                  </xsl:if>
-                </li>
-              </xsl:for-each>
-            </ul>
-          </xsl:if>
-        </li>
-      </xsl:for-each>
-    </ul>
-  </xsl:template>
-
   <!-- This is the master page structure -->
   <xsl:template match="/" mode="page">
     <xsl:param name="pagesrc"/>
diff --git a/scripts/hvsupport.py b/scripts/hvsupport.py
index 89fd0d1d94..5ae93f66d3 100755
--- a/scripts/hvsupport.py
+++ b/scripts/hvsupport.py
@@ -423,7 +423,15 @@ print('''<?xml version="1.0" encoding="UTF-8"?>
 <body id="hvsupport">
 <h1>libvirt API support matrix</h1>

-<ul id="toc"></ul>
+<nav class="contents" id="contents">
+<ul>
+''')
+
+for grp in sorted(groups.keys()):
+    print("<li><p><a href=\"#%s\">%s</a></p></li>" % (grp, groupheaders[grp]))
+
+print('''</ul>
+</nav>

 <p>
 This page documents which libvirt calls work on
-- 
2.40.1