Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62894 - trunk/tools/boostbook/xsl
From: steven_at_[hidden]
Date: 2010-06-12 23:08:38


Author: steven_watanabe
Date: 2010-06-12 23:08:36 EDT (Sat, 12 Jun 2010)
New Revision: 62894
URL: http://svn.boost.org/trac/boost/changeset/62894

Log:
Fix markup problems reported by Eric Niebler.
Text files modified:
   trunk/tools/boostbook/xsl/annotation.xsl | 8 ++++
   trunk/tools/boostbook/xsl/function.xsl | 62 +++++++++++++++++--------------
   trunk/tools/boostbook/xsl/reference.xsl | 79 ++++++++++++++++++++++++++++++++++++++-
   trunk/tools/boostbook/xsl/source-highlight.xsl | 4 +-
   trunk/tools/boostbook/xsl/type.xsl | 57 ++++++++++++++++------------
   5 files changed, 154 insertions(+), 56 deletions(-)

Modified: trunk/tools/boostbook/xsl/annotation.xsl
==============================================================================
--- trunk/tools/boostbook/xsl/annotation.xsl (original)
+++ trunk/tools/boostbook/xsl/annotation.xsl 2010-06-12 23:08:36 EDT (Sat, 12 Jun 2010)
@@ -374,6 +374,14 @@
     </xsl:choose>
   </xsl:template>
 
+ <xsl:template match="programlisting" mode="annotation">
+ <programlisting>
+ <xsl:apply-templates mode="annotation">
+ <xsl:with-param name="highlight" select="true()"/>
+ </xsl:apply-templates>
+ </programlisting>
+ </xsl:template>
+
   <xsl:template match="code" mode="annotation">
     <computeroutput>
       <xsl:apply-templates mode="annotation"/>

Modified: trunk/tools/boostbook/xsl/function.xsl
==============================================================================
--- trunk/tools/boostbook/xsl/function.xsl (original)
+++ trunk/tools/boostbook/xsl/function.xsl 2010-06-12 23:08:36 EDT (Sat, 12 Jun 2010)
@@ -654,16 +654,18 @@
       <xsl:call-template name="indent">
         <xsl:with-param name="indentation" select="$indentation"/>
       </xsl:call-template>
- <emphasis>
- <xsl:text>// </xsl:text>
- <xsl:call-template name="internal-link">
- <xsl:with-param name="to">
- <xsl:call-template name="generate.id"/>
- <xsl:text>construct-copy-destruct</xsl:text>
- </xsl:with-param>
- <xsl:with-param name="text" select="'construct/copy/destruct'"/>
- </xsl:call-template>
- </emphasis>
+ <xsl:call-template name="highlight-comment">
+ <xsl:with-param name="text">
+ <xsl:text>// </xsl:text>
+ <xsl:call-template name="internal-link">
+ <xsl:with-param name="to">
+ <xsl:call-template name="generate.id"/>
+ <xsl:text>construct-copy-destruct</xsl:text>
+ </xsl:with-param>
+ <xsl:with-param name="text" select="'construct/copy/destruct'"/>
+ </xsl:call-template>
+ </xsl:with-param>
+ </xsl:call-template>
       <xsl:apply-templates select="constructor" mode="synopsis">
         <xsl:with-param name="indentation" select="$indentation"/>
       </xsl:apply-templates>
@@ -1083,15 +1085,17 @@
       <xsl:call-template name="indent">
         <xsl:with-param name="indentation" select="$indentation"/>
       </xsl:call-template>
- <emphasis>
- <xsl:text>// </xsl:text>
- <xsl:call-template name="internal-link">
- <xsl:with-param name="to">
- <xsl:call-template name="generate.id"/>
- </xsl:with-param>
- <xsl:with-param name="text" select="string(@name)"/>
- </xsl:call-template>
- </emphasis>
+ <xsl:call-template name="highlight-comment">
+ <xsl:with-param name="text">
+ <xsl:text>// </xsl:text>
+ <xsl:call-template name="internal-link">
+ <xsl:with-param name="to">
+ <xsl:call-template name="generate.id"/>
+ </xsl:with-param>
+ <xsl:with-param name="text" select="string(@name)"/>
+ </xsl:call-template>
+ </xsl:with-param>
+ </xsl:call-template>
       <xsl:apply-templates select="method|overloaded-method"
         mode="synopsis">
         <xsl:with-param name="indentation" select="$indentation"/>
