Flex and ASDocs

30 01 2009

Flex builder offers a very easy way to generate documentation for your actionscript classes API. There are basically 2 steps involved:

– Comment your actionscript class as per ASDoc guidelines. You can refer the instructions in the Flex documentation.

– Use ASDoc external tool from within your Flex builder to generate the documentation. You can do this using commandline as well. However, I found it much more convenient using Flex builder.

Here’s what I did for my project:

Tool used: Flex Builder 3, SDK 3.2.0

1. Add comments to my custom UniConverter class (plz note this is not the complete class) as follows:

package com.bs.uni
{
	import fl.core.UIComponent;

	/**
	* This component class can be used to convert different
	* special characters to unicode characters for a given string.
	*
	*/
	public class UniConverter extends UIComponent
	{
		private var _strResult:String;

		/**
		* Convert basic latin special characters to unicode for a
		* given string.
		*
		* @param src The source string that contains basic latin
		* special characters which needs to be converted to unicode.
		*
		* @return The source string with basic latin
		* special characters converted to unicode.
		*/
		public function basicLatin(src:String):String
		{
			if (src == null)
			{
				throw("Invalid source string.");
			}
			else
			{
				_strResult = src;
				convert(BasicLatinXML.getXML());

				return _strResult;
			}
		}

2. Select Run > External Tools > Open External Tools Dialog

3. Add a program and name it ASDoc_Uni. You can give any name.

4. Location: field — add C:\Program Files\Adobe\Flex Builder 3\sdks\3.2.0\bin\asdoc.exe

5. Working Directory: field — browse to my project folder. The field shows ${workspace_loc:/UniConverter} which points to my working directory.

6. Arguments: field — add the following command

-source-path "C:\Program Files\Adobe\Adobe Flash CS4\Common\Configuration\Component Source\ActionScript 3.0\User Interface"
${workspace_loc:/UniConverter} 
-doc-classes fl.core.UIComponent
com.bs.uni.UniConverter 
-exclude-classes fl.core.UIComponent
-exclude-dependencies=true
-main-title "Unicode Converter" 
-window-title "Unicode Converter"

The above command adds 2 source paths for the classes that have been used – my project directory and the current actionscript API. It specifies 2 classes – my custom class and the UIcomponent class which it inherits. Now, I only want my custom class in the documentation and not the flash inbuilt UIComponent class. To exclude the UIComponent class, specify it next to -exclude-classes and also set -exclude-dependencies=true. Finally, I just set the documentation title and the window title as “Unicode Converter”. There’s more you can do, just check the ASDoc documentation.

7. Once through, click Run. A new folder named asdoc-output is created in project folder. Open the folder and launch index.html. There you go, documentation is all set.

 

Flex ASDoc Tool

Flex ASDoc Tool

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: