The GNUstep documentation markup language (GSDoc) is an XML language
designed specifically for writing documentation for the
GNUstep project.
In practice, that means that it is designed for writing about
software, and in particular, for writing about Objective-C classes.

This document itself is an example, as well as a test case, of GSDoc
itself.

There were no existing markup languages that dealt well with
documenting software written in the Objective-C language,
except the GDML language - which has no easy to use support
software.

While the DocBook system works nicely for general software
documentation, it requires a relatively large amount of
support software and comes with a lot of baggage that's
not directly useful for GNUstep.

The GNU info system comes with easy to use, lightweight
conversion tools, but is particularly ill suited to
Objective-C documentation because the colon character
using in Objective-C method names is used in info markup.

LinuxDoc, while being a nice basic system, seems to be
in the process of being replaced by DocBook.

So, with only one markup language available that supported
Objective-C, and with XML software becoming available, the
decision was to take GDML and update it to be an XML
language, in the hope that this would -

Provide optimal support for GNUstep documentation.

Minimize the amount of work needed for development of
software tools.

Provide future-proofing in that documentation written in one
XML language should be quite easy to convert to another if
necessary.

The GSDoc markup language is defined by an SGML DTD, that specifies
the tags that may be used in marking up a GSDoc document, and how
and where those tags may be placed. The reader is encouraged to
consult the DTD directly on any points that the present document leaves
unclear. The DTD is stored under
GNUSTEP_SYSTEM_LIBRARY/DTDs in a standard
GNUstep installation. .. where GNUSTEP_SYSTEM_LIBRARY is defined in
the GNUstep configuration file (GNUstep.conf).

The gsdoc DTD defines an XML language - that is, a markup language
that conforms to a specific subset of SGML features defined as XML.
The advantage of XML is that it provides most of the useful features
of SGML while being much more light-weight (easy to use) because
you can forget about the rest of SGML.
As XML looks set to become increasingly popular, we can hope that
documentation written with an XML language will be easily imported
into XML software tools as they become available, so we will not
(in the GNUstep project) need to devote a lot of time and effort
to maintaining documentation tools.

The above example shows a GSDoc document framework.
The first line specifies the XML version that the document
conforms to.
The second line specifies the version of GSDoc that the
document conforms to.
The third and final lines frame the main part of the document
and supply all the (optional) attributes of the gsdoc
element -

base

This is optional, but recommended - it specifies the base name
for the document. When the document is translated to another
format, the output file name should be based on this - eg.
if the base name of a document is foo then an html
output for this file would be foo.html.

prev

This optional attribute may be used as the name of a document
that precedes this one in logical reading order. If the
converted output format of the document supports some sort of
link between documents, the converter software may insert
a link between the two documents.

next

This optional attribute may be used as the name of a document
that follows this one in logical reading order. If the
converted output format of the document supports some sort of
link between documents, the converter software may insert
a link between the two documents.

up

This optional attribute may be used as the name of a document
that is above this document in some sort of hierarchical
structure (a contents list perhaps).
If the converted output format of the document supports some sort
of link between documents, the converter software may insert
a link between the two documents.

The document head contains information about the document as
a whole: its title, authors, version, modification date,
copyright, and perhaps an abstract of its contents.
The title is the only part of the document head that must be present,
although at least one author is strongly encouraged.

The author of the document, also specifying an email address at
which the author may be reached, a URL for a web page giving
some information about the author, and an additional description
of the author. (Of course, a document may have more than one
author, in which case you simply write multiple author elements.)
Not required, but strongly encouraged.

The document body contains the main part of the document, it
consists of an optional front part (for contents pages, overview
etc), a sequence of any number of chapters, and an optional back
part (for indexes, appendices etc). Normally, each of these three
parts of the document would be expected to have their own separate
page numbering schemes.

<body>
<front>
<contents/>
<chapter>
<heading>Preface</heading>
<p>
Here is an introductory chapter for a dummy document.
</p>
</chapter>
</front>
<chapter>
<heading>Main text</heading>
<p>
Here is the main text of a chapter in the document.
</p>
</chapter>
<back>
<chapter>
<heading>Afterword</heading>
<p>
And after the main part of the doucment we can have some other stuff.
</p>
</chapter>
<index type="class"/>
</back>
</body>

The above example shows all the elements possible at the top level in a document body -

<front>

This is an optional part of the document that can come before the
main text. Typically, this could be used to contain an automatically
generated contents page and possibly an introduction.
When output is generated in book form, this part of the document
would probably have a different page numbering scheme from the
main part.

The <contents> subelement is used as a marker
to specify that an automatically generated contents page (listing
the chapters in the document) is to be inserted.

<chapter>

After the front part of the document body comes a
mandatory sequence of one or more chapters. This is where
the main part of the document resides.
Each chapter
consists of a
heading
, any number
of blocks of information, and any number of sections.

<back>

After the chapters making up the main part of the body of the
document is an optional back part which may contain
chapters (such as appendices) possibly followed by an automatically
generated index.

The <index> element is used as a marker to
specify that an automatically generated index is to be inserted.
See below
for details.

This is the basic, top-level element of the document body.
Each chapter consists of a heading
,
zero or more blocks
, and zero or more
sections
. Each chapter in the document is
automatically listed in the documents contents page (if it has one).

