WEB APPLICATION CODE AUTOMATED DOCUMENTOR

USER GUIDE

Frans Coenen and Reshma Patel

Transglobal Express Ltd and The University of Liverpool


9 October 2007

Revisions: 17 October 2007, 17 July 2008


CONTENTS:
  1. Overview.
  2. Start Material.
  3. Hyperlinks.
 
  1. ASP blocks.
  2. ASP functions.
  3. Script blocks.
 
  1. Script functions.
  2. Code overview.
  3. Acknowledgements.

1. OVEREVIEW


The Transglobal Web Based Application (WBA) automated code documentor was developped for application to WBA code files used at Transglobal Express Ltd. The primary objective was to provide a means for automatically producing documentation for WBAs where no such documentation prviously existed. The basic concept and mode of operation is based on the Java Doc Tool produced ny Sun Microsystems, i.e. the documentor makes use of specially annotated commnets in the source code. The documentor was developed as part of the Transglobal KTP project; a joint venture between Transglobal Express Ltd and the Department of Computer Science at University of Liverpool.

Broadly the documentor identifies .asp and script blocks within WBA code files and then the functions within those blocks. Once identified information is extracted and displayed in a series of .html files (one per code file making up the WBA). The naming convention for the "document files" is to remove amy post fix (e.g. .asp or .html) and replace it with Doc.html. The documentation files are currently written to the same directory from which the documentation generator code is run.

Much of the information extracted is based on comments within the code, the onus is on the developers to include these comments. Alternatively the maintenance team can include appropriate comments, this is the approach that has been used at Transglobal Express for the purpose of reverse engineering WBA code.

In more detail the following code elements are identified:

  1. Start material, title and opening comments if any.
  2. Hyperinks.
  3. .asp code blocks.
  4. .asp functions.
  5. Script blocks.
  6. Script functions.

Each is discussed in further detail in the following sections.

Tge documentor code includes both a GUI and command line interface. In the case of the command line interface the list of WBA source code files to be documented must be hard coded into the application class (ASPdocApp.jaVA) by the user (remember to recompile). The GUI interface is more versatile. The nature of the output (links, ASP blocks, ASP functions, Script blocks and Script functions) is fixed in the case of the command line interface. HGowever, output can be influenced by the user in the case of the GUI. (Acctually output can also be influenced in the case of the command line interface but this requires editting of the code.)




2. START MATERIAL


The start material is considered to comprise a title and/or an opening comment.

The title, if present, is assumed to be contained between the <title> and </title> HTML tags. Note that the title tags may be located anywhere in the code file. Note also that where there are more than one pair of title tags the first pair arrived at will be selected.

The opening comment is considered to exist either:

  1. If a title tag exists, immediately (excluding white space) after the opening <body> HTML tag, or
  2. If the input is an ASP file on the second line of the code, or
  3. If none of the above on the first line of the code.

Note that if there is no opening body tag there may still be an opening comment on the first or second lines respectively (regardles of whether a title has been found as the tile may be contained later in the code file). The opening comments can go on for several lines. The comment is always assumed to be in the form of an HTML comment, i.e.:

<! Some example text to represent a
comment going over two lines.>




3. HYPERLINKS


Hyperlinks are identified by looking for opening <A HREF HTML tags. The URL is expected to be contained between the associated = and > characters, with or without quotes. Examples:

<A HREF = "anExampleLink.html">
<A HREF = "#anotherLink">
<A HREF = YetAnother/exampleLink.html>




4. ASP BLOCKS


ASP code blocks are identified by <% and %> tags. The start and end line numbers are identified and any opening comments found immediately after the start line. ASP comments are of the form:

' Some example text to represent a
' comment going over two lines.




5. ASP FUNCTIONS


ASP functions are assumed to have the format function name ... end function or function name (args) ... end function. The start and end line numbers are recorded together with the function name and any arguments. An explanatory comment, if included, is assumed to be located immediately before the start of the function (white space excepted) which is also extracted (if available).




6. SCRIPT BLOCKS


Script blocks are identified by <SCRIPT> and </SCRIPT> tags. The <SCRIPT> is assumed to be located at the beginning of a line. The start and end line numbers are identified and any opening comments found immediately before the start line (white space excepted). The nature of the scrript is determined from the LANGUAGE or TYPE script argument. Examples:

<SCRIPT TYPE="text/JavaScript">

<SCRIPT LANGUAGE="VBScript">




7. SCRIPT FUNCTIONS


Currently script functions are assumed to be written in either VBScript or JavaScript. For each function the start and end line numbers are recorded together with the function name, any arguments and a preceding comment if it exists. Functions have the form:

Java ScriptVB script
FUNCTION name
    ...
END FUNCTION
FUNCTION name {
    ...
    }
FUNCTION name(args)
    ...
END FUNCTION
FUNCTION name(args) {
    ...
    }

Preceding comments are of the form:

' Some example text to represent a VBScrtipt comment.

in VBScript, or:

/* Some example text to represent a Java Scrtipt comment. */

in JavaScript.




8. CODE OVERVIEW


The software is written in Java and comprises the following (note that there are two application classes):

  1. ASPdoc: The main class that does the majority of the documentation work.
  2. ASPdocApp: The command line application class.
  3. ASPdocApp_GUI: The GUI application class.
  4. ASPdocControl: The GUI control class.
  5. ASPfunctionStruct Data storage class to hold information about asp functions.
  6. ASPstruct Data storage class to hold information about asp blocks (within which asp functions are contained).
  7. LinkStruct Data storage class to hold information about links folund in WBA source code.
  8. ScriptFunctionStruct Data storage class to hold information about Java Script and VBScript script functions.
  9. ScriptStruct Data storage class to hold information about script blocks.

The code is compiled in the usual way:

javac *.java

and run using either the command line interface:

java ASPdocApp

or the GUI interface:

java ASPdocApp_GUI

To document the Java source code use:

javadoc -private -d temp *.java



9. ACKNOWLEDGEMENTS


Produced as part of the Transglobal Express KTP project.