@@ -1137,15 +1141,17 @@
     <xsl:call-template name="indent">
       <xsl:with-param name="indentation" select="$indentation"/>
     </xsl:call-template>
- <emphasis>
- <xsl:text>// </xsl:text>
- <xsl:call-template name="internal-link">
- <xsl:with-param name="to">
- <xsl:call-template name="generate.id"/>
- </xsl:with-param>
- <xsl:with-param name="text" select="string(@name)"/>
- </xsl:call-template>
- </emphasis>
+ <xsl:call-template name="highlight-comment">
+ <xsl:with-param name="text">
+ <xsl:text>// </xsl:text>
+ <xsl:call-template name="internal-link">
+ <xsl:with-param name="to">
+ <xsl:call-template name="generate.id"/>
+ </xsl:with-param>
+ <xsl:with-param name="text" select="string(@name)"/>
+ </xsl:call-template>
+ </xsl:with-param>
+ </xsl:call-template>
     <xsl:apply-templates select="function|overloaded-function" mode="synopsis">
       <xsl:with-param name="indentation" select="$indentation"/>
     </xsl:apply-templates>

Modified: trunk/tools/boostbook/xsl/reference.xsl
==============================================================================
--- trunk/tools/boostbook/xsl/reference.xsl (original)
+++ trunk/tools/boostbook/xsl/reference.xsl 2010-06-12 23:08:36 EDT (Sat, 12 Jun 2010)
@@ -98,9 +98,71 @@
   <xsl:template match="para|section" mode="synopsis"/>
   <xsl:template match="para|section" mode="reference"/>
 
+ <xsl:template name="find-wrap-point">
+ <xsl:param name="text"/>
+ <xsl:param name="prefix"/>
+ <xsl:param name="result" select="0"/>
+ <xsl:param name="default" select="$max-columns - string-length($prefix)"/>
+ <xsl:variable name="s" select="substring($text, 2)"/>
+ <xsl:variable name="candidate">
+ <xsl:choose>
+ <xsl:when test="contains($s, ' ')">
+ <xsl:value-of select="string-length(substring-before($s, ' ')) + 1"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="string-length($text)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="string-length($prefix) + $result + $candidate &lt;= $max-columns">
+ <xsl:call-template name="find-wrap-point">
+ <xsl:with-param name="text" select="substring($text, $candidate + 1)"/>
+ <xsl:with-param name="prefix" select="$prefix"/>
+ <xsl:with-param name="result" select="$result + $candidate"/>
+ <xsl:with-param name="default" select="$result + $candidate"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$default"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="wrap-comment">
+ <xsl:param name="prefix"/>
+ <xsl:param name="text"/>
+ <xsl:choose>
+ <xsl:when test="string-length($prefix) + string-length($text) &lt;= $max-columns">
+ <xsl:value-of select="$text"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="size">
+ <xsl:call-template name="find-wrap-point">
+ <xsl:with-param name="prefix" select="$prefix"/>
+ <xsl:with-param name="text" select="$text"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:value-of select="substring($text, 1, $size)"/>
+ <xsl:text>&#10;</xsl:text>
+ <xsl:value-of select="$prefix"/>
+ <xsl:call-template name="wrap-comment">
+ <xsl:with-param name="prefix" select="$prefix"/>
+ <xsl:with-param name="text" select="normalize-space(substring($text, $size + 1))"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
   <!-- Comment mode tries to wipe out any extra spacing in the output -->
   <xsl:template match="purpose" mode="comment">
- <xsl:apply-templates mode="comment"/>
+ <xsl:param name="wrap" select="false()"/>
+ <xsl:param name="prefix"/>
+ <xsl:apply-templates mode="comment">
+ <xsl:with-param name="wrap"
+ select="$wrap and count(*) = 0 and count(text()) = 1"/>
+ <xsl:with-param name="prefix" select="$prefix"/>
+ </xsl:apply-templates>
   </xsl:template>
 
   <xsl:template match="simpara|para" mode="comment">
@@ -108,7 +170,20 @@
   </xsl:template>
 
   <xsl:template match="text()" mode="comment">
