16 Mar 2009

ASDoc with Ant in Eclipse

Filed under: Playground | Taged as: , , | 0 comments

The Flex SDK offers a commandline interface for automatically generating documentation. With ASDoc you can easily create a HTML based documentation for your ActionScript projects and libraries if the code follows the doc style documentation standard. By adding an Ant script to the ActionScript, Flex or Air project in Eclipse, this task can be simplyfied and automated.

The following Ant script shows an example configuration for a task running on Windows. There are a few things that have to be considered:

  • ASDoc does not recognize the AIR libraries (the airframework.swc and airglobal.swc files) automatically. To make the tool find the classes they have to be added with the -library-path option.
  • To run the task on Windows, the executable path must link to the asdoc.exe executable in the SDK directory.
  • The documentation can be customized with the -package, -footer, -main-title and -window-title option
<?xml version="1.0"?>
<project name="ASDoc" default="asdoc">
    <!-- configuration settings -->
    <property name="FLEX" value="pathtosdk"/>
    <property name="TEMPLATES" value="${FLEX}\asdoctemplates"/>
    <property name="PROJECT_DIR" value="pathtoproject"/>
    <property name="LIB" value="${PROJECT_DIR}libs"/>
    <property name="DOC_SOURCE" value="${PROJECT_DIR}\srcfordocumentation"/>
    <property name="OUTPUT" value="${PROJECT_DIR}\docs"/>
        <!-- create as documentation and save in specified directory -->
    <target name="asdoc">
            <!-- clear target directory -->
            <delete includeemptydirs="true">
                <fileset dir="${OUTPUT}" includes="***" />
            </delete>
            <!-- execute asdoc -->
            <exec executable='${FLEX}\binasdoc.exe' os='Windows XP'>
                <!-- add template path -->
        <arg line='-templates-path ${TEMPLATES}'/>
        <!-- add libraries for flex and air -->
        <arg line='-library-path ${FLEX}\frameworks\libs'/>
        <arg line='-library-path ${FLEX}\frameworks\libs\air'/>
        <arg line='-library-path ${LIB}'/>
        <!-- add source path -->
        <arg line='-source-path ${PROJECT_DIR}\src'/>
        <arg line='-doc-sources ${DOC_SOURCE}'/>
        <!-- add descriptions -->
        <arg line='-package your.package.here "Some description"'/>
        <arg line='-footer "Some footer text"'/>
        <arg line='-main-title "Main title"'/>
        <arg line='-window-title "Window title"'/>
        <!-- add output directory -->
        <arg line='-output ${OUTPUT}'/>
            </exec>
        </target>
</project>

More information on Ant tasks and Eclipse.

Related posts

Share and Enjoy:

  • RSS
  • Digg
  • del.icio.us
  • Google Bookmarks
  • FriendFeed
  • MisterWong
  • StumbleUpon
  • Technorati
  • Twitter
  • NewsVine

Leave a Reply