GNUstep Documentation XML markup language (GSDoc) A person who has devotes far too much time to GNUstep development. 0.2 21 June, 2000 This documents the GNUstep Documentation markup language and tools Free Software Foundation, Inc. Introduction

The GSDoc markup language 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 is also an example, as well as a test case, of the new GNUstep documentation markup language (GSDoc).

Why another documentation language?

There are several reasons for producing the new markup language -

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 DTD and what it means

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. Please see the DTD for a precise specification.

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.

Overall document structure

A GSDoc document consists of a head and a body wrapped inside the overall document framework that looks like this -

<?xml version="1.0"?> <!DOCTYPE gsdoc PUBLIC "-//GNUstep//DTD gsdoc 0.6.6//EN" "http://www.gnustep.org/gsdoc-0_6_6.xml"> <gsdoc base="MyDoc" prev="First" next="Last" up="Overview"> <head> ... your document head here </head> <body> ... your document body here </body> </gsdoc>

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 body

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 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 element is used as a marker to specify that an automatically generated contents page (listing the chapters in the document) is to be inserted.

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. 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.

Element reference
block

Actually, there is no such thing as a block element, this is just shorthand for refering to a group of elements that can be used in similar ways. The block elements are -

embed embeded information from elsewhere example the example p the paragraph A variety of lists. list a simple list of items enum an enumerated list deflist a list of terms and their definitions qalist a list of questions and answers def A variety of specialised elements for software documentation. class An Objective-C class definition jclass A Java class definition category An Objective-C category definition protocol An Objective-C protocol or Java interface definition function A function definition macro A macro definition type A type definition variable A variable definition
br

The br element is an empty element that always appears as <br/> in the document. This element simply specifies that a line-break should appear in the output text at this point.

chapter

This is the basic unit of the document - the main part of a document body will contain at least one chapter. 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).

class

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 element, an optional description, zero or more method elements, and an optional standards element.

conform

This element contains simple text giving the name of a protocol or interface to which a class conforms.

declared

This element contains simple text giving the name of the header file in which something is declared.

desc

This element is used to contain descriptions of how software functions. It may contain text, but may also contain lists, paragraphs, examples and embedded data.

heading

Each chapter, section sub-section, or sub-sub-section has a heading as the first thing in it. These headings introduce the sections and are listed in the contents page.

p

The paragraph element simply contains text. Most descriptive writing is inside paragraphs.

section

The section element is just like a chapter, except that it contains sub-sections where a chapter would contain sections.

standards

The standards element contains any number of standard elements whioch specify what standards a particular piece of code does or does not conform to.
The defined values are -

<GNUstep/> <OpenStep/> <NotOpenStep/> <MacOS-X/> <NotMacOS-X/>
subsect

The subsect element is just like a section, except that it contains sub-sub-sections where a section would contain sub-sections.

subsubsect

The subsubsect element is just like a sub-section, except that it contains only a heading and zero or more blocks.

text

This is not really an element, we simply talk about text where we mean raw text and very simple markup such as -

br a forced line-break footnote a reference to a footnote that appears in full elsewhere label a piece of text marked so that it can be referred to from elsewhere. entry an invisible mark that can be referred to from elsewhere. ref text marked as a reference to elsewhere in the document. uref text marked as a reference to a hypertext URL. url a hypertext URL. email an email address.
The gsdoc conversion tool

The gsdoc tool is written in Objective-C and uses the GNUstep base library and the Gnome XML parser library.

This tool is intended to convert GSDoc documents to other formats though, at present, only HTML output is supported.

Use of the tool is trivial - just provide it with a list of gsdoc file names, and it will produce a load of html output files.

Parameters --makeRefs=ReferencesFileName With this option, gsdoc reads gsdoc files and create ReferencesFileName.gsdocrefs files which can be used as --refs to make links between elements --projectName=TheProjectName Set the project name to "TheProjectName".It is used fo index titles,... --refs=ARefFile or --refs=ARefDirectory Use ARefFile.gsdocrefs (or files whith extensions .gsdocrefs in ARefDirectory directory) as references files. It's enable to make links bettwen documentations --makeIndex=MyIndexFileName Create an index of the parsed files and save it as MyIndexName.gsdoc. You have to set --makeIndexTemplate option --makeIndexTemplate=MyIndexTemplateFileName The file used as index template for makeIndex option --define-XXX=YYY Used to define a constant named XXX with value YYY in .gsdoc file, all [[infoDictionary.XXX]] texts are replaced with YYY --verbose=X Level of traces from 0 to ... --location=file://usr/doc/gnustep/MyProject or --location=http://www.gnustep.org/gnustep/MyProject Location of the installed documentation (it helps to make kinks between projects) file1 file2 .gsdoc files
Exemple AutoDoc autodoc -allclasses -format html -template /usr/GNUstep/System/Libraries/Resources/DocTemplates/AutoDocTemplate.gsdoc -copyright "Orange Concept" -define-author-name "Manuel Guesdon" -define-author-email "mguesdon@orange-concept.com" -define-author-desc "Developer" -define-author-url "http://www.orange-concept.com" -define-dtd-ref "/usr/GNUstep/System/Libraries/Resources/DTDs/gsdoc-0_6_6.dtd" -define-stylesheeturl "http://www.orange-concept.com/styles/default.css" -define-basetitle "MyDoc:" -define-dtd-url "http://www.gnustep.org/gsdoc-0_6_6.xml" -define-next "[[next]]" -define-prev "[[prev]]" -define-up "[[up]]" MySource.h

The above example take MySource.h and MySource.m and generate one or more gsdoc files (they have the extension .html, so please rename them with .gsdoc extension after running AutoDoc

GSDoc gsdoc MyFile1.gsdoc MyFile2.gsdoc Explanations.gsdoc --makeRefs --makeIndex --makeIndexTemplate=/usr/GNUstep/System/Libraries/Resources/DocTemplates/indextemplate.gsdoc --projectName="MyProject" --refs=/usr/doc/gnustep --define-version=2.1 --verbose=1 --location="/usr/doc/gnustep/MyProject"

The above example will parse MyFile1.gsdoc MyFile2.gsdoc and generate MyFile1.html and MyFile2.html. It generate MyProject.gsdocrefs which will countain references of symbols found in MyFile1.gsdoc and MyFile2.gsdoc. MyFile1.html and MyFile2.html will have links to symbols found in MyProject.gsdocrefs and in .gsdocrefs founds in subdirectories of /usr/doc/gnustep. I indicate that the location of this doc will be /usr/doc/gnustep/MyProject. It also generate an index of MyFile1.html and MyFile2.html contents with the template /usr/GNUstep/System/Libraries/Resources/DocTemplates/indextemplate.gsdoc. Index file is index.gsdoc and the resulting file index.html is automatically generated. I define "version" so the index will take this version.