[vala: 3/7] manual: Generate section and sub-section numbers



commit 0e6ca4cf4703687ae2f8f1e273e9629ab29e17a7
Author: Alistair Thomas <astavale yahoo co uk>
Date:   Sun Mar 5 20:07:26 2017 +0000

    manual: Generate section and sub-section numbers

 doc/manual/Makefile.am |    4 +-
 doc/manual/default.css |   15 ++++++++++++
 doc/manual/xhtml.xsl   |   60 ++++++++++++++++++++++++++++++++++-------------
 3 files changed, 60 insertions(+), 19 deletions(-)
---
diff --git a/doc/manual/Makefile.am b/doc/manual/Makefile.am
index 08ec818..342feb4 100644
--- a/doc/manual/Makefile.am
+++ b/doc/manual/Makefile.am
@@ -11,7 +11,7 @@ book_DATA = \
 endif
 
 $(builddir)/devhelp/*: devhelp
-devhelp: manual.xml version.xml devhelp.xsl xhtml.xsl
+devhelp: manual.xml version.xml devhelp.xsl xhtml.xsl default.css
        @$(MKDIR_P) $@
        $(AM_V_GEN)$(XSLTPROC) \
                --xinclude \
@@ -26,7 +26,7 @@ devhelp: manual.xml version.xml devhelp.xsl xhtml.xsl
        @cp $(srcdir)/default.css $@
        @touch $@
 
-html: manual.xml version.xml xhtml.xsl
+html: manual.xml version.xml xhtml.xsl default.css
        @$(MKDIR_P) $@
        $(AM_V_GEN)$(XSLTPROC) \
                --xinclude \
diff --git a/doc/manual/default.css b/doc/manual/default.css
index 3c432cc..93d3ee3 100644
--- a/doc/manual/default.css
+++ b/doc/manual/default.css
@@ -47,6 +47,21 @@ a:link, a:visited, a:hover, a:active {
        background-color: #ddd;
 }
 
+.page_toc {
+       list-style: none;
+}
+
+.page_toc a {
+       width: 18em;
+       display: block;
+       border-radius: 0.4em;
+       padding-left: 0.4em;
+}
+
+.page_toc a:hover, .page_toc a:focus {
+       background: #ddd;
+}
+
 h3 {
        /* ensure anchors don't vanish below the fixed header */
        padding-top: 1.4em;
diff --git a/doc/manual/xhtml.xsl b/doc/manual/xhtml.xsl
index 9733846..ca7f39b 100644
--- a/doc/manual/xhtml.xsl
+++ b/doc/manual/xhtml.xsl
@@ -26,6 +26,7 @@
     <xsl:apply-templates select="article/section/title[1]" mode="html-head"/>
     </head><xsl:call-template name="whitespace-newline"/>
     <body><xsl:call-template name="whitespace-newline"/>
+    <xsl:apply-templates select="/article/section/title" mode="navigation-bar"/>
     <xsl:apply-templates select="article" mode="toc"/>
     </body><xsl:call-template name="whitespace-newline"/>
     </html>
@@ -49,18 +50,21 @@
         <xsl:apply-templates select="title" mode="html-head"/>
         </head>
         <body>
-          <div class="header">
-            <a href="index.html"><xsl:value-of select="/article/section/title"/></a>
-          </div>
-          <xsl:apply-templates select="title"/>
+          <xsl:apply-templates
+            select="/article/section/title"
+            mode="navigation-bar"
+          />
+          <xsl:apply-templates select="title" mode="heading"/>
           <xsl:if test="count(section) > 0">
             <ul class="page_toc">
               <xsl:for-each select="section">
                 <li>
                   <xsl:call-template name="linkto">
+                    <xsl:with-param name="title">
+                      <xsl:apply-templates select="title" mode="numbered-level-two"/>
+                    </xsl:with-param>
                     <xsl:with-param name="page" select="../title"/>
                     <xsl:with-param name="subpage" select="title"/>
-                    <xsl:with-param name="title" select="title"/>
                   </xsl:call-template>
                 </li>
               </xsl:for-each>
@@ -96,22 +100,23 @@
     <xsl:apply-templates select="articleinfo|section"/>
   </xsl:template>
 
-  <xsl:template match="article/section/title">
+  <xsl:template match="article/section/title" mode="navigation-bar">
     <div class="header">
       <a href="index.html"><xsl:value-of select="."/></a>
     </div>
-    <h1><xsl:value-of select="."/></h1>
   </xsl:template>
 
   <xsl:template match="article/section" mode="toc">
-      <xsl:apply-templates select="title"/>
+      <h1><xsl:apply-templates select="title"/></h1>
       <xsl:apply-templates select="document('version.xml')/articleinfo" mode="toc"/>
       <ul class="toc">
         <xsl:for-each select="section">
           <li>
             <xsl:call-template name="linkto">
+              <xsl:with-param name="title">
+                <xsl:apply-templates select="title" mode="numbered-level-one"/>
+              </xsl:with-param>
               <xsl:with-param name="page" select="title"/>
-              <xsl:with-param name="title" select="title"/>
             </xsl:call-template>
             <xsl:if test="count(section) > 0">
               <xsl:call-template name="whitespace-newline"/>
@@ -119,9 +124,11 @@
                 <xsl:for-each select="section">
                   <li>
                     <xsl:call-template name="linkto">
+                      <xsl:with-param name="title">
+                        <xsl:apply-templates select="title" mode="numbered-level-two"/>
+                      </xsl:with-param>
                       <xsl:with-param name="page" select="../title"/>
                       <xsl:with-param name="subpage" select="title"/>
-                      <xsl:with-param name="title" select="title"/>
                     </xsl:call-template>
                   </li>
                 </xsl:for-each>
@@ -151,12 +158,8 @@
     </table>
   </xsl:template>
 
-  <xsl:template match="article/section/section/title">
-    <h2><xsl:value-of select="."/></h2>
-  </xsl:template>
-
-  <xsl:template match="article/section/section/section">
-    <xsl:apply-templates select="para|section|programlisting|screen|itemizedlist|title|informaltable"/>
+  <xsl:template match="article/section/section/title" mode="heading">
+    <h2><xsl:apply-templates select="." mode="numbered-level-one"/></h2>
   </xsl:template>
 
   <xsl:template match="article/section/section/section/title">
@@ -167,7 +170,30 @@
     </xsl:variable>
     <xsl:call-template name="whitespace-newline"/>
     <xsl:call-template name="whitespace-newline"/>
-    <h3 id="{$id}"><xsl:value-of select="."/></h3>
+    <h3 id="{$id}"><xsl:apply-templates select="." mode="numbered-level-two"/></h3>
+  </xsl:template>
+
+  <xsl:template match="title" mode="numbered-level-one">
+    <xsl:number
+      count="/article/section/section[ancestor::*]"
+      from="/article/section"
+      level="multiple"
+      format="1. "
+    />
+    <xsl:value-of select="text()"/>
+  </xsl:template>
+
+  <xsl:template match="title" mode="numbered-level-two">
+    <xsl:number
+      count="article/section/section|article/section/section/section"
+      level="multiple"
+      format="1 "
+    />
+    <xsl:value-of select="text()"/>
+  </xsl:template>
+
+  <xsl:template match="article/section/section/section">
+    <xsl:apply-templates select="para|section|programlisting|screen|itemizedlist|title|informaltable"/>
   </xsl:template>
 
   <xsl:template match="article/section/section/section/section">


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