You are currently using the online version of ZenDoc available on www.zendoc.org.

ZenDoc 1.5.1

ZenDoc For ActionScript Manual

What is ZenDoc?

ZenDoc is a simple, free, (primarily) web-based application written in PHP used to generate customizable HTML documentation for Flash ActionScript 2.0 and ActionScript 3.0 source files. Like other tools of its kind, it uses Javadoc-style comments within source code to decide the content of the documentation generated. For more on correctly commenting source files for ZenDoc, see Commenting Source Files for ZenDoc. Note that ZenDoc works using a "consider only what's commented" approach to source code parsing meaning any code without Javadoc comments is ignored.

ZenDoc also gives you to control over the documentation content by way of HTML templates. These templates give you control over the style and layout of the documentation generated from source files. They follow conventions similar to those found in Dreamweaver making them easy to create and customize on your own. Learn more about templates in the ZenDoc Template Format section.

Though ZenDoc can document many files at one time, each file is documented individually, so it works best when documenting single classes rather than entire packages or collections of classes which relate to each other. Documenting multiple files (local) requires access to the file system in which ZenDoc is installed. If you do not have access, you can still use ZenDoc's external documentation feature but would be limited to documenting one file at a time.

You can start using ZenDoc right now by going to http://www.zendoc.org/zendoc/ and accessing the web interface there. You also have the option of downloading ZenDoc to use on your own (see Installation).

[index]

Installation

Requirements:

  • PHP (4.3.0+)
  • Web server
  • JavaScript-enabled Browser

ZenDoc is written in PHP. it requires an installation of PHP within the environment you are working to function. If you do not have PHP installed locally on your personal desktop or laptop computer, nor have the desire to do so, you may upload your copy of ZenDoc to your web hosting provider and using it there (assuming PHP is supported).

As a web-based application, ZenDoc web interface also requires a web server like Apache and a JavaScript-enabled Browser like Firefox (ZenDoc was originally written and tested on Windows XP Pro running Apache 2 with PHP 4.3.8 using Firefox 1.0.4+). If only using ZenDoc through the command line, you will only need to have PHP installed.

To download the latest version of ZenDoc, please visit www.zendoc.org.

To install, unzip the download into the desired location placing the zendoc folder in the directory you wish to run ZenDoc. When using the web interface, this should be in a folder on your web server.

To uninstall ZenDoc, all you need to do is delete the zendoc folder.

[index]

Using ZenDoc

ZenDoc can be used two ways, through the PHP Command Line Interface (CLI) and through a web interface. More than likely you will want to use ZenDoc through the web interface as it provides the most in terms of flexibility and options.

Before using ZenDoc in any context, you'll probably want to set options defined in the zendoc.ini file. This file is located in the root ZenDoc folder. It contains options accessed by ZenDoc when it runs for both the command line and the web interface. Many of these options can also be changed through the ZenDoc web interface when using ZenDoc with your browser. The values within the ini file represent the default values for the web interface.

ZenDoc in the Command Line

The script to use for ZenDoc with PHP's CLI is zendoc.php located in the bin folder. The only arguments it accepts are the source files you wish to have documented. All options are decided by zendoc.ini. Documentation created with zendoc.php is saved in the same directory as the source file it documents.

A Windows batch file template (ZenDoc.bat) is also provided in the bin directory to make working with zendoc.php a little more easy for Windows users. Before using ZenDoc.bat, you must open it in a text editor and edit the phpclipath and zendocfilepath variables as they relate to your system. Once that is done, you can just drag and drop source files onto the ZenDoc.bat file to instantly create documentation for them. Using this batch file you can also create a user tool to run ZenDoc through editors like SE|PY.

ZenDoc in the Browser

To run ZenDoc using its web interface, just navigate to the ZenDoc folder on your web server (index.php) using your browser. An interface for the ZenDoc application will appear.

The ZenDoc interface is divided into three sections accessible through tabs; Local Files, External Files, and Options. The Local Files section show files located on the server running ZenDoc and are best used with your own personal copy of ZenDoc. The External Files section is more appropriate for using ZenDoc on a server you do not have access to, or for just quickly generating documentation for one or two files not within the local files listed for ZenDoc. The final section, Options, provides a list of options for ZenDoc and its components. A link to the ZenDoc documentation is provided to the right of the tabs.

Browser Local Files Tab

The Local Files section lists out all .as source files in the specified directory (except folders that start with an underscore like _notes). Copy any and all .as files you wish to generate documentation for into this directory. You can click on the name of any listed file to view it. If ZenDoc recognizes that documentation already exists for a file a (doc) link will also be provided next to the file allowing you to view it as well.

Within the listing, check boxes are provided allowing you to select which files you wish to generate documentation for. Checking a folder will select all files within that folder as well as all files within all folders within that folder. When you make your selection, make sure that those selected are properly commented. For more on correctly commenting a file for ZenDoc, see Commenting Source Files for ZenDoc. If a file that is not recognized as a source file is selected, ZenDoc will skip that file when attempting to generate documentation.

Once files are selected, a template needs to be selected. A drop-down menu below the source file listing provides you with all available templates. These templates are those located within the templates folder in the ZenDoc install directory. By default, they should all have either an .htm, .html, or .dwt extension. Templates determine the style of the outputted documentation. Learn more about templates in the ZenDoc Template Format section.

Once all of your selections have been made, click on the Document Local button at the bottom of the interface to generate HTML documentation for all selected source files in the source file listing. The interface will reload with the inclusion of an output window located below the file listing indicating the results of the operation. There you will see what documents were generated and any errors if present.

Browser External Files Tab

The External Files section provides basic ZenDoc functionality to files not located on the machine that ZenDoc is running. Both external source files and template files can be used here, either uploaded or provided as text. Those templates available to ZenDoc are also available for use here, though the local source files are not.

