XML technologies / DocBook / Block elements / Synopses / Class synopses (classsynopsis)
(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)
Class descriptions include constructors, destructors and methods. The following example shows a class synopsis from the QT™ library. QT is a cross-platform library from QT software GmbH, formerly TrollTech. (C++ programmers will notice that this class declaration is not entirely correct: some const expressions after parentheses are missing from the DocBook markup.)
Example: Structure of a class reference (object-oriented programming, classsynopsis.xml)
<classsynopsis language="cpp">
<ooclass>
<modifier>class</modifier>
<classname>QDomElement</classname>
</ooclass>
<constructorsynopsis>
<modifier>public:</modifier>
<methodname>QDomElement</methodname>
<void/>
</constructorsynopsis>
<destructorsynopsis>
<methodname>QDomElement</methodname>
<void/>
</destructorsynopsis>
<methodsynopsis>
<type>QString</type>
<methodname>attribut</methodname>
<methodparam>
<modifier>const</modifier>
<type>QString&</type>
<parameter>name</parameter>
</methodparam>
<methodparam choice="opt">
<modifier>const</modifier>
<type>QString&</type>
<parameter>defValue</parameter>
<initializer>QString::null</initializer>
</methodparam>
</methodsynopsis>
</classsynopsis>Line 1: The element classsynopsis describes a class, interface or exception. This example is a class, so it uses ooclass. The attribute language on the first element specifies the programming language, here C++.
Line 3: The element modifier specifies C++ keywords, here class.
Line 4: Specifies the class name.
Line 6: Constructor of QDomElement. It is public, hence public in the element modifier.
Line 11: Destructor of QDomElement.
Line 15: Method with two parameters. The second is optional and therefore has the attribute choice with the value opt.
Line 27: A default value is marked up with the element initializer. It is passed to the parameter when omitted from the call.
The DocBook stylesheets generate this output:
class QDomElement {
public: QDomElement ();
QDomElement ();
QString attribut (const QString& name, const QString& defValue= QString::null);
}
DocBook aims to support classes in any programming language through classsynopsis. Since it cannot know every language, stylesheet customizations may be required.
Copyright © 2009 Millin Verlag
You may print the online version for your private use.
Otherwise, this chapter from "DocBook-XML: Medienneutrales und plattformunabhängiges Publizieren" is subject to the same provisions as the printed edition: the work, including all its parts, is protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Millin Verlag, Siebengebirgsring 36, 53797 Lohmar, info(at)millin.de
back to top