When I use {@inheritDoc}
in Eclipse, the superclass' javadoc comments are not appearing in my class' javadoc.
I have the following piece of code:
import javax.swing.table.AbstractTableModel;
public class TestTableModel extends AbstractTableModel {
/**
* {@inheritDoc}
*/
@Override
public int getRowCount() {
return 1;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
return null;
}
@Override
public int getColumnCount() {
return 0;
}
}
I make sure that rt.jar
library (which contains javax.swing.table.AbstractTableModel
) has source code and javadoc locations set, and indeed when I hover over getRowCount()
I get the AbstractTableModel
javadoc in a tool tip. When I generate the javadoc from Eclipse, I make sure that in the "referenced archives and projects" section that rt.jar
is selected. But the inherit doc does not work.
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."
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.
javadoc documentation : "the javadoc command allows method comment inheritance in classes and interfaces to fill in missing text or to explicitly inherit method comments." use {@inheritdoc} explicitly states that comments should be inherited.
When hovering over methods that override a parent method, the descriptions for @param tags in the parent's Javadoc are not inherited, which does not match the Javadoc tool's HTML output. Hover over the foo method name in Bar to see the Javadoc.
To inherit from a class, use the extends keyword. In the example below, the Car class (subclass) inherits the attributes and methods from the Vehicle class (superclass):
Java Inheritance (Subclass and Superclass) In Java, it is possible to inherit attributes and methods from one class to another. We group the "inheritance concept" into two categories: subclass (child) - the class that inherits from another class; superclass (parent) - the class being inherited from; To inherit from a class, use the extends keyword.
It looks like the superclass's source (in this case AbstractTableModel.java) must be on the sourcepath of javadoc. This is done in Eclipse by creating a project for AbstractTableModel and selecting it in the "Select types for which Javadoc will be generated" selection during javadoc generation.
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