January 5, 2007
Action Script Comment Guidelines
Posted by Eashwar Natarajan under ActionScript, Flex, Uncategorized1. Typical Class Comment
/** * First sentence of a multi-paragraph main description. * <p>Second paragraph of the description.</p> * @author "name" */
2. Standard Function comment
/**
* Typical format of a simple multiline documentation comment.
* This text describes the myFunction function, which is declared below.
*
* @langversion ActionScript 3.0
* @playerversion Flash 8
*
* @param param1 Describe param1 here.
* @param param2 Describe param2 here.
*
* @see someOtherFunction
*/
public function myFunction(param1:String, param2:Number):void {}
PS: Only public function comments are included by AsDocs.
3. Getter Setter Property - Takes the comment of the getter/setter function to be the comment of the property. Marks “readonly” if getter method alone is present and “read-write” if getter and setter are implemented. Example : See common.CurrentDeviceTimeHolder class DeviceTime property.
4. MetaData Tags - When Events are defined, comments are be added before the Event Tag. For Example
/**
* login event is dispatched after the login button is pressed.
* @eventType mx.events.DynamicEvent
*/
[Event(name="login",type="mx.events.DynamicEvent")]
For another example see propertySheet.as
5. @see, @example Tag - @see adds a “See Also ” text and indicates the related method to look in to. This tag can be used in class, method comments. @example Tag adds an example usage to a class/ method comment. CurrentDeviceTimeHolder class comment is an example for the above two tags.
/**
* Conforms to Singleton Design Pattern.
* @author Eashwar N
* @see http://en.wikipedia.org/wiki/Singleton_pattern#ActionScript_3_Example_Implementation * @example The following code gets the value of DeviceTime
* <listing version=”3.0″ >
* CurrentDeviceTimeHolder.getInstance().DeviceTime
* </listing>
*/
7. To copy a comment from the base class method @inheritDoc tag can be used. In case there is no such relation @copy Tag can be used. In classes implementing PropertyValueRenderer, like PropertyValueTitleRenderer, comments of base methods will be inherited.
8. It can render a variety of html tags - <div>,<span>,<listing>,<img>,<table>
Note: Comments inside // and /**/ are ignored by the AsDoc.
June 19, 2008 at 5:10 pm
Excellent, thanks !!