Javadoc {@inheritDoc} 标签类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2165008/
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
Javadoc {@inheritDoc} tag class
提问by LandonSchropp
I would like to use the {@inheritDoc}
class to inherit methods from my abstract class. In the documentation for the abstract class, I refer to the abstract class by name. How can I tag this so when the subclass inherits the documentation from the super class, it replaces the abstract class's name with the subclass's name?
我想使用{@inheritDoc}
该类从我的抽象类继承方法。在抽象类的文档中,我按名称引用了抽象类。我如何标记它,以便当子类从超类继承文档时,它将抽象类的名称替换为子类的名称?
采纳答案by bguiz
What you are describing is not supported by the javadoc generation tool.
javadoc 生成工具不支持您所描述的内容。
And I think that there is a good reasonfor this too:
而且我认为这样做也是有充分理由的:
If your method in the subclass is merely an implementation of an abstract method, then I think it would be correct to leave the abstract class' name in there.
如果您在子类中的方法只是抽象方法的实现,那么我认为将抽象类的名称留在那里是正确的。
On the flip side, if your method in the subclass is not just a simple implementation, and does something more that is noteworthy (enough to be mentioned in the javadoc), then you should write a new javadoc on the method in the subclass, instead of invoking inheritDoc.
另一方面,如果您在子类中的方法不仅仅是一个简单的实现,而且还做了一些值得注意的事情(足以在 javadoc 中提到),那么您应该在子类中的方法上编写一个新的 javadoc,而不是调用inheritDoc。
回答by trashgod
I'm not aware of a way, but you might elaborate on why you want {@inheritDoc}
to do this. I may misunderstand, but it seems confusing. You can document how your concrete implementation varies form the parent and use @see
to refer to the contract in the abstract class. Note "Automatic Copying of Method Comments"may obviate the need for an explicit {@inheritDoc}
.
我不知道有什么方法,但您可能会详细说明为什么{@inheritDoc}
要这样做。我可能会误解,但它似乎令人困惑。您可以记录您的具体实现如何从父级变化,并用于@see
引用抽象类中的契约。注意“方法注释的自动复制”可能不需要明确的{@inheritDoc}
。
回答by Ti Strga
You can also, IIRC, write additional text around the {@inheritDoc}
tag in your own comments.
IIRC,您还可以{@inheritDoc}
在自己的评论中围绕标签编写其他文本。