views:

40

answers:

3

I have a java compiled library in a jar.for which i have written documentation in source code.There is one more tool which generates the jar ,it included only those classes which are required for target project.I have huge projects which make use of this jar,and only those classes should go in the target project. Now the problem I want to give documentation for the classes.is it possible to generate documentation from the compiled classes?

+2  A: 

No. The documentation (javadoc) is generated from the source (.java) files. All the comments/javadocs are lost after compilation.

The users of the library will only be able to use the autocomplete of their IDEs as some sort of documentation.

I can't see your script, but I assume you could apply the same logic to the generation of the javadoc as the one generating the jars.

Bozho
A: 

I suppose you should filter the comments of classes required for target projects, separately and combine with the sub-jar being created.

nils_gate
+1  A: 

There is no simple way to do what you want, but you could try the following approach:

  1. Extract the names of all .class files in your JAR, filtering out any with $ in their name and mapping the remainder to the original .java file names.

  2. Create a temporary directory tree containing copies of all of the .java files selected above.

  3. Run the javadoc command using the about tree as the sourcepath.

If you don't have too many files, you could skip the step of creating a directory tree and run the javadoc command with all .java file names as command arguments.

Either way, you will have some non-trivial scripting ... or equivalent Java ... to implement.

Stephen C