docbook-cheat-sheet.xml 7.72 KB
Newer Older
1
<?xml version="1.0" encoding="iso-8859-1"?>
2
3
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
   "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

<article id="docbook-cheat-sheet">

  <articleinfo>
    <title>Using DocBook to write GHC documentation</title>
    <author><othername>The GHC Team</othername></author>
    <address><email>glasgow-haskell-&lcub;users,bugs&rcub;@dcs.gla.ac.uk</email></address>
    <pubdate>January 2000</pubdate>
  </articleinfo>

  <sect1 id="sec-getting-docbook">
    <title>Getting the DocBook tools</title>
    <para>See the installation guide.</para>
  </sect1>

  <sect1 id="doc-layout">
    <title>Document layout</title>

22
    <para>The GHC documentation is written using DocBook XML V4.5, so
23
24
25
26
    the first few lines should look like this:</para>

<programlisting>
&lt;?xml version="1.0" encoding="iso-8859-1"?>
27
28
&lt;!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
   "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
</programlisting>

    <para>The encoding can of course be chosen according to taste.</para>

    <para> This guide is <emphasis>not</emphasis> meant to teach you
    how to write DocBook; read the <ulink
    url="http://www.docbook.org/">DocBook book</ulink> for that. It is
    more of a reference than a tutorial, so see the <ulink
    url="http://www.oasis-open.org/docbook/">DocBook home page</ulink>
    for other links.</para>

    <para>However, by popular demand, here are some useful points:
    </para>

    <itemizedlist>
      <listitem>
        <para>Remember to use <sgmltag class="starttag">para</sgmltag>
        inside <sgmltag class="starttag">listitem</sgmltag>s.</para>
      </listitem>
    </itemizedlist>

    <para>The rest of this section outlines the use of several tags
    which may not be obvious (DocBook is rather scholastic in style:
    it has tags for many things from C function prototypes to keyboard
    bindings; at the same time it has many omissions and
    oddities). The current scheme has many infelicities, partly
    because it was dreamt up in a hurry while the author was learning
    DocBook and converting the documentation thereto, and partly
    because DocBook is rather C-centric.</para>

    <variablelist>

      <varlistentry>
        <term>Comments</term>
        <listitem>
64
          <para>Comments in XML look like this: <sgmltag
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
          class="sgmlcomment">This is a comment</sgmltag>.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><sgmltag class="starttag">command</sgmltag></term>
        <listitem>
          <para>Used for commands typed into interactive sessions
          (e.g. <command>cp foo bar</command> and the names of
          programs such as <command>gmake</command>.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><sgmltag class="starttag">constant</sgmltag></term>
        <listitem>
          <para>Used for system constants such as
          <constant>U_MAXINT</constant> and
          <filename>Makefile</filename> variables like
          <constant>SRC_FILES</constant> (because they are usually
          constant for a given run of <command>make</command>, and
          hence have a constant feel to them).</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><sgmltag class="starttag">email</sgmltag></term>
        <listitem>
          <para>For email addresses. This is a tag that's easy to
          overlook if you don't know it's there.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><sgmltag class="starttag">filename</sgmltag></term>
        <listitem>
          <para>Used for paths, filenames, file extensions.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><sgmltag class="starttag">function</sgmltag></term>
        <listitem>
          <para>Used for functions and constructors.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><sgmltag class="starttag">indexterm</sgmltag></term>
        <listitem>
          <para>The normal way to mark up an index term is
          <literal>&lt;indexterm&gt;&lt;primary&gt;term&lt;/primary&gt;&lt;/indexterm&gt;</literal>.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><sgmltag class="starttag">keycap</sgmltag></term>
        <term><sgmltag class="starttag">keycombo</sgmltag></term>
        <listitem>
          <para>Some more tags you may miss. Used for combinations
          such as
          <keycombo><keycap>Control</keycap><keycap>D</keycap></keycombo>.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><sgmltag class="starttag">literal</sgmltag></term>
        <listitem>
          <para>Used for everything that should appear in typewriter
          font that has no other obvious tag: types, monads, small
          snippets of program text that are formatted inline, and the
          like.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><sgmltag class="starttag">option</sgmltag></term>
        <listitem>
          <para>Used for compiler options and similar.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><sgmltag class="starttag">programlisting</sgmltag></term>
        <listitem>
          <para>For displayed program listings (including shell
          scripts).</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><sgmltag class="starttag">screen</sgmltag></term>
        <listitem>
          <para>For displayed screen dumps, such as portions of shell
          interaction. It's easy to tell the difference between these
          and shell scripts: the latter lack a shell prompt.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><sgmltag class="starttag">varname</sgmltag></term>
        <listitem>
          <para>Used for variables, but not type variables.</para>
        </listitem>
      </varlistentry>

    </variablelist>

  </sect1>

  <sect1 id="docbook-tables">
    <title>Tables</title>

178
    <para>Tables are quite complicated to write in DocBook XML (as in HTML,
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
    there are lots of fiddly tags), so here's an example you can
    cannibalise. In the spirit of the LaTeX short introduction I don't
    repeat all the markup verbatim; you have to look at the source for
    that.</para>

    <informaltable>
      <tgroup cols="3">
        <colspec colname="one" align="left" colsep="0"/>
        <colspec colname="two" align="center" colsep="0"/>
        <colspec colname="three" align="right" colsep="0"/>
        <tbody>

          <row>
            <entry>Here's</entry>
            <entry>a sample</entry>
            <entry>table</entry>
          </row>

          <row>
            <entry>With differently</entry>
            <entry>aligned</entry>
            <entry>cells</entry>
          </row>

          <row>
            <entry namest="one" nameend="three" morerows="1">
              <para> There's not much else to it. Entries can span
              both extra rows and extra columns; just be careful when
              using block markup (such as <sgmltag
              class="starttag">para</sgmltag>s) within an <sgmltag
              class="starttag">entry</sgmltag> that there is no space
              between the open and close <sgmltag
              class="starttag">entry</sgmltag> tags and the adjacent
              text, as otherwise you will suffer from <ulink
              url="http://www.docbook.org/tdg/html/entry.html">Pernicious
              Mixed Content</ulink> (the parser will think you're
              using inline markup).</para>
            </entry>
          </row>

        </tbody>
      </tgroup>
    </informaltable>
  </sect1>
</article>