[vala/wip/manual: 19/21] manual: Add print target for single page HTML and CSS paged media styling



commit 4ff9ae61e657001f2ac18493021fd3bfec006cdc
Author: Alistair Thomas <astavale yahoo co uk>
Date:   Sat Mar 11 21:33:18 2017 +0000

    manual: Add print target for single page HTML and CSS paged media styling

 doc/manual/.gitignore     |    3 +-
 doc/manual/Makefile.am    |   22 +++-
 doc/manual/common.xsl     |  268 +++++++++++++++++++++++++++++++++++++++++++-
 doc/manual/default.css    |   37 ++++++-
 doc/manual/print.xsl      |  138 ++++++++++++++++++++++
 doc/manual/version.xml.in |    2 +-
 doc/manual/xhtml.xsl      |  277 +++------------------------------------------
 7 files changed, 478 insertions(+), 269 deletions(-)
---
diff --git a/doc/manual/.gitignore b/doc/manual/.gitignore
index 944f5ee..36ced73 100644
--- a/doc/manual/.gitignore
+++ b/doc/manual/.gitignore
@@ -1,3 +1,4 @@
 version.xml
-html/
 devhelp/
+html/
+print/
diff --git a/doc/manual/Makefile.am b/doc/manual/Makefile.am
index 4a7f043..f933af0 100644
--- a/doc/manual/Makefile.am
+++ b/doc/manual/Makefile.am
@@ -10,38 +10,53 @@ book_DATA = \
        $(NULL)
 
 .PHONY: all