The Write text fields for either the ActionScript Source File or the Template Source File allow you to write in or copy and paste text for your source or template. If you wish to use this text, make sure the respective radio button is selected for that field. Additionally, you can choose to select a file on your hard drive using the option to Upload.

Clicking on the Document External button will generate documentation in a new window. You may save this documentation using your browser's save option. If there was an error, an error message will be displayed instead of the documentation.

Note: TemplateBeginFile and External Documentation

The Ignore TemplateBeginFile tags option is automatically considered checked when documenting external files as documentation is provided in a new window. Similarly, Client options involving saving files do not apply to external documentation.

Browser Options Tab

The options tab provides many of the options available to ZenDoc. Learn more about what options are available in the ZenDoc Options section. Most of these options will be applied to the next documentation operation making the use of the Apply option unnecessary. However, the Local Files tab uses the output file extension to recognize which files have documentation available to them. If you change that option, you will need to click Apply to update the files listing with documentation links associated with that extension.

[index]

ZenDoc Options

There are a number of options available for ZenDoc, each relating to a different part of the application. These can be set within the an ini file, or the ZenDoc HTML interface. Those set in the interface override those within the ini file unless the ini file locks the property. To lock a property, define a new property in the ini file with the name lock_ plus the name of the property you wish locked with a value of true.

Client Options

These options relate to the ZenDoc client.

Output file extension
The file extension used for documented files. This is also the extension used to determine whether not a source file exests within the Local Files pane. If identified, a (doc) link will be added next to the source files in the Local Files listing indicating that a documented file with this extension exists for the current source file.
ini file property: output_extension
Output destination directory
The directory in which documentation produced for local files is saved (make sure you have permissions to write to this directory). If this value is empty, the source file directory is used and documentation is saved in the same folder as the source file being documented.
ini file property: output_destination_directory
Overwrite existing files
If checked existing files on the file system will be replaced with new documentation created with the same name. When not checked, older files cannot be overwritten with newer files.
ini file property: overwrite_existing_files
Allow preferences to be set by template
When checked, this allows templates to modify preference (options) settings such as output file extension. Unchecking this assures that the options you set in the options pane are those used when documenting.
ini file property: allow_template_preferences

source_file_directory (as in ini; Browsing: field in External Files pane)
The directory to display in the Local Files pane where local source files are located.
source_file_extensions (ini file only)
A list of comma (,) separated source file extensions (without periods [.]) to be used in identifying ZenDoc source files.
template_directory (ini file only)
The directory to locate template files which are displayed in the Local Files and External Files templates lists.
template_extensions (ini file only)
A list of comma (,) separated extensions (without periods [.]) which are used to identify which files are templates.
default_template (ini file only)
The name of the template (with extension) that is to be the default template. This template will be initially selected within the ZenDoc web interface and will be the template used for URL based documentation where no template is specified.
remember_options (ini file only)
When true, the options last set in the Options pane of the ZenDoc interface will be saved and retained the next time the interface loads.
 

Translator Options

These options relate to the ZenDoc translator .

Date offset
The time offset in seconds to modify the time provided by the server running ZenDoc. This applies to the time provided by date TemplateParam tags.
ini file property: date_offset
Ignore TemplateBeginFile tags
Some templates may use TemplateBeginFile tags to create new, separate files for documentation consisting of more than one page. Selecting this option prevents the TemplateBeginFile tags from working in those templates.
ini file property: force_single_output

ActionScript Options

These options relate to the ZenDoc ActionScript parser.

Untagged comment text designation
Text not associated with an @ tag in Javadoc comments will be placed within the tag designated here.
ini file property: default_comment_tag
Interpret functions commented with the @event tag as events
If you use an @event tag in your comments to specify that a class memeber is an event, selecting this option will identify those members and place them within the events list for templates.
ini file property: use_event_tags
Interpret properties with a return type of Function that start with "on" followed by a capital letter or number as events
If you use this naming convention to specify that a property is an event (e.g. onMyEvent), selecting this option will identify those members and place them within the events list for templates.
ini file property: parse_property_on_events
Interpret functions with a return type of Void that start with "on" followed by a capital letter or number as events
If you use this naming convention to specify that a method is an event (e.g. onMyEvent), selecting this option will identify those members and place them within the events list for templates.
ini file property: parse_function_on_events
Use meta tags to determine events
If a meta tag is used to identify events and the meta tag is between your comment and the respective class member, selecting this option will identify those members and place them within the events list for templates.
ini file property: use_meta_events
Interpret variables of the type Function as methods
If you have properties defined in your class that are to be methods of that class (i.e. when using mixins), selecting this option will identify those members and place them within the methods list for templates.
ini file property: function_vars_as_methods
Interpret get/set functions as properties
Selecting this option will identify getter/setter methods and place them within the properties list for templates.
ini file property: get_set_functions_as_properties
Combine getters and setters into one definition
This option will take both the getter and setter of the same property and combine them into a single member of a template list. Both sets of comments and definitions will be retained and accessible to any template that checks for them.
ini file property: combine_get_set

Additional Options: External Files Pane

Options specific to external documentation are available in the External Files tab. They are as follows:

Reusable URL
By checking this option, when documenting a source file using a URL, ZenDoc will provide you with a page that contains a url that can be used to access the documentation on the fly (it is generated each time the page is loaded so it will never be out of date).

Additional Options: ini File

The ZenDoc ini file also allows for some options not available in the interface. They are as follows:

lock_[any ini option variable]
Forces the ini file value for this option to be used, disabling the option in the HTML interface. This is useful if you have a publically available version of ZenDoc online but do not want users to make changes to certain properties. Be sure that you define these options within the same section the respectively locked option is defined.
Ex: lock_output_extension = true

[index]

Commenting Source Files for ZenDoc

In order for ZenDoc to correctly generate documentation for your ActionScript file, you will need to have commented your script with definitions and explanations that describe your file; what it is, what it does, and how.

