4a4a8a5a38db639ff1ac33bd1de4c1becd1494bd
[ghc-hetmet.git] / docs / 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 </ListItem>
47 </ItemizedList>
48
49 <Para> The rest of this section outlines the use of several tags which may
50 not be obvious (DocBook is rather scholastic in style: it has tags for many
51 things from C function prototypes to keyboard bindings; at the same time it
52 has many omissions and oddities). The current scheme has many infelicities,
53 partly because it was dreamt up in a hurry while the author was learning
54 DocBook and converting the documentation thereto, and partly because DocBook
55 is rather C-centric. </Para>
56
57 <VariableList>
58
59 <VarListEntry><Term>Comments</Term>
60 <ListItem>
61 <Para>
62 Comments in SGML look like this: <SGMLTag class=SGMLComment>This is a
63 comment</SGMLTag>.
64 </Para>
65 </ListItem>
66 </VarListEntry>
67
68 <VarListEntry><Term><SGMLTag class="StartTag">Command</SGMLTag></Term>
69 <ListItem>
70 <Para>
71 Used for commands typed into interactive sessions (e.g. <Command>cp foo bar</Command> and the names of programs such as <Command>gmake</Command>.
72 </Para>
73 </ListItem>
74 </VarListEntry>
75
76 <VarListEntry><Term><SGMLTag class="StartTag">Constant</SGMLTag></Term>
77 <ListItem>
78 <Para>
79 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).
80 </Para>
81 </ListItem>
82 </VarListEntry>
83
84 <VarListEntry><Term><SGMLTag class="StartTag">Email</SGMLTag></Term>
85 <ListItem>
86 <Para>
87 For email addresses. This is a tag that's easy to overlook if you don't know it's there.
88 </Para>
89 </ListItem>
90 </VarListEntry>
91
92 <VarListEntry><Term><SGMLTag class="StartTag">Filename</SGMLTag></Term>
93 <ListItem>
94 <Para>
95 Used for paths, filenames, file extensions.
96 </Para>
97 </ListItem>
98 </VarListEntry>
99
100 <VarListEntry><Term><SGMLTag class="StartTag">Function</SGMLTag></Term>
101 <ListItem>
102 <Para>
103 Used for functions and constructors.
104 </Para>
105 </ListItem>
106 </VarListEntry>
107
108 <VarListEntry><Term><SGMLTag class="StartTag">IndexTerm</SGMLTag></Term>
109 <ListItem>
110 <Para>
111 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>.
112 </Para>
113 </ListItem>
114 </VarListEntry>
115
116 <VarListEntry><Term><SGMLTag class="StartTag">KeyCap</SGMLTag></Term><Term><SGMLTag class="StartTag">KeyCombo</SGMLTag></Term>
117 <ListItem>
118 <Para>
119 Some more tags you may miss. Used for combinations such as <KeyCombo><KeyCap>Control</KeyCap><KeyCap>D</KeyCap></KeyCombo>.
120 </Para>
121 </ListItem>
122 </VarListEntry>
123
124 <VarListEntry><Term><SGMLTag class="StartTag">Literal</SGMLTag></Term>
125 <ListItem>
126 <Para>
127 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.
128 </Para>
129 </ListItem>
130 </VarListEntry>
131
132 <VarListEntry><Term><SGMLTag class="StartTag">Option</SGMLTag></Term>
133 <ListItem>
134 <Para>
135 Used for compiler options and similar.
136 </Para>
137 </ListItem>
138 </VarListEntry>
139
140 <VarListEntry><Term><SGMLTag class="StartTag">ProgramListing</SGMLTag></Term>
141 <ListItem>
142 <Para>
143 For displayed program listings (including shell scripts).
144 </Para>
145 </ListItem>
146 </VarListEntry>
147
148 <VarListEntry><Term><SGMLTag class="StartTag">Screen</SGMLTag></Term>
149 <ListItem>
150 <Para>
151 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.
152 </Para>
153 </ListItem>
154 </VarListEntry>
155
156 <VarListEntry><Term><SGMLTag class="StartTag">VarName</SGMLTag></Term>
157 <ListItem>
158 <Para>
159 Used for variables, but not type variables.
160 </Para>
161 </ListItem>
162 </VarListEntry>
163
164 </VariableList>
165
166 </Sect1>
167
168 <Sect1 id="docbook-tables"><Title>Tables</Title>
169
170 <Para>
171 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.
172 </Para>
173
174 <Para>
175 <InformalTable>
176 <TGroup cols="3">
177 <ColSpec Colname="one" Align="Left" Colsep="0">
178 <ColSpec Colname="two" Align="Center" Colsep="0">
179 <ColSpec Colname="three" Align="Right" Colsep="0">
180 <TBody>
181
182 <Row>
183 <Entry>Here's</Entry>
184 <Entry>a sample</Entry>
185 <Entry>table</Entry>
186 </Row>
187
188 <Row>
189 <Entry>With differently</Entry>
190 <Entry>aligned</Entry>
191 <Entry>cells</Entry>
192 </Row>
193
194 <Row>
195 <Entry namest="one" nameend="three" morerows="1"><Para>
196 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>
197 </Row>
198
199 </TBody>
200
201 </TGroup>
202 </InformalTable>
203 </Para>
204
205 </Sect1>
206
207 </Article>