2

We have different Javadoc files for different 3rd party jars we use. We have to combine all of them into single Javadoc file to distribute with our product.

Is it possible to do that? Is there any tools available?

Atleast is there any tool where i input .class files related to one jar and javadoc for that jar and it generates the .java (source code) files with the documentation as well, so that i can combine these sources and generate the javadoc for all teh libraries in single shot?

Any pointer will greatly help me.

Syam
  • 1,202
  • 11
  • 23
  • If you already have the Javadocs and the jars for the libraries, why do you need to generate the sources? Also if you need the sources why not download them? – Matti Lyra Jul 18 '12 at 07:12
  • My utimate aim is to generate single javadoc.zip file which contains all the thirdparty libraries api merged. I thought atleast i can reverse engineer to create code with comments for all of them and generate the javadoc in single shot. – Syam Jul 18 '12 at 07:16
  • Dó the packages overlap between the individual javadoc archives? – Thorbjørn Ravn Andersen Jul 18 '12 at 07:41
  • @ Thorbjørn Ravn Andersen: Can you please eloborate little more – Syam Jul 18 '12 at 07:51
  • @Thorbjørn Ravn Andersen no I think the problem is that the general HTML files (frames, link trees etc.) overlap since they always have the same names for each docs package. – Matti Lyra Jul 18 '12 at 09:49

3 Answers3

2

I wanted to do the same and this question encouraged me to go further.

I found a solution that worked for me:

  1. Decompile all your class files to have compilable source files. There are several decompilers available (see this question). I first tried Java Decompiler but it produced too many syntax errors. I did it in Procyon then, which only produced 2 errors in guessed parameter names (on ~5000 classes):

    java -jar procyon-decompiler-0.5.26.jar -o src [jarfile.jar]
    
  2. Generate the javadoc for those decompiled classes:

    javadoc -sourcepath src -d javadoc -subpackages com
    

    This essentially produces garbage documentation since you don't have javadoc in your source files. However the index files are correct!

  3. Replace the package javadoc folders by the corresponding folders in your available javadoc. For me this meant the com folder.

Community
  • 1
  • 1
Didier L
  • 18,905
  • 10
  • 61
  • 103
0

You can combine them by unpacking them all into the same directory and packing them all again.

You can get de-compilers which turn .class into .java file but I don't know of any which will combine javadocs. You may have to do that manually if its important to you.

I would have thought distributing source for 3rd party libraries without their permission is a bad idea.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • 2
    if you unpack them all to single directory, there are so many files like index.html, overview-summary.html etc will override with each other. The reason i was looking for decompiler (with javadoc comments) is not to distribute the 3rd party library sources but atleast that way i can merge the generated sources and create single javadoc for entire sources in single shot. – Syam Jul 18 '12 at 07:22
  • I see what you are saying. I don't know a way to do this automatically. – Peter Lawrey Jul 18 '12 at 07:32
0

I think you're best bet is to download the sources for all three libraries, get all the sources into one IDE projcet (NetBeans, Eclipse ...) and then generate the docs from there. Decompiling the .class files and then combining them with the java docs seems like a bad idea. Since the javadocs are generated from the sources anyway combining all three projects should work the easiest. That said it'll probably be a fair bit of work.

The other option is to take out the relevant bits (folders) from the two libraries and copy them into the root of the third (having first unpacked the javadocs jar). For instance the Java 6 SE these folders would be java,javax and org. These contain the actual documentation files, all the rest is just links and frames and other html plumbing. From there you can make a script that goes through the class hierarchies of the two other libraries and adds them to the html plumbing of the third library. This though will be much more work than just regenerating the docs from the combined sources.

Matti Lyra
  • 12,828
  • 8
  • 49
  • 67