Commenting for ZenDoc largely follows the format used in Sun's Javadoc tool for Java. Basically this involves creating block comments that start with /** and end with */ above relevant segments of code. Within these comments goes the description for the code that lies below. The following is a simple example describing a public ActionScript property:

/**
 * The number of frames to be used in animating the selection
 */
public var frames:Number;

When commenting code that contains meta tags, put the comments above the meta tags.

/**
 * The number of frames to be used in animating the selection
 */
[MetaTag(value)]
public var frames:Number;

Within these comments, special tags can be included to represent specific information such as method parameters, return values, or really, anything you want. These tags are placed on new lines (which may or may not be preceded with an asterisk (*)) and start with a tag name immediately following an 'at' (@) symbol. Consider the following example that specifies the return value for a public method using the @return tag:

/**
 * Provides a means for obtaining the movie clip currently representing the parent
 * @return MovieClip instance
 */
public function getParentMovie(Void):MovieClip{
	// function body
}

With ZenDoc, there is no set of specific tags that you are limited to using. All tags, regardless of tag name (aside from @param, @throws, @return and @see), are treated equally. Their inclusion into the final documentation generated by ZenDoc is dependant on the HTML template used when that documentation is created. That means you can use a tag called @best_tag_ever and include its contents into your generated documentation so long as the template you use was built to support it.

The @param, @throws, @return and @see tags are special in that, due to their nature, require (or, at least, are given) some additional attention. The @param tag is used to describe a method parameter. It's special in that it consists of a parameter name as well as it's description. When ZenDoc reads an @param tag, it will separate the name and the description into separate parts so that you (the HTML template) can refer to them individually. Additionally, if ZenDoc recognizes that the parameter of the same name in the code is associated with a data type, that too will be added as a property of @param.

The @throws tag is treated much like @param, only it consists of a first word that is the error type of the error thrown followed by its description. ZenDoc does not include anything from the source code to the values supplied with @throws.

The @return tag in the comment is like most other tags, just having a description. However, as with @param and it too is given a data type based on that specified in the code.

The @see tag is used to provide references to other methods or properties that relate to the one being currently documented. Text following an @see tag should consist of only the related member's name or defintion, nothing else. If you wish to have multiple references, use a new @see tag for each. Do not use a comma separated list as that will be interpreted as one long name. ZenDoc reads @see tags differently in that it will search for another commented method or property with the specified name and associate a reference with that @see tag allowing you to possibly link to that member in an HTML template. The following method is documented with @param, @return and @see tags:

/**
 * Sets the position of the target object to a specific x,y location on the screen
 * @param xPos The horizontal position on the x axis to place the target
 * @param yPos The vertical position on the y axis to place the target
 * @throws IOException If an input or output exception occurred 
 * @see moveTargetBy
 * @see public function repositionTarget(Void):Void
 * @return True if the positioning is successful, False otherwise
 */
public function positionTarget(xPos:Number, yPos:Number):Boolean {
	// function body
}

HTML templates will be able to extract the additional properties associated with those tags for additional control in the documentation formatting process. See ZenDoc Template Format for more information on this.

Because documentation is created as HTML, the descriptions you provide may have contain HTML tags to help format their contents. In fact, if you do not include HTML tags, the result will be a single, long string of unformatted text which may run together when documentation is generated. It is recommended that HTML be included where needed to help keep your documentation nicely formatted.

Note: ZenDoc Comment and Code Parsing

One thing that is important to understand is that ZenDoc only considers definitions directly following Javadoc comment blocks (/** */). Those not commented will be overlooked when documentation is being generated (this includes those referenced with @see tags). This was done to keep ZenDoc simple and efficient.

[index]

ZenDoc Template Format

HTML templates are the most complicated aspect of ZenDoc, yet they are also what makes ZenDoc so flexible and customizable. Luckily you don't need to know how to create templates to make use of them; sample templates are already provided for pre-determined documentation styles. However, to create documentation that suits your taste and needs, you may want to create and use your own custom template.

The HTML templates used by ZenDoc are basic HTML files that define the layout of the documentation generated for a source file. Special Dreamweaver-like template tags within the template are used to determine what content from an ActionScript file is placed where. When the final HTML for the documentation is created, these tags are replaced with their respective values as interpreted by ZenDoc.

The following template tags are used by ZenDoc. Most are similar to commonly used Dreamweaver template tags.

<!-- TemplateBeginEditable name="..." [type="..."] [prefix="..."] [suffix="..."] [default="..."] --> 
	Default value
<!-- TemplateEndEditable -->
	
	
<!-- TemplateBeginIf cond="..." [type="..."] [prefix="..."] [suffix="..."] [default="..."] --> 
	Content
<!-- TemplateEndIf -->
	
	
<!-- TemplateBeginRepeat name="..." [type="..."] [prefix="..."] [separator="..."] [suffix="..."] [default="..."] --> 
	Repeated content
<!-- TemplateEndRepeat -->
	
	
<!-- TemplateParam name="..." type="..." value="..." -->


<!-- TemplateBeginFile -->
	File/output name
<!-- TemplateEndFile -->

*Properties surrounded by brackets ([]) represent optional properties.

There are actually 2 ways to write template tags, one using HTML comments as seen above with <!-- and -->, and an alternate way using the optional Dreamweaver expression tags @@( and )@@. For example, these tags are equivalent:

<!-- TemplateParam name="global" type="counter" value="+1" -->
@@( TemplateParam name='global' type='counter' value='+1' )@@

You would want to use <!-- and --> when writing template tags outside of other HTML tags and use @@( and )@@ when including template tags inside other HTML tags.

Note: Tag Rules

Tags are case sensitive and properties must be separated with spaces. Property values can be contained in either single or double quotes. Values within a property must use appropriate character entity replacements.

Here is each tag and its meaning:

