Make sure that every bit of C++ code that we output goes through the syntax highlighter

[SVN r62294]
This commit is contained in:
Steven Watanabe 2010-05-28 14:40:48 +00:00
parent a29da889c0
commit f3e0f03654
5 changed files with 290 additions and 61 deletions

View File

@ -161,7 +161,7 @@
<!-- Build the text that follows the declarator-->
<xsl:variable name="postdeclarator">
<xsl:if test="@cv">
<xsl:if test="@cv and @cv != ''">
<xsl:text> </xsl:text>
<xsl:value-of select="@cv"/>
</xsl:if>
@ -246,7 +246,9 @@
<xsl:with-param name="highlight" select="true()"/>
</xsl:call-template>
<xsl:text>(</xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="'('"/>
</xsl:call-template>
<xsl:call-template name="function-parameters">
<xsl:with-param name="include-names" select="$include-names"/>
<xsl:with-param name="indentation"
@ -254,12 +256,16 @@
+ string-length($function-name) + 1"/>
<xsl:with-param name="final" select="true()"/>
</xsl:call-template>
<xsl:text>)</xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="')'"/>
</xsl:call-template>
<xsl:call-template name="source-highlight">
<xsl:with-param name="text" select="$postdeclarator"/>
</xsl:call-template>
<xsl:text>;</xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="';'"/>
</xsl:call-template>
</xsl:when>
<!-- This declaration will take multiple lines -->
@ -317,7 +323,9 @@
<xsl:with-param name="link-type" select="$link-type"/>
<xsl:with-param name="highlight" select="true()"/>
</xsl:call-template>
<xsl:text>(</xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="'('"/>
</xsl:call-template>
<xsl:call-template name="function-parameters">
<xsl:with-param name="include-names" select="$include-names"/>
<xsl:with-param name="indentation"
@ -325,11 +333,15 @@
+ string-length($function-name) + 1"/>
<xsl:with-param name="final" select="true()"/>
</xsl:call-template>
<xsl:text>)</xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="')'"/>
</xsl:call-template>
<xsl:call-template name="source-highlight">
<xsl:with-param name="text" select="$postdeclarator"/>
</xsl:call-template>
<xsl:text>;</xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="';'"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
@ -364,7 +376,18 @@
<!-- Information for this parameter -->
<xsl:variable name="parameter" select="$parameters[position()=1]"/>
<xsl:variable name="pack">
<xsl:if test="$parameter/@pack=1"><xsl:text>...</xsl:text></xsl:if>
<xsl:if test="$parameter/@pack=1">
<xsl:choose>
<xsl:when test="$final">
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="'...'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text>...</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:variable>
<xsl:variable name="name">
<xsl:if test="$include-names and $parameter/@name != ''">
@ -377,18 +400,32 @@
<xsl:variable name="default">
<xsl:choose>
<xsl:when test="$parameter/@default">
<xsl:text> = </xsl:text>
<xsl:value-of select="$parameter/@default"/>
</xsl:when>
<xsl:when test="$parameter/default">
<xsl:text> = </xsl:text>
<xsl:choose>
<xsl:when test="$final">
<xsl:apply-templates
select="$parameter/default/*|$parameter/default/text()"
mode="annotation"/>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="concat(' = ', $parameter/@default)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text> = </xsl:text>
<xsl:value-of select="$parameter/@default"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$parameter/default">
<xsl:choose>
<xsl:when test="$final">
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="' = '"/>
</xsl:call-template>
<xsl:apply-templates
select="$parameter/default/*|$parameter/default/text()"
mode="annotation">
<xsl:with-param name="highlight" select="true()"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:text> = </xsl:text>
<xsl:value-of select="string($parameter/default)"/>
</xsl:otherwise>
</xsl:choose>
@ -407,13 +444,15 @@
or not($wrap)">
<xsl:choose>
<xsl:when test="$final">
<xsl:value-of select="$prefix"/>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="$prefix"/>
</xsl:call-template>
<xsl:apply-templates
select="$parameter/paramtype/*|$parameter/paramtype/text()"
mode="annotation">
<xsl:with-param name="highlight" select="true()"/>
</xsl:apply-templates>
<xsl:value-of select="$pack"/>
<xsl:copy-of select="$pack"/>
<xsl:value-of select="$name"/>
<xsl:copy-of select="$default"/>
</xsl:when>
@ -437,7 +476,17 @@
<!-- Parameter goes on next line -->
<xsl:otherwise>
<!-- The comma goes on this line -->
<xsl:value-of select="$prefix"/><xsl:text>&#10;</xsl:text>
<xsl:choose>
<xsl:when test="$final">
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="$prefix"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$prefix"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&#10;</xsl:text>
<!-- Indent and print the parameter -->
<xsl:call-template name="indent">

