How to create multiple levels of indentation in Javadoc?

后端 未结 3 1871
陌清茗
陌清茗 2021-02-01 11:43

Suppose, that as part of documenting your code (Javadoc) you want to indicate that the relationships between elements using deep indentation.

How can I create a nested

相关标签:
3条回答
  • 2021-02-01 12:07

    The nested list should be within its own <li>. <ul> is not a valid child element of <ul>.

    So your example would be:

    <ul>
      <li>some element</li>
      <li>
        <ul>
          <li>some other element</li>
          <li>
            <ul>
              <li>yet some other element</li>
            </ul>
          </li>
        </ul>
      </li>
    </ul>
    
    0 讨论(0)
  • 2021-02-01 12:16

    The correct way is as follows:

    /**
     * <ul>
     *   <li>some element
     *   <li><ul>
     *     <li>some other element
     *     <li><ul>
     *       <li>yet some other element
     *     </ul>
     *   </ul>
     * </ul>
     */
    

    Although JavaDoc borrows from HTML, it isn't HTML, and you should omit the </li> tags, just as you should omit </p> tags.

    0 讨论(0)
  • 2021-02-01 12:27
    <ul>
      <li>Element</li>
      <ul>
         <li>Subelement...</li>
    

    You can pretty freely use HTML inside javadoc comments.

    Update: Because it came up, I tried

    <ul>
        <li>one</li>
        <ul>
            <li>one point one</li>
        </ul>   
    </ul>
    

    and get

    • one
      • one point one

    I agree proper nesting is better.

    0 讨论(0)
提交回复
热议问题