In a prior posting, I talked about the pain point of creating SDK JavaDoc Help content for eclipse. It tends to get out of synch with the actual documentation, as the TOC.xml has to be maintained manually. I found a DocLet called JELDoclet that creates one or more XML files for the javadoc. With this created, one can do a little bit of XSLT to do the following:
- Create the HTML documentation for the class and package files, that are normally produced by the standard javadoc.
- Create the necessary Toc.xml file, that is used by the eclipse help system.
Since XSLT 1.0 doesn't include a group-by statement, and the Meunchian Grouping method can be confusing, I found this little piece of EXSLT magik by Oleg Tkachenko. Basically the code simulates a group-by clause. Here is the xslt that generates the toc.xml from the JEL xml file:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:set="http://exslt.org/sets"
xmlns:xalan="http://xml.apache.org/xalan"
exclude-result-prefixes="set"
>
<xsl:param name="sdkname">Some Name</xsl:param>
<xsl:param name="dir">doc/html</xsl:param>
<xsl:output indent="yes" encoding="UTF-8" xalan:indent-amount="3"/>
<xsl:key name="allPackages" match="jelclass" use="@package"/>
<xsl:template match="/jel">
<toc label="{$sdkname}">
<topic label="Reference">
<xsl:for-each select="set:distinct(jelclass/@package)">
<topic label="{.}">
<xsl:apply-templates select="key('allPackages', .)"/>
</topic>
</xsl:for-each>
</topic>
</toc>
</xsl:template>
<xsl:template match="jelclass">
<topic label="{@fulltype}" href="{$dir}/{@fulltype}.html"/>
</xsl:template>
</xsl:stylesheet>
Basically, the code reads the JEL xml file that contains all the java classes and their documentation, and groups all the packages together, it then processes each package and creates the necessary topic entries for each class in the toc.xml file.
The above xslt runs on Xalan, and should run on the Sun version of Xalan as well. The javadoc doclet steps, the html generation, and the toc.xml generation steps can be included in an Ant build script. This allows for the SDK JavaDoc Documentation to be generated automatically everytime a build is done. If a new class or package is included, that new class and it's corresponding documentation will be included as well. The same options that you have for the standard javadoc, are available with the jeldoclet, so you have the same level of control on what gets included and what doesn't.
No More Excuse for Outdated Documentation
[pulls out the soapbox]
Bug 231472 contains most of the work, except for the xslt above, but I'll get that added in a few days. As committers, it's our responsibility to the community to make sure they have the appropriate documentation. Not only so that they know how to use the classes we have created, but also for those people that need to come behind us and maintain the code that we provide. A couple of additional items that would be nice to do (PDE adds some checks to do some of these).
- Make sure all your classes both internal and public API have appropriate javadoc documentation.
- Automate the generation and upkeep of that documentation.
- Follow the JavaDoc best practices (Something that we in the XSL Tools project need to correct).
- Run the JavaDoc DocCheck doclet against your java source. It will provide a nice report telling you what is missing in the way of javadoc documentation.

0 comments:
Post a Comment