如何在 Eclipse 中的同一文件中为 2 个单独的类创建 javadoc

发布于 2024-12-27 13:21:22 字数 211 浏览 2 评论 0原文

我有一个包含 2 个类的短文件,我不想将它们放在单独的文件中。如何为列出这两个类的文件创建 javadoc?现在,当我生成 javadoc 时,它会忽略第二类。 我尝试放入

@see class2Name 

第一堂课的文档注释,但这只是创建了到第二堂课名称的非链接。 如果我的第二个类位于同一个文件中并且不是内部类,正确的方法是什么? 谢谢

I've a short file that comprises of 2 classes which I don't want to place in separate files. How can I create a javadoc for the file that lists both classes? Right now when I generate a javadoc it ignores the second class.
I tried placing

@see class2Name 

in the doc comments for the first class, but that simply created a non-link to the second class's name.
What is the proper approach if my second class is in the same file, and isn't an inner class?
Thanks

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

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

发布评论

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

评论(1

一人独醉 2025-01-03 13:21:22

您可以像任何其他类一样对第二个类进行 javadoc,并且应该为这两个类生成文档。如果您正在 Eclipse 中查看 Javadoc 视图,请确保链接到选择(带有 2 个箭头的按钮)并在每个类内部单击以查看其 javadoc,或者只需将鼠标悬停在类名称上。另外,请注意 {@link ExpertImpl},它允许您链接到第二个类的文档。

简单的例子:

/**
 * This is class one.
 * 
 * {@link ExpertImpl}
 * 
 * @author Me
 * 
 */
public class ClassOne {

}

/**
 * This is class two.
 * 
 * @author Me
 * 
 */
class ExpertImpl {

}

也就是说,这可能是一种个人偏好,但我建议不要将多个类放在同一个文件中。它使您的项目可读性较差,并使事情变得复杂,而没有提供任何真正的好处。您可能想尝试将非公共类放入其自己的文件中,或者将其嵌套在公共类中(如果有意义的话)。希望这有帮助。

You can javadoc the second class just like any other class, and documentation should be generated for both. If you are looking at the Javadoc view in Eclipse, make sure you link to selection (button with 2 arrows) and click inside each class to see its javadoc, or simply hover over the class name. Also, notice the {@link ExpertImpl}, which allows you to link to the second class' documentation.

Quick example:

/**
 * This is class one.
 * 
 * {@link ExpertImpl}
 * 
 * @author Me
 * 
 */
public class ClassOne {

}

/**
 * This is class two.
 * 
 * @author Me
 * 
 */
class ExpertImpl {

}

That said, it may be a personal preference, but I would recommend against putting more than one class in the same file. It makes your project less readable and complicates things without offering any real benefits. You may want to explore putting the non-public class in its own file, or nest it inside the public one, if it makes sense. Hope this helps.

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