Javadoc:package.html 或 package-info.java
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3644726/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Javadoc: package.html or package-info.java
提问by TheLQ
When trying to create package level Javadoc comments, whats the preferred method? What do you do?
尝试创建包级 Javadoc 注释时,首选方法是什么?你做什么工作?
package-info.java
包信息.java
- Pros
- Newer
- Cons
- Abuse of a class - Classes are for code, not for only comments
- 优点
- 较新
- 缺点
- 滥用类 - 类用于代码,而不仅仅是用于注释
package.html
包.html
- Pros
- HTML extension means its not code
- Syntax highlighting in IDE's/text editors
- Cons
- None?
- 优点
- HTML 扩展意味着它不是代码
- IDE/文本编辑器中的语法高亮
- 缺点
- 没有任何?
For me, I've always used Package.html. But I'm wondering if its the correct choice.
对我来说,我一直使用 Package.html。但我想知道它是否是正确的选择。
采纳答案by trashgod
package-info.java
: "This file is new in JDK 5.0, and is preferred over package.html."—javadoc - The Java API Documentation Generator
package-info.java
:“此文件是 JDK 5.0 中的新文件,优先于 package.html。”— javadoc - Java API 文档生成器
Addendum: The big difference seems to be package annotations. There's a little more in the way of rationale in 7.4 Package Declarations.
附录:最大的区别似乎是包注释。在7.4 Package Declarations 中还有一些基本原理。
Addendum: The annotation feature is also mentioned hereand here.
Addendum: See also What's package-info.java
for?.
附录:另请参阅是什么package-info.java
?.