ASDoc integration with build scripts

If you work in a team and use Flex, then you definitely use code written by other developers on your team. Wouldn’t it be nice to see the asdoc for their code the same way you see asdoc for the Flex SDK? Well now you no longer have to manually run asdoc, you can now leverage the <asdoc> ant task which is part of the Flex SDK.

The <asdoc> is available in the Flex 4 SDK only (not available in Flex 3). Nightly builds for the Flex 4 sdk can be downloaded from http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4

Here is an sample asdoc target that can be used in ant build file.

<target name="asdocgen">
		<!-- for svn users the flexTasks.jar is
			under <sdk root>/lib -->
		<available property="flexTasksJar"
			value="${sdk.dir}/lib/flexTasks.jar"
			file="${sdk.dir}/lib/flexTasks.jar"/>

		<!-- for sdk package (zip) the flexTasks.jar is
			under <sdk root>/ant/lib -->
		<available property="flexTasksJar"
			value="${sdk.dir}/ant/lib/flexTasks.jar"
			file="${sdk.dir}/ant/lib/flexTasks.jar"/>

	    <property name="FLEX_HOME" value="${sdk.dir}" />	

		<asdoc output="${output.folder}/asdoc-output"
			main-title="My asdoc main title"
			footer="<u>My custom footer.</u>"
			window-title="Custom asdoc documentation"
			left-frameset-width="300"
			failonerror="true" fork="true">

			<packages.package name="com.test"
				description="description for com.test" />

			<!-- top level class to include in asdoc.
				These should be in the source-path (src1, src2) -->
			<doc-classes class="com.test.CustomMain"/>
			<doc-classes class="com.test.Foo"/>

			<!-- generate asdoc for all as/mxml files in the doc-sources -->
			<doc-sources path-element="${basedir}/src3"/>

			<!-- don't try to generate asdoc for
				includeFile.as (its an include file
				and can't be independently compiled -->
			<exclude-sources path-element="${basedir}/src3/includeFile.as"/>

			<!-- source path for asdoc -->
			<compiler.source-path path-element="${basedir}/src1"/>
			<compiler.source-path path-element="${basedir}/src2"/>

			<!-- namespaces to include in asdoc -->
			<doc-namespaces uri="http://www.gauravj.com/blog/"/>

			<!-- namespace declaration for asdoc -->
			<namespace uri="http://www.gauravj.com/blog/"
			manifest="${basedir}/manifest.xml"/>

			<jvmarg line="-Xmx512m"/>
		</asdoc>
	</target>

As you can see it supports all the options of command line asdoc (doc-classes, doc-sources, doc-namespaces, source-path, etc.). So you can now write ant targets for your asdoc generation.

If you face any issues or have any feedback, you can log bugs at http://bugs.adobe.com/flex

5 comments to ASDoc integration with build scripts

  • JBAH

    You might want to change this sentence:
    The is not available in the Flex 4 SDK only (not available in Flex 3).

    to

    The is available in the Flex 4 SDK only (not available in Flex 3).

  • Gaurav

    Thanks for catching that!!

  • Ian

    Hi Gaurav,

    This looks brilliant, unfortunately I got stuck trying to run your script. I would feel incredibly thankful if you could share your complete build.xml and build.properties files. I just downloaded FB4 and it looks amazing, I am sure that it uses the most recent SDK. For some reason it throws an error saying:

    asdocgen:

    BUILD FAILED
    /Users/Ian/Documents/Flex Builder 3/InteractiveWorks [iFramework]/ant/build.xml:15: The following error occurred while executing this line:
    /Users/Ian/Documents/Flex Builder 3/InteractiveWorks [iFramework]/ant/build.xml:33: Problem: failed to create task or type asdoc
    Cause: The name is undefined.
    Action: Check the spelling.
    Action: Check that any custom tasks/types have been declared.
    Action: Check that any / declarations have taken place.

    It looks like it can’t find that specific asdoc task. :S

    I would love to learn how to make your script work so its not dependent on platform and can exclude unnecessary files (such as include files).

    Thanks in advance!

  • Gaurav

    You should pass in sdk.dir and point that to the sdk root folder. For example

    ant asdocgen -Dsdk.dir=/Users/Ian/Flex_SDK

    Also take a look at build.xml which is present under the asdoc folder of Flex SDK.

  • Ian

    I think I finally worked it out. Gumbo seems like a great upcoming release. Thanks for the information and keep up the great work!

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">