Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javadoc {@inheritDoc} tag class

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?

like image 859
LandonSchropp Avatar asked Jan 29 '10 20:01

LandonSchropp


People also ask

What is {@ Inheritdoc?

The @inheritdoc tag indicates that a symbol should inherit its documentation from its parent class. Any other tags that you include in the JSDoc comment will be ignored. This tag is provided for compatibility with Closure Compiler.

Should I use Inheritdoc?

You should only use @inheritDoc if you intend to add to the original superclass documentation. If you merely want it to be duplicated, Javadoc will do that already, noting that the superclass documentation applies to the subclass's overridden method because the subclass provided no additional documentation.

How do you write Javadoc comments for a class?

Writing Javadoc Comments In general, Javadoc comments are any multi-line comments (" /** ... */ ") that are placed before class, field, or method declarations. They must begin with a slash and two stars, and they can include special tags to describe characteristics like method parameters or return values.

How do you inherit javadocs?

use {@inheritdoc} explicitly states that comments should be inherited. javadoc documentation : "insert the {@inheritdoc} inline tag in a method main description or @return , @param , or @throws tag comment. the corresponding inherited main description or tag comment is copied into that spot."


1 Answers

What you are describing is not supported by the javadoc generation tool.

And I think that there is a good reason for 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.

like image 79
bguiz Avatar answered Sep 28 '22 09:09

bguiz