Reputation: 1020
I'm using Netbeans (currently 6.7) and I really like how I can generate javadoc from my source code. However my tests also have documentation (valuable documentation!). Is there anyway I can generate javadocs (ideally for both at the same time).
Thanks!
Upvotes: 3
Views: 2482
Reputation: 9526
Adding the following Ant target to build.xml does the trick for me:
<target depends="init" name="-javadoc-build">
<javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
<classpath>
<path path="${javac.classpath}:${javac.test.classpath}"/>
</classpath>
<fileset dir="${test.src.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="src/try" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
<include name="**/*.java"/>
<exclude name="*.java"/>
</fileset>
</javadoc>
<copy todir="${dist.javadoc.dir}">
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
<filename name="**/doc-files/**"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
<include name="**/doc-files/**"/>
</fileset>
</copy>
</target>
It's copied from nbproject/build-impl.xml with three changes:
classpath
to "${javac.classpath}:${javac.test.classpath}"
fileset
element with dir="${test.src.dir}"
there are the normal netbeans "Test Packages"fileset
element with dir="src/try"
this is and extra source directory that my project uses. (I don't know how to use a variable like ${test.src.dir} to refer to this directory.)Upvotes: 1
Reputation: 9526
In Build-impl.xml there is a target named "-javadoc-build". It contains two "fileset" sections. Perhaps its possible to add a third section here.
Upvotes: 0
Reputation: 24049
JUnit tests are productive, normal Java Code. They may contain normal JavaDoc comments.
Why don't you treat them like normal Java Code? Just run javadoc
over this package and you're done.
You can generate your JavaDoc via the Build Menu.
Good luck!
Upvotes: 2