- <xsl:value-of select="."/>
+ <xsl:param name="wrap" select="false()"/>
+ <xsl:param name="prefix"/>
+ <xsl:variable name="stripped" select="normalize-space(.)"/>
+ <xsl:choose>
+ <xsl:when test="$wrap">
+ <xsl:call-template name="wrap-comment">
+ <xsl:with-param name="prefix" select="$prefix"/>
+ <xsl:with-param name="text" select="$stripped"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
   </xsl:template>
 
   <xsl:template match="*" mode="comment">

Modified: trunk/tools/boostbook/xsl/source-highlight.xsl
==============================================================================
--- trunk/tools/boostbook/xsl/source-highlight.xsl (original)
+++ trunk/tools/boostbook/xsl/source-highlight.xsl 2010-06-12 23:08:36 EDT (Sat, 12 Jun 2010)
@@ -75,11 +75,11 @@
     <xsl:choose>
       <xsl:when test="$boost.syntax.highlight='1'">
         <phrase role="comment">
- <xsl:value-of select="$text"/>
+ <xsl:copy-of select="$text"/>
         </phrase>
       </xsl:when>
       <xsl:otherwise>
- <xsl:value-of select="$text"/>
+ <xsl:copy-of select="$text"/>
       </xsl:otherwise>
     </xsl:choose>
   </xsl:template>

Modified: trunk/tools/boostbook/xsl/type.xsl
==============================================================================
--- trunk/tools/boostbook/xsl/type.xsl (original)
+++ trunk/tools/boostbook/xsl/type.xsl 2010-06-12 23:08:36 EDT (Sat, 12 Jun 2010)
@@ -764,26 +764,28 @@
       <xsl:call-template name="indent">
         <xsl:with-param name="indentation" select="$indentation + 2"/>
       </xsl:call-template>
- <emphasis>
- <xsl:text>// </xsl:text>
- <!-- True if there are any non-compacted typedefs -->
- <xsl:variable name="have-typedef-references"
- select="typedef and ((typedef/para|typedef/description) or ($boost.compact.typedef='0'))"/>
- <xsl:choose>
- <xsl:when test="$have-typedef-references">
- <xsl:call-template name="internal-link">
- <xsl:with-param name="to">
- <xsl:call-template name="generate.id"/>
- <xsl:text>types</xsl:text>
- </xsl:with-param>
- <xsl:with-param name="text" select="'types'"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>types</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </emphasis>
+ <xsl:call-template name="highlight-comment">
+ <xsl:with-param name="text">
+ <xsl:text>// </xsl:text>
+ <!-- True if there are any non-compacted typedefs -->
+ <xsl:variable name="have-typedef-references"
+ select="typedef and ((typedef/para|typedef/description) or ($boost.compact.typedef='0'))"/>
+ <xsl:choose>
+ <xsl:when test="$have-typedef-references">
+ <xsl:call-template name="internal-link">
+ <xsl:with-param name="to">
+ <xsl:call-template name="generate.id"/>
+ <xsl:text>types</xsl:text>
+ </xsl:with-param>
+ <xsl:with-param name="text" select="'types'"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>types</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
+ </xsl:call-template>
 
       <xsl:variable name="max-type-length">
         <xsl:call-template name="find-max-type-length"/>
@@ -912,15 +914,22 @@
            comment. -->
       <xsl:if test="purpose">
         <xsl:text>&#10;</xsl:text>
- <xsl:call-template name="indent">
- <xsl:with-param name="indentation" select="$indentation"/>
- </xsl:call-template>
+ <xsl:variable name="spaces">
+ <xsl:call-template name="indent">
+ <xsl:with-param name="indentation" select="$indentation"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:copy-of select="$spaces"/>
         <xsl:call-template name="highlight-comment">
           <xsl:with-param name="text">
             <xsl:text>// </xsl:text>
- <xsl:apply-templates select="purpose" mode="comment"/>
+ <xsl:apply-templates select="purpose" mode="comment">
+ <xsl:with-param name="wrap" select="true()"/>
+ <xsl:with-param name="prefix" select="concat($spaces, '// ')"/>
+ </xsl:apply-templates>
           </xsl:with-param>
         </xsl:call-template>
+ <xsl:text>&#10;</xsl:text>
       </xsl:if>
     </xsl:if>
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk