我如何在 Java 中记录包?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/624422/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 17:04:52  来源:igfitidea点击:

How Do I Document Packages in Java?

javapackagesjavadoc

提问by jjnguy

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

在 Java API 中,我可以看到包的 Javadoc 注释。

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

如何/在哪里放置 Javadoc 注释来记录包?

采纳答案by Gareth Davis

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

从 1.5 开始,您可以定义package-info.java文件并为包提供标准的 javadoc 样式注释:

com/foo/package-info.java:

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

包的语言规范

回答by oxbow_lakes

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

使用package.html包级别的文件(即在该包的目录中)。这应该是一个完整的HTML文件,其中<html>定义了标签

回答by sleske

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

直到并包括 Java 1.4,您必须提供一个 HTML 文件 package.html,如其他答案中所述。

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).

从 Java 1.5 开始,您还可以提供package-info.java,其中包含常规 Javadoc 注释(无 HTML)。后者是首选,因为它为您提供了一些额外的功能(特别是包注释)。

Details: Sun's docs for javadoc

详细信息: Sun 的 javadoc 文档