如果我在JavaDocs中使用<br/>,有人会杀了我吗?

时间:2017-07-18 12:53:52

标签: java comments javadoc

我最近开始编写Java代码,我经常看到用于分隔行的单个<p>标记。但就我的目的而言,我实际上并不想制作“段落”,而只是制作换行符,所以读取文档并不会那么糟糕。 <br>代码是否可以容忍?

最后,我想出了适合该项目的3种风格的文档。我会被杀的是什么?

  • 在代码中看起来不错,在文档查看中看起来很糟糕

    /**
     * <p> Does highly important adorable things.      </p>
     * <p> Not only helping fields in being suitable
     *     for stack overflowing, but also loves cats. </p>
     * <p> Please do not call while there are
     *     some elephants in the main class.           </p>
     */
    
  • 在代码和文档查看中看起来很糟糕

    /**
     * Does highly important adorable things. <p>
     * Not only helping fields in being suitable
     * for stack overflowing, but also loves cats. <p>
     * Please do not call while there are
     * some elephants in the main class.
     */
    
  • 在代码和文档查看中看起来很好

    /**
     * Does highly important adorable things. <br>
     * Not only helping fields in being suitable
     * for stack overflowing, but also loves cats. <br>
     * Please do not call while there are
     * some elephants in the main class.
     */
    

1 个答案:

答案 0 :(得分:4)

也许更干净的选项是使用<pre></pre>(保持格式化):

/**
 * <pre>
 * Does highly important adorable things.
 * Not only helping fields in being suitable
 * for stack overflowing, but also loves cats.
 * Please do not call while there are
 * some elephants in the main class.
 * </pre>
 */