View File

@ -57,7 +57,9 @@
</xsl:call-template>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:apply-templates select="type/*|type/text()" mode="annotation" />
<xsl:apply-templates select="type/*|type/text()" mode="annotation">
<xsl:with-param name="highlight" select="true()"/>
</xsl:apply-templates>
<xsl:text> </xsl:text>
<xsl:call-template name="link-or-anchor">
<xsl:with-param name="to">
@ -66,7 +68,9 @@
<xsl:with-param name="text" select="@name" />
<xsl:with-param name="link-type" select="$link-type" />
</xsl:call-template>
<xsl:text>;</xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="';'"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="data-member" mode="generate.id">
<xsl:call-template name="fully-qualified-id">

View File

@ -29,9 +29,8 @@
<xsl:with-param name="indentation" select="$indentation"/>
</xsl:call-template>
<xsl:call-template name="source-highlight">
<xsl:with-param name="text" select="concat('namespace ',@name)"/>
<xsl:with-param name="text" select="concat('namespace ',@name, ' {')"/>
</xsl:call-template>
<xsl:text> {</xsl:text>
<!-- Emit namespace types -->
<xsl:apply-templates select="class|class-specialization|
@ -58,7 +57,9 @@
<xsl:call-template name="indent">
<xsl:with-param name="indentation" select="$indentation"/>
</xsl:call-template>
<xsl:text>}</xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="'}'"/>
</xsl:call-template>
</xsl:template>
<!-- Emit namespace synopsis -->

View File

