Just as you can use the Javadoc tool to generate documentation for Java, you can use ApamaDoc to generate documentation for EPL. ApamaDoc, which is based on Javadoc, generates reference documentation from EPL source code. To enhance what ApamaDoc automatically generates, you can insert annotations in block comments. Annotations are a mixture of text and tags.
ApamaDoc is an export wizard in Apama Plugin for Eclipse. It generates static HTML pages that document the structure of all EPL code in a project. This includes the .mon files that you create as well as all .mon files in all bundles that have been added to a project.
Alternatively, you can generate ApamaDoc using the apamadoc command-line tool or from an Ant script.
Code constructs that are documented
The ApamaDoc generates documentation for the following code constructs:
Monitors
Events (defined outside monitors)
Fields, constants and actions on events
Custom aggregate functions
Fields, constants and actions on custom aggregate functions
Plug-in import statements
By default, the ApamaDoc export wizard does not generate documentation for inner fields or events of a monitor. If you want to include inner fields and events of a monitor, generate ApamaDoc without a user interface using the --includeMonitorMembers option. See Generating ApamaDoc from the command line or Generating ApamaDoc from an Ant script for more information.
Right-click the project name and select Export from the context menu.
In the Export dialog, expand Apama, select ApamaDoc Export, and click Next.
Identify the folder that you want to contain the ApamaDoc output, and click Finish.
To view the ApamaDoc output, go to the output folder you identified and double-click the index.html file. The generated ApamaDoc opens in your browser.
Try this with any project you already have. Even if you have not added any ApamaDoc annotations, you can see that ApamaDoc automatically generates a lot of documentation.
Inserting ApamaDoc comments
To augment the documentation automatically generated by ApamaDoc, insert comments in your EPL files in the following format:
Start the comment with the /** characters, rather than the usual /* notation.
Enter the text you want to appear in the generated documentation.
After each newline, to continue the ApamaDoc comment, insert a * character at the beginning of the next line.
As needed, insert one or more tags for particular constructs. See Inserting ApamaDoc tags. Any tags must occur at the beginning of a newline (ignoring * and whitespace characters). Documentation for a tag ends when you declare another tag or end the comment.
End the comment with the usual */characters.
For example, your EPL code might look like this:
/**
* Called by the monitor when it executes the onload() action.
* This action maintains the configuration for this scenario.
* @param sId The scenario ID.
* @param updateCallback The callback after the configuration is updated.
*/action init(string sId, action<> updateCallback) {
scenarioId:=sId;
route GetConfiguration(scenarioId);
listener l:=on Configuration(scenarioId=scenarioId) as c {
config := c.configuration;
defaultConfig := c.defaults;
configurationUpdated();
updateCallback();
}
listeners.append(l);
}
When ApamaDoc processes these comments, it removes initial and trailing whitespace and * characters. For example, the ApamaDoc output would look like this:
init
void init(string sId, action< > updateCallback)
Called by the monitor during execution of the onload() action. This action
maintains the configuration for this scenario.
Parameters:
sId - The scenario ID.
updateCallback - The callback after the configuration is updated.
Listens:
com.apama.scenario.Configuration
Inserting ApamaDoc tags
ApamaDoc automatically generates documentation for EPL code constructs. To enhance the quality of the documentation, you can insert tags that let you provide and link to additional information. A tag begins with an @ symbol and is immediately followed by a name and other information. The following table describes the tags you can insert.
Tag
Description
Use For
@author name
There are no restrictions on the name. It can span multiple lines. It is ended by the start of the next tag.
Events, monitors, and custom aggregate functions
@deprecated [ description ]
The optional description can be anything pertinent to the deprecated construct. For example, you might want to suggest a newer equivalent or provide a reason for the deprecation.
All code constructs
@emits eventRef [ description ]
Documents events that are emitted. eventRef specifies a link to an event definition. The optional description can be anything pertinent to the emitting of the event. See Inserting ApamaDoc references.
Actions and their enclosing types
@enqueues eventRef [ description ]
Documents events that are enqueued. eventRef specifies a link to an event definition. The optional description can be anything pertinent to the enqueueing of the event. See Inserting ApamaDoc references.
Actions and their enclosing types
@listens eventRef [ description ]
Documents events that are being listened for. eventRef specifies a link to an event definition. The optional description can be anything pertinent to the event listener. See Inserting ApamaDoc references.
Actions and their enclosing types
@param codeRef [ description ]
Documents arguments to actions and custom aggregate functions. codeRef specifies the parameter name. The description should be a sentence describing the purpose of the parameter and any constraints on the permitted values that may be specified.
Actions and custom aggregate functions
@private
Hides constructs from ApamaDoc. On a line by itself, immediately precede the construct that you do not want to generate documentation for with the following: /** @private */
All code constructs
@returns description
Documents the return value of an action or custom aggregate function. The description should be a sentence describing the purpose of the return value, and any pertinent information about the possible values that may be returned. Note that for backwards compatibility reasons @return is maintained as an alias for @returns.
Actions and custom aggregate functions
@routes eventRef [ description ]
Documents events that are being routed. eventRef specifies a link to an event definition. The optional description can be anything pertinent to the routing of the event. See Inserting ApamaDoc references.
Actions and their enclosing types
@see
There are three forms of this tag. Each form documents a relationship between a code fragment and some other information. @see “description”
Lets you insert text that explains the relationship.
@see codeRef description
Lets you reference an EPL code construct and describe the relationship between this construct and that construct. codeRef specifies a link to some other EPL code. See Inserting ApamaDoc references.
@see <a href="url">linkText</a> [description]
Lets you specify an HTML link to an external resource. Optionally, you can add more information.
All code constructs
@sends eventRef [ description ]
Documents events that are sent to a channel. eventRef specifies a link to an event definition. The optional description can be anything pertinent to the sending of the event to a channel. See Inserting ApamaDoc references.
Actions and their enclosing types
@since version
Documents when a code construct was introduced. Replace version with a particular version number, for example, 9.9.
All code constructs
@spawns actionRef [ description ]
Lets you document the lifecycle of a monitor. actionRef specifies a link to an action definition. See Inserting ApamaDoc references.
Actions and their enclosing types
@throws [ description ]
Documents exceptions which may be thrown from an action and the conditions which would cause the action to throw an exception.
Actions
@version version
Lets you specify a version of the current incarnation of this code. Replace version with a particular version number, for example, 9.9.
Events, monitors, custom aggregate functions, and import statements
Inserting ApamaDoc references
Many ApamaDoc tags contain links to other parts of the EPL code. These tags specify one of the following link types:
Code references
Type references
Event references
Action references
A code reference is a link to a monitor definition, an event type definition, an action definition, a member (variable or named constant) declaration or an import declaration. A code reference has two forms.
The first form links to constructs that are in the monitor definition or event type definition that contains this ApamaDoc comment. The target of the link can be a variable declaration, named constant declaration, import declaration, or action definition. The format for this code reference is as follows:
[ # ](member | import | ( action() ) )
The hash symbol is optional. You must specify one of the following:
Name of a member (variable or named constant) that is in the monitor or event type definition that contains this ApamaDoc comment.
Name of an item that is being imported in the monitor or event type definition that contains this ApamaDoc comment.
Name of an action that is in the monitor that contains this ApamaDoc comment. If you specify an action, the name of the action must end with parentheses. For example:
#updateOrder()
The second form links to constructs that are not in the monitor or event type definition that contains this ApamaDoc comment. You can link to code constructs that are in the same package or in other packages. The format for this code reference is as follows:
Replace type with the name of a monitor or event type definition. If the ApamaDoc comment is in the same package as the link target, the package specification is optional. If you replaced type with the name of an event that is defined in a monitor, you must replace monitor with the name of that monitor and you must specify the package name.
The hash symbol followed by a name is required when the link target is a variable declaration, named constant declaration, import declaration, or action definition. If you specify an action, the name of the action must end with parentheses.
If the code reference is valid the rendered HTML output contains a hyperlink to the referenced code construct’s documentation followed by the descriptions text, if any. If the reference is not valid, the output displays only the tag’s description text if you provided it.
A type reference is a subset of a code reference. It always links to a monitor or event type definition.
An event reference is a subset of a type reference. It always links to an event type definition.
An action reference is a subset of code reference. It always links to an action. The action can be in an event type definition, in a monitor, or in an event type definition that is in a monitor.
Inserting EPL source code examples
ApamaDoc supports the <code>...</code> tag in ApamaDoc comments. You can use this tag to specify code snippets as part of the comment. In this case, you need not specify the comment character (*) at the beginning of each line.
The ApamaDoc <code> tag is a block element, and is not the same as the HTML <code> tag that is used for inline markup. Unlike the HTML <code> tag, the ApamaDoc <code> tag preserves the indentation and line breaks of the code snippet. You need not use the HTML <br> tag to force a line break.
If you want to mark up pieces of program code within the running text, use the HTML tag <tt>.
In many cases, you can enter the less-than (<) and greater-than (>) signs as they are. However, you need to take care when you have text that is enclosed in these signs in your comment and which has no spaces between the text and these signs (for example, sequence<string>). This will be interpreted as an HTML tag. To avoid this, we recommend that you always add spaces (for example, sequence< string >). If this is not possible for your particular use case, you have to use the < and > entities instead (for example, sequence<string>). So check the generated result carefully if you are using these signs.
Example:
/**
* This is an example of a comment.
*
* When using the <tt>code</tt> tag, all indentation and line breaks
* are preserved.
<code>
sequence< string > s :=
["Something", "Completely", "Different"];
print ", ".join(s);
</code>
* Note that the above < and > signs will be generated unchanged
* because spaces have been added.
*/
Info
If you have to use the special symbol @ within the ApamaDoc <code>...</code> tag, you must use the HTML ASCII code @ instead of the symbol. Otherwise, this will be interpreted as an ApamaDoc tag (such as @param).
Generating ApamaDoc from the command line
The apamadoc tool generates HTML documentation in ApamaDoc format from EPL files (.mon files).
The executable for this tool is located in the bin directory of the Apama installation. Running the tool in the Apama Command Prompt or using the apama_env wrapper (see Setting up the environment using the Apama Command Prompt) ensures that the environment variables are set correctly.
Synopsis
To generate HTML documentation from EPL files using the apamadoc tool, run the following command:
apamadoc [*options*] *output_folder* *input*...
When you run this command with the --help option, the usage message for this command is shown.
Description
The apamadoc tool generates the HTML documentation in the specified output folder, using the input method described below.
You can automatically link to an external ApamaDoc documentation. If you are online and have access to the official Apama documentation, if a type is not available in your ApamaDoc, but can be found in the official API Reference for EPL (ApamaDoc), the apamadoc tool automatically adds a link to the official ApamaDoc. If this is not possible, the type remains unlinked.
You can view the ApamaDoc by opening output_folder/index.html in a web browser.
Options
The apamadoc tool takes the following options:
Option
Description
-t title
Uses the specified title in the generated documentation.
-p
Generates documentation for elements marked as private.
-v
Generates verbose output on standard output.
--includeMonitorMembers
Generates documentation for monitor members. By default, ApamaDoc is only generated for the API exposed by the specified EPL files. The members of monitors are therefore not generated (for example, inner events, variables and constants, fields in events, and actions).
--link apamaDocURL
Generates links to an external ApamaDoc documentation. This is useful if you want to reference types in another ApamaDoc set. The apamaDocURL parameter specifies the URL where the external ApamaDoc is hosted. For example, example.com/ApamaDoc.
Info
This external documentation must have been created by ApamaDoc 10.15.5 or higher.
If a type cannot be resolved locally, the tool tries to find it in the linked ApamaDoc. You can specify this option multiple times, with later --link or --linkOffline options taking precedence.
--linkOffline apamaDocURL elementListLocation
Generates links to an external ApamaDoc documentation. This is useful if you want to reference types in another ApamaDoc set.The apamaDocURL parameter specifies the URL where the external ApamaDoc is hosted. For example, if the external ApamaDoc is located at example.com/ApamaDoc, this is the first parameter.
The elementListLocation parameter specifies the location of your element-list file. This can be inside a local copy of your ApamaDoc or at a remote URL.
If a type cannot be resolved locally, the tool tries to find it in the linked ApamaDoc. You can specify this option multiple times, with later --link or --linkOffline options taking precedence.
--warnings true|false
Prints warnings to stderr if set to true. Default: false.
--help | -help | -h
Displays usage information.
Operands
The apamadoc tool takes the following operands:
Operand
Description
output_folder
The name of the folder in which the documentation is to be generated.
input
The input method. Specify one or more of the following (you can specify any combination of these): - A file containing a list of EPL files, separated by newlines. The filename must be preceded by an ampersand (@). For example, @epl_list.txt.
A folder that is recursively searched for the EPL files.
An EPL file.
If the same EPL file occurs more than once in the input, this file is only processed once.
If an input file or folder is not found, the apamadoc tool reports an error. Documentation is not generated in this case.
Examples
The following examples show the different ways in which the apamadoc tool can be started:
Generate documentation in the doc folder, using the EPL files listed in the epl_list.txt file:
apamadoc doc @epl_list.txt
Generate documentation as above, but with “Example” as the title in the generated documentation:
apamadoc -t "Example" doc @epl_list.txt
Generate documentation in the doc folder, recursively processing the EPL files in the src/epl folder with verbose output enabled:
apamadoc -v doc src/epl
Generate documentation in the doc folder from the src/epl/example.mon file only:
apamadoc doc src/epl/example.mon
Generate documentation in the doc folder, using the following: the EPL files listed in the epl_list.txt file, the EPL files recursively found in the src/epl folder, and the myepl.mon file from the parent folder:
apamadoc doc @epl_list.txt src/epl../myepl.mon
Generating ApamaDoc from an Ant script
Generating ApamaDoc from an Ant script is useful if you want to control what ApamaDoc generates without user-interface intervention, for example, when you are running nightly build integrations. Also, using the Ant script, you can control which files are exported and which files are omitted. See the generate-apamadoc macro definition in the apama-macros.xml Ant script for more details. You can find this Ant script in the etc directory of your Apama installation.
To generate ApamaDoc from an Ant script, you have to create a build.xml Ant script that uses the generate-apamadoc macro to build ApamaDoc for the EPL files you wish to document. For example:
<?xml version="1.0" encoding="UTF-8"?><project name="" default="apamadoc" basedir="."><property environment="env"/><import file="${env.APAMA_HOME}/etc/apama-macros.xml"/><target name="apamadoc"><generate-apamadoc outputDir="./apamadoc-output" title="ApamaDoc Title"><!-- standard Ant fileset to specify which files should be documented --><fileset dir="./monitors"><include name="**/*.mon"/></fileset></generate-apamadoc></target></project>
By default, ApamaDoc is only generated for the API exposed by the specified EPL files. The members of monitors are therefore not generated (for example, inner events, variables and constants, fields in events, and actions). This can be enabled, however, using the includeMonitorMembers attribute.
Info
The script that you use to generate ApamaDoc requires Apache Ant. To set the path appropriately, it is recommended that you run your script from the Apama Command Prompt (see Setting up the environment using the Apama Command Prompt). If you do not use the Apama Command Prompt, then you must ensure that the PATH variable contains an entry for the Ant installation folder (such as C:\ant), which makes the Apama ant.bat file accessible to ApamaDoc generation.