The <index> tag is special in that it is
dynamically expanded during output based on information that has
been collated from reading in various documentation and source
files. The type attribute of the index specifies
what sort of item is to be in the index - the default type of
label causes an index of all label and
entry elements to be generated. Currently the allowable
types are: class, category,
protocol, method,
ivariable, function, type,
macro, variable, constant,
label, title, EOModel
(associated with the Enterprise Objects Framework, for interacting
with databases), EOEntity. The default is
"label".

The <index> element also takes three optional
attributes -

scope

Determines whether the index is generated for the current file
("file" scope), or for the whole of the current
project ("project" scope), or for everything the
software can find ("global" scope). In certain
contexts the specified scope is automatically overridden ... if
the document is processed in a standalone manner, the scope is
always "file". For method or ivariable indexing,
if the index is inside a class, protocol, or category, only
indexes for that unit are generated.

style

Determines whether the index is presented with standard
embellishments such as bulleted entries and a header
("normal" style) or in a minimalist style suitable
for, e.g., a navigation bar ("bare" style).

target

Provides additional information to accompany links formed from
the index. For HTML output, this is translated into a
"target" attribute to the <a>
href="..." element generated for a link. In most cases
this can safely be left out.

text elements

A variety of elements for text formatting, many based on HTML tags.
See below
for details.

An attribute-value list similar to an NSDictionary. Consists
of a sequence of <dictionaryItem> tags each with
a required key attribute and an optional
value attribute. If this is excluded, the element
content, which may be any
block element
(including
another <dictionary> tag) is the value.

Cross-reference elements can occur within blocks and
typically anywhere text elements can occur. They represent
references to other entities inside or outside the project being
documented. In output formats that support it, they are generally
transformed into hyperlinks. The cross-reference elements are -

A reference to another entity within collection of documents
describing the current project. In practice this means a reference
to an element in a GSDoc document. Standard conventions for document
naming and structure are used to generate a hyperlink in output.
To support this resolution, two attributes must be specified.

type

This is the type of entity being referenced. It may take
one of the following values: class,
category, protocol, method,
ivariable, function, type,
macro, variable, constant,
label, EOModel, EOEntity.
If type is not specified, "label" is
assumed.

id

Specifies the identifier of the reference. In most cases
this will be the name of the class, method, or other specific
entity being referenced. In the case of label
references, this is the id attribute of the label
being referenced.

class

In the case where a method is being referenced,
the class attribute should be specified as well, and
should contain the name of the class the method occurs in, in one
of the following formats: "classname", "classname(categoryname)",
or "(protocolname)".

A reference to another project, which assumedly has also had
GSDoc generated for it. A link in the output will be generated to
???. The <prjref> tag may contain text content,
which appears in the output.

An entry for the general index. Contains text elements but
this text appears only in the index, and never in the text itself.
It takes a single attribute, id, which may be used to
refer to the entry. (If it is absent any text content is taken to
be the id.)

A general purpose marker that can contain text elements,
which will appear in the output where the label occurs.
It takes a single attribute, id, which may be used to
refer to the label. (If it is absent any text content is taken to
be the id.)

Definition elements are specialized elements for software
documentation. They can occur in most places that block elements
can occur. They represent specific Objective-C elements, and are
formatted specially in output. In the majority of cases, you will
not need to write GSDoc using these elements, since they can be
autogenerated from Objective-C source files and special comments
within them. Most of the elements representing parts of the API
have optional attributes ovadd, ovdep and ovrem which may be used to
specify the OpenStep/OPENSTEP/MacOS-X versions at which the
documented element was added to, deprecated in, or removed from
the API, Similarly they have gvadd, gvdep and gvrem which may be
used to specify when an elment was added to or removed from
the API of the source code being documented
(eg a gnustep library).
The definition elements are -

An Objective-C class definition. This is the main element
for Objective-C code documentation. The name attribute
is required for this element - it is the name of the class. The
super attribute is normally necessary to provide the
name of the superclass.

The elements in a <class> are - an optional
declared
element,
zero or more conform
elements,
an optional desc
,
zero or more ivariable
elements,
zero or more method
elements.

A C constant definition. It requires
name and type attributes and a
value attribute is optional. In addition, an
Objective-C role for the constant may be specified using the
role attribute. Acceptable values for this attribute
are: "except", "defaults",
"notify", or "key".

The elements in a <constant> are -
an optional declared
element,
an optional desc
.

An objective C instance variable definition. It requires
name and type attributes and a
validity attribute optionally specifies the access
level for the variable (may be "public",
"protected", or "private", the default
is "public").

Describes an Objective-C method. Only valid within a
class
, protocol
,
or category
. An optional
type attribute describes the return type; an optional
factory attribute ("yes" or
"no", defaults to "no") specifies whether
this is a class or instance method. (Class methods are typically
only used for construction purposes in Objective-C.) An optional
init attribute (also taking
"yes" / "no") specifies whether this is
the designated constructor. An optional override
attribute specifies whether this method should be overridden.
If it must be overridden enter "subclass",
if it must not be overridden enter never",
if it is an empty/dummy implementation which is intended to be
overridden enter dummy, otherwise (for most methods
which may be but are not particularly designed to be overridden)
leave this attribute unset.

The elements in a <method> are -
the method's name (in a sel
element), the
method's arguments (a sequence of arg
then
sel
,arg
pairs, then an
optional vararg
element),
followed by an optional desc
,
zero or more ivariable
elements,
zero or more method
elements.