TopicMapDoclet

The class org.tm4j.topicmap.utils.TopicMapDoclet implements the Doclet interface used by Javadoc for creating java code documentation. The TopicMapDoclet can be used to create a topic map from java source code.

Note

At the time of writing, the TopicMapDoclet is not yet complete. The topic map output contains many of the relationships between classes, interfaces, packages and methods exposed by the JavaDoc tool, but not all. However, the output is sufficient to create a usable topic map of your Java code!

Invoking the TopicMapDoclet

The TopicMapDoclet is invoked from the Javadoc command line as any other standard Doclet, using the -doclet and -docletpath commandline parameters. (see Sun's Javadoc documentation for more information).

The TopicMapDoclet expects an additional 2 parameters:

-out
The name of the XTM file to be written to. This file will be replaced if it already exists or created if it does not exist.
-baseuri
A URI which will be used as the base resource address of the generated topic map. In most cases, the URI you specify here is not important.

The TopicMapDoclet can also be invoked from within an Ant build script using the standard javadoc task. The following Ant target is copied from the build.xml shipped with the source distribution of TM4J which creates the topic map for the TM4J source code.

Example 7.3. Invoking the TopicMapDoclet from Ant

  <target name="doc-map">
    <description>
      Uses org.tm4j.topicmap.utils.TopicMapDoclet to generate an XTM file of
      the source code (via Javadoc).
    </description>
    <javadoc maxmemory="128M"
      sourcepath="src"
      classpathref="project.class.path"
      packagenames="${api.doc.packages}"
      doclet="org.tm4j.topicmap.utils.TopicMapDoclet"
      docletpathref="project.class.path"
      additionalparam="-out tm4j-doc.xtm 
                       -baseuri http://tm4j.org/topicmaps/tm4j-doc.xtm"
      failonerror="yes"/>
  </target>