Added preliminary support for macro documentation

[SVN r19845]
This commit is contained in:
Douglas Gregor 2003-08-29 01:37:03 +00:00
parent 79cf01a36d
commit 529ad13fa2
5 changed files with 121 additions and 3 deletions

View File

@ -5,6 +5,7 @@
<xsl:key name="methods" match="method|overloaded-method" use="@name"/>
<xsl:key name="functions" match="function|overloaded-function" use="@name"/>
<xsl:key name="libraries" match="library" use="@name"/>
<xsl:key name="macros" match="macro" use="@name"/>
<xsl:template match="classname" mode="annotation">
<!-- Determine the (possibly qualified) class name we are looking for -->
@ -161,6 +162,42 @@
</xsl:call-template>
</xsl:template>
<xsl:template match="macroname" mode="annotation">
<xsl:param name="name" select="text()"/>
<xsl:variable name="node" select="key('macros', $name)"/>
<xsl:choose>
<xsl:when test="count($node) = 0">
<xsl:message>
<xsl:text>warning: cannot find macro `</xsl:text>
<xsl:value-of select="$name"/>
<xsl:text>'</xsl:text>
</xsl:message>
<xsl:value-of select="$name"/>
</xsl:when>
<xsl:when test="count($node) = 1">
<xsl:call-template name="internal-link">
<xsl:with-param name="to">
<xsl:call-template name="generate.id">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="text" select="$name"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:message>
<xsl:text>error: macro `</xsl:text>
<xsl:value-of select="$name"/>
<xsl:text>' is multiply defined.</xsl:text>
</xsl:message>
<xsl:value-of select="$node"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="text()" mode="annotation">
<xsl:param name="highlight" select="false()"/>
<xsl:choose>

View File

@ -69,7 +69,17 @@
<xsl:apply-templates select="para|section" mode="annotation"/>
<xsl:apply-templates mode="synopsis">
<xsl:if test="macro and namespace">
<xsl:call-template name="synopsis">
<xsl:with-param name="text">
<xsl:apply-templates mode="synopsis" select="macro">
<xsl:with-param name="indentation" select="0"/>
</xsl:apply-templates>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
<xsl:apply-templates mode="synopsis" select="namespace">
<xsl:with-param name="indentation" select="0"/>
</xsl:apply-templates>
@ -341,7 +351,7 @@ Error: XSL template 'link-or-anchor' called with invalid link-type '<xsl:value-o
<!-- These DocBook elements have special meaning. Use the annotation mode -->
<xsl:template match="classname|methodname|functionname|libraryname|
conceptname">
conceptname|macroname">
<xsl:apply-templates select="." mode="annotation"/>
</xsl:template>

70
xsl/macro.xsl Normal file
View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="macro" mode="synopsis">
<xsl:param name="indentation" select="0"/>
<xsl:text>&#10;</xsl:text>
<xsl:if
test="not(local-name(preceding-sibling::*[position()=1])=local-name(.))">
<xsl:text>&#10;</xsl:text>
</xsl:if>
<xsl:call-template name="indent">
<xsl:with-param name="indentation" select="$indentation"/>
</xsl:call-template>
<xsl:call-template name="macro-synopsis">
<xsl:with-param name="link-type" select="'link'"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="macro" mode="reference">
<xsl:call-template name="reference-documentation">
<xsl:with-param name="refname" select="@name"/>
<xsl:with-param name="purpose" select="purpose"/>
<xsl:with-param name="anchor">
<xsl:call-template name="generate.id"/>
</xsl:with-param>
<xsl:with-param name="name">
<xsl:text>Macro </xsl:text>
<xsl:call-template name="monospaced">
<xsl:with-param name="text" select="@name"/>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="synopsis">
<xsl:call-template name="macro-synopsis">
<xsl:with-param name="link-type" select="'none'"/>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="text">
<xsl:apply-templates select="description"/>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="macro-synopsis">
<xsl:param name="link-type"/>
<xsl:call-template name="link-or-anchor">
<xsl:with-param name="to">
<xsl:call-template name="generate.id" select="."/>
</xsl:with-param>
<xsl:with-param name="text" select="@name"/>
<xsl:with-param name="link-type" select="$link-type"/>
</xsl:call-template>
<xsl:if test="@kind='functionlike'">
<xsl:text>(</xsl:text>
<xsl:for-each select="macro-parameter">
<xsl:if test="position() &gt; 1">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:value-of select="@name"/>
</xsl:for-each>
<xsl:text>)</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="macro" mode="generate.id">
<xsl:value-of select="@name"/>
</xsl:template>
</xsl:stylesheet>

View File

@ -11,6 +11,7 @@
<xsl:include href="library.xsl"/>
<xsl:include href="index.xsl"/>
<xsl:include href="error.xsl"/>
<xsl:include href="macro.xsl"/>
<xsl:include href="testing/testsuite.xsl"/>
<xsl:include href="caramel/concept2docbook.xsl"/>

View File

@ -152,7 +152,7 @@
</xsl:template>
<xsl:template match="classname|methodname|functionname|libraryname|
conceptname" mode="highlight">
conceptname|macroname" mode="highlight">
<xsl:apply-templates select="." mode="annotation"/>
</xsl:template>
</xsl:stylesheet>