ASDoc in MXML - Functional and Design SpecificationSummary and Background | Usage Scenarios | Detailed Description | API Description | B Features | Examples and Usage | Additional Implementation Details | Compiler Work | Web Tier Compiler Impact | Flex Feature Dependencies | Backwards Compatibility | Accessibility | Performance | Globalization | Localization | Issues and Recommendations | Documentation
Summary and BackgroundCurrently there is no way for users to add documentation to components defined in mxml files. The asdoc tool doesn't read the comments in mxml files. Increasingly more components in the flex framework are being written in mxml. Adding support for mxml in the asdoc tool would help developers to generate documentation for their components. Several customer have also added requests in JIRA to support class level comments in mxml files. Usage ScenariosJane is a component developer and provides swc files to her customers. Her customers want api documentation in order to easily use the components, the asdoc tool doesn't support documentation for the components written in mxml. Using the new version of asdoc tool she would be able to generate documentation for mxml components. Detailed DescriptionAsdoc commentTo specify comments for asdoc generation in mxml file, the syntax that needs to be followed is <!--- asdoc comment --> The — (3) dashes following the <! are required, else the comment will be ignored by the asdoc tool. Components and Class level CommentComments for components defined inside mxml or for class level comments must be placed before the <?xml version="1.0"?> <!-- Standard MXML comment: events\myComponents\MyButton.mxml --> <!--- The class level comment for the component. This tag supports all ASDoc tags, and does not require a CDATA block. @see mx.container.VBox --> <mx:VBox xmlns="http://ns.adobe.com/mxml/2009" xmlns:mx="library:adobe/flex/halo" > <!--- Comment for button --> <mx:Button id="myButton" label="This button has comment"/> <!--- This comment doesn't belong to any component and will be ignored --> </mx:VBox> Language ElementsLanguage Elements are elements like <Script> or <Metadata> Asdoc comments preceding such element will be ignored. Elements (properties/methods/styles/effect/event) defined inside such element will need to follow the /** comment */ syntax. <?xml version="1.0"?> <!-- Standard MXML comment: events\myComponents\MyButton.mxml --> <!--- The class level comment for the component. This tag supports all ASDoc tags, and does not require a CDATA block. @see mx.container.VBox --> <mx:VBox xmlns="http://ns.adobe.com/mxml/2009" xmlns:mx="library:adobe/flex/halo" > <!--- Comment for language element - this comment will be ignored. --> <Script> <![CDATA[ import flash.events.Event; /** * For a method in an <mx:Script> block, * same rules as in an AS file. * * @eventType myEvents.EnableChangeEvent */ private function handleCloseEventInternal(eventObj:Event):void { dispatchEvent(eventObj); } ]]> </Script> <Metadata> <![CDATA[ /** * Defines the default style of selected text. */ [Style(name="textSelectedColor",type="Number",format="Color",inherit="yes")] /** * The component dispatches the darken event * when the darken property changes. * * @eventType flash.events.Event */ [Event(name="darken", type="flash.events.Event")] /** * Played when the component darkens. */ [Effect(name="darkenEffect", event="darken")] ]]> </Metadata> </mx:VBox> Comments before Definition, Library, and Private tag will be ignored. Also comments inside the private block will not be processed. <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns="http://ns.adobe.com/mxml/2009" xmlns:mx="library:adobe/flex/halo" width="900" height="700"> <!--- Comment will be ignored ---> <Library> <!--- Comment will be IGNORED --> <Definition name="BlueRect"> <Group> <Rect width="200" height="200"> <fill> <SolidColor color="#0000FF" /> </fill> </Rect> </Group> </Definition> </Library> <Graphic> <BlueRect width="100" height="200"/> <BlueRect /> </Graphic> <!--- comment will be ignored --> <Private> <!--- Design-time metadata - comment will be ignored --> <foo>author</foo> <bar>4.0.0</bar> </Private> </mx:Application> Regular commentTo specify regular comments in mxml file, the syntax that needs to be followed is <!-- Regular comment - no asdoc --> These comments will be ignored while scanning the mxml files. <?xml version="1.0"?> <!-- Standard MXML comment: events\myComponents\MyButton.mxml --> <!-- This is a regular comment and will not be included in generated asdoc. --> <mx:VBox xmlns="http://ns.adobe.com/mxml/2009" xmlns:mx="library:adobe/flex/halo" > <!-- Comment for button - this is also a regular comment and will be ignored. --> <mx:Button id="myButton" label="This button has comment"/> </mx:VBox> API DescriptionB FeaturesSome metadata tags may requires special handling. These would be treated as B feature. The tags which require special handing are Support for new metadata [SkinState] introduced in gumbo will be treated as B feature. Since [Bindable] is widely used - it will not be a B feature. Examples and UsageHere are some examples of how users would be able to add asdoc comments in mxml files. Comments should always be in one single comment block. If comments is spread across multiple blocks the last block will only be used <?xml version="1.0"?> <!-- Standard MXML comment: events\myComponents\MyButton.mxml --> <!--- First class level comment - this will not be picked because there is one more comment between this an the component declaration. LAST one WINS. --> <!--- Second class level comment for the component. Because this is last - it WINS @see mx.container.VBox --> <mx:VBox xmlns="http://ns.adobe.com/mxml/2009" xmlns:mx="library:adobe/flex/halo" > <Script> <![CDATA[ import flash.events.Event; /** * For a method in an <mx:Script> block, * same rules as in an AS file. * * @eventType myEvents.EnableChangeEvent */ private function handleCloseEventInternal(eventObj:Event):void { dispatchEvent(eventObj); } ]]> </Script> </mx:VBox> Special Class level CommentsFollowing is the example for a mxml component which also implements an interface. This should result in the "Implements foo.Bar" in the class header. <?xml version="1.0"?> <!--- This is a class level comment. --> <mx:VBox xmlns="http://ns.adobe.com/mxml/2009" xmlns:mx="library:adobe/flex/halo" implements="foo.Bar"> <mx:Button id="myButton" label="This button has comment"/> </mx:VBox> Following is the example for a mxml component which is deprecated. This should result in the "Deprecated NewComp" in the class header. <?xml version="1.0"?> <!--- This is a class level comment. --> <mx:VBox xmlns="http://ns.adobe.com/mxml/2009" xmlns:mx="library:adobe/flex/halo" > <mx:Metadata> [Deprecated("NewComp")] </mx:Metadata> <mx:Button id="myButton" label="This button has comment"/> </mx:VBox> Following is the example for a mxml component which is excluded. This should result in the class getting excluded from the documentation. <?xml version="1.0"?> <!--- This is a class level comment. --> <mx:VBox xmlns="http://ns.adobe.com/mxml/2009" xmlns:mx="library:adobe/flex/halo" > <mx:Metadata> [ExcludeClass] </mx:Metadata> <mx:Button id="myButton" label="This button has comment"/> </mx:VBox> Inline mxml componentsAny inline mxml components must have the id property in order to the comment to be processed. <?xml version="1.0"?> <!--- This is a class level comment. --> <mx:VBox xmlns="http://ns.adobe.com/mxml/2009" xmlns:mx="library:adobe/flex/halo" > <!--- Comment for button - will not be processed because there is no id for button. --> <mx:Button label="This button has comment"/> </mx:VBox> Any inline mxml components has an id property but no comment. It should still appear in the class documentation. <?xml version="1.0"?> <!--- This is a class level comment. --> <mx:VBox xmlns="http://ns.adobe.com/mxml/2009" xmlns:mx="library:adobe/flex/halo" > <mx:Button id="myButtonId" label="This button has comment"/> </mx:VBox> Additional Implementation DetailsEnter implementation/design details for the feature here. This section may be updated after the spec signs off. Compiler WorkCurrently comments are totally ignored while parsing a mxml file. For this feature the comments will have to be considered during mxml parsing. Also in case of actionscript, the actionscript parser goes through all the tokens so it is able to handle special asdoc tags like @see, @inheritDoc, etc. During mxml parsing when a comment is encountered it will have to be parsed again for the special tags. The comment will need to be attached to the following element node so that during implementation generation it can be converted to a comment node and attached to syntax tree in the appropriate place. Web Tier Compiler ImpactNo changes are expected to the Flex Web Tier compiler. No changes should apply to the OEM Compiler API as a result of these changes. Flex Feature DependenciesNone. Backwards CompatibilityNo compatibility related changes are expected. Syntax changesNo syntax change for writing mxml files. Only syntax change is the new comment syntax introduced in this feature. <!--- comment --> Warnings/DeprecationThis feature does not introduce any new warnings/deprecation. AccessibilityThere are no expected changes to accessibility with this feature. PerformanceWe need to keep an eye for any performance impact that may occur due to additional parsing of comments. If there is any significant impact then we can make sure that comments are only parsed when mxml parsing is invoked via asdoc. Because currently no one except for asdoc cares about comments. GlobalizationNo globalization issues are anticipated for this feature. LocalizationCompiler FeaturesThis feature is not expected to introduce any compiler localization changes. Framework FeaturesThis feature is not expected to introduce any framework localization changes. Issues and RecommendationsNone at this time. DocumentationOnce this specification is signed off, significant documentation will be required to capture the changes and explain the usage scenarios. |
|
| You must be logged in to comment. |
|---|
FB will hopefully highlight this differently, but I know many editors don't differentiate between comments that cause docs and comments that don't.
I think we'll see how folks feel about triple-dash when they're using it. It was this way in ColdFusion I believe and went over fine. I'd imagine it won't be too hard to figure out what's going on. But if after some user testing folks vote for a change we can probably do that without difficulty.
I could not agree more with Ev W. on this issue. At my current job I'm doing development in C#, Flex, and Java. C# standard commenting, with the triple-slash, is abhorrent to me and another example of MS wanting to create a new standard. So I'm using the NDoc/JavaDoc style in the hopes that Doxygen will parse it for me.
I am primarily a tool builder and build tools that can be used generally by my staff. These are young engineers with little experience in tool building and tool usage. My habit is do document profusely using a full line of asterisks to designate comment blocks. This makes the code simple to decifer. Consistency of documentation is a great aid to the ready understanding of blackbox tools and to the education of less-experienced engineers.
I Currently use the <!--* construct in documenting my MXML files and it would be wonderful if ASDoc could interpret these constructs.
I agree with Ev W. that the triple-dash idea is not only easy to miss but easy to misstype and have your comments simply be ignored. The <!--* construct would not only be easier to see but would be consistent with the NDoc/JavaDoc/ASDoc documenting standard.
Perfect - exactly what I'm waiting for ...
Might be a dumb question, but is there any information on when we can expect the first sdk including the feature ?
I can see [SkinPart] being useful information in ASDoc for developers/designers creating Skin.
To know which SkinParts are NECESSARY and HOW a component intends to use a SkinPart.
This topic looks great. For more Flex 4 and Flash Builder 4 information, see this new course 'Flex 4 Top 10 Features' taught by Rivello Multimedia Consulting. Sign up or request it come to your town today! http://www.blog.rivello.org/?p=324

Excellent work.
I have a small concern though. Might <!--- compared to <!-- be easy to miss in a page of code? Perhaps something like <!--* be easier to spot (it's still XML compliant).
Also would FlexBuilder's syntax highlighting have a different colour for this?