Fix handling of multiple exception descriptions, support free form description.

When there are multiple \throws entries in a function documentation, the second
and further exception names were omitted from output and a combined description
was associated with the first exception. Fix this by producing separate
paragraphs, one per exception.

Additionally, support free form exception description when the exception type
is specified as "~". In this case, the exception name is not used, and the
entry description is used to initialize the paragraph in the output.

Updated test to verify these changes.
This commit is contained in:
Andrey Semashev 2024-07-06 17:39:23 +03:00
parent c220a12c17
commit 719af2337f
3 changed files with 29 additions and 16 deletions

View File

@ -104,13 +104,17 @@ int foo2();
<function id="doxygen.example_reference.example_8hpp_1addcdeb7a8901ec383539fabdc69b1ae1" name="namespace_func"><type>int</type><parameter name="i"><paramtype>int</paramtype><description><para>A function parameter </para></description></parameter><parameter name="j"><paramtype>int</paramtype><description><para>Another </para></description></parameter><description><para> <function id="doxygen.example_reference.example_8hpp_1addcdeb7a8901ec383539fabdc69b1ae1" name="namespace_func"><type>int</type><parameter name="i"><paramtype>int</paramtype><description><para>A function parameter </para></description></parameter><parameter name="j"><paramtype>int</paramtype><description><para>Another </para></description></parameter><description><para>
This is a test function. <link linkend="doxygen.example_reference.classexample_1_1example">Link to class</link> <link linkend="doxygen.example_reference.structexample_1_1example__template">Link to class template</link> <note><para>This is a note.</para> This is a test function. <link linkend="doxygen.example_reference.classexample_1_1example">Link to class</link> <link linkend="doxygen.example_reference.structexample_1_1example__template">Link to class template</link> <note><para>This is a note.</para>
</note> </note>
<formalpara><title>See Also:</title><para><link linkend="doxygen.example_reference.classexample_1_1example">example::example</link> and <link linkend="doxygen.example_reference.structexample_1_1example__template">example_template</link> </para> <formalpara><title>See Also:</title><para><link linkend="doxygen.example_reference.classexample_1_1example">example::example</link> and <link linkend="doxygen.example_reference.structexample_1_1example__template">example_template</link> </para>
</formalpara> </formalpara>
</para></description><requires><para>i &gt; j</para> </para></description><requires><para>i &gt; j</para>
</requires><returns><para>The answer </para> </requires><returns><para>The answer </para>
</returns></function> </returns><throws><simpara><classname>std::runtime_error</classname> Some error description </simpara>
<simpara><classname>std::bad_alloc</classname> Memory allocation error </simpara>
<simpara>Free form description of exception throwing </simpara>
</throws></function>
<function id="doxygen.example_reference.example_8hpp_1ae06fcc1d7c044252611b2ebb2b665e53" name="namespace_func_template"><type>void</type><template> <function id="doxygen.example_reference.example_8hpp_1ae06fcc1d7c044252611b2ebb2b665e53" name="namespace_func_template"><type>void</type><template>
<template-type-parameter name="TypeParameter"><purpose><para>A template parameter </para></purpose></template-type-parameter> <template-type-parameter name="TypeParameter"><purpose><para>A template parameter </para></purpose></template-type-parameter>
<template-nontype-parameter name="NonTypeParameter"><type>int</type><purpose><para>This is a non-type template parameter </para></purpose></template-nontype-parameter> <template-nontype-parameter name="NonTypeParameter"><type>int</type><purpose><para>This is a non-type template parameter </para></purpose></template-nontype-parameter>

View File

@ -196,6 +196,9 @@ namespace example
* \param i A function parameter * \param i A function parameter
* \param j Another * \param j Another
* \return The answer * \return The answer
* \throw std::runtime_error Some error description
* \throw std::bad_alloc Memory allocation error
* \throw ~ Free form description of exception throwing
* \pre i > j * \pre i > j
* *
* This is a test function. * This is a test function.

View File

@ -1804,24 +1804,30 @@
<xsl:template match="parameterlist" mode="function-clauses"> <xsl:template match="parameterlist" mode="function-clauses">
<xsl:if test="@kind='exception'"> <xsl:if test="@kind='exception'">
<simpara> <xsl:apply-templates mode="exception.description"/>
<xsl:choose> </xsl:if>
<xsl:when test="normalize-space(.//parametername//text())='nothrow'"> </xsl:template>
<xsl:text>Will not throw.</xsl:text>
</xsl:when> <xsl:template match="parameteritem" mode="exception.description">
<xsl:otherwise> <simpara>
<xsl:choose>
<xsl:when test="normalize-space(./parameternamelist/parametername//text())='nothrow'">
<xsl:text>Will not throw.</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:if test="normalize-space(./parameternamelist/parametername//text())!='~'">
<classname> <classname>
<xsl:value-of select=".//parametername//text()"/> <xsl:value-of select="./parameternamelist/parametername//text()"/>
</classname> </classname>
<xsl:text> </xsl:text> <xsl:text> </xsl:text>
<xsl:apply-templates </xsl:if>
select=".//parameterdescription/para/text() <xsl:apply-templates
|.//parameterdescription/para/*" select="./parameterdescription/para/text()
mode="passthrough"/> |./parameterdescription/para/*"
</xsl:otherwise> mode="passthrough"/>
</xsl:choose> </xsl:otherwise>
</simpara> </xsl:choose>
</xsl:if> </simpara>
</xsl:template> </xsl:template>
<xsl:template match="type"> <xsl:template match="type">