Similar to javadoc, ajdoc renders HTML documentation for pointcuts, advice, and inter-type declarations, as well as the Java constructs that Javadoc renders. ajdoc also links advice from members affected by the advice and the inter-type declaration for members declared from aspects. The aspect will be fully documented, as will your target classes, including links to any advice or declarations that affect the class. That means, for example, that you can see everything affecting a method when reading the documentation for the method.
To run ajdoc, use one of the scripts in the AspectJ bin directory. The ajdoc implementation builds on Sun's javadoc command line tool, and you use it in the same way with many of the same options (javadoc options are not documented here; for more information on javadoc usage, see the Javadoc homepage.)
As with ajc (but unlike javadoc), you pass ajdoc all your aspect source files and any files containing types affected by the aspects; it's often easiest to just pass all the .java files in your system. Unlike ajc, ajdoc will try to find package sources using the specified sourcepath if you list packages on the command line.
To provide an argfile listing the source files, you can use use the same argfile (@filename) conventions as with ajc. For example, the following documents all the source files listed in argfile.lst, sending the output to the docDir output directory.
ajdoc -d docDir @argfile.lstSee the ajc documentation for details on the text file format.
ajdoc currently requires the tools.jar from J2SE 1.3 to be on the classpath. Normally the scripts set this up, assuming that your JAVA_HOME variable points to an appropriate installation of Java. You may need to provide this jar when using a different version of Java or a JRE.
ajdoc documents advice and pointcut members, shows where advice applies and links affected members back to the advice. It currently does not document or add structural links for any inter-type declarations or other declare forms.
Example 4. Documenting Spacewar
Type mkdir doc to create the destination directory for the documentation.
Type ajdoc -private -d doc spacewar coordination to generate the documentation.
Type ajdoc -private -d doc @spacewar/demo.lst to use the argfile associated with Spacewar.
To view the documentation, open the file index.html in the doc directory using a web browser.