Shock, horror! ASDoc working?!!
OK, ASDoc IS a cool thing. If, like me, you've spent many a happy hour trying to figure out how to make it actually work and been driven insane by it's habit of pointing out errors in your code - or worse, errors in third-party code - and not just producing the blasted documents you wanted, then hopefully I can help just a little. With a little help from Seb Lee-Delisle and a cool little tool called Dita - it's an AIR app!
ASDoc is delivered along with Flex Builder and is free, so why not use it to produce some nice API documentation for your latest project?
Because it's command-line and very very fiddly?
I was determined to make it work this time (after giving up on a previous project) and surfed around for clues to get it working. I'd tried Dita on it's own before and also tried the ASDocGUI AIR app - neither worked for me for some reason. So, google it is...
I immediately found Seb's excellent blog post on the theme. He explains a neat little way to set up ASDoc within Flex, as an external tool. He also recommends using external SWCs instead of libraries to avoid ASDoc's annoying tendency to document everything it finds unless you specifically exclude all classes you don't want documented - individually 
Now I had the issue that my project HAS used external linked libraries and I didn't want to rework everything now that the project is final. This means that I needed to exclude several classes. That's where, as Seb points out, Dita comes in.
Dita does not run ASDoc but allows you to create a batch file with all commands necessary to run it for your project. As I said, I couldn't get it to work for me before, but this time I had other plans for it
I was going to use it simply to create that long list of classes to be excluded (in my case the Greensock TweenLite classes) and save me having to type them in manually.
Simply enter the project details and paths into Dita and include the file system path to the classes you wish to exclude, for example:

Entries in Dita for your project
You'll see that I have specified the path to the greensock libraries for the parameter exclude classes/packages (in the src/com folder).
Hit "GO" and you'll produce a batch file as mentioned above.
Open up the batch file with an editor (notepad?) and you'll see something like the following:
"C:\Program Files\Adobe\Flex Builder 3\sdks\3.2.0\bin\asdoc.exe" -output "C:\Documents and Settings\robert\My Documents\Flex Builder 3\Donut\docs" -source-path C:\Documents and Settings\robert\My Documents\Flex Builder 3\Donut\src -library-path -main-title "" -window-title "" -footer "" -doc-classes CAD Card CardContent CardEvent CardStack ChoiceDropdown CirclePreloader CoinStack com.greensock.core.PropTween com.greensock.core.SimpleTimeline com.greensock.core.TweenCore com.greensock.data.BevelFilterVars com.greensock.data.BlurFilterVars com.greensock.data.ColorMatrixFilterVars com.greensock.data.ColorTransformVars com.greensock.data.DropShadowFilterVars com.greensock.data.FilterVars com.greensock.data.GlowFilterVars com.greensock.data.TransformAroundCenterVars com.greensock.data.TransformAroundPointVars com.greensock.data.TweenLiteVars com.greensock.data.TweenMaxVars com.greensock.data.VarsCore com.greensock.easing.Back com.greensock.easing.Bounce com.greensock.easing.Circ com.greensock.easing.Cubic com.greensock.easing.EaseLookup com.greensock.easing.Elastic com.greensock.easing.Expo com.greensock.easing.FastEase com.greensock.easing.Linear com.greensock.easing.Quad com.greensock.easing.Quart com.greensock.easing.Quint com.greensock.easing.Sine com.greensock.easing.Strong com.greensock.events.TweenEvent com.greensock.OverwriteManager com.greensock.plugins.AutoAlphaPlugin com.greensock.plugins.BevelFilterPlugin com.greensock.plugins.BezierPlugin com.greensock.plugins.BezierThroughPlugin com.greensock.plugins.BlurFilterPlugin com.greensock.plugins.ColorMatrixFilterPlugin com.greensock.plugins.ColorTransformPlugin com.greensock.plugins.DropShadowFilterPlugin com.greensock.plugins.EndArrayPlugin com.greensock.plugins.EndVectorPlugin com.greensock.plugins.FilterPlugin com.greensock.plugins.FrameLabelPlugin com.greensock.plugins.FramePlugin com.greensock.plugins.GlowFilterPlugin com.greensock.plugins.HexColorsPlugin com.greensock.plugins.QuaternionsPlugin com.greensock.plugins.RemoveTintPlugin com.greensock.plugins.RoundPropsPlugin com.greensock.plugins.ScalePlugin com.greensock.plugins.ScrollRectPlugin com.greensock.plugins.SetActualSizePlugin com.greensock.plugins.SetSizePlugin com.greensock.plugins.ShortRotationPlugin com.greensock.plugins.SoundTransformPlugin com.greensock.plugins.TintPlugin com.greensock.plugins.TransformMatrixPlugin com.greensock.plugins.TweenPlugin com.greensock.plugins.VisiblePlugin com.greensock.plugins.VolumePlugin com.greensock.TimelineLite com.greensock.TimelineMax com.greensock.TweenAlign com.greensock.TweenLite com.greensock.TweenMax com.greensock.TweenNano com.hybrid.ui.ToolTip ConfigLoader CustomCellRenderer DependantNotice DependantNoticeChoice DependantNoticeChoice2 Diabetes DOB Donut5 DonutEvent DonutSegment DropDown EmailValidation fl.controls.ScrollBar FundValue GreyButton Halo HealthDropDowns Item Measurements MultilineCheckBox Options Overlay PostCode Pot QuestionButton Radio2 Radio3 RightPanel RightPanelEvent SegmentCheck SeriousConds Slider SliderForm StopEvent SummaryScreen SummaryScreenEvent TwoChoice TwoChoiceDeps YellowButton -exclude-dependencies
pause
I've no idea why the exclude classes are listed along with the actual classes in my app but at least I don't have to type them out... Now all you need to do is to go back to Seb's instructions and set up an external tool (Step 1) through to Step 5. Then add the -exclude-classes directive and copy and paste the nice long stream of class names into the Arguments window of the external tool dialog, resulting in something like the following:

