Search code examples
javaantjavadoc

Javadoc not generating comments for inherited methods


I am using Ant to create my documentation. I used {@inheritDoc} for methods such as equals, hashCode, and toString. However, no description shows up for these methods. See screenshot:

enter image description here

Here is my Ant script:

<project name="javadoc" default="javadoc.tool">
  <description>
    Provides JavaDoc. 
  </description>

  <import file="build.xml" />
  <property name="javadoc.dir" location="${build.dir}/javadoc" />
  <property name="javadoc.failonerror" value="false" />

  <target name="javadoc.tool" depends="compile" description="Generate JavaDoc.">
    <mkdir dir="${javadoc.dir}" />
    <javadoc classpathref="compile.classpath"
             sourcepath="${src.dir}"
             destdir="${javadoc.dir}"
             author="true"
             version="true"
             use="true"
             package="true"
             overview="${src.dir}/overview.html"
             windowtitle="${system.name} API"
             doctitle="${system.name} API"
             failonerror="${javadoc.failonerror}"
             excludepackagenames="junit"
             linksource="true" />
  </target>
</project>

How can I get descriptions for inherited methods to show up in the documentation? Your advice will be greatly appreciated. Thanks!


Solution

  • If you're trying to inherit the docs from the standard Java classes then you need to include JDK src.zip in the sourcepath, I think. (You may need to unzip it as well; I don't recall.)

    That said, if your methods to something "unexpected", you should write your own docs anyway. If they don't, IMO you don't really need the description for them.