@ -72,18 +72,31 @@
<xsl:call-template name="highlight-keyword">
<xsl:with-param name="keyword" select="'template'"/>
</xsl:call-template>
<xsl:call-template name="highlight-special">
<xsl:with-param name="text" select="'&lt;'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text>template</xsl:text>
<xsl:text>&lt;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&lt;</xsl:text>
<xsl:call-template name="template.synopsis.parameters">
<xsl:with-param name="indentation" select="$indentation + 9"/>
<xsl:with-param name="wrap" select="$wrap"/>
<xsl:with-param name="highlight" select="$highlight"/>
</xsl:call-template>
<xsl:choose>
<xsl:when test="$highlight">
<xsl:call-template name="highlight-special">
<xsl:with-param name="text" select="'&gt;'"/>
</xsl:call-template>
<xsl:text> </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>&gt; </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Display a list of template parameters for a synopsis (no comments) -->
@ -100,7 +113,16 @@
<xsl:if test="$parameters">
<!-- Emit the prefix (either a comma-space, or empty if this is
the first parameter) -->
<xsl:choose>
<xsl:when test="$highlight">
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="$prefix"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$prefix"/>
</xsl:otherwise>
</xsl:choose>
<!-- Get the actual parameter and its attributes -->
<xsl:variable name="parameter" select="$parameters[position()=1]"/>
@ -179,17 +201,30 @@
<xsl:call-template name="highlight-keyword">
<xsl:with-param name="keyword" select="'template'"/>
</xsl:call-template>
<xsl:call-template name="highlight-special">
<xsl:with-param name="text" select="'&lt;'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text>template</xsl:text>
<xsl:text>&lt;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&lt;</xsl:text>
<xsl:call-template name="template.reference.parameters">
<xsl:with-param name="indentation" select="$indentation + 9"/>
<xsl:with-param name="highlight" select="$highlight"/>
</xsl:call-template>
<xsl:choose>
<xsl:when test="$highlight">
<xsl:call-template name="highlight-special">
<xsl:with-param name="text" select="'&gt;'"/>
</xsl:call-template>
<xsl:text> </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>&gt; </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
@ -236,7 +271,16 @@
</xsl:call-template>
<xsl:if test="$rest">
<xsl:choose>
<xsl:when test="$highlight">
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="', '"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text>, </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<!-- Display the comment -->
@ -314,7 +358,18 @@
<xsl:text>typename</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$parameter/@pack=1"><xsl:text>...</xsl:text></xsl:if>
<xsl:if test="$parameter/@pack=1">
<xsl:choose>
<xsl:when test="$highlight">
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="'...'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text>...</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:text> </xsl:text>
<xsl:call-template name="template.parameter.name">
@ -358,7 +413,16 @@
</xsl:variable>
<xsl:if test="not($def='')">
<xsl:choose>
<xsl:when test="$highlight">
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="' = '"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text> = </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:copy-of select="$def"/>
@ -389,7 +453,18 @@
<xsl:value-of select="$parameter/type/*|$parameter/type/text()"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$parameter/@pack=1"><xsl:text>...</xsl:text></xsl:if>
<xsl:if test="$parameter/@pack=1">
<xsl:choose>
<xsl:when test="$highlight">
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="'...'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text>...</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:text> </xsl:text>
<xsl:call-template name="template.parameter.name">
@ -402,7 +477,16 @@
</xsl:variable>
<xsl:if test="not($def='')">
<xsl:choose>
<xsl:when test="$highlight">
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="' = '"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text> = </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$highlight">
@ -423,25 +507,72 @@
</xsl:template>
<xsl:template match="template-varargs" mode="print.parameter">
<xsl:param name="highlight" select="true()"/>
<xsl:choose>
<xsl:when test="$highlight">
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="'...'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text>...</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="specialization">
<xsl:param name="highlight" select="true()"/>
<xsl:choose>
<xsl:when test="$highlight">
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="'&lt;'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text>&lt;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="template-arg">
<xsl:with-param name="highlight" select="$highlight"/>
</xsl:apply-templates>
<xsl:choose>
<xsl:when test="$highlight">
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="'&gt;'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text>&gt;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="template-arg">
<xsl:param name="highlight" select="true()"/>
<xsl:if test="position() &gt; 1">
<xsl:choose>
<xsl:when test="$highlight">
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="', '"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text>, </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:apply-templates mode="highlight"/>
<xsl:if test="@pack=1">
<xsl:choose>
<xsl:when test="$highlight">
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="'...'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text>...</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

View File

