Improved presentation of unnamed enums.

Instead of Doxygen-synthesized names like "@0", either omit the name
entirely, when the enum name is not a link to a separate definition,
or display "[unnamed]" placeholder for the name that serves as a link.
This commit is contained in:
Andrey Semashev 2024-06-30 20:13:19 +03:00
parent 5216db3959
commit 7f4efc149a
2 changed files with 61 additions and 10 deletions

View File

@ -158,15 +158,20 @@
<!-- Build the fully-qualified name of the given node -->
<xsl:template name="fully-qualified-name">
<xsl:param name="node"/>
<xsl:apply-templates select="$node" mode="fully-qualified-name"/>
<xsl:param name="replace-unnamed" select="false()"/>
<xsl:apply-templates select="$node" mode="fully-qualified-name">
<xsl:with-param name="replace-unnamed" select="$replace-unnamed"/>
</xsl:apply-templates>
</xsl:template>
<!-- Hack to make the node we are building the current node so that the
ancestor:: syntax will work -->
<xsl:template match="*" mode="fully-qualified-name">
<xsl:param name="is.id" select="false()"/>
<xsl:param name="replace-unnamed" select="false()"/>
<xsl:call-template name="build-fully-qualified-name">
<xsl:with-param name="is.id" select="$is.id"/>
<xsl:with-param name="replace-unnamed" select="$replace-unnamed"/>
</xsl:call-template>
</xsl:template>
@ -174,6 +179,7 @@
node. -->
<xsl:template name="build-fully-qualified-name">
<xsl:param name="is.id" select="false()"/>
<xsl:param name="replace-unnamed" select="false()"/>
<!-- Determine the set of ancestor namespaces -->
<xsl:variable name="ancestors"
@ -184,6 +190,7 @@
<xsl:for-each select="$ancestors">
<xsl:apply-templates select="." mode="fast-print-id-part">
<xsl:with-param name="is.id" select="$is.id"/>
<xsl:with-param name="replace-unnamed" select="$replace-unnamed"/>
</xsl:apply-templates>
<xsl:choose>
<xsl:when test="$is.id"><xsl:text>.</xsl:text></xsl:when>
@ -192,6 +199,7 @@
</xsl:for-each>
<xsl:apply-templates select="." mode="fast-print-id-part">
<xsl:with-param name="is.id" select="$is.id"/>
<xsl:with-param name="replace-unnamed" select="$replace-unnamed"/>
</xsl:apply-templates>
</xsl:template>
@ -219,9 +227,12 @@
<xsl:template match="*" mode="fast-print-id-part">
<xsl:param name="is.id"/>
<xsl:param name="replace-unnamed" select="false()"/>
<xsl:choose>
<xsl:when test="not($is.id)">
<xsl:apply-templates select="." mode="print-name"/>
<xsl:apply-templates select="." mode="print-name">
<xsl:with-param name="replace-unnamed" select="$replace-unnamed"/>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="$fast-elements[@id=generate-id()]">
<xsl:value-of select="$fast-elements[@id=generate-id()]/@part-id"/>
@ -297,7 +308,15 @@
<!-- Print the name of the current node -->
<xsl:template match="*" mode="print-name">
<xsl:param name="replace-unnamed" select="false()"/>
<xsl:choose>
<xsl:when test="not($replace-unnamed) or not(string(@name)='' or starts-with(string(@name), '@'))">
<xsl:value-of select="@name"/>
</xsl:when>
<xsl:otherwise>
<emphasis>[unnamed]</emphasis>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="template-arg" mode="print-name">

View File

@ -85,7 +85,14 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
</xsl:if>
<xsl:call-template name="monospaced">
<xsl:with-param name="text">
<xsl:choose>
<xsl:when test="not(string(@name)='' or starts-with(string(@name), '@'))">
<xsl:value-of select="@name"/>
</xsl:when>
<xsl:otherwise>
<emphasis>[unnamed]</emphasis>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="specialization"/>
</xsl:with-param>
</xsl:call-template>
@ -1417,6 +1424,9 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<xsl:with-param name="indentation" select="$indentation"/>
</xsl:call-template>
<!-- Doxygen generates unnamed enums with a name starting with '@' -->
<xsl:variable name="has-name" select="not(string(@name)='' or starts-with(string(@name), '@'))"/>
<xsl:choose>
<!-- When there is a detailed description, we only put the
declaration in the synopsis and will put detailed documentation
@ -1434,7 +1444,16 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<xsl:with-param name="node" select="."/>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="text" select="string(@name)"/>
<xsl:with-param name="text">
<xsl:choose>
<xsl:when test="$has-name">
<xsl:value-of select="@name"/>
</xsl:when>
<xsl:otherwise>
<emphasis>[unnamed]</emphasis>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="higlhight" select="false()"/>
</xsl:call-template>
</xsl:when>
@ -1462,7 +1481,9 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<xsl:with-param name="keyword" select="'enum'"/>
</xsl:call-template>
<xsl:if test="$has-name">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:call-template name="anchor">
<xsl:with-param name="to">
@ -1470,7 +1491,11 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<xsl:with-param name="node" select="."/>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="text" select="@name"/>
<xsl:with-param name="text">
<xsl:if test="$has-name">
<xsl:value-of select="@name"/>
</xsl:if>
</xsl:with-param>
<xsl:with-param name="higlhight" select="false()"/>
</xsl:call-template>
@ -1502,6 +1527,7 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
<xsl:with-param name="refname">
<xsl:call-template name="fully-qualified-name">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="replace-unnamed" select="true()"/>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="purpose" select="purpose/*|purpose/text()"/>
@ -1550,7 +1576,13 @@ Unknown type element "<xsl:value-of select="local-name(.)"/>" in type.display.na
</xsl:call-template>
<!-- Header -->
<xsl:variable name="header" select="concat(' ', @name, ' { ')"/>
<xsl:variable name="header">
<!-- Doxygen generates unnamed enums with a name starting with '@' -->
<xsl:if test="not(string(@name)='' or starts-with(string(@name), '@'))">
<xsl:value-of select="concat(' ', @name)"/>
</xsl:if>
<xsl:text> { </xsl:text>
</xsl:variable>
<xsl:call-template name="highlight-text">
<xsl:with-param name="text" select="$header"/>
</xsl:call-template>