Search code examples
javaeclipsehtml-tablecomments

Eclipse - How do I create a table in the comment section of class/method?


I want to use <\tbody>, <\tr> and <\td> to create a table in the comment section of a method :

<tbody>
<tr>
    <td>personId</td>
    <td>y</td>
    <td>identifiant</td>
    <td>C16</td>
    <td>String</td>
</tr>
<tr>
    <td>lastName</td>
    <td>n</td>
    <td>nom</td>
    <td>C32</td>
    <td>String</td>
</tr>
</tbody>

Unfortunately it doesn't work as I don't see a table in the Java doc, just the following :

personId y identifiant C16 String lastName n nom C32 String

What should I do ? The <\table> tag is not proposed by Eclipse and if I use it it doens't change anything. If it matters, I am using eclipse Neon.


Solution

  • First, you should specify the table element before tbody to be conform to the table element :

    Permitted content

    In this order:

    • an optional caption element,

    • zero or more colgroup elements,

    • an optional thead element,

    • either one of the following:

      • zero or more tbody elements

      • one or more tr elements

    • an optional tfoot element

    Second, you don't need Eclipse wizard or tool to document your Javadoc with HTML tags.
    Just write your HTML content in a javadoc comment :

    /**
    <table><tbody>
    <tr>
        <td>personId</td>
        <td>y</td>
        <td>identifiant</td>
        <td>C16</td>
        <td>String</td>
    </tr>
    <tr>
        <td>lastName</td>
        <td>n</td>
        <td>nom</td>
        <td>C32</td>
        <td>String</td>
    </tr>
    </tbody></table>
     */
    public void foo(){
      ...
    }
    

    And it should display it in a tabular way in the javadoc view or generation:

    void foo()

    personId y identifiant C16 String

    lastName n nom C32 String