How to make javadoc tool include method comments from superclass or interface?

Viewed 32

I know this question has been asked before here, but without much of an answer, let alone a green tick mark. So: how do I get the javadoc tool to use the method comments from the superclass or interface if you do not document the method you override or implement yourself?

For example, when I create a class implementing java.util.List, and I implement the isEmpty() method without adding any javadoc myself, I expect the javadoc tool to magically do it for me: "Returns true if this list contains no elements."

The documentation states: The standard doclet allows method comment inheritance in classes and interfaces to fill in missing text or to explicitly inherit method comments.

And it then goes on to say: Note: The source file for an inherited method must be on the path specified by the -sourcepath option for the documentation comment to be available to copy.

I downloaded the JDK-18 source (src.zip) and unzipped it to /home/me/jdk18-src. Since I could not get IntelliJ to generate the javadoc I was after, I created and ran this script:

#!/bin/bash
javadoc \
    -sourcepath /home/me/git-repos/my-own-app/src/main/java/:/home/me/jdk18-src/java.base \
    -d /home/me/my-own-app/docs/api/ \
    -protected \
    com.foo.bar

(My com.foo.bar module happens to only depend on java.base.)

But whatever slight variant and permutation of the above I tried ... no success. Anyone ever wanted this and succeeded?

Please, do not respond with {@inheritDoc} stuff. Read the documentation (link above).

0 Answers
Related