<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Russ Back &#187; asdoc</title>
	<atom:link href="http://www.russback.com/tags/asdoc/feed" rel="self" type="application/rss+xml" />
	<link>http://www.russback.com</link>
	<description>Professional Web Development</description>
	<lastBuildDate>Mon, 02 Nov 2009 08:16:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Compiling documentation with Ant and asdoc</title>
		<link>http://www.russback.com/adobe-flex/compiling-documentation-with-ant-and-asdoc.html</link>
		<comments>http://www.russback.com/adobe-flex/compiling-documentation-with-ant-and-asdoc.html#comments</comments>
		<pubDate>Fri, 21 Aug 2009 07:46:03 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[Ant]]></category>
		<category><![CDATA[asdoc]]></category>

		<guid isPermaLink="false">http://www.russback.com/?p=548</guid>
		<description><![CDATA[The documention tool in Flex - asdoc - is a great tool for documenting your code but getting it running isn't the easiest task. I had a few problems with this on Mac OSX Leopard 10.5.8 so hopefully this will help you if you're struggling.]]></description>
			<content:encoded><![CDATA[<h2>Documenting code for asdoc</h2>
<p>Documenting your code for asdoc is easy and there&#8217;s plenty of help available on this and I&#8217;d suggest starting with the <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=asdoc_2.html">Flex help</a>.</p>
<h2>Installing Ant</h2>
<p>You can run asdoc from the command line but I found it much easier to install Ant in Flex Builder, which is as simple as this:</p>
<ol>
<li>In Flex Builder  go to Help &gt; Software Updates &gt; Find and Install</li>
<li>Click on the option to <strong>Search for new features to install</strong></li>
<li>Make sure <strong>The Eclipse Project Updates</strong> is selected and then hit Finish</li>
<li>Expand the tree <strong>Eclipse 3.3.2 or newer,</strong> select <strong>Eclipse Java Development Tools</strong> and install</li>
<li>Restart Flex Builder and then go to Window &gt; Other Views</li>
<li>Expand the <strong>Ant</strong> directory, click on the <strong>Ant</strong> icon and hit OK</li>
<li>You should now have an Ant panel, though the position of it may vary according to your perspective settings (mine is alongside Console at the bottom)</li>
</ol>
<p><img src="/wp-content/uploads/ant-installed.jpg" width="553" height="173" alt="Ant installed" /></p>
<h2>Create a symbolic link to asdoc</h2>
<p>A copy of asdoc lives in each SDK directory so if you&#8217;re using 3.3.0, you&#8217;ll find it at  /Applications/Adobe Flex Builder 3/sdks/3.3.0/bin/asdoc. We&#8217;ll be using Ant to build our documentation and giving it the path to the asdocs progrm but asdoc has a problem with spaces in pathnames, which although not a problem on Windows, is a pain on Mac as the path above has spaces in it and attempting to use this in Ant throws an error. I first tried <a href="http://thanksmister.com/?p=87">the approach in this excellent article</a> but still had the same problem so instead I created a symbolic link (shortcut) to asdoc in my hard disc root.</p>
<p>You can do this in a number of ways, the easiest of which is perhaps using this <a href="http://www.macupdate.com/info.php/id/10433">little plugin</a>. </p>
<p><img src="/wp-content/uploads/symbolic-linker.jpg" width="553" height="299" alt="Symbolic Linker" /></p>
<p>Once you&#8217;ve created your symobolic link, name it something obvious with no funny characters. Mine is flex-sdk-330. When you click on this symbolic link in the Finder you&#8217;ll see the contents of the 3.3.0 directory and inside that, the bin directory and asdoc program. So far so good.</p>
<p><img src="/wp-content/uploads/symbolic-link.jpg" width="553" height="229" alt="Symbolic Linker" /></p>
<h2>Create the Ant  files</h2>
<p>To compile our documentation we need an XML file called build.xml and a properties file called build.properties so we create these in the root of our Flex Project. If Ant has installed properly you&#8217;ll probably see a little Ant icon on your file. </p>
<p><img src="/wp-content/uploads/ant-files.jpg" width="553" height="262" alt="Ant files" /></p>
<h3>The build.properties file</h3>
<p>The properties file contains a set of values that the XML file will use. </p>
<p>We start with a reference to the symbolic link we created earlier.</p>
<pre># Path to SDK
SDK_PATH = /flex-sdk-330</pre>
<p> Then we add something very important: the path to the Flash player we are using for this project. Setting the target player in Flex Builder will only tell the Flex compiler to target a specific player but Ant won&#8217;t know about that so if you&#8217;re targetting version 10, make sure you reference the version 10 player here.</p>
<p>One problem you may find if you don&#8217;t do this is you end up with compile errors. One that I got tripped up by was an error to do with the FileReference class. This was changed in Flash player 10 to include the ability to load files from the user&#8217;s environment without the need to load them to a server first. If you get errors to do with FileReference, make sure you have this set correctly.</p>
<pre># Path to target Flash Player library (relative to the SDK_PATH
PLAYER_PATH = /frameworks/libs/player/10/playerglobal.swc</pre>
<p>The next property is where you reference any SWC library files your project uses. In the example I&#8217;m providing for download below I&#8217;m not including any so this is just blank:
</p>
<pre># Paths to libraries to include
# LIBRARIES = ./libs/SomeLibrary.swc ./libs/SomeOtherLibrary.swc
LIBRARIES = </pre>
<p>Next comes the path the the source files for the project, which are typically in the src directory:
</p>
<pre># Source files
SOURCE = ./src</pre>
<p>The next two settings are used for the documentation output &#8211; the TITLE appears in the title of the documents and the FOOTER text appears at the bottom of each page.</p>
<pre>
# Title for the documentation
TITLE = Compiling Documentation with Ant and asdoc</pre>
<pre># Text to add to the footer of each page
FOOTER = Compiled using Ant and asdoc (build.xml and build.properties)</pre>
<p>Finally we have a location to output our documentation to, in this case a directory called docs in the Flex Project:
</p>
<pre># Output location
OUTPUT_PATH = ./docs</pre>
<h2>The build.xml file</h2>
<p>Now we have our properties file we can go ahead and use them in our XML file. The properties file is referenced right at the outset and then we include a path to the flexTasks.jar file (note the properties throughout this file are called in as follows ${PROPERTY}).</p>
<pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;project name=&quot;Compiling Documentation with Ant and asdoc&quot; default=&quot;Clean and Build&quot; basedir=&quot;.&quot;&gt;

	&lt;property file=&quot;./build.properties&quot; /&gt;

	&lt;!-- Path to Flex Ant Tasks (info at http://labs.adobe.com/wiki/index.php/Flex_Ant_Tasks) --&gt;
	&lt;taskdef resource=&quot;flexTasks.tasks&quot; classpath=&quot;${SDK_PATH}/ant/lib/flexTasks.jar&quot; /&gt;</pre>
<p>Next we have our default Ant task which simply calls the two other tasks in the file Clean, and Build.
</p>
<pre>	&lt;target name=&quot;Clean and Build&quot; description=&quot;Calls the Clean and Build tasks&quot;&gt;
		&lt;antcall target=&quot;Clean&quot; description=&quot;Calls the Clean task&quot; /&gt;
		&lt;antcall target=&quot;Build&quot; description=&quot;Calls the Build task&quot; /&gt;
	&lt;/target&gt;</pre>
<p>This is followed by a simple task that deletes the existing documentation if there is any:</p>
<pre>	&lt;target name=&quot;Clean&quot; description=&quot;Deletes the existing documentation and recreates the directory&quot;&gt;
		&lt;delete dir=&quot;${OUTPUT_PATH}&quot; failOnError=&quot;true&quot; includeEmptyDirs=&quot;true&quot; /&gt;
		&lt;mkdir dir=&quot;${OUTPUT_PATH}&quot;/&gt;
		&lt;echo&gt;Clean task completed successfully&lt;/echo&gt;
	&lt;/target&gt;
</pre>
<p>And finally the task that will build our documentation:</p>
<pre>	&lt;target name=&quot;Build&quot; description=&quot;Builds the documentation&quot;&gt;
		&lt;exec executable=&quot;${SDK_PATH}/bin/asdoc&quot; failonerror=&quot;true&quot;&gt;
			&lt;arg line=&quot;-load-config ${SDK_PATH}/frameworks/flex-config.xml&quot; /&gt;
			&lt;arg line=&quot;-doc-sources ${SOURCE}&quot; /&gt;
			&lt;arg line=&quot;-source-path ${SOURCE}&quot; /&gt;
			&lt;arg line=&quot;-external-library-path ${SDK_PATH}/${PLAYER_PATH}&quot; /&gt;
			&lt;arg line=&quot;-include-libraries ${LIBRARIES}&quot; /&gt;
			&lt;arg line=&quot;-window-title '${TITLE}'&quot; /&gt;
			&lt;arg line=&quot;-footer '${FOOTER}'&quot; /&gt;
			&lt;arg line=&quot;-output ${OUTPUT_PATH}&quot;/&gt;
		&lt;/exec&gt;
		&lt;echo&gt;Build taks completed successfully&lt;/echo&gt;
	&lt;/target&gt;

&lt;/project&gt;</pre>
<h2>Compile the documentation </h2>
<p>Now everything is set up we simply need to drag the build.xml file onto the Ant panel and double-click on it or hit the Play button in the Ant panel.</p>
<p><img src="/wp-content/uploads/ant-ready.jpg" width="553" height="131" alt="Ant ready to run" /></p>
<p> If everything is set up correctly we should get a couple of confirmation messages in the Console panel and the documentation will be created in a /docs directory in the root of our Flex Project.</p>
<p><img src="/wp-content/uploads/ant-done.jpg" width="553" height="239" alt="Ant done" /></p>
<h2>Download an example project</h2>
<p>To see an example in action you can  <a href="/wp-content/examples/compiling-documentation-with-ant-and-asdoc/compiling-documentation-with-ant-and-asdoc.zip">download and edit the source code</a> here. This should work if you follow the steps above but obviously can be modified as required.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.russback.com/adobe-flex/compiling-documentation-with-ant-and-asdoc.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