-all: devhelp html
+all: devhelp html print
 endif
 
 $(builddir)/devhelp/*: devhelp
-devhelp: manual.xml version.xml devhelp.xsl xhtml.xsl default.css
+devhelp: manual.xml version.xml common.xsl devhelp.xsl xhtml.xsl default.css
        @$(MKDIR_P) $@
        $(AM_V_GEN)$(XSLTPROC) \
                --xinclude \
+               --path $(srcdir) \
                --output $@/$(BOOK_NAME).devhelp2 \
                $(srcdir)/devhelp.xsl \
                $(srcdir)/manual.xml
        @$(XSLTPROC) \
                --xinclude \
+               --path $(srcdir) \
                --output $@/index.html \
                $(srcdir)/xhtml.xsl \
                $(srcdir)/manual.xml
        @cp $(srcdir)/default.css $@
        @touch $@
 
-html: manual.xml version.xml xhtml.xsl default.css
+html: manual.xml version.xml common.xsl xhtml.xsl default.css
        @$(MKDIR_P) $@
        $(AM_V_GEN)$(XSLTPROC) \
                --xinclude \
+               --stringparam body-class u-center \
                --output $@/index.html \
                $(srcdir)/xhtml.xsl \
                $(srcdir)/manual.xml
        @cp $(srcdir)/default.css $@
        @touch $@
 
+print: manual.xml version.xml common.xsl print.xsl default.css
+       @$(MKDIR_P) $@
+       $(AM_V_GEN)$(XSLTPROC) \
+               --xinclude \
+               --path $(srcdir) \
+               --output $@/index.html \
+               $(srcdir)/print.xsl \
+               $(srcdir)/manual.xml
+       @cp $(srcdir)/default.css $@
+       @touch $@
+
 mostlyclean-local:
        rm -rf devhelp
        rm -rf html
+       rm -rf print
 
 CLEANFILES = \
        version.xml \
@@ -52,6 +67,7 @@ EXTRA_DIST = \
        default.css \
        devhelp.xsl \
        manual.xml \
+       print.xsl \
        xhtml.xsl \
        $(NULL)
 
diff --git a/doc/manual/common.xsl b/doc/manual/common.xsl
index 68cf4bf..713e6da 100644
--- a/doc/manual/common.xsl
+++ b/doc/manual/common.xsl
@@ -4,8 +4,9 @@
   version="1.0"
   xmlns:str="http://exslt.org/strings";
   xmlns:exsl="http://exslt.org/common";
+  xmlns:date="http://exslt.org/dates-and-times";
   extension-element-prefixes="exsl"
-  exclude-result-prefixes="str"
+  exclude-result-prefixes="str date"

 
   <xsl:template name="normalizepath">
@@ -33,10 +34,275 @@
       <xsl:when test="$fragment=''">
       <a href="{$path}.html"><xsl:value-of select="$title"/></a>
       </xsl:when>
+      <xsl:when test="$page='' and $fragment!=''">
+      <a href="#{$fragment}"><xsl:value-of select="$title"/></a>
+      </xsl:when>
       <xsl:otherwise>
       <a href="{$path}.html#{$fragment}"><xsl:value-of select="$title"/></a>
       </xsl:otherwise>
     </xsl:choose>
   </xsl:template>
 
+  <xsl:template name="html5-doctype">
+    <xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html&gt;</xsl:text>
+    <xsl:call-template name="whitespace-newline"/>
+  </xsl:template>
+
+  <xsl:template match="*" mode="html5-charset">
+    <xsl:text disable-output-escaping='yes'>&lt;meta charset="UTF-8" /&gt;</xsl:text>
+    <xsl:call-template name="whitespace-newline"/>
+  </xsl:template>
+
+  <xsl:template name="html-no-initial-scaling">
+    <xsl:text disable-output-escaping='yes'>&lt;meta name="viewport" content="initial-scale=1"&gt;</xsl:text>
+    <xsl:call-template name="whitespace-newline"/>
+  </xsl:template>
+
+  <xsl:template name="whitespace-newline">
+    <xsl:text>&#10;</xsl:text>
+  </xsl:template>
+
+  <xsl:template match="title" mode="html-head">
+      <xsl:apply-templates select="." mode="html5-charset"/>
+      <title><xsl:value-of select="text()"/> - <xsl:value-of select="/article/section/title"/></title>
+      <link rel="stylesheet" type="text/css" href="default.css"/>
+  </xsl:template>
+
+  <xsl:template match="article">
+    <xsl:apply-templates select="articleinfo|section"/>
+  </xsl:template>
+
+  <xsl:template match="article/section" mode="toc">
+      <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:call-template>
+            <xsl:if test="count(section) > 0">
+              <xsl:call-template name="whitespace-newline"/>
+              <ul>
+                <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:call-template>
+                  </li>
+                </xsl:for-each>
+              </ul>
+            </xsl:if>
+          </li>
+        </xsl:for-each>
+      </ul>
+      <xsl:apply-templates select="section"/>
+  </xsl:template>
+
+  <xsl:template match="articleinfo" mode="toc">
+    <xsl:apply-templates select="abstract"/>
+    <table class="c-document_version">
+    <tr><td>Vala version:</td><td><xsl:apply-templates select="str:replace(edition, '-', '')"/></td></tr>
+    <tr><td>Release:</td><td><xsl:apply-templates select="releaseinfo/text()"/></td></tr>
+    <tr><td>Status:</td><td><xsl:apply-templates select="releaseinfo/remark"/></td></tr>
+    <tr><td>Copyright:</td>
+    <td>
+    <xsl:text>&#169;&#32;</xsl:text>
+    <xsl:apply-templates select="copyright/holder"/>
+    <xsl:text>&#32;</xsl:text>
+    <xsl:value-of select="date:year()"/>
+    </td>
+    </tr>
+    <tr><td>License:</td><td><xsl:apply-templates select="legalnotice"/></td></tr>
+    </table>
+  </xsl:template>
+
+  <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 name="id">
+      <xsl:call-template name="normalizepath">
+        <xsl:with-param name="title" select="."/>
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:call-template name="whitespace-newline"/>
+    <xsl:call-template name="whitespace-newline"/>
+    <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/section/title">
+    <xsl:variable name="id">
+      <xsl:call-template name="normalizepath">
+        <xsl:with-param name="title" select="."/>
+      </xsl:call-template>
+    </xsl:variable>
+    <h4><xsl:value-of select="."/><a name="{$id}">&#160;</a></h4>
+  </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">
+    <xsl:apply-templates select="para|section|programlisting|screen|itemizedlist|title|informaltable"/>
+  </xsl:template>
+
+  <xsl:template match="para">
+    <p><xsl:apply-templates select="text()|code|ulink|emphasis"/></p>
+  </xsl:template>
+
+  <xsl:template match="emphasis">
+    <strong><xsl:apply-templates select="text()"/></strong>
+  </xsl:template>
+
+  <xsl:template match="ulink">
+    <xsl:if 
test="starts-with(@url,'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/')">
+      <xsl:variable name="pageid">
+        <xsl:call-template name="normalizepath">
+          <xsl:with-param name="title" select="str:decode-uri(str:tokenize(substring-after(@url, 
'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/'),'#')[1])"/>
+        </xsl:call-template>
+      </xsl:variable>
+      <a href="{$pageid}.html#{str:tokenize(substring-after(@url, 
'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/'),'#')[2]}"><xsl:value-of 
select="."/></a>
+    </xsl:if>
+    <xsl:if 
test="not(starts-with(@url,'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/'))">
+      <a href="{@url}"><xsl:value-of select="."/></a>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="para/code">
+    <xsl:if test="contains (text(), '&#x0a;')">
+      <pre><xsl:value-of select="text()"/></pre>
+    </xsl:if>
+    <xsl:if test="not (contains (text(), '&#x0a;'))">
+      <code><xsl:value-of select="text()"/></code>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="screen">
+    <pre><xsl:value-of select="text()"/></pre>
+  </xsl:template>
+
+  <!-- program listing -->
+  <xsl:template match="programlisting">
+    <pre class="o-box c-program"><xsl:apply-templates 
select="text()|type|methodname|token|phrase|lineannotation"/></pre>
+  </xsl:template>
+
+  <xsl:template match="type">
+    <span class="c-program-type"><xsl:value-of select="."/></span>
+  </xsl:template>
+
+  <xsl:template match="token">
+    <span class="c-program-token"><xsl:value-of select="."/></span>
+  </xsl:template>
+
+  <xsl:template match="methodname">
+    <span class="c-program-methodname"><xsl:value-of select="."/></span>
+  </xsl:template>
+
+  <xsl:template match="lineannotation">
+    <span class="c-program-comment"><xsl:value-of select="."/></span>
+  </xsl:template>
+
+  <xsl:template match="phrase">
+    <span class="c-program-phrase"><xsl:value-of select="."/></span>
+  </xsl:template>
+
+  <xsl:template match="programlisting/text()[. = '&#10;'][preceding-sibling::*[1][self::phrase]]">
+    <span class="c-program-phrase"><xsl:text>\n</xsl:text></span>
+  </xsl:template>
+
+  <xsl:template match="programlisting/text()[. = '&#10;&#10;'][preceding-sibling::*[1][self::phrase]]">
+    <span class="c-program-phrase"><xsl:text>\n\n</xsl:text></span>
+  </xsl:template>
+
+  <!-- lists -->
+  <xsl:template match="itemizedlist[listitem[not(@override)]]">
+    <ul><xsl:apply-templates select="listitem"/></ul>
+  </xsl:template>
+
+  <xsl:template match="listitem[not(@override)]">
+    <li><xsl:apply-templates select="para"/></li>
+  </xsl:template>
+
+  <xsl:template match="itemizedlist[listitem[@override='none']]">
+    <blockquote class="o-box c-rules"><xsl:apply-templates select="listitem"/></blockquote>
+  </xsl:template>
+
+  <xsl:template match="listitem[@override='none']/itemizedlist"><xsl:apply-templates 
select="listitem"/><xsl:text>
+</xsl:text></xsl:template>
+
+  <xsl:template match="listitem[@override='none']">
+    <xsl:apply-templates select="para|itemizedlist"/>
+  </xsl:template>
+
+  <xsl:template match="listitem[@override='none']/para"><xsl:apply-templates 
select="text()|emphasis"/><xsl:text>
+</xsl:text></xsl:template>
+
+  <xsl:template match="listitem[@override='none']/para/text()">
+    <xsl:if test="position()=1 and starts-with(.,' ')">
+      <xsl:if test="normalize-space(.)!=''"><xsl:value-of select="substring-after(.,' ')"/></xsl:if>
+    </xsl:if>
+    <xsl:if test="position()!=1 or not(starts-with(.,' '))">
+      <xsl:if test="normalize-space(.)!=''"><xsl:value-of select="."/></xsl:if>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="listitem[@override='none']/para/emphasis[@role='strong']"><span 
class="literal"><xsl:value-of select="."/></span></xsl:template>
+<xsl:template 
match="listitem[@override='none']/itemizedlist/listitem[@override='none']/para"><xsl:text>&#x09;</xsl:text><xsl:apply-templates
 select="text()|emphasis"/><xsl:text>
+</xsl:text></xsl:template>
+
+  <!-- tables -->
+  <xsl:template match="informaltable">
+    <table class="c-informaltable">
+      <xsl:apply-templates select="tgroup/tbody/row"/>
+    </table>
+  </xsl:template>
+
+  <xsl:template match="row">
+    <tr>
+      <xsl:apply-templates select="entry"/>
+    </tr>
+  </xsl:template>
+
+  <xsl:template match="entry">
+    <td xsl:use-attribute-sets="entry-attrs">
+      <xsl:apply-templates select="para"/>
+    </td>
+  </xsl:template>
+
+  <xsl:attribute-set name="entry-attrs">
+    <xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute>
+    <xsl:attribute name="colspan">
+      <xsl:if test="@nameend"><xsl:value-of select="number(substring-after(@nameend, 'col_'))+1"/></xsl:if>
+    </xsl:attribute>
+  </xsl:attribute-set>
+
 </xsl:stylesheet>
diff --git a/doc/manual/default.css b/doc/manual/default.css
index f118ad5..bbe4ab7 100644
--- a/doc/manual/default.css
+++ b/doc/manual/default.css
@@ -3,7 +3,6 @@ body {
        font-family: cantarell, sans-serif;
        text-align: justify;
        margin-top: 2.8em;
-       max-width: 35em;
 }
 
 h1, h2, h3, h4 {
@@ -160,7 +159,6 @@ pre {
 .c-document_version { border: solid 2px #ccc;
        border-radius: 4px;
        width: 100%;
-       font-sizde: 95%;
 }
 .c-document_version tr td:first-child { text-align: right; }
 .c-document_version tr:nth-child(odd) { background-color: #f0f0f0; }
@@ -180,3 +178,38 @@ blockquote span.literal {
        float: right;
        overflow: hidden;
 }
+.u-center {
+       margin-left: auto;
+       margin-right: auto;
+}
+
+@media screen {
+       body { max-width: 35em; }
+}
+
+@media print {
+       * { background: none !important; }
+       h1 {
+               text-align: center;
+               padding: 2em 0 4em 0;
+       }
+       h1+p, h1+p+p, h1+p+p+p { max-width: 28em;
+       margin: 0 auto 1em;
+       }
+       .c-document_version { position: absolute; bottom: 0; }
+       h2, .toc { page-break-before: always; }
+       h1, h2, h3, h4 { page-break-after: avoid; }
+       h2, h3, h4 {
+               border: none;
+               padding: 0;
+               }
+       table, .o-box { page-break-inside: avoid; }
+}
+
+@page {
+       counter-increment: page;
+       @top-center { content: "Vala Reference Manual"; }
+       @bottom-center {
+               content: "Page " counter( page ) " of " counter( pages );
+       }
+}
diff --git a/doc/manual/print.xsl b/doc/manual/print.xsl
new file mode 100644
index 0000000..969e93d
--- /dev/null
+++ b/doc/manual/print.xsl
@@ -0,0 +1,138 @@
+<?xml version="1.0"?>
+<xsl:stylesheet
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+  version="1.0"
+  xmlns:str="http://exslt.org/strings";
+  xmlns:exsl="http://exslt.org/common";
+  xmlns:date="http://exslt.org/dates-and-times";
+  extension-element-prefixes="exsl"
+  exclude-result-prefixes="str date"
+>
+
+  <xsl:import href="common.xsl"/>
+
+  <xsl:output
+    method="html"
+    indent="yes"
+    omit-xml-declaration="yes"
+    encoding="UTF-8"
+    media-type="text/html"
+  />
+
+  <xsl:template match="/">
+    <xsl:call-template name="html5-doctype"/>
+    <html><xsl:call-template name="whitespace-newline"/>
+    <head><xsl:call-template name="whitespace-newline"/>
+    <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" mode="toc"/>
+    </body><xsl:call-template name="whitespace-newline"/>
+    </html>
+  </xsl:template>
+
+  <xsl:template match="article/section/section">
+    <xsl:variable name="path">
+      <xsl:call-template name="normalizepath">
+        <xsl:with-param name="title" select="title"/>
+      </xsl:call-template>
+    </xsl:variable>
+    <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="''"/>
+              <xsl:with-param name="subpage" select="concat( ../title, '_', title )"/>
+            </xsl:call-template>
+          </li>
+        </xsl:for-each>
+      </ul>
+    </xsl:if>
+    <xsl:apply-templates select="para|section|programlisting|screen|itemizedlist"/>
+  </xsl:template>
+
+  <xsl:template match="article/section" mode="toc">
+      <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="''"/>
+              <xsl:with-param name="subpage" select="title"/>
+            </xsl:call-template>
+            <xsl:if test="count(section) > 0">
+              <xsl:call-template name="whitespace-newline"/>
+              <ul>
+                <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="''"/>
+                      <xsl:with-param name="subpage" select="concat( ../title, '_', title )"/>
+                    </xsl:call-template>
+                  </li>
+                </xsl:for-each>
+              </ul>
+            </xsl:if>
+          </li>
+        </xsl:for-each>
+      </ul>
+      <xsl:apply-templates select="section"/>
+  </xsl:template>
+
+  <xsl:template match="article/section/section/title" mode="heading">
+    <xsl:variable name="id">
+      <xsl:call-template name="normalizepath">
+        <xsl:with-param name="title" select="."/>
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:call-template name="whitespace-newline"/>
+    <xsl:call-template name="whitespace-newline"/>
+    <h2 id="{$id}"><xsl:apply-templates select="." mode="numbered-level-one"/></h2>
+  </xsl:template>
+
+  <xsl:template match="article/section/section/section/title">
+    <xsl:variable name="id">
+      <xsl:call-template name="normalizepath">
+        <xsl:with-param name="title" select="concat( ../../title, '_', . )"/>
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:call-template name="whitespace-newline"/>
+    <xsl:call-template name="whitespace-newline"/>
+    <h3 id="{$id}"><xsl:apply-templates select="." mode="numbered-level-two"/></h3>
+  </xsl:template>
+
+  <xsl:template match="ulink">
+    <xsl:if 
test="starts-with(@url,'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/')">
+      <xsl:variable name="pageid">
+        <xsl:call-template name="normalizepath">
+          <xsl:with-param name="title" select="str:decode-uri(str:tokenize(substring-after(@url, 
'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/'),'#')[1])"/>
+        </xsl:call-template>
+      </xsl:variable>
+      <xsl:choose>
+      <xsl:when test="substring-after(@url, '#') = ''">
+      <a href="#{$pageid}"><xsl:value-of select="."/></a>
+      </xsl:when>
+      <xsl:otherwise>
+      <a href="#{$pageid}_{str:tokenize(substring-after(@url, 
'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/'),'#')[2]}"><xsl:value-of 
select="."/></a>
+      </xsl:otherwise>
+      </xsl:choose>
+    </xsl:if>
+    <xsl:if 
test="not(starts-with(@url,'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/'))">
+      <a href="{@url}"><xsl:value-of select="."/></a>
+    </xsl:if>
+  </xsl:template>
+
+</xsl:stylesheet>
+
diff --git a/doc/manual/version.xml.in b/doc/manual/version.xml.in
index e896768..3811e28 100644
--- a/doc/manual/version.xml.in
+++ b/doc/manual/version.xml.in
@@ -2,7 +2,7 @@
 <!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  
'http://www.docbook.org/xml/4.4/docbookx.dtd'>
 <articleinfo>
 <abstract>
-<para>The Vala programming language is a high level language that produces binaries for the native platform. 
The binaries maintain the C Application Binary Interface (ABI) and so can be built as either an application 
or a library.</para>
+<para>Vala is a high level programming language that produces binaries for the native platform. The binaries 
maintain the C Application Binary Interface (ABI) and can be built as either an application or a 
library.</para>
 <para>The Vala Reference Manual gives details on Vala's syntax and type system, including polymorphism using 
interfaces and type parameters (generics). Vala includes additional code generation routines, for example 
D-Bus inter-process communication and GTK+3 composite templates, these are only referred to in the Attributes 
section. The reference manual does not provide a tutorial for these features.</para>
 <para>Vala is developed in a collaborative and self-supporting way by its users. They provide bug reports, 
documentation, patches, patch reviews and core development. Following this model of development the manual 
has an editable version at <ulink 
url="https://wiki.gnome.org/Projects/Vala/Manual";>https://wiki.gnome.org/Projects/Vala/Manual</ulink> .</para>
 </abstract>
diff --git a/doc/manual/xhtml.xsl b/doc/manual/xhtml.xsl
index 4253090..19390bc 100644
--- a/doc/manual/xhtml.xsl
+++ b/doc/manual/xhtml.xsl
@@ -4,9 +4,8 @@
   version="1.0"
   xmlns:str="http://exslt.org/strings";
   xmlns:exsl="http://exslt.org/common";
-  xmlns:date="http://exslt.org/dates-and-times";
   extension-element-prefixes="exsl"
-  exclude-result-prefixes="str date"
+  exclude-result-prefixes="str"

 
   <xsl:import href="common.xsl"/>
@@ -19,13 +18,20 @@
     media-type="text/html"
   />
 
+  <xsl:param name="body-class"></xsl:param>
+
   <xsl:template match="/">
     <xsl:call-template name="html5-doctype"/>
     <html><xsl:call-template name="whitespace-newline"/>
     <head><xsl:call-template name="whitespace-newline"/>
+    <xsl:call-template name="html-no-initial-scaling"/>
     <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"/>
+    <body>
+    <xsl:if test="$body-class != ''">
+      <xsl:attribute name="class"><xsl:value-of select="$body-class"/></xsl:attribute>
+    </xsl:if>
+    <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"/>
@@ -48,8 +54,12 @@
       <html>
         <head>
         <xsl:apply-templates select="title" mode="html-head"/>
+        <xsl:call-template name="html-no-initial-scaling"/>
         </head>
         <body>
+        <xsl:if test="$body-class != ''">
+          <xsl:attribute name="class"><xsl:value-of select="$body-class"/></xsl:attribute>
+        </xsl:if>
           <xsl:apply-templates
             select="title"
             mode="navigation-bar"
@@ -76,33 +86,12 @@
     </exsl:document>
   </xsl:template>
 
-  <xsl:template name="html5-doctype">
-    <xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html&gt;</xsl:text>
-    <xsl:call-template name="whitespace-newline"/>
-  </xsl:template>
-
-  <xsl:template match="*" mode="html5-charset">
-    <xsl:text disable-output-escaping='yes'>&lt;meta charset="UTF-8" /&gt;</xsl:text>
-    <xsl:call-template name="whitespace-newline"/>
-  </xsl:template>
-
-  <xsl:template name="whitespace-newline">
-    <xsl:text>&#10;</xsl:text>
-  </xsl:template>
-
-  <xsl:template match="title" mode="html-head">
-      <xsl:apply-templates select="." mode="html5-charset"/>
-      <title><xsl:value-of select="text()"/> - <xsl:value-of select="/article/section/title"/></title>
-      <link rel="stylesheet" type="text/css" href="default.css"/>
-  </xsl:template>
-
-  <xsl:template match="article">
-    <xsl:apply-templates select="articleinfo|section"/>
-  </xsl:template>
-
   <xsl:template match="title" mode="navigation-bar">
     <div class="o-fixedtop c-navbar">
       <div class="o-navbar">
+      <xsl:if test="$body-class != ''">
+        <xsl:attribute name="class">o-navbar <xsl:value-of select="$body-class"/></xsl:attribute>
+      </xsl:if>
       <span class="c-pageturner u-float-left"><a href="index.html">Contents</a></span>
       <span><xsl:value-of select="/article/section/title"/></span>
       <div class="u-float-right">
@@ -141,238 +130,4 @@
     </xsl:choose>
   </xsl:template>
 
-  <xsl:template match="article/section" mode="toc">
-      <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:call-template>
-            <xsl:if test="count(section) > 0">
-              <xsl:call-template name="whitespace-newline"/>
-              <ul>
-                <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:call-template>
-                  </li>
-                </xsl:for-each>
-              </ul>
-            </xsl:if>
-          </li>
-        </xsl:for-each>
-      </ul>
-      <xsl:apply-templates select="section"/>
-  </xsl:template>
-
-  <xsl:template match="articleinfo" mode="toc">
-    <xsl:apply-templates select="abstract"/>
-    <table class="c-document_version">
-    <tr><td>Vala version:</td><td><xsl:apply-templates select="str:replace(edition, '-', '')"/></td></tr>
-    <tr><td>Release:</td><td><xsl:apply-templates select="releaseinfo/text()"/></td></tr>
-    <tr><td>Status:</td><td><xsl:apply-templates select="releaseinfo/remark"/></td></tr>
-    <tr><td>Copyright:</td>
-    <td>
-    <xsl:text>&#169;&#32;</xsl:text>
-    <xsl:apply-templates select="copyright/holder"/>
-    <xsl:text>&#32;</xsl:text>
-    <xsl:value-of select="date:year()"/>
-    </td>
-    </tr>
-    <tr><td>License:</td><td><xsl:apply-templates select="legalnotice"/></td></tr>
-    </table>
-  </xsl:template>
-
-  <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 name="id">
-      <xsl:call-template name="normalizepath">
-        <xsl:with-param name="title" select="."/>
-      </xsl:call-template>
-    </xsl:variable>
-    <xsl:call-template name="whitespace-newline"/>
-    <xsl:call-template name="whitespace-newline"/>
-    <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">
-    <xsl:apply-templates select="para|section|programlisting|screen|itemizedlist|title|informaltable"/>
-  </xsl:template>
-
-  <xsl:template match="article/section/section/section/section/title">
-    <xsl:variable name="id">
-      <xsl:call-template name="normalizepath">
-        <xsl:with-param name="title" select="."/>
-      </xsl:call-template>
-    </xsl:variable>
-    <h4><xsl:value-of select="."/><a name="{$id}">&#160;</a></h4>
-  </xsl:template>
-
-  <xsl:template match="para">
-    <p><xsl:apply-templates select="text()|code|ulink|emphasis"/></p>
-  </xsl:template>
-
-  <xsl:template match="emphasis">
-    <strong><xsl:apply-templates select="text()"/></strong>
-  </xsl:template>
-
-  <xsl:template match="ulink">
-    <xsl:if 
test="starts-with(@url,'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/')">
-      <xsl:variable name="pageid">
-        <xsl:call-template name="normalizepath">
-          <xsl:with-param name="title" select="str:decode-uri(str:tokenize(substring-after(@url, 
'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/'),'#')[1])"/>
-        </xsl:call-template>
-      </xsl:variable>
-      <a href="{$pageid}.html#{str:tokenize(substring-after(@url, 
'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/'),'#')[2]}"><xsl:value-of 
select="."/></a>
-    </xsl:if>
-    <xsl:if 
test="not(starts-with(@url,'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/'))">
-      <a href="{@url}"><xsl:value-of select="."/></a>
-    </xsl:if>
-  </xsl:template>
-
-
-  <xsl:template match="para/code">
-    <xsl:if test="contains (text(), '&#x0a;')">
-      <pre><xsl:value-of select="text()"/></pre>
-    </xsl:if>
-    <xsl:if test="not (contains (text(), '&#x0a;'))">
-      <code><xsl:value-of select="text()"/></code>
-    </xsl:if>
-  </xsl:template>
-
-  <xsl:template match="screen">
-    <pre><xsl:value-of select="text()"/></pre>
-  </xsl:template>
-
-  <!-- program listing -->
-  <xsl:template match="programlisting">
-    <pre class="o-box c-program"><xsl:apply-templates 
select="text()|type|methodname|token|phrase|lineannotation"/></pre>
-  </xsl:template>
-
-  <xsl:template match="type">
-    <span class="c-program-type"><xsl:value-of select="."/></span>
-  </xsl:template>
-
-  <xsl:template match="token">
-    <span class="c-program-token"><xsl:value-of select="."/></span>
-  </xsl:template>
-
-  <xsl:template match="methodname">
-    <span class="c-program-methodname"><xsl:value-of select="."/></span>
-  </xsl:template>
-
-  <xsl:template match="lineannotation">
-    <span class="c-program-comment"><xsl:value-of select="."/></span>
-  </xsl:template>
-
-  <xsl:template match="phrase">
-    <span class="c-program-phrase"><xsl:value-of select="."/></span>
-  </xsl:template>
-
-  <xsl:template match="programlisting/text()[. = '&#10;'][preceding-sibling::*[1][self::phrase]]">
-    <span class="c-program-phrase"><xsl:text>\n</xsl:text></span>
-  </xsl:template>
-
-  <xsl:template match="programlisting/text()[. = '&#10;&#10;'][preceding-sibling::*[1][self::phrase]]">
-    <span class="c-program-phrase"><xsl:text>\n\n</xsl:text></span>
-  </xsl:template>
-
-  <!-- lists -->
-  <xsl:template match="itemizedlist[listitem[not(@override)]]">
-    <ul><xsl:apply-templates select="listitem"/></ul>
-  </xsl:template>
-
-  <xsl:template match="listitem[not(@override)]">
-    <li><xsl:apply-templates select="para"/></li>
-  </xsl:template>
-
-  <xsl:template match="itemizedlist[listitem[@override='none']]">
-    <blockquote class="o-box c-rules"><xsl:apply-templates select="listitem"/></blockquote>
-  </xsl:template>
-
-  <xsl:template match="listitem[@override='none']/itemizedlist"><xsl:apply-templates 
select="listitem"/><xsl:text>
-</xsl:text></xsl:template>
-
-  <xsl:template match="listitem[@override='none']">
-    <xsl:apply-templates select="para|itemizedlist"/>
-  </xsl:template>
-
-  <xsl:template match="listitem[@override='none']/para"><xsl:apply-templates 
select="text()|emphasis"/><xsl:text>
-</xsl:text></xsl:template>
-
-  <xsl:template match="listitem[@override='none']/para/text()">
-    <xsl:if test="position()=1 and starts-with(.,' ')">
-      <xsl:if test="normalize-space(.)!=''"><xsl:value-of select="substring-after(.,' ')"/></xsl:if>
-    </xsl:if>
-    <xsl:if test="position()!=1 or not(starts-with(.,' '))">
-      <xsl:if test="normalize-space(.)!=''"><xsl:value-of select="."/></xsl:if>
-    </xsl:if>
-  </xsl:template>
-
-  <xsl:template match="listitem[@override='none']/para/emphasis[@role='strong']"><span 
class="literal"><xsl:value-of select="."/></span></xsl:template>
-<xsl:template 
match="listitem[@override='none']/itemizedlist/listitem[@override='none']/para"><xsl:text>&#x09;</xsl:text><xsl:apply-templates
 select="text()|emphasis"/><xsl:text>
-</xsl:text></xsl:template>
-
-  <!-- tables -->
-  <xsl:template match="informaltable">
-    <table class="c-informaltable">
-      <xsl:apply-templates select="tgroup/tbody/row"/>
-    </table>
-  </xsl:template>
-
-  <xsl:template match="row">
-    <tr>
-      <xsl:apply-templates select="entry"/>
-    </tr>
-  </xsl:template>
-
-  <xsl:template match="entry">
-    <td xsl:use-attribute-sets="entry-attrs">
-      <xsl:apply-templates select="para"/>
-    </td>
-  </xsl:template>
-
-  <xsl:attribute-set name="entry-attrs">
-    <xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute>
-    <xsl:attribute name="colspan">
-      <xsl:if test="@nameend"><xsl:value-of select="number(substring-after(@nameend, 'col_'))+1"/></xsl:if>
-    </xsl:attribute>
-  </xsl:attribute-set>
-
 </xsl:stylesheet>


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