[project @ 2004-08-26 20:08:39 by panne]
[ghc-hetmet.git] / docs / docbook-cheat-sheet / docbook-cheat-sheet.xml
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">
4
5 <article id="docbook-cheat-sheet">
6
7   <articleinfo>
8     <title>Using DocBook to write GHC documentation</title>
9     <author><othername>The GHC Team</othername></author>
10     <address><email>glasgow-haskell-&lcub;users,bugs&rcub;@dcs.gla.ac.uk</email></address>
11     <pubdate>January 2000</pubdate>
12   </articleinfo>
13
14   <sect1 id="sec-getting-docbook">
15     <title>Getting the DocBook tools</title>
16     <para>See the installation guide.</para>
17   </sect1>
18
19   <sect1 id="doc-layout">
20     <title>Document layout</title>
21
22     <para>The GHC documentation is written using DocBook XML V4.2, so
23     the first few lines should look like this:</para>
24
25 <programlisting>
26 &lt;?xml version="1.0" encoding="iso-8859-1"?>
27 &lt;!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
28    "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
29 </programlisting>
30
31     <para>The encoding can of course be chosen according to taste.</para>
32
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>
39
40     <para>However, by popular demand, here are some useful points:
41     </para>
42
43     <itemizedlist>
44       <listitem>
45         <para>Remember to use <sgmltag class="starttag">para</sgmltag>
46         inside <sgmltag class="starttag">listitem</sgmltag>s.</para>
47       </listitem>
48     </itemizedlist>
49
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>
58
59     <variablelist>
60
61       <varlistentry>
62         <term>Comments</term>
63         <listitem>
64           <para>Comments in XML look like this: <sgmltag
65           class="sgmlcomment">This is a comment</sgmltag>.</para>
66         </listitem>
67       </varlistentry>
68
69       <varlistentry>
70         <term><sgmltag class="starttag">command</sgmltag></term>
71         <listitem>
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>
75         </listitem>
76       </varlistentry>
77
78       <varlistentry>
79         <term><sgmltag class="starttag">constant</sgmltag></term>
80         <listitem>
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>
87         </listitem>
88       </varlistentry>
89
90       <varlistentry>
91         <term><sgmltag class="starttag">email</sgmltag></term>
92         <listitem>
93           <para>For email addresses. This is a tag that's easy to
94           overlook if you don't know it's there.</para>
95         </listitem>
96       </varlistentry>
97
98       <varlistentry>
99         <term><sgmltag class="starttag">filename</sgmltag></term>
100         <listitem>
101           <para>Used for paths, filenames, file extensions.</para>
102         </listitem>
103       </varlistentry>
104
105       <varlistentry>
106         <term><sgmltag class="starttag">function</sgmltag></term>
107         <listitem>
108           <para>Used for functions and constructors.</para>
109         </listitem>
110       </varlistentry>
111
112       <varlistentry>
113         <term><sgmltag class="starttag">indexterm</sgmltag></term>
114         <listitem>
115           <para>The normal way to mark up an index term is
116           <literal>&lt;indexterm&gt;&lt;primary&gt;term&lt;/primary&gt;&lt;/indexterm&gt;</literal>.</para>
117         </listitem>
118       </varlistentry>
119
120       <varlistentry>
121         <term><sgmltag class="starttag">keycap</sgmltag></term>
122         <term><sgmltag class="starttag">keycombo</sgmltag></term>
123         <listitem>
124           <para>Some more tags you may miss. Used for combinations
125           such as
126           <keycombo><keycap>Control</keycap><keycap>D</keycap></keycombo>.</para>
127         </listitem>
128       </varlistentry>
129
130       <varlistentry>
131         <term><sgmltag class="starttag">literal</sgmltag></term>
132         <listitem>
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
136           like.</para>
137         </listitem>
138       </varlistentry>
139
140       <varlistentry>
141         <term><sgmltag class="starttag">option</sgmltag></term>
142         <listitem>
143           <para>Used for compiler options and similar.</para>
144         </listitem>
145       </varlistentry>
146
147       <varlistentry>
148         <term><sgmltag class="starttag">programlisting</sgmltag></term>
149         <listitem>
150           <para>For displayed program listings (including shell
151           scripts).</para>
152         </listitem>
153       </varlistentry>
154
155       <varlistentry>
156         <term><sgmltag class="starttag">screen</sgmltag></term>
157         <listitem>
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>
161         </listitem>
162       </varlistentry>
163
164       <varlistentry>
165         <term><sgmltag class="starttag">varname</sgmltag></term>
166         <listitem>
167           <para>Used for variables, but not type variables.</para>
168         </listitem>
169       </varlistentry>
170
171     </variablelist>
172
173   </sect1>
174
175   <sect1 id="docbook-tables">
176     <title>Tables</title>
177
178     <para>Tables are quite complicated to write in DocBook XML (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
182     that.</para>
183
184     <informaltable>
185       <tgroup cols="3">
186         <colspec colname="one" align="left" colsep="0"/>
187         <colspec colname="two" align="center" colsep="0"/>
188         <colspec colname="three" align="right" colsep="0"/>
189         <tbody>
190
191           <row>
192             <entry>Here's</entry>
193             <entry>a sample</entry>
194             <entry>table</entry>
195           </row>
196
197           <row>
198             <entry>With differently</entry>
199             <entry>aligned</entry>
200             <entry>cells</entry>
201           </row>
202
203           <row>
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>
216             </entry>
217           </row>
218
219         </tbody>
220       </tgroup>
221     </informaltable>
222   </sect1>
223 </article>