A method that overrides another method does not inherit documentation of the method it is overriding. Is there any way to explicitly tell it to inherit the documentation?
/**
* {@inheritDoc}
*
* This implementation uses a dynamic programming approach.
*/
@Override
public int[] a(int b) {
return null;
}
Yes. If you don't have javadoc comments on a subclass, javadocs will be be generated based on the superclasses javadoc.
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.
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.
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."
According to the javadoc documentation:
Inheriting of comments occurs in all three possible cases of inheritance from classes and interfaces:
- When a method in a class overrides a method in a superclass
- When a method in an interface overrides a method in a superinterface
- When a method in a class implements a method in an interface
Comments can be explicitly inherited using the {@inheritDoc} tag. If no comments are provided for an overriding method, comments will be implicitly inherited. Aspects of the inheriting comments (e.g. params, return value, etc.) can be overridden if you so desire.
Importantly, you need to make sure that the source file containing the code with the comment to be inherited is available to the javadoc tool. You can do this by using the -sourcepath option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With