TemplateBeginEditable:
Represents a value from the ActionScript file. This can represent a value from the comment used to describe a section of code, or a value from the line of code directly following that comment.
TemplateBeginIf:
Tests for whether or not a property name exists. If the condition is satisfied, the contents of the block is used
TemplateBeginRepeat:
Loops through a list of values (or other lists) as extracted from the ActionScript file repeating the contents between it and the following TemplateEndRepeat tag for each item in the list. The order of iteration is based on the order the code appears in the source file
TemplateParam:
Used for inserting non-ActionScript file related values such as the current date or a sequence of numbers incremented with each iteration of a TemplateBeginRepeat loop. It can also be used to set preferences.
TemplateBeginFile:
Sets a new output name for HTML output generated by ZenDoc (output is handled by the document implementing the ZenDoc class)

Before going into more detail about each of those tags and what they're capable of exactly, you'll need to understand the structure of an ActionScript file as interpreted by ZenDoc. The TemplateBeginEditable and TemplateBeginRepeat template tags rely on this structure to properly return a value or loop through the correct list of values when documentation is generated.

When ZenDoc interprets an ActionScript file, it reads through finding each /** ... */ block comment and logs it with the line of code that follows into a list called the members list. This list is then subdivided into 5 other lists: doctypes, properties, constructors, methods, and events. Each of these represent the primary "root" lists of an ActionScript document and contain content that is relevant to their name (i.e. the properties list contains a list of all the properties documented in the ActionScript file). Content within lists is interpreted further into additional lists or specific property values.

members:
A list of all Javadoc-commented doctypes, constructors, properties, methods and events within an ActionScript file
doctypes:
A list of document types associated with the ActionScript file. Technically, there should be only one, either a class definition or interface definition
properties:
A list of properties within the file
constructors:
A list of constructors within the file. There is usually one or none of these
methods:
A list of methods within the file
events:
A list of events within the file. Events are identified as properties declared with a name starting with "on" followed by a capital letter or number and have a Function data type

TemplateBeginRepeat tags are used to loop through lists. TemplateBeginRepeat tags can be used within other TemplateBeginRepeat tag blocks to loop through lists defined within those lists. TemplateBeginEditable tags get property values from the current loop within a TemplateBeginRepeat block (a block being between the TemplateBeginRepeat and TemplateEndRepeat tags). Anything within a TemplateBeginEditable block represents a default value if the property referenced doesn't exist or contains an empty value. Each TemplateBeginRepeat and TemplateBeginEditable require their respective closing tags.

Every template tag has their own properties which let you specify which ActionScript property they reference as well as let you set some text values to be used for the generated HTML. These include properties the respective Dreamweaver template tags supports as well as additional properties they do not.

TemplateBeginEditable
name:
(required) the name of the ActionScript or comment property to obtain
type:
(required in root list loops) specifies whether, in the ActionScript, the comment block or the section of code it references is used to obtain properties from when looping through a primary root list. Additionally, if not within root, it can be used to specify a loop created as though in the context of the document root. Acceptable values are "root", "comment", and "code"
prefix:
(optional) text to be placed at the beginning of the property value obtained. This is not added if the default value is used
suffix:
(optional) text to be placed at the end of the property value obtained. This is not added if the default value is used
default:
(optional) text to be used if the property being accessed is empty or does not exist. If the default attribute is not provided and the property is empty or does not exist, the contents of the TemplateBeginEditable tag will be used instead.
TemplateBeginIf
cond:
(required) the condition for the if block. This can be used to check for the existence of an ActionScript property or to compare its value with text. When checking for the existence of a property, the property's name is the condition, e.g. cond="description". When checking for a value, the property name and text to compare is used separated by an equals sign (=), e.g. cond="name=getValue". An exclamation point (!) can be used to negate conditions. For example cond="!description" will be true if description does exist and cond="name!=getValue" will be true if name does not equal getValue.
type:
(required in root list loops) specifies whether, in the ActionScript, the comment block or the section of code it references is used to obtain properties from when looping through a primary root list. Additionally, if not within root, it can be used to specify a loop created as though in the context of the document root. Acceptable values are "root", "comment", and "code"
prefix:
(optional) text to be placed at the beginning of the property value obtained. This is not added if the default value is used
suffix:
(optional) text to be placed at the end of the property value obtained. This is not added if the default value is used
default:
(optional) text to be used if the condition resolves to be false
TemplateBeginRepeat
name:
(required) the name of the ActionScript list to loop through
type:
(required in root list loops) specifies whether, in the ActionScript, the comment block or the section of code it references is used to obtain properties from when looping through a primary root list. Additionally, if not within root, it can be used to specify a loop created as though in the context of the document root. Acceptable values are "root", "comment", and "code"
prefix:
(optional) text to be placed at the beginning of the loop. This is not added if the default value is used
separator:
(optional) text to be placed between each item looped through. This is not added if the default value is used
suffix:
(optional) text to be placed at the end of the loop. This is not added if the default value is used
default:
(optional) text to be used if the list referenced is empty or does not exist
TemplateParam
type:
(required for some parameters) determines whether or not the parameter is run local to the loop or globally. Acceptable values are "preference", "local", and "global." Note: preferences set in this manner are set prior to the creation of documentation and cannot changed during the documentation process.
name:
(required) the name of the type of parameter to use. Acceptable values are "date", "counter", and "cycle" for non-preference types, and anything preference related if type="preference"
value:
(required) text that defines a parameters behavior
TemplateBeginFile
(none)

When starting with an HTML template, to start extracting ActionScript values, you normally start with a TemplateBeginRepeat tag since all values are contained within any or all of the primary root lists. Which loop is specified in the TemplateBeginRepeat tag's name property. For primary root lists, this is the only required property. Within a TemplateBeginRepeat block that is looping through a primary root list, you can specify additional TemplateBeginRepeat or TemplateBeginEditable tags for more loops or property extraction. For tags directly within a primary root list loop, a type property is required to specify "code" or "comment" to determine which part of the current list object you wish to use, that which makes up the comment or that which makes up the code.

