FlexBuilder: generating documentation

Has anyone tryed to document ActionScript code using asdoc? I for myself hate to input shell commands in Windoze. I used to be a unix – bash hacker (in another life), and i find particularly annoying the windows shell (don’t even talk about the one in Vista..).

So i said to my good old friend Google: how can i use ant (which can be used in eclipse) to generate documentation with some clicks?

The answer lies around and need a few hacks, I post here my version for the sake of clarity.

I won’t tell you how to install ANT in Eclipse / Flex Builder using the Software Update tool, this may offend you.

Instead i’ll tell you that once setup is done, you need to upen the Ant view and you need an xml named build.xml with some rules in it, that tells which program to run, in which folder to save the output and so on. The xml is pretty self explaining, but in case just drop a line.

<?xml version="1.0" encoding="UTF-8"?>
<project name="asdoc" default="main" basedir=".">

    <property name="Flex.dir" location="C:\Program Files\Adobe\Flex Builder 3"/>

    <property name="FlexSDK.dir" location="${Flex.dir}\sdks\3.2.0"/>

    <property name="AsDocs.dir" location="${FlexSDK.dir}\bin\asdoc.exe"/>

    <property name="AppClasses.dir" location="${basedir}\..\src"/>

    <property name="Output.dir" location="${basedir}\out" />

    <target name="main" depends="clean,compile" description="full build of asdocs"/>

    <target name="clean">
        <delete dir="${Output.dir}" failOnError="false" includeEmptyDirs="true"/>
        <mkdir dir="${Output.dir}"/>
    </target>

    <target name="compile">
        <exec executable="${AsDocs.dir}" failonerror="true">
            <arg line='+configname=air'/>
            <arg line='-doc-sources ${AppClasses.dir}'/>
            <arg line='-window-title "My Application"'/>
            <arg line='-output ${Output.dir}'/>
        </exec>
    </target>

</project>

Note that the paths are relative to the position of the build.xml file.
(Also, i didn’t build the xml from scratch, there are many version of the same file on many blogs, so if the one who wrote it shows up, it will be an honor to credit him)

Flexbuilder & SVN

In real life, projects need to be kept under control, specially when you work on a team. I usually use subversion, and the TortoiseSVN client for Windows, which I kinda like. But using flex, which is a port of eclipse, I didn’t see a reason why not to use the eclipe svn plugin.

To install subclipse fon Flex just follow these instructions. Remember that you also need to have SVNKit installed.

It’s really easy to use, all options you need are in the Team menu, in the right click over the project list.

Thanks to Samuele for the support with eclipse.