[project @ 2004-08-16 16:26:51 by simonpj]
[ghc-hetmet.git] / docs / docbook-cheat-sheet / docbook-cheat-sheet.sgml
1 <!DOCTYPE Article PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
2
3 <Article id="docbook-cheat-sheet">
4
5 <ArtHeader>
6
7 <Title>Using DocBook to write GHC documentation</Title>
8 <Author><OtherName>The GHC Team</OtherName></Author>
9 <Address><Email>glasgow-haskell-&lcub;users,bugs&rcub;@dcs.gla.ac.uk</Email></Address>
10 <PubDate>January 2000</PubDate>
11
12 </ArtHeader>
13
14
15 <Sect1 id="sec-getting-docbook"><Title>Getting the DocBook tools</Title>
16
17 <Para>
18 See the installation guide.
19 </Para>
20
21 </Sect1>
22
23
24 <Sect1 id="doc-layout"><Title>Document layout</Title>
25
26 <Para>
27 The GHC documentation is written using DocBook 3.1, so the DTD line should be:
28 </Para>
29
30 <Screen>
31 &lt;!DOCTYPE Article PUBLIC "-//OASIS//DTD DocBook V3.1//EN"&gt;
32 </Screen>
33
34 <Para> This guide is <Emphasis>not</Emphasis> meant to teach you how to
35 write DocBook; read the <ULink URL="http://www.docbook.org/">DocBook
36 book</ULink> for that. It is more of a reference than a tutorial, so see the
37 <ULink 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: </Para>
41
42 <ItemizedList>
43 <ListItem>
44 <Para>Remember to use <SGMLTag class="StartTag">Para</SGMLTag> inside
45 <SGMLTag class="StartTag">ListItem</SGMLTag>s.
46 </Para>
47 </ListItem>
48 </ItemizedList>
49
50 <Para> The rest of this section outlines the use of several tags which may
51 not be obvious (DocBook is rather scholastic in style: it has tags for many
52 things from C function prototypes to keyboard bindings; at the same time it
53 has many omissions and oddities). The current scheme has many infelicities,
54 partly because it was dreamt up in a hurry while the author was learning
55 DocBook and converting the documentation thereto, and partly because DocBook
56 is rather C-centric. </Para>
57
58 <VariableList>
59
60 <VarListEntry><Term>Comments</Term>
61 <ListItem>
62 <Para>
63 Comments in SGML look like this: <SGMLTag class=SGMLComment>This is a
64 comment</SGMLTag>.
65 </Para>
66 </ListItem>
67 </VarListEntry>
68
69 <VarListEntry><Term><SGMLTag class="StartTag">Command</SGMLTag></Term>
70 <ListItem>
71 <Para>
72 Used for commands typed into interactive sessions (e.g. <Command>cp foo bar</Command> and the names of programs such as <Command>gmake</Command>.
73 </Para>
74 </ListItem>
75 </VarListEntry>
76
77 <VarListEntry><Term><SGMLTag class="StartTag">Constant</SGMLTag></Term>
78 <ListItem>
79 <Para>
80 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).
81 </Para>
82 </ListItem>
83 </VarListEntry>
84
85 <VarListEntry><Term><SGMLTag class="StartTag">Email</SGMLTag></Term>
86 <ListItem>
87 <Para>
88 For email addresses. This is a tag that's easy to overlook if you don't know it's there.
89 </Para>
90 </ListItem>
91 </VarListEntry>
92
93 <VarListEntry><Term><SGMLTag class="StartTag">Filename</SGMLTag></Term>
94 <ListItem>
95 <Para>
96 Used for paths, filenames, file extensions.
97 </Para>
98 </ListItem>
99 </VarListEntry>
100
101 <VarListEntry><Term><SGMLTag class="StartTag">Function</SGMLTag></Term>
102 <ListItem>
103 <Para>
104 Used for functions and constructors.
105 </Para>
106 </ListItem>
107 </VarListEntry>
108
109 <VarListEntry><Term><SGMLTag class="StartTag">IndexTerm</SGMLTag></Term>
110 <ListItem>
111 <Para>
112 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>.
113 </Para>
114 </ListItem>
115 </VarListEntry>
116
117 <VarListEntry><Term><SGMLTag class="StartTag">KeyCap</SGMLTag></Term><Term><SGMLTag class="StartTag">KeyCombo</SGMLTag></Term>
118 <ListItem>
119 <Para>
120 Some more tags you may miss. Used for combinations such as <KeyCombo><KeyCap>Control</KeyCap><KeyCap>D</KeyCap></KeyCombo>.
121 </Para>
122 </ListItem>
123 </VarListEntry>
124
125 <VarListEntry><Term><SGMLTag class="StartTag">Literal</SGMLTag></Term>
126 <ListItem>
127 <Para>
128 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.
129 </Para>
130 </ListItem>
131 </VarListEntry>
132
133 <VarListEntry><Term><SGMLTag class="StartTag">Option</SGMLTag></Term>
134 <ListItem>
135 <Para>
136 Used for compiler options and similar.
137 </Para>
138 </ListItem>
139 </VarListEntry>
140
141 <VarListEntry><Term><SGMLTag class="StartTag">ProgramListing</SGMLTag></Term>
142 <ListItem>
143 <Para>
144 For displayed program listings (including shell scripts).
145 </Para>
146 </ListItem>
147 </VarListEntry>
148
149 <VarListEntry><Term><SGMLTag class="StartTag">Screen</SGMLTag></Term>
150 <ListItem>
151 <Para>
152 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.
153 </Para>
154 </ListItem>
155 </VarListEntry>
156
157 <VarListEntry><Term><SGMLTag class="StartTag">VarName</SGMLTag></Term>
158 <ListItem>
159 <Para>
160 Used for variables, but not type variables.
161 </Para>
162 </ListItem>
163 </VarListEntry>
164
165 </VariableList>
166
167 </Sect1>
168
169 <Sect1 id="docbook-tables"><Title>Tables</Title>
170
171 <Para>
172 Tables are quite complicated to write in SGML (as in HTML, 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.
173 </Para>
174
175 <Para>
176 <InformalTable>
177 <TGroup cols="3">
178 <ColSpec Colname="one" Align="Left" Colsep="0">
179 <ColSpec Colname="two" Align="Center" Colsep="0">
180 <ColSpec Colname="three" Align="Right" Colsep="0">
181 <TBody>
182
183 <Row>
184 <Entry>Here's</Entry>
185 <Entry>a sample</Entry>
186 <Entry>table</Entry>
187 </Row>
188
189 <Row>
190 <Entry>With differently</Entry>
191 <Entry>aligned</Entry>
192 <Entry>cells</Entry>
193 </Row>
194
195 <Row>
196 <Entry namest="one" nameend="three" morerows="1"><Para>
197 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>
198 </Row>
199
200 </TBody>
201
202 </TGroup>
203 </InformalTable>
204 </Para>
205
206 </Sect1>
207
208 </Article>