Javadoc: package.html or package-info.java

本秂侑毒 提交于 2019-11-26 17:53:31

问题


When trying to create package level Javadoc comments, whats the preferred method? What do you do?

package-info.java

  • Pros
    • Newer
  • Cons
    • Abuse of a class - Classes are for code, not for only comments

package.html

  • Pros
    • HTML extension means its not code
    • Syntax highlighting in IDE's/text editors
  • Cons
    • None?

For me, I've always used Package.html. But I'm wondering if its the correct choice.


回答1:


package-info.java: "This file is new in JDK 5.0, and is preferred over package.html."—javadoc - The Java API Documentation Generator

Addendum: The big difference seems to be package annotations. There's a little more in the way of rationale in 7.4 Package Declarations.

Addendum: The annotation feature is also mentioned here and here.

Addendum: See also What’s package-info.java for?.



来源:https://stackoverflow.com/questions/3644726/javadoc-package-html-or-package-info-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!