Because ZenDoc allows for any block comment @ tag to be specified, in order to prevent confliction between properties defined in the comment and those used to represent aspects of the code they reference, each comment and code are extracted into separate blocks of reference. These are specified with the type template tag. Once this type has been specified for a repeat tag, nested loops within that tag do not specify type. The only time type would be used within those is if a repeat loop is needed to start back in the document root using a type value of root. This lets you loop through primary root lists while within other nested lists (if, for example, you need to get the class name within a loop).

The following maps out how an ActionScript block (comment and code) is interpreted:

root (document):

name="members" &                  // <- members are all comment-code blocks retrieved
name="doctypes" &                 // each following primary global list consists of individual
name="methods" &                  // blocks copied from the members list
name="properties" &
name="constructors" &

name="events"
 |
 +- type="comment"                // <- user defined properties in /** ... */ block comment
 |   |
 |   +- name="user-specified"     // <- any user-specified tag and respective text
 |   |   |
 |   |   +- name="text"
 |   |
 |   +- name="description"        // <- description (usually first untagged group of text)
 |   |   |
 |   |   +- name="text"
 |   |
 |   +- name="param"              // <- parameters
 |   |   |
 |   |   +- name="name"           // <- parameter name (first word in following text)
 |   |   +- name="type"           // <- parameter data type (as provided in code)
 |   |   +- name="description"    // <- parameter description (text following name)
 |   |   +- name="text"
 |   |
 |   +- name="throws"             // <- error method might throw (a.k.a. exception)
 |   |   |
 |   |   +- name="type"           // <- error data type
 |   |   +- name="description"    // <- error description (text following type)
 |   |   +- name="text"
 |   |
 |   +- name="return"             // <- return value
 |   |   |
 |   |   +- name="type"           // <- return data type (as provided in code (i.e. returntype))
 |   |   +- name="text"
 |   |
 |   +- name="see"                // <- see - references another member
 |       |
 |       +- name="id"             // <- id matching the id of the member the name references
 |       +- name="name"           // <- name of the matching member
 |       +- name="definition"     // <- definition of the matching member
 |       +- name="text"
 |
 +- type="code"                   // <- properties extracted from line of code following comment
     |
     +- name="kind"               // <- code identifier: "package", "class", "var", etc.
     +- name="list"               // <- the name of the primary global list the block belongs to
     +- name="definition"         // <- full line including extends and implements;
     |   |                        // (will contain multiple definitions for combined get and set)
     |   +- name="text"
     | 
     +- name="meta"               // <- meta tags for the block
     |   |
     |   +- name="text"
     |
     +- name="intrinsic"          // <- "intrinsic" if code identified as intrinsic
     +- name="native"             // <- "native" if code identified as native
     +- name="final"              // <- "final" if code identified as final
     +- name="override"           // <- "override" if code identified as being an override
     +- name="get"                // <- "get" if code identified as being a getter
     +- name="set"                // <- "set" if code identified as being a setter
     +- name="dynamic"            // <- "dynamic" if code identified as dynamic
     +- name="access"             // <- provides "public", "private", etc. or namespace
     +- name="static"             // <- "static" if code identified as static
     +- name="extends"            // <- (doctypes only) object the document extends if any
     |   |
     |   +- name="name"           // <- base name of the superclass
     |   +- name="path"           // <- package path directories, not including name
     |   |   |
     |   |   +- name="text"
     |   |
     |   +- name="text"
     |
     +- name="implements"         // <- (doctypes only) interfaces that the document implements
     |   |
     |   +- name="name"           // <- base name of the interface
     |   +- name="path"           // <- package path directories, not including name
     |   |   |
     |   |   +- name="text"
     |   |
     |   +- name="text"
     |
     +- name="type"               // <- data type
     +- name="param"              // <- (methods and constructors) parameters
     |   |
     |   +- name="name"           // <- parameter name
     |   +- name="type"           // <- parameter data type
     |   +- name="text"
     |
     +- name="value"              // <- (properties only) default value if assigned
     +- name="returntype"         // <- return value's data type (same as type if property var)
     +- name="id"                 // <- unique numeric id representing order in file
     +- name="path"               // <- package path directories, not including name
     |   |
     |   +- name="text"
     |
     +- name="name"               // <- item name, not including package (path)

Each branch represents a value that can be looped with TemplateBeginRepeat. Those without branching are direct values which can be obtained with TemplateBeginEditable. Be aware that the branching for type (comment and code) is placed in the same tag that the subsequent name property is specified. So going through comment descriptions with a TemplateBeginRepeat within a root methods loop uses only one TemplateBeginRepeat tag with both type and name specified. The methods loop itself doesn't require a type, nor does any loop used within the descriptions loop.

Notice that each comment property (/list) branches out at least once, even if only containing one text property (a text property simply represents the direct text associated with the named property). This is because you can have the same @ tag repeated multiple times as seen with @param and @see in a previous example. Each comment property is assumed to be a list. Code properties, on the other hand, are more specific and may be lists or simply property values. If a TemplateBeginEditable is used on a list, the first value within that list is returned.

HTML templates use the TemplateParam tag to generate text not specific to the ActionScript file being interpreted. There are 3 variations: date, counter, and cycle which are specified in the name property of a TemplateParam tag.

date:
Provides the current date
counter:
Creates a number that can be incremented, often used to number items in a loop
cycle:
Creates a cycle of values that repeat themselves when looped

Additional properties, type and value, define their behavior.

