#863 html+fo: Problems with classsynopsis output

output: all formats
open
nobody
XSL (1066)
5
2007-01-29
2007-01-20
No

There are problems with generated text for classsynopsis (both HTML and FO). Below are a couple of Java examples.

A. This interface synopsis

<classsynopsis class="interface" language="java">
<oointerface>
<modifier>public</modifier>
<interfacename>TestInterface</interfacename>
</oointerface>
</classsynopsis>

becomes "implements public TestInterface" (+ braces). Expected output would be "public interface TestInterface".

B. This class synopsis

<classsynopsis language="java">
<ooclass>
<modifier>public</modifier>
<classname>TestClass</classname>
</ooclass>
</classsynopsis>

becomes "public TestClass" (+ braces). Expected output would be "public class TestClass".

Discussion

  • Mauritz Jeanson

    Mauritz Jeanson - 2007-01-20
    • summary: Problems with classsynopis output --> Problems with classsynopsis output
     
  • Mauritz Jeanson

    Mauritz Jeanson - 2007-01-20

    Logged In: YES
    user_id=582041
    Originator: YES

    Additional example:

    C. This synopsis (involving a class, two interfaces, and an exception)

    <classsynopsis language="java">
    <ooclass>
    <modifier>public</modifier>
    <package>com.example</package>
    <classname>MyClass</classname>
    </ooclass>
    <oointerface>
    <interfacename>MyInterface</interfacename>
    </oointerface>
    <oointerface>
    <interfacename>MyOtherInterface</interfacename>
    </oointerface>
    <ooexception>
    <exceptionname>TestException</exceptionname>
    </ooexception>

    <constructorsynopsis>
    <methodname>MyClass</methodname>
    </constructorsynopsis>

    <methodsynopsis>
    <void/>
    <methodname>testMethod</methodname>
    <methodparam>
    <parameter>String s</parameter>
    </methodparam>
    </methodsynopsis>
    </classsynopsis>

    becomes

    public MyClassimplements, MyInterface, MyOtherInterface
    throws, TestException {
    MyClass();
    void testMethod(String s);
    }

    Bugs:
    1. Missing space between "MyClass" and "implements"
    2. Spurious commas after "implements" and "throws".

     
  • Michael(tm) Smith

    • summary: Problems with classsynopsis output --> html+fo: Problems with classsynopsis output
     
  • EMJ

    EMJ - 2009-04-08

    I noticed this also. It is a real bummer when documenting complex Java APIs. Many of the things I document require documenting interfaces that a programmer needs to implement. I resort to just using <programlisting>.

     
  • EMJ

    EMJ - 2009-04-08

    This should fix the XHTML template. The others can be modified to match.

    <xsl:template match="d:classsynopsis" mode="java">
    <pre>
    <xsl:choose>
    <xsl:when test="@class='interface'">
    <xsl:apply-templates select="." mode="class.attribute"/>
    <xsl:apply-templates select="d:oointerface[1]" mode="java"/>
    <xsl:if test="d:ooexception">
    <br/>
    <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
    <xsl:text>throws</xsl:text>
    <xsl:apply-templates select="d:ooexception" mode="java"/>
    </xsl:if>
    </xsl:when>
    <xsl:otherwise>
    <xsl:apply-templates select="." mode="class.attribute"/>
    <xsl:apply-templates select="d:ooclass[1]" mode="java"/>
    <xsl:if test="d:ooclass[preceding-sibling::*]">
    <xsl:text> extends</xsl:text>
    <xsl:apply-templates select="d:ooclass[preceding-sibling::*]" mode="java"/>
    <xsl:if test="d:oointerface|d:ooexception">
    <br/>
    <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
    </xsl:if>
    </xsl:if>
    <xsl:if test="d:oointerface">
    <xsl:text> implements</xsl:text>
    <xsl:apply-templates select="d:oointerface" mode="java"/>
    <xsl:if test="d:ooexception">
    <br/>
    <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
    </xsl:if>
    </xsl:if>
    <xsl:if test="d:ooexception">
    <xsl:text>throws</xsl:text>
    <xsl:apply-templates select="d:ooexception" mode="java"/>
    </xsl:if>
    </xsl:otherwise>
    </xsl:choose>
    <xsl:text>&#160;{</xsl:text>
    <br/>
    <xsl:apply-templates select="d:constructorsynopsis |d:destructorsynopsis |d:fieldsynopsis |d:methodsynopsis |d:classsynopsisinfo" mode="java"/>
    <xsl:text>}</xsl:text>
    </pre>
    </xsl:template>

    <xsl:template match="d:classsynopsisinfo" mode="java">
    <xsl:apply-templates mode="java"/>
    </xsl:template>

    <xsl:template match="d:ooclass|d:ooexception" mode="java">
    <xsl:choose>
    <xsl:when test="preceding-sibling::*">
    <xsl:text>, </xsl:text>
    </xsl:when>
    <xsl:otherwise>
    <xsl:text> </xsl:text>
    </xsl:otherwise>
    </xsl:choose>
    <span>
    <xsl:apply-templates select="." mode="class.attribute"/>
    <xsl:apply-templates mode="java"/>
    </span>
    </xsl:template>

    <xsl:template match="d:oointerface" mode="java">
    <xsl:choose>
    <xsl:when test="preceding-sibling::*">
    <xsl:text>, </xsl:text>
    </xsl:when>
    <xsl:otherwise>
    <xsl:text>interface </xsl:text>
    </xsl:otherwise>
    </xsl:choose>
    <span>
    <xsl:apply-templates select="." mode="class.attribute"/>
    <xsl:apply-templates mode="java"/>
    </span>
    </xsl:template>

     
  • Mauritz Jeanson

    Mauritz Jeanson - 2009-05-12

    The patch submitted on 2009-04-09 does not help when used on the classsynopsis example:

    <classsynopsis language="java">
    <ooclass>
    <modifier>public</modifier>
    <classname>TestClass</classname>
    </ooclass>
    </classsynopsis>

    Here I would expect the output to be:

    public class TestClass {
    }

    But what I get is:

    public
    TestClass
    {
    }

    The "class" keyword is not generated.

    I also tried the interface example:

    <classsynopsis class="interface" language="java">
    <oointerface>
    <modifier>public</modifier>
    <interfacename>TestInterface</interfacename>
    </oointerface>
    </classsynopsis>

    The output from this is:

    interface
    public
    TestInterface
    {
    }

    Here, "interface" should come after "public".

     
  • Mauritz Jeanson

    Mauritz Jeanson - 2009-05-14

    It would be nice if the whitespace handling could be improved. I think there are too many line breaks in the generated output.

    BTW, the third example that I provided as a follow-up to the original bug report seems a little confused. What does it mean, if anything, to have <ooexception> as a following-sibling of <oointerface>?

     

Log in to post a comment.