]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
manual: Generate section and sub-section numbers
authorAlistair Thomas <astavale@yahoo.co.uk>
Sun, 5 Mar 2017 20:07:26 +0000 (20:07 +0000)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 12 Mar 2017 13:15:48 +0000 (14:15 +0100)
doc/manual/Makefile.am
doc/manual/default.css
doc/manual/xhtml.xsl

index 08ec8182bb07356077b0c2df2f34d79db80227a0..342feb46e069e2c3902bbb65e037de3d247e1bf8 100644 (file)
@@ -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 \
index 3c432ccb455c9c5c397cad834c2c3b69cfc20592..93d3ee39e046b1396365fb0707ddc167fb273dab 100644 (file)
@@ -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;
index 97338467c84070a36997907237496259ede81f88..ca7f39b9390ed33fdef80f3b2fff380a3f9f9803 100644 (file)
@@ -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>
         <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>
     <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"/>
                 <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>
     </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">
     </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">