How Do I Document Packages in Java?

烈酒焚心 提交于 2019-11-26 18:54:42

问题


In the Java APIs I can see Javadoc comments for packages.

How/where do I place Javadoc comments to document a package?


回答1:


As of 1.5 you can define a package-info.java file and provide a standard javadoc style comment for a package:

com/foo/package-info.java:

/**
 * com.foo is a group of bar utils for operating on foo things.
 */
package com.foo;

//rest of the file is empty

Language specification for packages




回答2:


Up to and including Java 1.4, you had to provide a HTML file package.html, as described in the other answers.

Since Java 1.5 you can also provide a package-info.java, which contains a regular Javadoc comment (no HTML). The latter is preferred, as it gives you some extra features (notably package annotations).

Details: Sun's docs for javadoc




回答3:


With a package.html file at the package level (i.e. in the directory for that package). This should be a fully-formed HTML file, with the <html> tag defined in it



来源:https://stackoverflow.com/questions/624422/how-do-i-document-packages-in-java

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