Itcl files written for Tycho should follow a certain style in body. The file header is discussed elsewhere.
The tydoc
system automatically generates html documentation from the source
code file, so the comments should follow the tydoc
comment format conventions.
The Itcl
template file contains a template of an itcl file with the
appropriate copyright and comment formats.
The Itcl editor has a
file template menu choice
that will insert the Itcl template file.
The Itcl editor contains a menu choice that will create a Itcl body template that is useful for creating definition bodies.
###################################################################### #### MyClass # This class does very little, but here is an example # <tcl><pre> # ::tycho::MyClass # </pre></tcl> # ::tycho::MyClass {Class comments have the following elements:
######################################################################
#### MyClass
tydoc
.
# This class does very little, but here is an example
# <pre><tcl> # ::tycho::MyClass # </pre></tcl>
#
::tycho::MyClass {
body
statements. However, the Tycho convention
require that methods and procedures that are longer than one
line be in separate body
statements after the class body
itself. This makes the file more readable.
See the Itcl template file for a complete example of a Itcl class body. Below we discuss the major elements of a class body.
inherits
line should be the first line of the class body.
constructor
and destructor
declarations should come first. These may or may not have a one
line comment.
# Call exit method myMethod {a b} { exit }
options
public methods
public procs
protected methods
protected procs
protected variables
private methods
private procs
private variables
public methods
section
should start with:
################################################################### #### public methods ####
body
definitions after the
class declaration.
Here's an example class definition body:
####################################################################### #### NameA # Description. # body ::tycho::ClassName::publicMethodA {} { }