详细说明“ see”和“继承文档”之间的区别

我已经查看了 JavaDoc 引用,虽然我理解了 @see(各种链接)和 {@inheritDoc}(导出超类 JavaDoc 注释)之间的基本区别,但是我需要澄清事情实际上是如何实现的。

在 Eclipse IDE 中,当我为继承的方法(从 interface 或 toString ()覆盖等)选择“ Generate Element Comments”时,它会创建以下注释

/* (non-Javadoc)
* @see SomeClass#someMethod()
*/

如果我被要求生成 JavaDoc,我应该把它放在那里,用 {@inheritDoc}替换 @see,或者像这样把它转换成 善意的 JavaDoc:

/**
* {@inheritDoc}
*/

当我这样做的时候,我还应该保留 class # method 标志吗?

95681 次浏览

First of all, you should remove the original eclipse template because it is just noisy junk. Either put meaningful docs in or don't put anything at all. But useless restating of the obvious using IDE templates just clutters the code.

Second, if you are required to produce javadoc, then you have to make the comment start with /**. Otherwise, it's not javadoc.

Lastly, if you are overriding then you should use @inheritDoc (assuming you want to add to the original docs, as @seh noted in a comment, if you just want to duplicate the original docs, then you don't need anything). @see should only really be used to reference other related methods.