date
value:
Date format as used in the PHP date() function.
counter
value:
A starting value for the counter (e.g. "set 1") or the increment at which the counter increases (e.g. "+1")
type:
Determines whether or not the counter continues within only the current loop (local) or within any loop (global). Acceptable values are "local" and "global"
cycle
value:
A pipe ("|") delimited list of strings that will be used in a cycle. When the last string in a loop is reached, the next value returned will be the first
type:
Determines whether or not the cycle continues within only the current loop (local) or within any loop (global). Acceptable values are "local" and "global"

That basically covers it. The following examples will better illustrate how HTML templates generate content from an interpreted ActionScript file.

[index]

Examples

The first example will cover basic usage of TemplateBeginRepeat and TemplateBeginEditable.

  1. ActionScript File: Tree.as
    The Tree class is a simple class with 3 properties: bark, branches, and roots. The class definition and 2 properties are commented with /** ... */ block commenting.
     
  2. Template File: template1.html (txt)
    The HTML template used for this class consists of two TemplateBeginRepeat tags, one for looping through doctypes and the other for properties. In each are two TemplateBeginEditable tags, one for name and the other for description. Notice that, since each are in a root loop, a type property is provided to specify whether values from the comments or code are being used. The text within the TemplateBeginEditable tags represent default values - what to use if the property is empty or doesn't exist. Typically we shouldn't see this in the final documentation if the class is commented as it should be.
     
  3. Resulting Documentation: Tree.html
    You can see the comment replacements in the resulting generated documentation. Though there are 3 properties for the Tree class, notice that only 2 are listed. This is because the roots property wasn't provided with a preceding block comment so ZenDoc ignored it. As you can see, all property names and descriptions were properly found so none of the default text within the TemplateBeginEditable tags was used.

The next example is an ActionScript interface file. The template being used will make use of nested TemplateBeginRepeat tags as well as some TemplateBeginIf tags to A) help distinguish classes from interfaces and B) only list parameters for methods if they exist. Comment @ tags will also be used to extract more information about methods defined within the interface.

  1. ActionScript File: FightingStyle.as
    FightingStyle is a basic interface with 2 methods. The interface itself along with each method is commented so nothing will be missed in the template. Each method has @ tags helping describe their characteristics.
     
  2. Template File: template2.html (txt)
    The HTML template consists of two parts, one for the doctype(s) and one for the methods. For the doctype, a TemplateBeginRepeat is used to cycle through the doctypes - the only doctype. Within that loop is a TemplateBeginIf tag. It's condition is cond="kind=interface" which checks to see if this doctype is an interface. If so, the interface's name is displayed as "Interface (name)". Following that TemplateBeginIf is another TemplateBeginIf which checks the kind to be a class. If a class, the message "This template does not support classes." is displayed.

    Following the doctypes loop is a TemplateBeginIf checking for methods. If methods exist, they are looped through. Following the name and description for each method is another TemplateBeginIf checking for parameters. If they exist, a TemplateBeginRepeat is used to loop through and display them as well.
     
  3. Resulting Documentation: FightingStyle.html
    One thing you'll probably notice right away with the resulting documentation is the excess white space. If you want to avoid this, you'll have to remove the white space between template tags. This can make for an ugly (and horizontally lengthy) template file but is sometimes needed for appropriate formatting. Also notice that the description for the headbutt method says only "Massive blows with the forehead" and not "Causes this fighter to headbutt opponent". This is because description, like every other comment property, is a list. When a list is retrieved with TemplateBeginEditable, the last value in that list is returned. Since the first un-tagged comment line is contained under the description property, it becomes the first of two, the other being that associated with the explicit @description tag. This is the last tag in the list so its value is returned. If all descriptions are desired, a TemplateBeginRepeat would be needed to loop through and display each.

    Everything else works out as it should. The document is correctly identified as an interface and parameters for kick and only kick are displayed as it was the only method that had them all thanks to TemplateBeginIf tags.

The last example covers some uses of TemplateParam tags and how @see links can be created using see's id property.

  1. ActionScript File: Cursor.as
    This Cursor class resides in the com.senocular package and extends MovieClip. It has a few properties and methods, all commented. One method, onFade represents an event. ZenDoc will recognize it as being one as it begins with "on" followed by a capital letter and has Void as a return type. Any method with those qualities are seen as events.
     
  2. Template File: template3.html (txt)
    Things to note in this template file are the use of TemplateParam tags and how id properties are used in HTML anchors. Each of the three TemplateParam tags are used. A counter tag, which increments itself by 1 every time its used, generates numbers for each property, method and event listed. Because it is of the type global, the value doesn't reset is kept for each list in which its used. The cycle TemplateParam tag, however, is defined with a type of local. It resets itself for each list starting again by its first value. If it were global, the background colors wouldn't start back at blue for the beginning of each list. At the bottom of the page, the date is posted using the date TemplateParam tag.

    Each property, method, and event are preceded by a named anchor tag. This allows for links to be followed to their location within the page - links such as those created with @see tags. Each list references the see properties within them. If they exist, links are created that go to #[id] which reference their respective named anchor tags. Member names could also be used as links. Notice that @@( and )@@ template tags were used for those within other HTML tags.
     
  3. Resulting Documentation: Cursor.html
    I'm sure it's everything you had hoped it would be.
[index]

