15

Consider that I am extending a class such as:

public class MyComboBox<T> extends JComboBox<T> {

    public MyComboBox() {
        super();
    }

    public MyComboBox(ComboBoxModel<T> model ) {
        super(model);
    }

}

Re-defining the parent's constructors (which are fitting for my new class, of course) is annoying enough, but to also copy each constructors documentation is even worse. Not to mention that it's bad for further inheritance, since I now have to update the documentation multiple times.

Obviously, {@inheritDoc} won't work as I am not overriding anything. This is, however, the behavior I'm looking for. Is there any way to achieve this?

How to inherit the parent constructors documentation?

Zar
  • 6,786
  • 8
  • 54
  • 76
  • Isn't parent class documentation used as default for subclass one ? – Riduidel Jan 18 '13 at 15:40
  • @Riduidel No, atleast not in Eclipse Juno + Java 7. It's not showing any documentation at all, using my example. – Zar Jan 18 '13 at 15:43
  • you talk about the "Javadoc view" of Eclipse ? – Riduidel Jan 18 '13 at 15:47
  • 1
    There isn't really a concept of 'parent' constructor. Constructors are not related between parent and child. Your `SUComboBox()` could very well call `super([some made up model])` instead of `super()`. – artbristol Jan 18 '13 at 15:48
  • 3
    Since you do have to invoke a __single__ superconstructor as the __first__ statement in the constructor, JavaDoc could provide a mechanism of identifying which constructor to inherit the doc from, and the IDE could automatically generate that identifier based on the first statement in the given constructor. – Zoltán May 13 '13 at 14:04

2 Answers2

3

Use the @see tag and put the class & member name. To see how that shows up look at JDocs where you can jump from javadoc to source code.

The exact syntax is:

 @see com.x.y.z.ClassName#methodName()
Henrique de Sousa
  • 5,727
  • 49
  • 55
Καrτhικ
  • 3,833
  • 2
  • 29
  • 42
  • Well, while this is somewhat what I am looking for, I still have to "click" to get to the parent's documentation. – Zar Jan 18 '13 at 15:59
  • @Zar - you really prefere copied content over linked content? – Patrick Sep 21 '15 at 08:53
  • 3
    @for3st No, you misunderstood me. I want the documentation to be inherited, i.e., displayed directly on the actual item, without clicking a `@see` or pasting it from the parent. The same way `@inheritDoc` works for methods. – Zar Sep 22 '15 at 19:59
  • Further, you can put constructor argument types in there: @see com.x.ClassName#ClassName (ClassOfArg1, ClassOfArg2) and variations. In 2022, the JDocs site seems to have been repurposed by some non-Java entity. – Alan Jan 21 '22 at 20:06
0

You can not override constructors, therefore there is no need to propagate javadocs. Just explain what the client of your object needs to know about how that particular constructor would contruct the object. If it just passes construction on to an extended object, then say just that.