7.4. Elements for classes and methods

For describing classes and methods DocBook offers the following elements.

An example of a Java Class synopsys and its typeset result follows.

Example 7.8. Class synopsys

<classsynopsis language="java">
<ooclass>
<modifier>public</modifier>
<classname>TextFileWriter</classname>
</ooclass>
<ooclass>
<classname>HandlerBase</classname></ooclass>
<fieldsynopsis>
<modifier>private</modifier>
<type>Writer</type>
<varname>writer</varname>
</fieldsynopsis>
<fieldsynopsis>
<modifier>public</modifier>
<type>String</type>
<varname>writerName</varname>
<initializer>"MyWriter"</initializer>
</fieldsynopsis>
<methodsynopsis>
<modifier>static</modifier>
<modifier>public</modifier>
<void/>
<methodname>write</methodname>
<methodparam>
<type>ResultTreeFragment</type>
<parameter>frag</parameter>
</methodparam>
<methodparam>
<type>String</type>
<parameter>file</parameter>
</methodparam>
<exceptionname>SAXException</exceptionname>
</methodsynopsis>
</classsynopsis>
 public TextFileWriter extends HandlerBase {
  private Writer writer ;
  public String writerName = "MyWriter";
  static public void write(ResultTreeFragment frag,
                           String file)
    throws SAXException;

}

Another example of a class definition, this time for IDL, follows.

 <classsynopsis class="interface" language="idl">
<oointerface>
<interfacename>Element</interfacename></oointerface>
<oointerface>
<interfacename>Node</interfacename></oointerface>
<fieldsynopsis>
<modifier>readonly</modifier>
<modifier>attribute</modifier>
<type>DOMString</type>
<varname>tagName</varname>
</fieldsynopsis>
<methodsynopsis>
<type>DOMString</type>
<methodname>getAttribute</methodname>
<methodparam>
<modifier>in</modifier>
<type>DOMString</type>
<parameter>name</parameter>
</methodparam>
</methodsynopsis>
<methodsynopsis>
<void/>
<methodname>setAttribute</methodname>
<methodparam>
<modifier>in</modifier>
<type>DOMString</type>
<parameter>name</parameter>
</methodparam>
<methodparam>
<modifier>in</modifier>
<type>DOMString</type>
<parameter>value</parameter>
</methodparam>
<exceptionname>DOMException</exceptionname>
</methodsynopsis>
</classsynopsis>
interface  implementsElement, Node {
  readonly attribute DOMString tagName ;
  DOMString getAttribute(in DOMString name);
  void setAttribute(in DOMString name, in DOMString value)
    raises(DOMException);

}