Tips and Tricks

  • Keep in mind that white space matters when using HTML template comment (<!-- -->) tags. This is especially important in something such as a comma separated list generated with a TemplateBeginRepeat. If your TemplateEndRepeat is not directly after the content of the block, a space may be seen in the resulting HTML.
  • Though some template tags have default properties where you can specify default text to be used (if the property doesn't exist or consists of an empty value), it would be a good idea to, instead, use TemplateBeginIf tags to first check for the existence of the property. The advantage of TemplateBeginIf tags is that you can use other tags within a TemplateBeginIf block, unlike that with the default property. Simply use cond="!propertyname" and include your "default" values within the TemplateBeginIf tag block.
  • It may be useful to create your own HTML templates for your files so that you can easily change their style. Current samples use inline styles. With a custom HTML template, you can use a linked style sheet and easily edit that style sheet to change the look and feel of all your documentation. If you do not feel comfortable with making your own HTML templates, you can always copy one used as a sample and edit its style information to suit your needs.
  • ZenDoc recognizes the next line of text (not including blank lines or meta tags) following a /** ... */ block comment as the code relating to that comment, even if the following line is, itself, a comment (single-line // comment). If you "comment-out" a property definition that is preceded by a block comment, it will be picked up by ZenDoc as though it were uncommented. This can work against you if you wish for that not to happen. However, it can also work for you in that it allows you to create documentation for elements within the ActionScript file that won't actually be interpreted by Flash if commented. You may want to use commented lines for describing multiple constructors, getter/setter definitions, definitions that are inherited, or for those that exist in some other way that don't require a declaration/definition.
  • Making your own lists. Keep in mind that all blocks interpreted by ZenDoc are categorized into their own respective lists such as methods and properties, but also are all retained within the members list. You can effectively create your own lists by defining a custom @ tag in your code that specifies a category or custom list name for that block. Then, all you need to do in the HTML template is repeat through the root members list and use a TemplateBeginIf to check for the value of that @ tag. If it matches the category or custom list you specified, the repeat loop will only loop through those associated with that tag.
  • You can use condition template blocks that resolve to false to create content for templates which will not be seen in the documentation output. This will let you add notes or other HTML that is helpful solely to the template.
[index]

Limitations

Despite the possibilities with ZenDoc, there are, as with most things, limitations:

  • ZenDoc only parses a single source file at a time not taking into consideration other files such as those that the current class might inherit from (as Javadoc does to show complete inheritance hierarchy)
  • Inline tags such as {@link} are not supported
  • Javadoc %I% and %G% for @version are not supported
  • ZenDoc does not recognize paths for objects whose paths are imported with the import command
  • ZenDoc cannot differentiate from multiple classes contained within the same file

* Remember ZenDoc only parses code which has a block /** ... */ comment preceeding it - this includes meta tags.

[index]

Version History

  • 1.5.1:
    • Removed packages list in templates root in favor of using path in doctype
    • support has been added for the Javadoc serialField tag
    • Javadoc tags are no longer case sensitive
    • returns tags are remapped to return and exception tags are remapped to throws in templates
  • 1.5.0:
    • Further improved support for ActionScript 3.0
    • 'package' is a new template list along with doctypes and methods etc. as well as a new kind (for AS3)
    • Fixed issues revolving around options not being set from within the HTML interface
    • Prevented Apply in options from opening a new window if used after external documentation
    • Added URL option in external documentation. If the source file is from a URL and the template file is from a URL or a sample, the resulting URL in the documentation page can be reused to access that file's documentation
    • Text within write (and URL) fields of External Files retained after applying options
    • Automatic selection behavior of the radio buttons in the External Files tab has changed from using onfocus to onchanged
    • Prevented options settings from always saving even if remember_options was false
    • The remember_options property is now off by default
    • Added get, set, native, final, and override as template properties for code
    • Added combine getter setters option (combine_get_set) that allows get and set methods for a single property to be under one definition (both must be commented)
    • The code property definition in templates now a list to facilitate combined get and set definitions
    • TemplateBeginEditable tags now, if used in a list, will reference the first item in that list until at the lowest level of of that list where the text value of the property is used (which is the last item in the list, not the first)
    • Manual and HTML errors for external documentation are now in the style of the ZenDoc interface
    • Fixed a bug causing all check boxes in options pane to be checked or unchecked with root directory of local files listing
    • Added a view link for local templates
    • Added Reusable URL option for URL-based actionscript files
    • TemplateBeginEditable tags now support the default attribute. If provided, it will be used as the alternative to the tag's value rather than the contents between TemplateBeginEditable and TemplateEndEditable
  • 1.1.0:
    • Improved support for ActionScript 3.0
    • Corrected a type mismatch error
  • 1.0.0:
    • File links no longer forced to open in new window (Document External continues to open a new window)
    • Results pane now correctly displays an error when local documentation was attempted with no files selected
    • Links load source and documentation using a new, more secure behavior
    • Added a (doc) documentation link for source files in the local source file listing if a documentation document was found for it
    • Options tab now has an Apply button to save options set (this also updates the local file list with documentation links if applicable)
    • Added a remember_options option in the ini file that will allow the HTML version of ZenDoc to use its most recently used settings upon reopen
    • The root directory in the file listing no longer shows the full path of that directory, just the directory name
    • Minor cleaning up of the ZenDoc directory
  • 0.10.1:
    • Fixed issue where code values of 0 were interpreted as having no value
    • Changed set option in counter from displaying set value to not displaying anything. Use +(#) to display
    • Fixed errors associated with saving documents when a output_destination_directory is set
    • Added command like option -i allowing you to specify an ini file to use with the call
    • Added a few additions to error reporting
    • Included lock_output_extension in the ini file and defaults (was missing)
  • 0.10.0:
    • Updated to a new tabbed interface
    • Fixed Notice warning array to string conversion
    • Fixed missing NO_FILE error
    • Added protection for lock_output_extension (locks other than lock_output_extension, lock_source_file_directory, and lock_output_destination_directory are based on browser client support)
  • 0.9.9:
    • Added script to be used with PHP's CLI (Command Line Interface); allows ZenDoc to be run through SE|PY
    • Added a number of options for the client including specifying a source file directory, specifying a documentation extension, determining whether or not generated documentation can overwrite existing files, and a few others.
    • Files within the source file listing are now opened through a php script to help with compatibility between source file directory locations (OS paths vs server paths)
    • Removed // comments from script strings preventing instances when they sometimes appeared in code
    • Fixed error in @throws tags if no description was given with type thrown
    • Improved implementation of preferences set through template tags; also now with an option to ignore them
    • Changed tabbed interface to work through JavaScript instead of reloading the page each time a new tab is selected
    • Separated options into new tab
    • Removed documentation (help) from tabs and made it its own page; help is now accessible through a link to the right of the tabs
  • 0.9.8:
    • Changed the name from AS2Docular to ZenDoc
    • Changed the tabs of the interface to Local, External, and Help
    • Fixed some resizing difference between tabs in the interface
    • When documenting local files, you now stay in the same tab
    • Updated available documentation options
    • Defined a class to control the client interface
    • Completed method for saving multiple files when a template uses TemplateBeginfile tags
    • Added support for @throws tag (@exception can also be used in place of throws)
  • 0.9.7:
    • Added support for TemplateParam type="preference" allowing you to set preferences through the template; name="preferenceToSet", value="preferenceValue"
    • Prevented whitespace at the beginning and ends of output strings from being trimmed off
    • Allowed a filename to be used more than once in TemplateBeginFile allowing you to continue adding to a file if needed
    • An empty TemplateBeginFile block now returns output to the original buffer
    • Removed responsibility of file content extraction from the ZenDoc class (left to the client)
    • Separated Template parser and ActionScript parser into separate classes
    • Abandoned escaped quotes in template tags in favor of using html entities
    • Added support for new template tag using @@( and )@@ instead of <!-- and --> to allow for (X)HTML-compatible inline template tags
    • Fixed a bug improperly translating script if no comments were used
    • Fixed problem where block comments in function parameter lists became part of parameter definition
    • Flash class meta tags now recognized
    • Added use_meta_events preference to allow event detection from flash meta tags
    • Changed parse_events preference to parse_on_events
    • Included option to recognize events from an ambiguous @event comment tag
    • Prevented comment tags without any associated text from being ignored
    • Better commenting for source code
  • 0.9.6:
    • Updated to a new tabbed interface
  • 0.9.5:
    • Removed the type applied to the default value of TemplateBeginEditable blocks if that TemplateBeginEditable specified one. Before this change, you couldn't access comment properties within a TemplateBeginEditable default block if the TemplateBeginEditable type was specified as being code.
    • Included preferences for the ZenDoc class
    • Included custom parameters (TemplateParam type="custom") for the ZenDoc class
    • Fixed a typo causing the date TemplateParam to always result in 0
  • 0.9.4:
    • Added support for a <!-- TemplateBeginFile --><!-- TemplateEndFile --> tag (this is not a standard Dreamweaver tag). Content within a TemplateBeginFile block is resolved as a filename. Whenever a filename is defined through TemplateBeginFile, all following template translation is output associated with that name. This also meant changing the output of ASDocular->translate() from a sting to an array of an unnamed buffer and an array of TemplateBeginFile-named files and their respective outputs. Note that the saving of a file is not handled by ASDocular; it simply generates HTML strings from ActionScript and HTML templates. File saving would be left to the PHP document implementing the ASDocular class
    • Fixed unmatched TemplateEndIf warning message which incorrectly identified itself as an unmatched TemplateEndEditable
    • Added list code property which represents the root list the code item belongs to (can be used when cycling through members to distinguish items)
    • Changed behavior that removed preceding asterisks (*) in a comment block to only remove up to 1 character of white space following an asterisk. This makes it easier to include preformatted text within a comment block whose lines are all preceded by asterisks
  • 0.9.3:
    • Fixed bug causing erroneous asterisks (*) to be left in a comment definition when not followed by text
    • Allowed @see tags to recognize members not only through name, but also definition. Definition was also included as a property of see
  • 0.9.2:
    • Added type property to @param and @return comment tag properties. Comment params now have the properties name, description, type and text; and returns now have type and text. Type values are those extracted from the comment's relating code line
    • Included code properties for interface, dynamic, static, access (public or private), and value
    • Fixed pattern matching bug where keywords surrounded by "$" in definition names would be incorrectly recognized as the valid keywords applying to that definition, e.g. class my$dynamic$Class { ... } would be recognized as being dynamic
    • Included support for <!-- TemplateBeginIf --><!-- TemplateEndIf --> template tag blocks which support checking for whether or not a property or list exists and for comparing property values with text
    • Changed event recognition from using variables to using methods.
  • 0.9.1:
    • Public Release
    • Provided condition where a primary root list name property can be retrieved using a TemplateBeginEditable, skipping the need for TemplateBeginRepeat (only in the root scope)
    • Set order of primary root list name and inner property text properties to be last in properties available
    • Included support for extends and implements, parsing those objects and interfaces within the doctype definition
    • Returned event recognition to be based on a var with the "on" + [A-Z0-9] pattern and a Function data type in favor of the event keyword.
[index]

Related Tools

  • Acid
    http://icube.freezope.org/acid/
  • ActionDoc
    http://www.jellyvision.com/actiondoc/
  • as2api
    http://www.badgers-in-foil.co.uk/projects/as2api/
  • AS2Doc
    http://www.as2doc.com/
  • ASDoc
    http://labs.adobe.com/wiki/index.php/ASDoc
  • ASDocGen
    http://osflash.org/asdocgen
  • AS2DocGenerator
    http://as2docgenerator.berlios.de/
  • AS2Docs
    http://www.as2docs.com/
  • ASTD
    http://asdt.sourceforge.net/
  • BLDoc
    http://www.blinex.com/index.cfm?view=bldoc
  • Doxygen
    http://www.stack.nl/~dimitri/doxygen/
  • Javadoc
    http://java.sun.com/products/jdk/javadoc/
  • Natural Docs
    http://www.naturaldocs.org/
  • phpDocumentor
    http://www.phpdoc.org/
  • VisDoc
    http://www.visiblearea.com/visdoc/

Additional Template References

[index]

Credits

ZenDoc was conceived and written by Trevor McCauley (www.senocular.com). For the latest version and updates visit www.zendoc.org. Special thanks to Pixelwit.

[index]