Javadoc or Doxygen?

 Step 3. Doxygen and Ant.

In order to use Doxygen, we need an Ant task. There is already an Ant task written for Doxygen which you can download from here.
As always, since using Mac, when I downloaded the binaries and tried to use them, I got the ever famous error message :

java.lang.UnsupportedClassVersionError: Bad version number in .class file

 So, had to do download the source, compile, and jar it up. Copy this library to your projects folder. Next, lets start making changes to our build file.

3.a: Lets define the Doxygen task.

<taskdef name="doxygen" classname="org.doxygen.tools.DoxygenTask" classpath="lib/ant_doxygen.jar" />

3.b: To generate HTML documentation:

<doxygen configFilename="reports/Doxyfile">
<property name="INPUT" value="${srcdir}" />
<property name="RECURSIVE" value="yes" />
</doxygen>

3.c: Lets combine them in target and run:
 

<target name="generate-doxygen-docs">
<taskdef name="doxygen" classname="org.doxygen.tools.DoxygenTask"
classpath="lib/ant_doxygen.jar" />
<doxygen configFilename="reports/Doxyfile">
<property name="INPUT" value="${srcdir}" />
<property name="RECURSIVE" value="yes" />
</doxygen>
</target>

  [doxygen] Exec: /Applications/Doxygen.app reports/Doxyfile

BUILD FAILED
/CodeMetricsProject/build.xml:91: Doxygen not found on the PATH.

Total time: 7 seconds

3.d: So, to launch Doxygen not in the path.

we make change to the doxygen task as shown below:

<doxygen doxygenPath="/Applications/Doxygen.app/Contents/Resources/doxygen" configFilename="reports/Doxyfile">

Lets run the target again and see if it fixed things.Yes indeed.

generate-doxygen-docs:
  [doxygen] Exec: /Applications/Doxygen.app/Contents/Resources/doxygen reports/Doxyfile

BUILD SUCCESSFUL
Total time: 8 seconds

Subtitle: 
Javadoc or Doxygen
Article Type: 
How-to
0
Average: 4 (1 vote)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

gianfranco replied on Wed, 2008/09/10 - 10:07am

Hi Meera,

Thanks for your article, I always enjoy reading them...

I think javadoc is doing a good job and although Doxygen looks fine I wouldn't necessarily want to migrate to it.

It took some serious effort to convince people to document their code in javadoc in the first place.

Gian

Meera Subbarao replied on Wed, 2008/09/10 - 10:18am in response to: gianfranco

[quote=gianfranco]

Thanks,Gian. I appreciate your comments. If you had to convince your developers to document their code in Javadoc, than you definitely need Doxygen. They have to hardly remember any HTML tags at all. 

[/quote] Meera Subbarao

cfagan replied on Wed, 2008/09/10 - 4:36pm

If I remember correctly Doxygen supports Javadoc style comments. I've seen people run Doxygen over the JDK sources and come out with advanced documentation. It's a great tool even if you want to stay javadoc compatible.

Meera Subbarao replied on Wed, 2008/09/10 - 5:14pm in response to: cfagan

Yes indeed. If you already have Javadoc comments, you need nothing else.

Meera Subbarao

David Sills replied on Thu, 2008/09/11 - 5:58am

Obviously, I'm going to have to try Doxygen. This looks great! Thanks, Meera!

Meera Subbarao replied on Thu, 2008/09/11 - 7:05am in response to: davidsills

[quote=davidsills]Obviously, I'm going to have to try Doxygen. [/quote]

 Thanks, David. Give it a try and you will be surprised how easy it is to keep the technical documentation up-to date.

Meera Subbarao

Meera Subbarao replied on Thu, 2008/09/11 - 7:16am in response to:

[quote=pdrummond]

I blogged about this ages ago:

http://gushieblog.blogspot.com/2006/06/doxygen-versus-javadoc.html

[/quote]

Thanks for sharing the link, Paul. Interesting article.

Meera Subbarao

Philippe Lhoste replied on Fri, 2008/09/12 - 4:43am

I discovered Doxygen some years ago, and found it was a very valuable tool. I was so disappointed to see, later, that JavaDoc was so limited!

One advantage you don't seem to mention is that being HTML agnostic, it allows to output documentation in various formats like RTF, PDF or CHM.
One thing I like too is flexibility: you can use line comments as well as block comments, and even more, you don't have to put all documentation in the header of a method: you can document a function parameter directly where it is defined, Doxygen will extract the names from the code. I have seen way too often JavaDoc headers missing half of parameters (added later in the code) or referencing wrong variable names, either because they have changed or because of copy/paste of a header of another function, forgetting to update it!

PS: You have a typo: Dxoygen. :)

Meera Subbarao replied on Fri, 2008/09/12 - 5:48am in response to: philho

[quote=philho]

One advantage you don't seem to mention is that being HTML agnostic, it allows to output documentation in various formats like RTF, PDF or CHM.

PS: You have a typo: Dxoygen. :)

[/quote]

Yes, I am not sure how I missed writing about other formats. Thanks for sharing.

Corrected the one and only typo.

Meera Subbarao

Richard Kowalsky replied on Mon, 2008/09/29 - 7:58am

Thanks for the excellent article.  Tips like these go a long ways towards helping some of

us do a much more thorough job with our software development.  Keep up the good work!

;-)

jdoxy replied on Sat, 2008/11/29 - 9:26am

I am using a std. header we have set in our software division to work for C++ code and also for other documentation preperation.

We have a significant amount of Java code too. Since our priority is Docygen , recently I was trying to port written java code documentation to Doxygen.

However  I could  not prepare the html doxygen outputs correctly with the Java class headers we had. So I modified one or two headers, like the way we have done for C++ so that we would use one doc tool for both java and C++.  Now the java headeer works well work for Doxygen.

We have some guys who prefer Javadocs. So I was trying to use Javadocs with the new Java header I created (that works with Doxygen). But now I cannot produce the proper Javadoc html with that header.

So it seems that 100% javadoc working header comments does not work 100% with Doxygen and vise versa.

I cannot change the C++ std header style we use as that is our standard.

But I am trying hard to get this headers working in Javadocs.

Willing to post a sample header if someone here has any ideas.

 

Thanks

MP

 

sunrise1 replied on Fri, 2009/10/23 - 2:07am

We have some guys who prefer Javadocs. So I was trying to use Javadocs with the newnike shoes new Java header I created (that works with Doxygen). But now I cannot produce the proper Javadoc html with that header.

sunrise1 replied on Sun, 2009/10/25 - 8:50am

I've seen people run Doxygen over the JDK nike shoes chinasources and come out with advanced documentation. It's a great tool even if you want to stay javadoc compatible.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.