1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
5 <article id="docbook-cheat-sheet">
8 <title>Using DocBook to write GHC documentation</title>
9 <author><othername>The GHC Team</othername></author>
10 <address><email>glasgow-haskell-{users,bugs}@dcs.gla.ac.uk</email></address>
11 <pubdate>January 2000</pubdate>
14 <sect1 id="sec-getting-docbook">
15 <title>Getting the DocBook tools</title>
16 <para>See the installation guide.</para>
19 <sect1 id="doc-layout">
20 <title>Document layout</title>
22 <para>The GHC documentation is written using DocBook XML V4.2, so
23 the first few lines should look like this:</para>
26 <?xml version="1.0" encoding="iso-8859-1"?>
27 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
28 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
31 <para>The encoding can of course be chosen according to taste.</para>
33 <para> This guide is <emphasis>not</emphasis> meant to teach you
34 how to write DocBook; read the <ulink
35 url="http://www.docbook.org/">DocBook book</ulink> for that. It is
36 more of a reference than a tutorial, so see the <ulink
37 url="http://www.oasis-open.org/docbook/">DocBook home page</ulink>
38 for other links.</para>
40 <para>However, by popular demand, here are some useful points:
45 <para>Remember to use <sgmltag class="starttag">para</sgmltag>
46 inside <sgmltag class="starttag">listitem</sgmltag>s.</para>
50 <para>The rest of this section outlines the use of several tags
51 which may not be obvious (DocBook is rather scholastic in style:
52 it has tags for many things from C function prototypes to keyboard
53 bindings; at the same time it has many omissions and
54 oddities). The current scheme has many infelicities, partly
55 because it was dreamt up in a hurry while the author was learning
56 DocBook and converting the documentation thereto, and partly
57 because DocBook is rather C-centric.</para>
64 <para>Comments in SGML look like this: <sgmltag
65 class="sgmlcomment">This is a comment</sgmltag>.</para>
70 <term><sgmltag class="starttag">command</sgmltag></term>
72 <para>Used for commands typed into interactive sessions
73 (e.g. <command>cp foo bar</command> and the names of
74 programs such as <command>gmake</command>.</para>
79 <term><sgmltag class="starttag">constant</sgmltag></term>
81 <para>Used for system constants such as
82 <constant>U_MAXINT</constant> and
83 <filename>Makefile</filename> variables like
84 <constant>SRC_FILES</constant> (because they are usually
85 constant for a given run of <command>make</command>, and
86 hence have a constant feel to them).</para>
91 <term><sgmltag class="starttag">email</sgmltag></term>
93 <para>For email addresses. This is a tag that's easy to
94 overlook if you don't know it's there.</para>
99 <term><sgmltag class="starttag">filename</sgmltag></term>
101 <para>Used for paths, filenames, file extensions.</para>
106 <term><sgmltag class="starttag">function</sgmltag></term>
108 <para>Used for functions and constructors.</para>
113 <term><sgmltag class="starttag">indexterm</sgmltag></term>
115 <para>The normal way to mark up an index term is
116 <literal><indexterm><primary>term</primary></indexterm></literal>.</para>
121 <term><sgmltag class="starttag">keycap</sgmltag></term>
122 <term><sgmltag class="starttag">keycombo</sgmltag></term>
124 <para>Some more tags you may miss. Used for combinations
126 <keycombo><keycap>Control</keycap><keycap>D</keycap></keycombo>.</para>
131 <term><sgmltag class="starttag">literal</sgmltag></term>
133 <para>Used for everything that should appear in typewriter
134 font that has no other obvious tag: types, monads, small
135 snippets of program text that are formatted inline, and the
141 <term><sgmltag class="starttag">option</sgmltag></term>
143 <para>Used for compiler options and similar.</para>
148 <term><sgmltag class="starttag">programlisting</sgmltag></term>
150 <para>For displayed program listings (including shell
156 <term><sgmltag class="starttag">screen</sgmltag></term>
158 <para>For displayed screen dumps, such as portions of shell
159 interaction. It's easy to tell the difference between these
160 and shell scripts: the latter lack a shell prompt.</para>
165 <term><sgmltag class="starttag">varname</sgmltag></term>
167 <para>Used for variables, but not type variables.</para>
175 <sect1 id="docbook-tables">
176 <title>Tables</title>
178 <para>Tables are quite complicated to write in SGML (as in HTML,
179 there are lots of fiddly tags), so here's an example you can
180 cannibalise. In the spirit of the LaTeX short introduction I don't
181 repeat all the markup verbatim; you have to look at the source for
186 <colspec colname="one" align="left" colsep="0"/>
187 <colspec colname="two" align="center" colsep="0"/>
188 <colspec colname="three" align="right" colsep="0"/>
192 <entry>Here's</entry>
193 <entry>a sample</entry>
198 <entry>With differently</entry>
199 <entry>aligned</entry>
204 <entry namest="one" nameend="three" morerows="1">
205 <para> There's not much else to it. Entries can span
206 both extra rows and extra columns; just be careful when
207 using block markup (such as <sgmltag
208 class="starttag">para</sgmltag>s) within an <sgmltag
209 class="starttag">entry</sgmltag> that there is no space
210 between the open and close <sgmltag
211 class="starttag">entry</sgmltag> tags and the adjacent
212 text, as otherwise you will suffer from <ulink
213 url="http://www.docbook.org/tdg/html/entry.html">Pernicious
214 Mixed Content</ulink> (the parser will think you're
215 using inline markup).</para>