[yelp-xsl] db2html: Cleanup of some *synopsis handling code
- From: Shaun McCance <shaunm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [yelp-xsl] db2html: Cleanup of some *synopsis handling code
- Date: Wed, 18 May 2011 16:01:30 +0000 (UTC)
commit 70a876a3bb6de230aafc5b686d2f1fe193916109
Author: Shaun McCance <shaunm gnome org>
Date: Mon May 16 20:39:47 2011 -0400
db2html: Cleanup of some *synopsis handling code
doc/yelp-xsl/xsldoc-scan.xsl | 2 +-
xslt/docbook/html/db2html-callout.xsl | 6 +-
xslt/docbook/html/db2html-classsynopsis.xsl | 66 +++++++++---------
xslt/docbook/html/db2html-cmdsynopsis.xsl | 97 +++++++++++----------------
4 files changed, 76 insertions(+), 95 deletions(-)
---
diff --git a/doc/yelp-xsl/xsldoc-scan.xsl b/doc/yelp-xsl/xsldoc-scan.xsl
index fc13f52..160103c 100644
--- a/doc/yelp-xsl/xsldoc-scan.xsl
+++ b/doc/yelp-xsl/xsldoc-scan.xsl
@@ -266,7 +266,7 @@ free software.
<exsl:document href="{$id}.page">
<page id="{$id}" type="topic" style="{ style}">
<info>
- <link type="guide" xref="{$xsldoc.id}" group="#{$type}"/>
+ <link type="guide" xref="{$xsldoc.id}" group="{$type}"/>
<link type="guide" xref="index__{$type}"/>
<xsl:call-template name="revision"/>
<xsl:copy-of select="mal:info/*[not(self::mal:revision)]"/>
diff --git a/xslt/docbook/html/db2html-callout.xsl b/xslt/docbook/html/db2html-callout.xsl
index 476c793..8bd5ed7 100644
--- a/xslt/docbook/html/db2html-callout.xsl
+++ b/xslt/docbook/html/db2html-callout.xsl
@@ -44,9 +44,9 @@ Create a callout label for a #{co} element.
$node: The #{co} element to create a callout label for.
This template creates a label for a callout, taking a #{co} element as the
-${node} parameter. The label is numbered according to the position of #{co}
-in the document. To create the corresponding label for a #{callout} element,
-locate the corresponding #{co} element and call this template on it.
+${node} parameter. The label is numbered according to the position of the #{co}
+element in the document. To create the corresponding label for a #{callout}
+element, locate the corresponding #{co} element and call this template on it.
-->
<xsl:template name="db2html.callout.label">
<xsl:param name="node" select="."/>
diff --git a/xslt/docbook/html/db2html-classsynopsis.xsl b/xslt/docbook/html/db2html-classsynopsis.xsl
index 99ba06f..e551bb2 100644
--- a/xslt/docbook/html/db2html-classsynopsis.xsl
+++ b/xslt/docbook/html/db2html-classsynopsis.xsl
@@ -24,22 +24,28 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
<!--!!==========================================================================
DocBook to HTML - Class Synopses
-:Requires: db2html-inline db2html-xref gettext
+:Requires: db2html-xref html
+:Revision:version="1.0" date="2011-05-16" status="final"
-REMARK: Describe this module. Implmentation note: for C++, we expect the first
-modifier to be the visibility
+This module handles the DocBook #{classsynopsis} and related elements. The
+contents of the class-modeling elements are processed in a mode depending on
+the programming language to format the synopsis correctly.
-->
-<xsl:variable name="cpp.tab" select="'    '"/>
-<xsl:variable name="python.tab" select="'    '"/>
+<xsl:variable name="db2html.classsynopsis.tab"
+ select="'    '"/>
-<!-- FIXME: document PI -->
<!--@@==========================================================================
db2html.classsynopsis.language
-The default programming language used to format #{classsynopsis} elements
-
-REMARK: Describe this param
+The default programming language used to format #{classsynopsis} elements.
+:Revision:version="1.0" date="2011-05-16" status="final"
+
+This parameter sets the default value for the #{language} attribute of elements
+like #{classsynopsis}. Templates in this module will always use the #{language}
+attribute if present. Otherwise, they fall back to this value. This parameter
+can be set with the #{db2html.classsynopsis.language} processing instruction
+at the root of a DocBook document.
-->
<xsl:param name="db2html.classsynopsis.language">
<xsl:choose>
@@ -73,20 +79,7 @@ REMARK: Describe this param
</xsl:choose>
</xsl:variable>
<div>
- <xsl:choose>
- <xsl:when test="@lang | @xml:lang">
- <xsl:attribute name="dir">
- <xsl:call-template name="l10n.direction">
- <xsl:with-param name="lang" select="@lang | @xml:lang"/>
- </xsl:call-template>
- </xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="dir">
- <xsl:text>ltr</xsl:text>
- </xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
+ <xsl:call-template name="html.lang.attrs"/>
<xsl:attribute name="class">
<xsl:text>synopsis </xsl:text>
<xsl:value-of select="local-name(.)"/>
@@ -158,8 +151,12 @@ REMARK: Describe this param
<!--%%==========================================================================
db2html.class.cpp.mode
+Process a C++ synopsis.
+:Revision:version="1.0" date="2011-05-16" status="final"
-REMARK: Describe this mode
+This mode is applied to child elements for synopsis elements for the C++
+programming language. In C++ synopses, the first #{modifier} element for
+methods is expected to mark the visibility, such as #{public} or #{private}.
-->
<xsl:template mode="db2html.class.cpp.mode" match="*">
<xsl:apply-templates select="."/>
@@ -222,7 +219,7 @@ REMARK: Describe this mode
}
-->
<xsl:call-template name="db2html.class.cpp.modifier"/>
- <xsl:value-of select="$cpp.tab"/>
+ <xsl:value-of select="$db2html.classsynopsis.tab"/>
<xsl:for-each select="modifier[position() != 1] | db:modifier[position() != 1]">
<xsl:apply-templates mode="db2html.class.cpp.mode" select="."/>
<xsl:text> </xsl:text>
@@ -264,7 +261,7 @@ REMARK: Describe this mode
}
-->
<xsl:call-template name="db2html.class.cpp.modifier"/>
- <xsl:value-of select="$cpp.tab"/>
+ <xsl:value-of select="$db2html.classsynopsis.tab"/>
<xsl:for-each select="modifier[position() != 1] | db:modifier[position() != 1]">
<xsl:apply-templates mode="db2html.class.cpp.mode" select="."/>
<xsl:text> </xsl:text>
@@ -309,7 +306,7 @@ REMARK: Describe this mode
}
-->
<xsl:call-template name="db2html.class.cpp.modifier"/>
- <xsl:value-of select="$cpp.tab"/>
+ <xsl:value-of select="$db2html.classsynopsis.tab"/>
<xsl:for-each select="modifier[position() != 1] | db:modifier[position() != 1]">
<xsl:apply-templates mode="db2html.class.cpp.mode" select="."/>
<xsl:text> </xsl:text>
@@ -356,7 +353,7 @@ REMARK: Describe this mode
}
-->
<xsl:call-template name="db2html.class.cpp.modifier"/>
- <xsl:value-of select="$cpp.tab"/>
+ <xsl:value-of select="$db2html.classsynopsis.tab"/>
<!-- Parens for document order -->
<xsl:for-each select="(methodname/preceding-sibling::modifier |
db:methodname/preceding-sibling::db:modifier)[position() != 1]">
@@ -388,8 +385,11 @@ REMARK: Describe this mode
<!--%%==========================================================================
db2html.class.python.mode
+Process a Python synopsis.
+:Revision:version="1.0" date="2011-05-16" status="final"
-REMARK: Describe this mode
+This mode is applied to child elements for synopsis elements for the Python
+programming language.
-->
<xsl:template mode="db2html.class.python.mode" match="*">
<xsl:apply-templates select="."/>
@@ -448,7 +448,7 @@ REMARK: Describe this mode
-->
<xsl:variable name="tab">
<xsl:if test="../self::classsynopsis or ../self::db:classsynopsis">
- <xsl:value-of select="$python.tab"/>
+ <xsl:value-of select="$db2html.classsynopsis.tab"/>
</xsl:if>
</xsl:variable>
<xsl:for-each select="modifier | db:modifier">
@@ -502,7 +502,7 @@ REMARK: Describe this mode
-->
<xsl:variable name="tab">
<xsl:if test="../self::classsynopsis or ../self::db:classsynopsis">
- <xsl:value-of select="$python.tab"/>
+ <xsl:value-of select="$db2html.classsynopsis.tab"/>
</xsl:if>
</xsl:variable>
<xsl:for-each select="modifier | db:modifier">
@@ -552,7 +552,7 @@ REMARK: Describe this mode
-->
<xsl:variable name="tab">
<xsl:if test="../self::classsynopsis or ../self::db:classsynopsis">
- <xsl:value-of select="$python.tab"/>
+ <xsl:value-of select="$db2html.classsynopsis.tab"/>
</xsl:if>
</xsl:variable>
<xsl:for-each select="modifier | db:modifier">
@@ -609,7 +609,7 @@ REMARK: Describe this mode
-->
<xsl:variable name="tab">
<xsl:if test="../self::classsynopsis or ../self::db:classsynopsis">
- <xsl:value-of select="$python.tab"/>
+ <xsl:value-of select="$db2html.classsynopsis.tab"/>
</xsl:if>
</xsl:variable>
<xsl:for-each select="modifier | db:modifier">
diff --git a/xslt/docbook/html/db2html-cmdsynopsis.xsl b/xslt/docbook/html/db2html-cmdsynopsis.xsl
index 89a85e0..b6e78b5 100644
--- a/xslt/docbook/html/db2html-cmdsynopsis.xsl
+++ b/xslt/docbook/html/db2html-cmdsynopsis.xsl
@@ -27,47 +27,36 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
<!--!!==========================================================================
DocBook to HTML - Command Synopses
-:Requires: db2html-xref gettext
+:Requires: db2html-xref html
+:Revision:version="1.0" date="2011-05-16" status="final"
This module contains templates to process DocBook command synopsis elements.
-->
-<!--@@==========================================================================
-db2html.arg.choice
-The default value of the #{choice} parameter for #{arg} elements
-
-REMARK: Describe this param
--->
-<xsl:param name="db2html.arg.choice" select="'opt'"/>
-
-
-<!--@@==========================================================================
-db2html.arg.rep
-The default value of the #{rep} parameter for #{arg} elements
-
-REMARK: Describe this param
--->
-<xsl:param name="db2html.arg.rep" select="'norepeat'"/>
+<xsl:key name="db2html.cmdsynopsis.synopfragment.key"
+ match="synopfragment | db:synopfragment"
+ use="@id | @xml:id"/>
-<!--@@==========================================================================
-db2html.group.choice
-The default value of the #{choice} parameter for #{group} elements
+<!--**==========================================================================
+db2html.cmdsynopsis.synopfragment.label
+Create a label for a #{synopfragment} element.
+:Revision:version="1.0" date="2011-05-16" status="final"
+$node: The #{synopfragment} element to create a label for.
-REMARK: Describe this param
+This template creates a label for a command synopsis fragment, taking a
+#{synopfragment} element as the ${node} parameter. The label is numbered
+according to the position of the #{synopfragment} element in the document.
+To create the corresponding label for a #{synopfragmentref} element, locate
+the corresponding #{synopfragment} element and call this template on it.
-->
-<xsl:param name="db2html.group.choice" select="'opt'"/>
-
-
-<!--@@==========================================================================
-db2html.group.rep
-The default value of the #{rep} parameter for #{group} elements
-
-REMARK: Describe this param
--->
-<xsl:param name="db2html.group.rep" select="'norepeat'"/>
-
+<xsl:template name="db2html.cmdsynopsis.synopfragment.label">
+ <xsl:param name="node" select="."/>
+ <span class="co">
+ <xsl:value-of select="count($node/preceding::synopfragment) + count($node/preceding::db:synopfragment) + 1"/>
+ </span>
+</xsl:template>
<!-- == Matched Templates == -->
@@ -92,7 +81,7 @@ REMARK: Describe this param
<xsl:value-of select="@choice"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="$db2html.arg.choice"/>
+ <xsl:value-of select="'opt'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:param>
@@ -102,7 +91,7 @@ REMARK: Describe this param
<xsl:value-of select="@rep"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="$db2html.arg.rep"/>
+ <xsl:value-of select="'norepeat'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:param>
@@ -165,23 +154,10 @@ REMARK: Describe this param
</xsl:choose>
</xsl:param>
<div>
- <xsl:choose>
- <xsl:when test="@lang or @xml:lang">
- <xsl:attribute name="dir">
- <xsl:call-template name="l10n.direction">
- <xsl:with-param name="lang" select="@lang | @xml:lang"/>
- </xsl:call-template>
- </xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="dir">
- <xsl:text>ltr</xsl:text>
- </xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
<xsl:attribute name="class">
<xsl:text>synopsis cmdsynopsis</xsl:text>
</xsl:attribute>
+ <xsl:call-template name="html.lang.attrs"/>
<xsl:call-template name="db2html.anchor"/>
<pre class="contents cmdsynopsis">
<xsl:for-each select="command | arg | group | sbr |
@@ -235,7 +211,7 @@ REMARK: Describe this param
<xsl:value-of select="@choice"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="$db2html.group.choice"/>
+ <xsl:value-of select="'opt'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:param>
@@ -245,7 +221,7 @@ REMARK: Describe this param
<xsl:value-of select="@rep"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="$db2html.group.rep"/>
+ <xsl:value-of select="'norepeat'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:param>
@@ -324,8 +300,7 @@ REMARK: Describe this param
</xsl:param>
<div class="synopfragment">
<xsl:call-template name="db2html.anchor"/>
- <!-- FIXME -->
- <i><xsl:call-template name="db.label"/></i>
+ <xsl:call-template name="db2html.cmdsynopsis.synopfragment.label"/>
<xsl:for-each select="*">
<xsl:value-of select="$sepchar"/>
<xsl:apply-templates select=".">
@@ -337,13 +312,20 @@ REMARK: Describe this param
<!-- = synopfragmentref = -->
<xsl:template match="synopfragmentref | db:synopfragmentref">
- <xsl:call-template name="db2html.xref"/>
+ <xsl:variable name="node" select="key('db2html.cmdsynopsis.synopfragment.key', @linkend)"/>
+ <xsl:call-template name="db2html.cmdsynopsis.synopfragment.label">
+ <xsl:with-param name="node" select="$node"/>
+ </xsl:call-template>
</xsl:template>
+<xsl:template name="db.label">
+ <span class="co"><xsl:value-of select="preceding::synopfragment + 1"/></span>
+</xsl:template>
<!--%%==========================================================================
db2html.cmdsynopsis.sbr.padding.mode
-Outputs padding for elements leading up to an #{sbr} element
+Output padding for elements leading up to an #{sbr} element.
+:Revision:version="1.0" date="2011-05-16" status="final"
$sbr: The #{sbr} element to pad up to
$sepchar: The value of the #{sepchar} attribute on the enclosing #{cmdsynopsis}
@@ -548,10 +530,9 @@ selectors, which are generally expensive to perform.
<!-- = synopfragmentref % db2html.cmdsynopsis.sbr.padding.mode = -->
<xsl:template mode="db2html.cmdsynopsis.sbr.padding.mode"
match="synopfragmentref | db:synopfragmentref">
- <xsl:variable name="label">
- <xsl:call-template name="db2html.xref"/>
- </xsl:variable>
- <xsl:value-of select="str:padding(string-length($label), ' ')"/>
+ <xsl:variable name="node" select="key('db2html.cmdsynopsis.synopfragment.key', @linkend)"/>
+ <xsl:variable name="count" select="count($node/preceding::synopfragment) + count($node/preceding::db:synopfragment) + 1"/>
+ <xsl:value-of select="str:padding(string-length($count) + 2, ' ')"/>
</xsl:template>
</xsl:stylesheet>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]