@ -134,7 +134,9 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<xsl:text> </xsl:text>
<xsl:value-of select="@name"/>
<xsl:apply-templates select="specialization"/>
<xsl:text>;</xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="';'"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
@ -160,7 +162,9 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates select="specialization"/>
<xsl:text>;</xsl:text>
<xsl:call-template name="highlight-special">
<xsl:with-param name="text" select="';'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
@ -195,7 +199,9 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<xsl:with-param name="text" select="string(@name)"/>
</xsl:call-template>
<xsl:apply-templates select="specialization"/>
<xsl:text>;</xsl:text>
<xsl:call-template name="highlight-special">
<xsl:with-param name="text" select="';'"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
@ -338,7 +344,9 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<xsl:with-param name="link-type" select="$link-type"/>
<xsl:with-param name="highlight" select="true()"/>
</xsl:call-template>
<xsl:text>;</xsl:text>
<xsl:call-template name="highlight-special">
<xsl:with-param name="text" select="';'"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
@ -461,7 +469,9 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<xsl:if test="not(@name = '')">
<xsl:text> </xsl:text>
<xsl:value-of select="@name"/>
<xsl:call-template name="source-highlight">
<xsl:with-param name="text" select="@name"/>
</xsl:call-template>
</xsl:if>
<xsl:text> = </xsl:text>
@ -471,7 +481,9 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<xsl:apply-templates select="default/*|default/text()"/>
</xsl:with-param>
</xsl:call-template>
<xsl:text>;</xsl:text>
<xsl:call-template name="highlight-special">
<xsl:with-param name="text" select="';'"/>
</xsl:call-template>
<xsl:if test="purpose">
<xsl:text> </xsl:text>
@ -523,7 +535,9 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<!-- Output the type -->
<xsl:choose>
<xsl:when test="type">
<xsl:apply-templates select="type/*|type/text()" mode="annotation"/>
<xsl:apply-templates select="type/*|type/text()" mode="annotation">
<xsl:with-param name="highlight" select="true()"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:message>
@ -581,14 +595,20 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<xsl:when test="$single-line-candidate and
(string-length($single-line) + $indentation + 3
&lt; $max-columns)">
<xsl:text> : </xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="' : '"/>
</xsl:call-template>
<xsl:call-template name="print.base.classes.single"/>
<xsl:text> {</xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="' {'"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$single-line-candidate and
(string-length($single-line) + $base-indentation + 2
&lt; $max-columns)">
<xsl:text> :&#10;</xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="' :&#10;'"/>
</xsl:call-template>
<xsl:call-template name="indent">
<xsl:with-param name="indentation" select="$base-indentation + 2"/>
</xsl:call-template>
@ -597,10 +617,14 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<xsl:call-template name="indent">
<xsl:with-param name="indentation" select="$base-indentation"/>
</xsl:call-template>
<xsl:text>{</xsl:text>
<xsl:call-template name="highlight-special">
<xsl:with-param name="text" select="'{'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text> : </xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="' : '"/>
</xsl:call-template>
<xsl:call-template name="print.base.classes.multi">
<xsl:with-param name="indentation" select="$indentation + 3"/>
</xsl:call-template>
@ -608,7 +632,9 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<xsl:call-template name="indent">
<xsl:with-param name="indentation" select="$base-indentation"/>
</xsl:call-template>
<xsl:text>{</xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="'{'"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
@ -846,7 +872,9 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<xsl:call-template name="highlight-keyword">
<xsl:with-param name="keyword" select="$specification"/>
</xsl:call-template>
<xsl:text>:</xsl:text>
<xsl:call-template name="highlight-special">
<xsl:with-param name="text" select="':'"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="access" mode="synopsis">
@ -940,7 +968,9 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
</xsl:when>
<xsl:otherwise>
<!-- Opening brace -->
<xsl:text> {</xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="' {'"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
@ -973,7 +1003,9 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<xsl:call-template name="indent">
<xsl:with-param name="indentation" select="$indentation"/>
</xsl:call-template>
<xsl:text>};</xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="'};'"/>
</xsl:call-template>
</xsl:template>
<!-- Emit nested class reference documentation -->
@ -1169,7 +1201,9 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<xsl:apply-templates select="type" mode="highlight"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>;</xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="';'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
@ -1283,16 +1317,22 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<xsl:with-param name="higlhight" select="false()"/>
</xsl:call-template>
<xsl:text> { </xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="' { '"/>
</xsl:call-template>
<xsl:call-template name="type.enum.list.compact">
<xsl:with-param name="indentation"
select="$indentation + string-length(@name) + 8"/>
<xsl:with-param name="compact" select="true()"/>
</xsl:call-template>
<xsl:text> }</xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="' }'"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<xsl:text>;</xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="';'"/>
</xsl:call-template>
</xsl:template>
<!-- Enumeration reference at namespace level -->
@ -1354,14 +1394,18 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<!-- Header -->
<xsl:variable name="header" select="concat(' ', @name, ' { ')"/>
<xsl:value-of select="$header"/>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="$header"/>
</xsl:call-template>
<!-- Print the enumeration values -->
<xsl:call-template name="type.enum.list.compact">
<xsl:with-param name="indentation" select="4 + string-length($header)"/>
</xsl:call-template>
<xsl:text> };</xsl:text>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="' };'"/>
</xsl:call-template>
</xsl:template>
<!-- List enumeration values in a compact form e.g.,