JavaDoc 中 @see 的用法?
处理 JavaDocs 时什么时候使用 @see
?它的用途是什么?
例如,如果 MethodA
调用 MethodB
那么我是否必须将 @see
放入 MethodB
的 javadoc 并引用 < code>MethodA 因为这就是调用它的方法,或者我是否必须从 MethodA
引用 MethodB
因为它正在调用它。我在 Oracle 网站上读过有关 @see
的内容,在我看来,它非常模糊,它表示“另请参阅”,但实际上并不是什么意思!
When do I use @see
when dealing with JavaDocs? What is its usage?
For example if MethodA
calls MethodB
then do I have to put @see
in MethodB
's javadoc and reference MethodA
because that is what called it, or do I have to put a reference to MethodB
from MethodA
because it's calling it. I've read the stuff about @see
on the Oracle website and it seems to me to be incredibly vague, it says it means "see also" but not really what that means!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
是的,这很模糊。
只要对您的方法文档的读者查看其他方法可能有用,您就应该使用它。如果你的 methodA 的文档说“与 methodB 类似,但是......”,那么你肯定应该添加一个链接。
@see
的替代方案是内联{@link ...}
标记:当 methodA 调用 methodB 的事实是一个实现细节并且与来自的方法没有真正的关系时在外面,您不需要此处的链接。
Yeah, it is quite vague.
You should use it whenever it may be useful for readers of the documentation of your method to also look at some other method. If the documentation of your methodA says "Works like methodB but ...", then you surely should put a link.
An alternative to
@see
would be the inline{@link ...}
tag:When the fact that methodA calls methodB is an implementation detail and there is no real relation from the outside, you don't need a link here.
@see
标记与@link
标记略有不同,在某些方面受到限制,而在其他方面则更加灵活。
以下示例来自 Eclipse:
不同的JavaDoc链接类型
The
@see
tag is a bit different than the@link
tag,limited in some ways and more flexible in others.
The following examples are from Eclipse:
Different JavaDoc link types
@see
items, commas in the description make the output confusingSee the results below:
JavaDoc generation results with different link types
Best regards.
@see 有用的一个很好的例子是实现或重写接口/抽象类方法。该声明将包含详细说明该方法的
javadoc
部分,并且重写/实现的方法可以使用@see
标记来引用基础标记。相关问题:
使用 @see 编写正确的 javadoc?
Java SE 文档:
@see
A good example of a situation when
@see
can be useful would be implementing or overriding an interface/abstract class method. The declaration would havejavadoc
section detailing the method and the overridden/implemented method could use a@see
tag, referring to the base one.Related question:
Writing proper javadoc with @see?
Java SE documentation:
@see
@see 对于有关 API 中相关方法/类的信息很有用。它将生成文档中引用的方法/代码的链接。当有相关代码可以帮助用户了解如何使用 API 时,请使用它。
@see is useful for information about related methods/classes in an API. It will produce a link to the referenced method/code on the documentation. Use it when there is related code that might help the user understand how to use the API.
我使用 @see 来注释接口实现类的方法,其中该方法的描述已在接口的 javadoc 中提供。当我们这样做时,我注意到 Eclipse 会提取接口的文档,即使我在代码完成期间查找实现参考上的方法也是如此
I use @see to annotate methods of an interface implementation class where the description of the method is already provided in the javadoc of the interface. When we do that I notice that Eclipse pulls up the interface's documentation even when I am looking up method on the implementation reference during code complete