ASDoc settings in the external tool dialog in Flex
That's dealt with the classes to be excluded. What about external linked libraries that are needed by the compiler? Simply specify them by entering their file path as follows:
-source-path "C:\Program Files\Adobe\Adobe Flash CS4\Common\Configuration\Component Source\ActionScript 3.0\User Interface"
If you want the classes in this library excluded then don't forget to run it through Dita again with this path in the exclude classes/packages field to get a nice list. I wanted them documented in this case as they've been partially sub-classed in my app (custom skinning and component extending, fun
).
Don't forget then to add a custom title, footer text and browser window title:
-window-title "xxxxxx Classes Documentation"
-main-title "xxxxxx Classes Documentation"
-footer "created by me using ASDoc"
Now, back to those annoying little compilation errors that can stop you from producing nice shiny documentation. I know we shouldn't have errors but you may be using a third-party library that has them, right? 
Make the compiler more tolerant by adding:
-strict=false
-warnings=false
and the compiler should happily skip those duplicate variable definitions or untyped variables (in my experience the most common things that pop up here).
Now, if you've followed Seb's suggested argument parameters and used -doc-sources, make sure you don't use -exclude-dependencies as ASDoc doesn't like it and you'll only get another error message.
By now you should have a whole stream of parameters listed in the Arguments section of the external tool dialog - something like this:
-strict=false
-warnings=false
-exclude-classes com.greensock.core.PropTween com.greensock.core.SimpleTimeline com.greensock.core.TweenCore com.greensock.data.BevelFilterVars com.greensock.data.BlurFilterVars com.greensock.data.ColorMatrixFilterVars com.greensock.data.ColorTransformVars com.greensock.data.DropShadowFilterVars com.greensock.data.FilterVars com.greensock.data.GlowFilterVars com.greensock.data.TransformAroundCenterVars com.greensock.data.TransformAroundPointVars com.greensock.data.TweenLiteVars com.greensock.data.TweenMaxVars com.greensock.data.VarsCore com.greensock.easing.Back com.greensock.easing.Bounce com.greensock.easing.Circ com.greensock.easing.Cubic com.greensock.easing.EaseLookup com.greensock.easing.Elastic com.greensock.easing.Expo com.greensock.easing.FastEase com.greensock.easing.Linear com.greensock.easing.Quad com.greensock.easing.Quart com.greensock.easing.Quint com.greensock.easing.Sine com.greensock.easing.Strong com.greensock.events.TweenEvent com.greensock.OverwriteManager com.greensock.plugins.AutoAlphaPlugin com.greensock.plugins.BevelFilterPlugin com.greensock.plugins.BezierPlugin com.greensock.plugins.BezierThroughPlugin com.greensock.plugins.BlurFilterPlugin com.greensock.plugins.ColorMatrixFilterPlugin com.greensock.plugins.ColorTransformPlugin com.greensock.plugins.DropShadowFilterPlugin com.greensock.plugins.EndArrayPlugin com.greensock.plugins.EndVectorPlugin com.greensock.plugins.FilterPlugin com.greensock.plugins.FrameLabelPlugin com.greensock.plugins.FramePlugin com.greensock.plugins.GlowFilterPlugin com.greensock.plugins.HexColorsPlugin com.greensock.plugins.QuaternionsPlugin com.greensock.plugins.RemoveTintPlugin com.greensock.plugins.RoundPropsPlugin com.greensock.plugins.ScalePlugin com.greensock.plugins.ScrollRectPlugin com.greensock.plugins.SetActualSizePlugin com.greensock.plugins.SetSizePlugin com.greensock.plugins.ShortRotationPlugin com.greensock.plugins.SoundTransformPlugin com.greensock.plugins.TintPlugin com.greensock.plugins.TransformMatrixPlugin com.greensock.plugins.TweenPlugin com.greensock.plugins.VisiblePlugin com.greensock.plugins.VolumePlugin com.greensock.TimelineLite com.greensock.TimelineMax com.greensock.TweenAlign com.greensock.TweenLite com.greensock.TweenMax com.greensock.TweenNano
-external-library-path="C:\Program Files\Adobe\Adobe Flash CS4\Common\Configuration\ActionScript 3.0\libs"
-external-library-path="C:\Program Files\Adobe\Adobe Flash CS4\Common\Configuration\ActionScript 3.0\FP10"
-source-path src
-source-path "C:\Program Files\Adobe\Adobe Flash CS4\Common\Configuration\Component Source\ActionScript 3.0\User Interface"
-doc-sources src
-window-title "xxxxxx Classes Documentation"
-main-title "xxxxxxx Classes Documentation"
-footer "created by Robert Turrall using ASDoc"
Now. Hit the "Run" button and off you go!
I hope this works for you too!
Just remember that what is output is a collection of web pages, with fairly-well implemented CSS styling. It's therefore pretty straight-forward to style the output so that it's "on brand" and to produce some nice end-of-project API documentation.
Thanks to Seb, Dita and a little bit of fiddling, I can now produce ASDoc documentation for my projects, straight out of Flex, and with no need to mess around with the command line. Nice.
I don't pretend to be an ASDoc expert but I hope I've been able to help with this elaboration on it's use in Flex.
Happy documenting!
Recent comments