上面的Javadoc评论包裹声明有什么作用?

发布于 2025-02-07 11:24:45 字数 241 浏览 2 评论 0原文

当我在Eclipse中创建新类并检查“生成评论”时,我会明白:

/**
 *
 */
package my_package;

/**
 * @author myname
 *
 */
public class MyClass {

}

评论上方的评论声明是什么意义?当我生成Javadocs时,它似乎并不包含在任何地方(如果我放在那里)。它只是日食失火,还是我拥有的怪异日食设置,还是在那里是有原因的?

When I create a new class in Eclipse and check "Generate comments", I get this:

/**
 *
 */
package my_package;

/**
 * @author myname
 *
 */
public class MyClass {

}

What's the point of the comment above the package declaration? It doesn't seem to be included anywhere (if I put something there) when I generate javadocs. Is it just Eclipse misfiring, or a weird Eclipse setting I have, or is it there for a reason?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

染火枫林 2025-02-14 11:24:45

<

文档评论是用html编写的,必须在类,字段之前,
构造函数或方法声明

package-level评论放置在名为package> package-info.java的文件中,该文件用于生成文档,例如软件包java.time

尝试在常规源文件中包含软件包级注释似乎是一个错误。 docs state'> docs state'您可以将您的评论放在其中一个以下文件...” 。 Intellij还显示了在常规源文件中放置包级评论时的警告“悬挂式Javadoc评论”。

From Oracle

A doc comment is written in HTML and must precede a class, field,
constructor or method declaration

There are also package-level comments which are placed in a file called package-info.java, which are used for generating documentation such as for the package java.time.

Trying to include a package-level comment in a regular source file seems like a bug. The docs state "you can place your comments in one of the following files...". IntelliJ also shows the warning "Dangling Javadoc comment" when package-level comments are placed in a regular source file.

音盲 2025-02-14 11:24:45

对我来说,上面生成的评论是由于偏好设置:

​不是我出现的。

此外,如果我编辑文件注释,则每当我生成注释时,文件级别注释都不会出现。

For me, The comments generated above package are because of preference settings:

enter image description here

If I un-check Automatically add comments for new methods, types, modules ,packages and files, it is not appearing for me.

Moreover, if I edit Files comments, then File level comments are not appearing whenever I generate comments.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文