/[gentoo]/xml/htdocs/doc/en/xml-guide.xml
Gentoo

Diff of /xml/htdocs/doc/en/xml-guide.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.3 Revision 1.70
1<?xml version='1.0' encoding="UTF-8"?> 1<?xml version="1.0" encoding="UTF-8"?>
2<?xml-stylesheet href="/xsl/guide.xsl" type="text/xsl"?>
3
4<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> 2<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
3<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/xml-guide.xml,v 1.70 2010/12/06 11:27:27 nightmorph Exp $ -->
5 4
6<guide link="/doc/en/xml-guide.xml"> 5<guide>
7<title>Gentoo Linux Documentation Guide</title> 6<title>Gentoo GuideXML Guide</title>
8<author title="Chief Architect"><mail link="drobbins@gentoo.org">Daniel Robbins</mail></author>
9 7
8<author title="Author">
9 <mail link="neysx"/>
10</author>
11<author title="Author">
12 <mail link="drobbins@gentoo.org">Daniel Robbins</mail>
13</author>
14<author title="Author"><!-- zhen@gentoo.org -->
15 John P. Davis
16</author>
17<author title="Editor">
18 <mail link="peesh@gentoo.org">Jorge Paulo</mail>
19</author>
20<author title="Editor">
21 <mail link="swift@gentoo.org">Sven Vermeulen</mail>
22</author>
23<author title="Editor">
24 <mail link="nightmorph"/>
25</author>
26
27<abstract>
10<abstract>This guide shows you how to compose web documentation using the new lightweight Gentoo guide 28This guide shows you how to compose web documentation using the new lightweight
11XML syntax. This syntax is the official format for Gentoo Linux documentation, and this document 29Gentoo GuideXML syntax. This syntax is the official format for Gentoo
12itself was created using guide XML. This guide assumes a basic working knowledge of XML and HTML. 30documentation, and this document itself was created using GuideXML. This guide
31assumes a basic working knowledge of XML and HTML.
13</abstract> 32</abstract>
14 33
34<!-- The content of this document is licensed under the CC-BY-SA license -->
35<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
36<license/>
37
15<version>1.0</version> 38<version>11</version>
16<date>07 Mar 2002</date> 39<date>2010-12-06</date>
17 40
18<chapter> 41<chapter>
19<title>Guide basics</title> 42<title>GuideXML basics</title>
20
21<section> 43<section>
22<title>Guide XML design goals</title> 44<title>GuideXML design goals</title>
23<body> 45<body>
24 46
47<p>
25<p> The guide XML syntax is lightweight yet expressive, so that it is easy to 48The guideXML syntax is lightweight yet expressive, so that it is easy to
26learn yet also provides all the features we need for the creation of web 49learn yet also provides all the features we need for the creation of web
27documentation. The number of tags is kept to a minimum -- just those we need. 50documentation. The number of tags is kept to a minimum -- just those we need.
28This makes it easy to transform guide into other formats, such as DocBook 51This makes it easy to transform guide into other formats, such as DocBook
29XML/SGML or web-ready HTML. </p> 52XML/SGML or web-ready HTML.
53</p>
30 54
55<p>
31<p>The goal is to make it easy to <e>create</e> and <e>transform</e> guide XML 56The goal is to make it easy to <e>create</e> and <e>transform</e> guideXML
32documents.</p> 57documents.
58</p>
33 59
34</body> 60</body>
35</section>
36
37<section> 61</section>
38<title>How to transform guide XML into HTML</title> 62<section>
63<title>Further Resources</title>
39<body> 64<body>
40 65
41<p> Before we take a look at the guide syntax itself, it's helpful to know how
42guide XML is transformed into web-ready HTML. To do this, we use a special
43file called <path>guide-main.xsl</path>, along with a command-line XSLT processing
44tool (also called an "engine"). The <path>guide-main.xsl</path> file describes
45exactly how to transform the contents of the source guide XML document to
46create the target HTML file. Two popular XSLT processors are <c>sabcmd</c>
47(included in the <path>app-text/sablotron</path> package) and <c>xsltproc</c>
48(found in the <path>dev-libs/libxslt</path> package). From experience, we've
49found that <c>xsltproc</c> is the higher-quality and more feature-rich XSLT
50processor. </p>
51
52<p> Once you have either <c>xsltproc</c> or <c>sabcmd</c> installed, you're
53ready to convert guide XML into web-ready HTML. Here's how it works. First,
54download the latest snapshot of our Web site from
55<uri>http://www.gentoo.org/projects/xml.html</uri>, found in the <uri
56link="http://www.gentoo.org/projects/guide-xml-latest.tar.gz">xml-guide-latest.tar.gz</uri>
57file. Extract the tarball. Inside it, you'll find a <path>gentoo-src</path>
58directory, as well as a <path>gentoo-src/xml</path> directory, etc. Now, find
59<path>gentoo-src/xml/install.xml</path>. (The new user installation guide).
60This will be our source XML guide document. The easiest way to perform the
61transformation is to change directories to the location of the
62<path>guide-main.xsl</path> file. Then, execute <c>xsltproc</c> as follows:
63</p> 66<p>
64 67If you are planning on contributing documentation to Gentoo, or you want to
65<pre> 68test GuideXML, please read our <uri
66# <i>cd gentoo-web/xsl</i> 69link="/proj/en/gdp/doc/doc-tipsntricks.xml">Doc Tips 'n' Tricks</uri> guide
67# <i>xsltproc guide-main.xsl ../xml/install.xml &gt; /tmp/install.html</i> 70which contains tips and tricks for documentation development.
68</pre> 71</p>
69 72
70<p> If all went well, you should have a web-ready version of 73<p>
71<path>install.xml</path> at <path>/tmp/install.html</path>. For this document 74You may want to look at the <uri link="?passthru=1">XML source</uri> of this
72to display properly in a web browser, you may have to copy some files from 75document while you read it.
73<path>gentoo-web</path> to <path>/tmp</path>, such
74as <path>css/main-new.css</path> and (to be safe) the entire <path>images</path>
75directory.
76</p> 76</p>
77 77
78</body> 78</body>
79</section> 79</section>
80</chapter> 80</chapter>
81
81<chapter> 82<chapter>
82 <title>Guide XML</title> 83<title>GuideXML</title>
83<section> 84<section>
84<title>Basic structure</title> 85<title>Basic structure</title>
85<body> 86<body>
86 87
87<p>Now that you know how to transform guide XML, you're ready to start learning 88<p>
88the guide XML syntax. We'll start with the the initial tags used in a guide 89Let's start learning the GuideXML syntax. We'll start with the the initial
89XML document: </p> 90tags used in a GuideXML document:
91</p>
90 92
91<pre caption="The initial part of a guide XML document"> 93<pre caption="The initial part of a guide XML document">
92&lt;?xml version='1.0'?&gt; 94&lt;?xml version="1.0" encoding="UTF-8"?&gt;
93&lt;guide&gt; 95&lt;!DOCTYPE guide SYSTEM "/dtd/guide.dtd"&gt;
96&lt;!-- &#36;Header&#36; --&gt;
97
98&lt;guide link="<i>/doc/en/guide.xml</i>" lang="<i>en</i>"&gt;
94&lt;title&gt;<i>Gentoo Linux Documentation Guide</i>&lt;/title&gt; 99&lt;title&gt;<i>Gentoo Documentation Guide</i>&lt;/title&gt;
95&lt;author title="<i>Chief Architect</i>"&gt;&lt;mail link="<i>drobbins@gentoo.org</i>"&gt; 100
96 <i>Daniel Robbins</i>&lt;/mail&gt; 101&lt;author title="<i>Author</i>"&gt;
102 &lt;mail link="<i>yourname@gentoo.org</i>"&gt;<i>Your Name</i>&lt;/mail&gt;
97&lt;/author&gt; 103&lt;/author&gt;
98&lt;author title="<i>Editor</i>"&gt;&lt;mail link="<i>thomasfl@gentoo.org</i>"&gt;
99 <i>Thomas Flavel</i>&lt;/mail&gt;
100&lt;/author&gt;
101 104
105&lt;abstract&gt;
102&lt;abstract&gt;<i>This guide shows you how to compose web documentation using 106<i>This guide shows you how to compose web documentation using
103our new lightweight Gentoo guide XML syntax. This syntax is the official 107our new lightweight Gentoo GuideXML syntax. This syntax is the official
104format for Gentoo Linux web documentation, and this document itself was created 108format for Gentoo web documentation, and this document itself was created
105using guide XML.</i> &lt;/abstract&gt; 109using GuideXML.</i>
110&lt;/abstract&gt;
106 111
112&lt;!-- The content of this document is licensed under the CC-BY-SA license --&gt;
113&lt;!-- See http://creativecommons.org/licenses/by-sa/2.5 --&gt;
114&lt;license/&gt;
115
107&lt;version&gt;<i>1.0</i>&lt;/version&gt; 116&lt;version&gt;<i>1</i>&lt;/version&gt;
108&lt;date&gt;<i>29 Mar 2001</i>&lt;/date&gt; 117&lt;date&gt;<i>2010-12-25</i>&lt;/date&gt;
109</pre> 118</pre>
110 119
120<p>
111<p>On the first, line, we see the requisite tag that identifies this as an XML 121On the first lines, we see the requisite tag that identifies this as an XML
112document. Following it, there's a <c>&lt;guide&gt;</c> tag -- the entire 122document and specifies its DTD. The <c>&lt;!-- &#36;Header&#36; --&gt;</c> line
123will be automatically modified by the CVS server and helps to track revisions.
124Next, there's a <c>&lt;guide&gt;</c> tag -- the entire guide document is
113guide document is enclosed within a <c>&lt;guide&gt; &lt;/guide&gt;</c> pair. 125enclosed within a <c>&lt;guide&gt; &lt;/guide&gt;</c> pair.
126<br/>
127The <c>link</c> attribute is optional and should preferably contain the
128absolute path to the document relatively to the document root even though the
129file name alone will work. It is only used to generate a link to a
130printer-friendly version of your document and check whether a translation is
131up-to-date. Our XSL back-engine passes the actual path to our XSL stylesheet.
132The link attribute is only used as a fall-back value in case the XML is
133processed by other means.
134<br/>
135The <c>lang</c> attribute should be used to specify the language code of your
136document. It is used to format the date and insert strings like "<e>Note</e>",
137"<e>Content</e>", etc. in the specified language. The default is English.
138</p>
139
140<p>
114Next, there's a <c>&lt;title&gt;</c> tag, used to set the title for the entire 141Next, there's a <c>&lt;title&gt;</c> tag, used to set the title for the entire
115guide document. </p> 142guide document.
143</p>
116 144
145<p>
117<p>Then, we come to the <c>&lt;author&gt;</c> tags, which contain information 146Then, we come to the <c>&lt;author&gt;</c> tags, which contain information
118about the various authors of the document. Each <c>&lt;author&gt;</c> tag 147about the various authors of the document. Each <c>&lt;author&gt;</c> tag
119allows for an optional <c>title=</c> element, used to specify the author's 148allows for an optional <c>title</c> element, used to specify the author's
120relationship to the document (author, co-author, editor, etc.). In this 149relationship to the document (author, co-author, editor, etc.). In this
121particular example, the authors' names are enclosed in another tag -- a 150particular example, the authors' names are enclosed in another tag -- a
122<c>&lt;mail&gt;</c> tag, used to specify an email address for this particular 151<c>&lt;mail&gt;</c> tag, used to specify an email address for this particular
123person. The <c>&lt;mail&gt;</c> tag is optional and can be omitted, and no 152person. The <c>&lt;mail&gt;</c> tag is optional and can be omitted, and at
124more than one <c>&lt;author&gt;</c> element is required per guide document. 153least one <c>&lt;author&gt;</c> element is required per guide document.
154</p>
155
125</p> 156<p>
126
127<p>Next, we come to the <c>&lt;abstract&gt;</c>, <c>&lt;version&gt;</c> and 157Next, we come to the <c>&lt;abstract&gt;</c>, <c>&lt;version&gt;</c> and
128<c>&lt;date&gt;</c> tags, used to specify a summary of the document, the 158<c>&lt;date&gt;</c> tags, used to specify a summary of the document, the
129current version number, and the current version date (in DD MMM YYYY format) 159current version number, and the current version date (in YYYY-MM-DD format)
130respectively. This rounds out the tags that should appear at the beginning of 160respectively. Dates that are invalid or not in the YYYY-MM-DD format will
161appear verbatim in the rendered document.
162</p>
163
164<p>
165This sums up the tags that should appear at the beginning of a guide document.
131a guide document. Besides the <c>&lt;title&gt;</c> and <c>&lt;mail&gt;</c> 166Besides the <c>&lt;title&gt;</c> and <c>&lt;mail&gt;</c> tags, these tags
132tags, these tags shouldn't appear anywhere else except immediately inside the 167shouldn't appear anywhere else except immediately inside the
133<c>&lt;guide&gt;</c> tag, and for consistency it's recommended (but not 168<c>&lt;guide&gt;</c> tag, and for consistency it's recommended (but not
134required) that these tags appear before the content of the document. </p> 169required) that these tags appear before the content of the document.
170</p>
135 171
136</body> 172<p>
137</section> 173Finally we have the <c>&lt;license/&gt;</c> tag, used to publish the document
174under the <uri link="http://creativecommons.org/licenses/by-sa/2.5/">Creative
175Commons - Attribution / Share Alike</uri> license as required by the <uri
176link="/proj/en/gdp/doc/doc-policy.xml">Documentation Policy</uri>.
177</p>
138 178
179</body>
180</section>
139<section> 181<section>
140<title>Chapters and sections</title> 182<title>Chapters and sections</title>
141<body> 183<body>
184
185<p>
142<p>Once the initial tags have been specified, you're ready to start adding 186Once the initial tags have been specified, you're ready to start adding the
143the structural elements of the document. Guide documents are divided into 187structural elements of the document. Guide documents are divided into
144chapters, and each chapter can hold one or more sections. Every chapter 188chapters, and each chapter can hold one or more sections. Every chapter and
145and section has a title. Here's an example chapter with a single section, 189section has a title. Here's an example chapter with a single section,
146consisting of a paragraph. If you append this XML to the XML in the <uri link="#doc_pre2">previous 190consisting of a paragraph. If you append this XML to the XML in the <uri
191link="#doc_chap2_pre1">previous excerpt</uri> and append a
147excerpt</uri> and append a <c>&lt;/guide&gt;</c> to the end of the file, you'll have a valid 192<c>&lt;/guide&gt;</c> to the end of the file, you'll have a valid (if minimal)
148(if minimal) guide document: 193guide document:
149</p> 194</p>
150 195
151<pre> 196<pre caption="Minimal guide example">
152&lt;chapter&gt; 197&lt;chapter&gt;
153&lt;title&gt;<i>This is my chapter</i>&lt;/title&gt; 198&lt;title&gt;<i>This is my chapter</i>&lt;/title&gt;
154&lt;section&gt; 199&lt;section&gt;
155 &lt;title&gt;<i>This is section one of my chapter</i>&lt;/title&gt; 200&lt;title&gt;<i>This is section one of my chapter</i>&lt;/title&gt;
156 &lt;body&gt; 201&lt;body&gt;
202
203&lt;p&gt;
157 &lt;p&gt;<i>This is the actual text content of my section.</i>&lt;/p&gt; 204<i>This is the actual text content of my section.</i>
205&lt;/p&gt;
206
158 &lt;/body&gt; 207&lt;/body&gt;
159&lt;/section&gt; 208&lt;/section&gt;
160&lt;/chapter&gt; 209&lt;/chapter&gt;
161</pre> 210</pre>
162 211
212<p>
163<p>Above, I set the chapter title by adding a child <c>&lt;title&gt;</c> 213Above, I set the chapter title by adding a child <c>&lt;title&gt;</c>
164element to the <c>&lt;chapter&gt;</c> element. Then, I created a section by 214element to the <c>&lt;chapter&gt;</c> element. Then, I created a section by
165adding a <c>&lt;section&gt;</c> element. If you look inside the 215adding a <c>&lt;section&gt;</c> element. If you look inside the
166<c>&lt;section&gt;</c> element, you'll see that it has two child elements -- a 216<c>&lt;section&gt;</c> element, you'll see that it has two child elements -- a
167<c>&lt;title&gt;</c> and a <c>&lt;body&gt;</c>. While the <c>&lt;title&gt;</c> 217<c>&lt;title&gt;</c> and a <c>&lt;body&gt;</c>. While the <c>&lt;title&gt;</c>
168is nothing new, the <c>&lt;body&gt;</c> is -- it contains the actual text 218is nothing new, the <c>&lt;body&gt;</c> is -- it contains the actual text
169content of this particular section. We'll look at the tags that are allowed 219content of this particular section. We'll look at the tags that are allowed
170inside a <c>&lt;body&gt;</c> element in a bit. </p> 220inside a <c>&lt;body&gt;</c> element in a bit.
221</p>
171 222
172<note>A <c>&lt;guide&gt;</c> element can contain multiple 223<note>
173<c>&lt;chapter&gt;</c> elements, and a <c>&lt;chapter&gt;</c> can contain 224A <c>&lt;guide&gt;</c> element must contain at least one <c>&lt;chapter&gt;</c>
225elements, a <c>&lt;chapter&gt;</c> must contain at least one
174multiple <c>&lt;section&gt;</c> elements. However, a <c>&lt;section&gt;</c> 226<c>&lt;section&gt;</c> elements and a <c>&lt;section&gt;</c> element must
175element can only contain one <c>&lt;body&gt;</c> element. </note> 227contain at least one <c>&lt;body&gt;</c> element.
228</note>
176 229
177</body> 230</body>
178</section> 231</section>
179
180<section> 232<section>
181<title>An example &lt;body&gt;</title> 233<title>An example &lt;body&gt;</title>
182<body> 234<body>
183<p> 235
184Now, it's time to learn how to mark up actual content. Here's the XML code for an example <c>&lt;body&gt;</c> element:
185</p> 236<p>
186<pre> 237Now, it's time to learn how to mark up actual content. Here's the XML code for
238an example <c>&lt;body&gt;</c> element:
239</p>
240
241<pre caption="Example of a body element">
187&lt;p&gt; 242&lt;p&gt;
188This is a paragraph. &lt;path&gt;/etc/passwd&lt;/path&gt; is a file. 243This is a paragraph. &lt;path&gt;/etc/passwd&lt;/path&gt; is a file.
189&lt;uri&gt;http://www.gentoo.org&lt;/uri&gt; is my favorite website. 244&lt;uri&gt;http://forums.gentoo.org&lt;/uri&gt; is my favorite website.
190Type &lt;c&gt;ls&lt;/c&gt; if you feel like it. I &lt;e&gt;really&lt;/e&gt; want to go to sleep now. 245Type &lt;c&gt;ls&lt;/c&gt; if you feel like it. I &lt;e&gt;really&lt;/e&gt; want to go to sleep now.
191&lt;/p&gt; 246&lt;/p&gt;
192 247
193&lt;pre&gt; 248&lt;pre caption="Code Sample"&gt;
194This is text output or code. 249This is text output or code.
195# &lt;i&gt;this is user input&lt;/i&gt; 250# &lt;i&gt;this is user input&lt;/i&gt;
196 251
197Make HTML/XML easier to read by using selective emphasis: 252Make HTML/XML easier to read by using selective emphasis:
198&lt;foo&gt;&lt;i&gt;bar&lt;/i&gt;&lt;/foo&gt; 253&lt;foo&gt;&lt;i&gt;bar&lt;/i&gt;&lt;/foo&gt;
199 254
200&lt;codenote&gt;This is how to insert an inline note into the code block&lt;/codenote&gt; 255&lt;comment&gt;(This is how to insert a comment into a code block)&lt;/comment&gt;
201&lt;/pre&gt; 256&lt;/pre&gt;
202&lt;note&gt;This is a note.&lt;/note&gt; 257
203&lt;warn&gt;This is a warning.&lt;/warn&gt; 258&lt;note&gt;
204&lt;impo&gt;This is important.&lt;/impo&gt; 259This is a note.
260&lt;/note&gt;
261
262&lt;warn&gt;
263This is a warning.
264&lt;/warn&gt;
265
266&lt;impo&gt;
267This is important.
268&lt;/impo&gt;
205</pre> 269</pre>
270
271<p>
206<p>Now, here's how this <c>&lt;body&gt;</c> element is rendered:</p> 272Now, here's how the <c>&lt;body&gt;</c> element above is rendered:
273</p>
207 274
208<p> 275<p>
209This is a paragraph. <path>/etc/passwd</path> is a file. 276This is a paragraph. <path>/etc/passwd</path> is a file.
210<uri>http://www.gentoo.org</uri> is my favorite website. 277<uri>http://forums.gentoo.org</uri> is my favorite web site.
211Type <c>ls</c> if you feel like it. I <e>really</e> want to go to sleep now. 278Type <c>ls</c> if you feel like it. I <e>really</e> want to go to sleep now.
212</p> 279</p>
213 280
214<pre> 281<pre caption="Code Sample">
215This is text output or code. 282This is text output or code.
216# <i>this is user input</i> 283# <i>this is user input</i>
217 284
218Make HTML/XML easier to read by using selective emphasis: 285Make HTML/XML easier to read by using selective emphasis:
219&lt;foo&gt;<i>bar</i>&lt;/foo&gt; 286&lt;foo&gt;<i>bar</i>&lt;/foo&gt;
220 287
221<codenote>This is how to insert an inline note into the code block</codenote> 288<comment>(This is how to insert a comment into a code block)</comment>
222</pre> 289</pre>
223<note>This is a note.</note>
224<warn>This is a warning.</warn>
225<impo>This is important.</impo>
226</body>
227</section>
228 290
291<note>
292This is a note.
293</note>
294
295<warn>
296This is a warning.
297</warn>
298
299<impo>
300This is important.
301</impo>
302
303</body>
304</section>
229<section> 305<section>
230<title>The &lt;body&gt; tags</title> 306<title>The &lt;body&gt; tags</title>
231<body> 307<body>
232 308
309<p>
233<p> We introduced a lot of new tags in the previous section -- here's what you 310We introduced a lot of new tags in the previous section -- here's what you need
234need to know. The <c>&lt;p&gt;</c> (paragraph), <c>&lt;pre&gt;</c> (code 311to know. The <c>&lt;p&gt;</c> (paragraph), <c>&lt;pre&gt;</c> (code block),
235block), <c>&lt;note&gt;</c>, <c>&lt;warn&gt;</c> (warning) and 312<c>&lt;note&gt;</c>, <c>&lt;warn&gt;</c> (warning) and <c>&lt;impo&gt;</c>
236<c>&lt;impo&gt;</c> (important) tags all can contain one or more lines of text. 313(important) tags all can contain one or more lines of text. Besides the
314<c>&lt;table&gt;</c>, <c>&lt;ul&gt;</c>, <c>&lt;ol&gt;</c> and
237Besides the <c>&lt;table&gt;</c> element (which we'll cover in just a bit), 315<c>&lt;dl&gt;</c> elements (which we'll cover in just a bit), these are the
238these are the only tags that should appear immediately inside a 316only tags that should appear immediately inside a <c>&lt;body&gt;</c> element.
239<c>&lt;body&gt;</c> element. Another thing -- these tags <e>should not</e> be 317Another thing -- these tags <e>should not</e> be stacked -- in other words,
240stacked -- in other words, don't put a <c>&lt;note&gt;</c> element inside a 318don't put a <c>&lt;note&gt;</c> element inside a <c>&lt;p&gt;</c> element. As
241<c>&lt;p&gt;</c> element. As you might guess, the <c>&lt;pre&gt;</c> element 319you might guess, the <c>&lt;pre&gt;</c> element preserves its whitespace
242preserves its whitespace exactly, making it well-suited for code excerpts.</p> 320exactly, making it well-suited for code excerpts. You must name the
321<c>&lt;pre&gt;</c> tag with a <c>caption</c> attribute:
322</p>
243 323
324<pre caption="Named &lt;pre&gt;">
325&lt;pre caption="Output of uptime"&gt;
326# &lt;i&gt;uptime&lt;/i&gt;
32716:50:47 up 164 days, 2:06, 5 users, load average: 0.23, 0.20, 0.25
328&lt;/pre&gt;
329</pre>
330
244</body> 331</body>
245</section>
246<section> 332</section>
247<title>&lt;path&gt;, &lt;c&gt; and &lt;e&gt;</title> 333<section>
334<title>Epigraphs</title>
335<body>
336
337<p by="Anonymous student">
338Delegates from the original 13 states formed the Contented Congress. Thomas
339Jefferson, a Virgin, and Benjamin Franklin were two singers of the Declaration
340of Independence. Franklin discovered electricity by rubbing two cats backwards
341and declared, "A horse divided against itself cannot stand." Franklin died in
3421790 and is still dead.
343</p>
344
345<p>
346Epigraphs are sometimes used at the beginning of chapters to illustrate what is
347to follow. It is simply a paragraph with a <c>by</c> attribute that contains
348the signature.
349</p>
350
351<pre caption="Short epigraph">
352&lt;p by="Anonymous student"&gt;
353Delegates from the original 13 states formed the...
354&lt;/p&gt;
355</pre>
356
248<body> 357</body>
358</section>
359<section>
360<title>
361 &lt;path&gt;, &lt;c&gt;, &lt;b&gt;, &lt;e&gt;, &lt;sub&gt; and &lt;sup&gt;
362</title>
363<body>
249 364
250<p>The <c>&lt;path&gt;</c>, <c>&lt;c&gt;</c> and <c>&lt;e&gt;</c> elements can 365<p>
251be used inside any child <c>&lt;body&gt;</c> tag, except for 366The <c>&lt;path&gt;</c>, <c>&lt;c&gt;</c>, <c>&lt;b&gt;</c>, <c>&lt;e&gt;</c>,
252<c>&lt;pre&gt;</c>. </p> 367<c>&lt;sub&gt;</c> and <c>&lt;sup&gt;</c> elements can be used inside any child
368<c>&lt;body&gt;</c> tag, except for <c>&lt;pre&gt;</c>.
369</p>
253 370
371<p>
254<p>The <c>&lt;path&gt;</c> element is used to mark text that refers to an 372The <c>&lt;path&gt;</c> element is used to mark text that refers to an
255<e>on-disk file</e> -- either an <e>absolute or relative path</e>, or a <e>simple filename</e>. 373<e>on-disk file</e> -- either an <e>absolute or relative path</e>, or a
256This element is generally rendered with a monospaced font to offset it from the 374<e>simple filename</e>. This element is generally rendered with a mono spaced
257standard paragraph type. </p> 375font to offset it from the standard paragraph type.
376</p>
258 377
378<p>
259<p>The <c>&lt;c&gt;</c> element is used to mark up a <e>command</e> or <e>user 379The <c>&lt;c&gt;</c> element is used to mark up a <e>command</e> or <e>user
260input</e>. Think of <c>&lt;c&gt;</c> as a way to alert the reader to something 380input</e>. Think of <c>&lt;c&gt;</c> as a way to alert the reader to something
261that they can type in that will perform some kind of action. For example, all 381that they can type in that will perform some kind of action. For example, all
262the XML tags displayed in this document are enclosed in a <c>&lt;c&gt;</c> 382the XML tags displayed in this document are enclosed in a <c>&lt;c&gt;</c>
263element because they represent something that the user could type in that is 383element because they represent something that the user could type in that is
264not a path. By using <c>&lt;c&gt;</c> elements, you'll help your readers 384not a path. By using <c>&lt;c&gt;</c> elements, you'll help your readers
265quickly identify commands that they need to type in. Also, because 385quickly identify commands that they need to type in. Also, because
266<c>&lt;c&gt;</c> elements are already offset from regular text, <e>it is rarely 386<c>&lt;c&gt;</c> elements are already offset from regular text, <e>it is rarely
267necessary to surround user input with double-quotes</e>. For example, don't 387necessary to surround user input with double-quotes</e>. For example, don't
268refer to a "<c>&lt;c&gt;</c>" element like I did in this sentence. Avoiding 388refer to a "<c>&lt;c&gt;</c>" element like I did in this sentence. Avoiding
269the use of unnecessary double-quotes makes a document more readable -- and adorable!</p> 389the use of unnecessary double-quotes makes a document more readable -- and
390adorable!
391</p>
270 392
393<p>
394As you might have guessed, <c>&lt;b&gt;</c> is used to <b>boldface</b> some
395text.
396</p>
397
398<p>
271<p><c>&lt;e&gt;</c> is used to apply emphasis to a word or phrase; for example: 399<c>&lt;e&gt;</c> is used to apply emphasis to a word or phrase; for example:
272I <e>really</e> should use semicolons more often. As you can see, this text is 400I <e>really</e> should use semicolons more often. As you can see, this text is
273offset from the regular paragraph type for emphasis. This helps to give your 401offset from the regular paragraph type for emphasis. This helps to give your
274prose more <e>punch</e>!</p> 402prose more <e>punch</e>!
403</p>
275 404
405<p>
406The <c>&lt;sub&gt;</c> and <c>&lt;sup&gt;</c> elements are used to specify
407<sub>subscript</sub> and <sup>superscript</sup>.
408</p>
409
276</body> 410</body>
411</section>
277</section> 412<section>
413<title>Code samples and colour-coding</title>
414<body>
278 415
416<p>
417To improve the readability of code samples, the following tags are allowed
418inside <c>&lt;pre&gt;</c> blocks:
419</p>
420
421<dl>
422 <dt><c>&lt;i&gt;</c></dt>
423 <dd>Distinguishes user input from displayed text</dd>
424 <dt><c>&lt;comment&gt;</c></dt>
425 <dd>Comments relevant to the action(s) that appear after the comment</dd>
426 <dt><c>&lt;keyword&gt;</c></dt>
427 <dd>Denotes a keyword in the language used in the code sample
428 </dd>
429 <dt><c>&lt;ident&gt;</c></dt>
430 <dd>Used for an identifier
431 </dd>
432 <dt><c>&lt;const&gt;</c></dt>
433 <dd>Used for a constant
434 </dd>
435 <dt><c>&lt;stmt&gt;</c></dt>
436 <dd>Used for a statement
437 </dd>
438 <dt><c>&lt;var&gt;</c></dt>
439 <dd>Used for a variable
440 </dd>
441</dl>
442
443<note>
444Remember that all leading and trailing spaces, and line breaks in
445<c>&lt;pre&gt;</c> blocks will appear in the displayed html page.
446</note>
447
448<p>
449Sample colour-coded <c>&lt;pre&gt;</c> block:
450</p>
451
452<pre caption="My first ebuild">
453<comment># Copyright 1999-2009 <b>Gentoo Foundation</b>
454# Distributed under the terms of the GNU General Public License v2
455# &#36;Header: $</comment>
456
457<ident>DESCRIPTION</ident>=<const>"Exuberant ctags generates tags files for quick source navigation"</const>
458<ident>HOMEPAGE</ident>=<const>"http://ctags.sourceforge.net"</const>
459<ident>SRC_URI</ident>=<const>"mirror://sourceforge/ctags/<var>${P}</var>.tar.gz"</const>
460
461<ident>LICENSE</ident>=<const>"GPL-2"</const>
462<ident>SLOT</ident>=<const>"0"</const>
463<ident>KEYWORDS</ident>=<const>"~mips ~sparc ~x86"</const>
464<ident>IUSE</ident>=<const>""</const>
465
466<stmt>src_compile()</stmt> {
467 <keyword>econf</keyword> --with-posix-regex
468 <keyword>emake</keyword> || <keyword>die</keyword> <const>"emake failed"</const>
469}
470
471<stmt>src_install()</stmt> {
472 <keyword>make</keyword> <ident>DESTDIR</ident>="<var>${D}</var>" install || <keyword>die</keyword> <const>"install failed"</const>
473
474 <keyword>dodoc</keyword> FAQ NEWS README
475 <keyword>dohtml</keyword> EXTENDING.html ctags.html
476}
477</pre>
478
479</body>
480</section>
279<section> 481<section>
280<title>&lt;mail&gt; and &lt;uri&gt;</title> 482<title>&lt;mail&gt; and &lt;uri&gt;</title>
281<body> 483<body>
282 484
485<p>
283<p>We've taken a look at the <c>&lt;mail&gt;</c> tag earlier; it's used to link some text 486We've taken a look at the <c>&lt;mail&gt;</c> tag earlier; it's used to link
284with a particular email address, and takes the form <c>&lt;mail link="foo@bar.com"&gt;Mr. Foo Bar&lt;/mail&gt;</c>.</p> 487some text with a particular email address, and takes the form <c>&lt;mail
488link="foo.bar@example.com"&gt;Mr. Foo Bar&lt;/mail&gt;</c>. If you want to display the
489email address, you can use <c>&lt;mail&gt;foo.bar@example.com&lt;/mail&gt;</c>, this
490would be displayed as <mail>foo.bar@example.com</mail>.
491</p>
285 492
493<p>
494Shorter forms make it easier to use names and emails of Gentoo developers. Both
495<c>&lt;mail&gt;neysx&lt;/mail&gt;</c> and <c>&lt;mail link="neysx"/&gt;</c>
496would appear as <mail>neysx</mail>. If you want to use a Gentoo dev's email
497with a different content than his full name, use the second form with some
498content. For instance, use a dev's first name: <c>&lt;mail
499link="neysx"&gt;Xavier&lt;/mail&gt;</c> appears as <mail
500link="neysx">Xavier</mail>.
501<br/>
502This is particularly useful when you want to name a developer whose name
503contains "funny" characters that you can't type.
504</p>
505
506<p>
286<p>The <c>&lt;uri&gt;</c> tag is used to point to files/locations on the 507The <c>&lt;uri&gt;</c> tag is used to point to files/locations on the Internet.
287Internet. It has two forms -- the first can be used when you want to have the 508It has two forms -- the first can be used when you want to have the actual URI
288actual URI displayed in the body text, such as this link to 509displayed in the body text, such as this link to
289<uri>http://www.gentoo.org</uri>. To create this link, I typed 510<uri>http://forums.gentoo.org/</uri>. To create this link, I typed
290<c>&lt;uri&gt;http://www.gentoo.org&lt;/uri&gt;</c>. The alternate form is 511<c>&lt;uri&gt;http://forums.gentoo.org/&lt;/uri&gt;</c>. The alternate form is
291when you want to associate a URI with some other text -- for example, <uri 512when you want to associate a URI with some other text -- for example, <uri
292link="http://www.gentoo.org">the Gentoo Linux website</uri>. To create <e>this</e> 513link="http://forums.gentoo.org/">the Gentoo Forums</uri>. To create
293link, I typed <c>&lt;uri link="http://www.gentoo.org"&gt;the Gentoo Linux website&lt;/uri&gt;</c>. 514<e>this</e> link, I typed <c>&lt;uri link="http://forums.gentoo.org/"&gt;the
515Gentoo Forums&lt;/uri&gt;</c>. You don't need to write
516<c>http://www.gentoo.org/</c> to link to other parts of the Gentoo web site.
517For instance, a link to the <uri link="/doc/en/">documentation main index</uri>
518should be simply <c>&lt;uri link="/doc/en/index.xml"&gt;documentation main
519index&lt;/uri&gt;</c>. You can even omit <c>index.xml</c> when you link to a
520directory index, e.g. <c>&lt;uri link="/doc/en/"&gt;documentation main
521index&lt;/uri&gt;</c>. Leaving the trailing slash saves an extra HTTP request.
522</p>
523
294</p> 524<p>
525You should not use a <c>&lt;uri&gt;</c> tag with a <c>link</c> attribute that
526starts with <c>mailto:</c>. In this case, use a <c>&lt;mail&gt;</c> tag.
527</p>
295 528
296</body> 529<p>
297</section> 530Please avoid the <uri link="http://en.wikipedia.org/wiki/Click_here">click here
531syndrome</uri> as recommended by the <uri
532link="http://www.w3.org/QA/Tips/noClickHere">W3C</uri>.
533</p>
298 534
535</body>
536</section>
299<section> 537<section>
300<title>Figures</title> 538<title>Figures</title>
301
302<body> 539<body>
303 540
541<p>
304<p>Here's how to insert a figure into a document -- <c>&lt;figure 542Here's how to insert a figure into a document -- <c>&lt;figure
305link="mygfx.png" short="my picture" caption="my favorite picture of all 543link="mygfx.png" short="my picture" caption="my favorite picture of all
306time"/&gt;</c>. The <c>link=</c> attribute points to the actual graphic image, 544time"/&gt;</c>. The <c>link</c> attribute points to the actual graphic image,
307the <c>short=</c> attribute specifies a short description (currently used for 545the <c>short</c> attribute specifies a short description (currently used for
308the image's HTML <c>alt=</c> attribute), and a caption. Not too difficult 546the image's HTML <c>alt</c> attribute), and a caption. Not too difficult
309:) We also support the standard HTML-style &lt;img src="foo.gif"/&gt; tag 547:) We also support the standard HTML-style &lt;img src="foo.gif"/&gt; tag
310for adding images without captions, borders, etc.</p> 548for adding images without captions, borders, etc.
549</p>
311 550
312</body> 551</body>
313</section>
314<section> 552</section>
553<section>
315<title>Tables and lists</title> 554<title>Tables</title>
316<body> 555<body>
317 556
557<p>
318<p>Guide supports a simplified table syntax similar to that of HTML. To start 558GuideXML supports a simplified table syntax similar to that of HTML. To start a
319a table, use a <c>&lt;table&gt;</c> tag. Start a row with a <c>&lt;tr&gt;</c> 559table, use a <c>&lt;table&gt;</c> tag. Start a row with a <c>&lt;tr&gt;</c>
320tag. However, for inserting actual table data, we <e>don't</e> support the 560tag. However, for inserting actual table data, we <e>don't</e> support the HTML
321HTML &lt;td&gt; tag; instead, use the <c>&lt;th&gt;</c> if you are inserting a 561&lt;td&gt; tag; instead, use the <c>&lt;th&gt;</c> if you are inserting a
322header, and <c>&lt;ti&gt;</c> if you are inserting a normal informational 562header, and <c>&lt;ti&gt;</c> if you are inserting a normal informational
323block. You can use a <c>&lt;th&gt;</c> anywhere you can use a <c>&lt;ti&gt;</c> -- 563block. You can use a <c>&lt;th&gt;</c> anywhere you can use a <c>&lt;ti&gt;</c>
324there's no requirement that <c>&lt;th&gt;</c> elements appear only in the 564-- there's no requirement that <c>&lt;th&gt;</c> elements appear only in the
325first row. Currently, these tags don't support any attributes, but some will 565first row.
326be added (such as a <c>caption=</c> attribute for <c>&lt;table&gt;</c>) soon. 566</p>
567
327</p> 568<p>
569Besides, both table headers (<c>&lt;th&gt;</c>) and table items
570(<c>&lt;ti&gt;</c>) accept the <c>colspan</c> and <c>rowspan</c> attributes to
571span their content across rows, columns or both.
572</p>
328 573
574<p>
575Furthermore, table cells (<c>&lt;ti&gt;</c> &amp; <c>&lt;th&gt;</c>) can be
576right-aligned, left-aligned or centered with the <c>align</c> attribute.
577</p>
578
579<table>
580 <tr>
581 <th align="center" colspan="4">This title spans 4 columns</th>
582 </tr>
583 <tr>
584 <th rowspan="6">This title spans 6 rows</th>
585 <ti>Item A1</ti>
586 <ti>Item A2</ti>
587 <ti>Item A3</ti>
588 </tr>
589 <tr>
590 <ti align="center">Item B1</ti>
591 <th colspan="2" rowspan="2" align="right">Blocky 2x2 title</th>
592 </tr>
593 <tr>
594 <ti align="right">Item C1</ti>
595 </tr>
596 <tr>
597 <ti colspan="3" align="center">Item D1..D3</ti>
598 </tr>
599 <tr>
600 <ti rowspan="2">Item E1..F1</ti>
601 <ti colspan="2" align="right">Item E2..E3</ti>
602 </tr>
603 <tr>
604 <ti colspan="2" align="right">Item F2..F3</ti>
605 </tr>
606</table>
607
608</body>
609</section>
610<section>
611<title>Lists</title>
612<body>
613
614<p>
329<p> To create ordered or unordered lists, simply use the HTML-style 615To create ordered or unordered lists, simply use the XHTML-style
330<c>&lt;ol&gt;</c>, <c>&lt;ul&gt;</c> and <c>&lt;li&gt;</c> tags. List tags 616<c>&lt;ol&gt;</c>, <c>&lt;ul&gt;</c> and <c>&lt;li&gt;</c> tags. Lists may only
331should only appear inside a <c>&lt;p&gt;</c>, <c>&lt;ti&gt;</c>, 617appear inside the <c>&lt;body&gt;</c> and <c>&lt;li&gt;</c> tags which means
332<c>&lt;note&gt;</c>, <c>&lt;warn&gt;</c> or <c>&lt;impo&gt;</c> tag. </p> 618that you can have lists inside lists. Don't forget that you are writing XML and
619that you must close all tags including list items unlike in HTML.
620</p>
333 621
334</body> 622<p>
335</section> 623Definition lists (<c>&lt;dl&gt;</c>) are also supported. Please note that
624neither the definition term tag (<c>&lt;dt&gt;</c>) nor the definition data tag
625(<c>&lt;dd&gt;</c>) accept any other block level tag such as paragraphs or
626admonitions. A definition list comprises:
627</p>
336 628
629<dl>
630 <dt><c>&lt;dl&gt;</c></dt>
631 <dd>A <b>D</b>efinition <b>L</b>ist Tag containing</dd>
632 <dt><c>&lt;dt&gt;</c></dt>
633 <dd>Pairs of <b>D</b>efinition <b>T</b>erm Tags</dd>
634 <dt><c>&lt;dd&gt;</c></dt>
635 <dd>and <b>D</b>efinition <b>D</b>ata Tags</dd>
636</dl>
637
638<p>
639The following list copied from <uri
640link="http://www.w3.org/TR/REC-html40/struct/lists.html">w3.org</uri> shows
641that a definition list can contain ordered and unordered lists. It may not
642contain another definition list though.
643</p>
644
645<dl>
646 <dt><b>The ingredients:</b></dt>
647 <dd>
648 <ul>
649 <li>100 g. flour</li>
650 <li>10 g. sugar</li>
651 <li>1 cup water</li>
652 <li>2 eggs</li>
653 <li>salt, pepper</li>
654 </ul>
655 </dd>
656 <dt><b>The procedure:</b></dt>
657 <dd>
658 <ol>
659 <li>Mix dry ingredients thoroughly</li>
660 <li>Pour in wet ingredients</li>
661 <li>Mix for 10 minutes</li>
662 <li>Bake for one hour at 300 degrees</li>
663 </ol>
664 </dd>
665 <dt><b>Notes:</b></dt>
666 <dd>The recipe may be improved by adding raisins</dd>
667</dl>
668
669</body>
670</section>
337<section> 671<section>
338<title>Intra-document references</title> 672<title>Intra-document references</title>
339<body> 673<body>
340 674
675<p>
341<p>Guide makes it really easy to reference other parts of the document using 676GuideXML makes it really easy to reference other parts of the document using
342hyperlinks. You can create a link pointing to <uri link="#doc_chap1">Chapter 677hyperlinks. You can create a link pointing to <uri link="#doc_chap1">Chapter
343One</uri> by typing <c>&lt;uri link="#doc_chap1"&gt;Chapter 678One</uri> by typing <c>&lt;uri link="#doc_chap1"&gt;Chapter
344One&lt;/uri&gt;</c>. To point to <uri link="#doc_chap1_sect2">section two of 679One&lt;/uri&gt;</c>. To point to <uri link="#doc_chap1_sect2">section two of
345Chapter One</uri>, type <c>&lt;uri link="#doc_chap1_sect2"&gt;section two of 680Chapter One</uri>, type <c>&lt;uri link="#doc_chap1_sect2"&gt;section two of
346Chapter One&lt;/uri&gt;</c>. To refer to figure 3 in chapter 1, type <c>&lt;uri 681Chapter One&lt;/uri&gt;</c>. To refer to figure 3 in chapter 1, type
347link="doc_chap1_fig3"&gt;figure 1.3&lt;/uri&gt;</c>. Or, to refer to <uri link="#doc_chap2_pre2">code listing 2 in chapter 2</uri>, 682<c>&lt;uri link="#doc_chap1_fig3"&gt;figure 1.3&lt;/uri&gt;</c>. Or, to refer
683to <uri link="#doc_chap2_pre2">code listing 2 in chapter 2</uri>, type
348type <c>&lt;uri link="doc_chap2_pre2"&gt;code listing 2.2&lt;/uri&gt;</c>. We'll be 684<c>&lt;uri link="#doc_chap2_pre2"&gt;code listing 2.2&lt;/uri&gt;</c>.
349adding other auto-link abilities (such as table support) soon.</p> 685</p>
686
687<p>
688However, some guides change often and using such "counting" can lead to broken
689links. In order to cope with this, you can define a name for a
690<c>&lt;chapter&gt;</c>, <c>&lt;section&gt;</c> or a <c>&lt;tr&gt;</c> by using
691the <c>id</c> attribute, and then point to that attribute, like this:
692</p>
693
694<pre caption="Using the id attribute">
695&lt;chapter id="foo"&gt;
696&lt;title&gt;This is foo!&lt;/title&gt;
697...
698&lt;p&gt;
699More information can be found in the &lt;uri link="#foo"&gt;foo chapter&lt;/uri&gt;
700&lt;/p&gt;
701</pre>
702
703</body>
704</section>
705<section>
706<title>Disclaimers and obsolete documents</title>
707<body>
708
709<p>
710A <c>disclaimer</c> attribute can be applied to guides and handbooks to display
711a predefined disclaimer at the top of the document. The available disclaimers
712are:
713</p>
714
715<ul>
716 <li>
717 <b>articles</b> is used for <uri link="/doc/en/articles/">republished
718 articles</uri>
719 </li>
720 <li>
721 <b>draft</b> is used to indicate a document is still being worked on and
722 should not be considered official
723 </li>
724 <li>
725 <b>oldbook</b> is used on old handbooks to indicate they are not maintained
726 anymore
727 </li>
728 <li><b>obsolete</b> is used to mark a document as obsolete.</li>
729</ul>
730
731<p>
732When marking a document as obsolete, you might want to add a link to a new
733version. The <c>redirect</c> attribute does just that. The user might be
734automatically redirected to the new page but you should not rely on that
735behaviour.
736</p>
737
738<pre caption="Disclaimer sample">
739&lt;?xml version="1.0" encoding="UTF-8"?&gt;
740&lt;!DOCTYPE guide SYSTEM "/dtd/guide.dtd"&gt;
741&lt;!-- &#36;Header&#36; --&gt;
742
743&lt;guide disclaimer="obsolete" redirect="/doc/en/handbook/handbook-x86.xml"&gt;
744&lt;title>Gentoo x86 Installation Guide&lt;/title&gt;
745
746&lt;author title="Author"&gt;
747...
748</pre>
749
750</body>
751</section>
752<section>
753<title>FAQs</title>
754<body>
755
756<p>
757FAQ documents need to start with a list of questions with links to their
758answers. Creating such a list is both time-consuming and error-prone. The list
759can be created automatically if you use a <c>faqindex</c> element as the first
760chapter of your document. This element has the same structure as a
761<c>chapter</c> to allow some introductory text. The structure of the document
762is expected to be split into chapters (at least one chapter) containing
763sections, each section containing one question specified in its <c>title</c>
764element with the answer in its <c>body</c>. The FAQ index will appear as one
765section per chapter and one link per question.
766</p>
767
768<p>
769A quick look at a <uri link="/doc/en/faq.xml">FAQ</uri> and <uri
770link="/doc/en/faq.xml?passthru=1">its source</uri> should make the above
771obvious.
772</p>
350 773
351</body> 774</body>
352</section> 775</section>
353</chapter> 776</chapter>
777
778<chapter>
779<title>Handbook Format</title>
780<section>
781<title>Guide vs Book</title>
782<body>
783
784<p>
785For high-volume documentation, such as the <uri
786link="/doc/en/handbook/handbook-x86.xml?part=1">Installation Instructions</uri>, a
787broader format was needed. We designed a GuideXML-compatible enhancement that
788allows us to write modular and multi-page documentation.
789</p>
790
791</body>
792</section>
793<section>
794<title>Main File</title>
795<body>
796
797<p>
798The first change is the need for a "master" document. This document contains no
799real content, but links to the individual documentation modules. The syntax
800doesn't differ much from GuideXML:
801</p>
802
803<pre caption="Example book usage">
804&lt;?xml version='1.0' encoding='UTF-8'?&gt;
805&lt;!DOCTYPE book SYSTEM "/dtd/book.dtd"&gt;
806&lt;!-- &#36;Header&#36; --&gt;
807
808&lt;<i>book</i>&gt;
809&lt;title&gt;Example Book Usage&lt;/title&gt;
810
811&lt;author...&gt;
812 ...
813&lt;/author&gt;
814
815&lt;abstract&gt;
816 ...
817&lt;/abstract&gt;
818
819&lt;!-- The content of this document is licensed under the CC-BY-SA license --&gt;
820&lt;!-- See http://creativecommons.org/licenses/by-sa/2.5 --&gt;
821&lt;license/&gt;
822
823&lt;version&gt;...&lt;/version&gt;
824&lt;date&gt;...&lt;/date&gt;
825</pre>
826
827<p>
828So far no real differences (except for the <c>&lt;book&gt;</c> instead of
829<c>&lt;guide&gt;</c> tag). Instead of starting with the individual
830<c>&lt;chapter&gt;</c>s, you define a <c>&lt;part&gt;</c>, which is the
831equivalent of a separate part in a book:
832</p>
833
834<pre caption="Defining a part">
835&lt;part&gt;
836&lt;title&gt;Part One&lt;/title&gt;
837&lt;abstract&gt;
838 ...
839&lt;/abstract&gt;
840
841<comment>(Defining the several chapters)</comment>
842&lt;/part&gt;
843</pre>
844
845<p>
846Each part is accompanied by a <c>&lt;title&gt;</c> and an
847<c>&lt;abstract&gt;</c> which gives a small introduction to the part.
848</p>
849
850<p>
851Inside each part, you define the individual <c>&lt;chapter&gt;</c>s. Each
852chapter <e>must</e> be a separate document. As a result it is no surprise that
853a special tag (<c>&lt;include&gt;</c>) is added to allow including the separate
854document.
855</p>
856
857<pre caption="Defining a chapter">
858&lt;chapter&gt;
859&lt;title&gt;Chapter One&lt;/title&gt;
860
861 &lt;include href="path/to/chapter-one.xml"/&gt;
862
863&lt;/chapter&gt;
864</pre>
865
866</body>
867</section>
868<section>
869<title>Designing the Individual Chapters</title>
870<body>
871
872<p>
873The content of an individual chapter is structured as follows:
874</p>
875
876<pre caption="Chapter Syntax">
877&lt;?xml version='1.0' encoding='UTF-8'?&gt;
878&lt;!DOCTYPE sections SYSTEM "/dtd/book.dtd"&gt;
879&lt;!-- &#36;Header&#36; --&gt;
880
881&lt;!-- The content of this document is licensed under the CC-BY-SA license --&gt;
882&lt;!-- See http://creativecommons.org/licenses/by-sa/2.5 --&gt;
883
884&lt;sections&gt;
885
886&lt;abstract&gt;
887 This is a small explanation on chapter one.
888&lt;/abstract&gt;
889
890&lt;version&gt;...&lt;/version&gt;
891&lt;date&gt;...&lt;/date&gt;
892
893<comment>(Define the several &lt;section&gt; and &lt;subsection&gt;)</comment>
894
895&lt;/sections&gt;
896</pre>
897
898<p>
899Inside each chapter you can define <c>&lt;section&gt;</c>s (equivalent of
900<c>&lt;chapter&gt;</c> in a Guide) and <c>&lt;subsection&gt;</c>s (equivalent
901of <c>&lt;section&gt;</c> in a Guide).
902</p>
903
904<p>
905Each individual chapter should have its own date and version elements. The
906latest date of all chapters and master document will be displayed when a user
907browses through all parts of the book.
908</p>
909
910</body>
911</section>
912</chapter>
913
914<chapter>
915<title>Advanced Handbook Features</title>
916<section>
917<title>Global Values</title>
918<body>
919
920<p>
921Sometimes, the same values are repeated many times in several parts of a
922handbook. Global search and replace operations tend to forget some or introduce
923unwanted changes. Besides, it can be useful to define different values to be
924used in shared chapters depending on which handbook includes the chapter.
925</p>
926
927<p>
928Global values can be defined in a handbook master file and used in all included
929chapters.
930</p>
931
932<p>
933To define global values, add a <c>&lt;values&gt;</c> element to the handbook
934master file. Each value is then defined in a <c>&lt;key&gt;</c> element whose
935<c>id</c> attribute identifies the value, i.e. it is the name of your variable.
936The content of the <c>&lt;key&gt;</c> is its value.
937</p>
938
939<p>
940The following example defines three values in a handbook master file:
941</p>
942
943<pre caption="Define values in a handbook">
944&lt;?xml version='1.0' encoding='UTF-8'?&gt;
945&lt;!DOCTYPE book SYSTEM "/dtd/book.dtd"&gt;
946&lt;!-- &#36;Header&#36; --&gt;
947
948&lt;book&gt;
949&lt;title&gt;Example Book Usage&lt;/title&gt;
950
951<i>&lt;values>
952 &lt;key id="arch"&gt;x86&lt;/key&gt;
953 &lt;key id="min-cd-name"&gt;install-x86-minimal-2007.0-r1.iso&lt;/key&gt;
954 &lt;key id="min-cd-size"&gt;57&lt;/key&gt;
955&lt;/values&gt;</i>
956
957&lt;author...&gt;
958 ...
959&lt;/author&gt;
960
961...
962</pre>
963
964<p>
965The defined values can then be used throughout the handbook with the in-line
966<c>&lt;keyval id="key_id"/&gt;</c> element. Specify the name of the key in its
967<c>id</c> attribute, e.g. &lt;keyval id="min-cd-name"/&gt; would be replaced by
968"install-x86-minimal-2007.0-r1.iso" in our example.
969</p>
970
971<pre caption="Using defined values">
972&lt;p&gt;
973The Minimal Installation CD is called &lt;c&gt;<i>&lt;keyval id="min-cd-name"/&gt;</i>&lt;/c&gt;
974and takes up only <i>&lt;keyval id="min-cd-size"/&gt;</i> MB of diskspace. You can use this
975Installation CD to install Gentoo, but &lt;e&gt;only&lt;/e&gt; with a working Internet
976connection.
977&lt;/p&gt;
978</pre>
979
980<p>
981To make life easier on our translators, only use actual values, i.e. content
982that does not need to be translated. For instance, we defined the
983<c>min-cd-size</c> value to <c>57</c> and not <c>57 MB</c>.
984</p>
985
986</body>
987</section>
988<section>
989<title>Conditional Elements</title>
990<body>
991
992<p>
993Chapters that are shared by several handbooks such as our <uri
994link="/doc/en/handbook/">Installation Handbooks</uri> often have small
995differences depending on which handbook includes them. Instead of adding
996content that is irrelevant to some handbooks, authors can add a condition to
997the following elements: <c>&lt;section&gt;</c>, <c>&lt;subsection&gt;</c>,
998<c>&lt;body&gt;</c>, <c>&lt;note&gt;</c>, <c>&lt;impo&gt;</c>,
999<c>&lt;warn&gt;</c>, <c>&lt;pre&gt;</c>, <c>&lt;p&gt;</c>,
1000<c>&lt;table&gt;</c>, <c>&lt;tr&gt;</c>, <c>&lt;ul&gt;</c>, <c>&lt;ol&gt;</c>
1001and <c>&lt;li&gt;</c>.
1002</p>
1003
1004<p>
1005The condition must be an <uri
1006link="http://en.wikipedia.org/wiki/XPath">XPATH</uri> expression that will be
1007evaluated when transforming the XML. If it evaluates to <c>true</c>, the
1008element is processed, if not, it is ignored. The condition is specified in a
1009<c>test</c> attribute.
1010</p>
1011
1012<p>
1013The following example uses the <c>arch</c> value that is defined in each
1014handbook master file to condition some content:
1015</p>
1016
1017<pre caption="Using conditional elements">
1018&lt;body test="contains('AMD64 x86',func:keyval('arch'))"&gt;
1019
1020&lt;p&gt;
1021This paragraph applies to both x86 and AMD64 architectures.
1022&lt;/p&gt;
1023
1024&lt;p test="func:keyval('arch')='x86'"&gt;
1025This paragraph only applies to the x86 architecture.
1026&lt;/p&gt;
1027
1028&lt;p test="func:keyval('arch')='AMD64'"&gt;
1029This paragraph only applies to the AMD64 architecture.
1030&lt;/p&gt;
1031
1032&lt;p test="func:keyval('arch')='PPC'"&gt;
1033This paragraph will never be seen!
1034The whole body is skipped because of the first condition.
1035&lt;/p&gt;
1036
1037&lt;/body&gt;
1038
1039&lt;body test="contains('AMD64 PPC64',func:keyval('arch'))"&gt;
1040
1041&lt;p&gt;
1042This paragraph applies to the AMD64, PPC64 <comment>and PPC</comment> architectures because
1043the 'AMD64 PPC64' string does contain 'PPC'.
1044&lt;/p&gt;
1045
1046&lt;note test="func:keyval('arch')='AMD64' or func:keyval('arch')='PPC64'"&gt;
1047This note only applies to the AMD64 and PPC64 architectures.
1048&lt;/note&gt;
1049
1050&lt;/body&gt;
1051</pre>
1052
1053</body>
1054</section>
1055</chapter>
1056
1057<chapter id="codingstyle">
1058<title>Coding Style</title>
1059<section>
1060<title>Introduction</title>
1061<body>
1062
1063<p>
1064Since all Gentoo Documentation is a joint effort and several people will
1065most likely change existing documentation, a coding style is needed.
1066A coding style contains two sections. The first one is regarding
1067internal coding - how the XML-tags are placed. The second one is
1068regarding the content - how not to confuse the reader.
1069</p>
1070
1071<p>
1072Both sections are described next.
1073</p>
1074
1075</body>
1076</section>
1077<section>
1078<title>Internal Coding Style</title>
1079<body>
1080
1081<p>
1082<b>Newlines</b> must be placed immediately after <e>every</e>
1083GuideXML-tag (both opening as closing), except for:
1084<c>&lt;version&gt;</c>, <c>&lt;date&gt;</c>, <c>&lt;title&gt;</c>,
1085<c>&lt;th&gt;</c>, <c>&lt;ti&gt;</c>,
1086<c>&lt;li&gt;</c>, <c>&lt;i&gt;</c>, <c>&lt;e&gt;</c>,
1087<c>&lt;uri&gt;</c>, <c>&lt;path&gt;</c>, <c>&lt;b&gt;</c>, <c>&lt;c&gt;</c>,
1088<c>&lt;comment&gt;</c>, <c>&lt;mail&gt;</c>.
1089</p>
1090
1091<p>
1092<b>Blank lines</b> must be placed immediately after <e>every</e>
1093<c>&lt;body&gt;</c> (opening tag only) and before <e>every</e>
1094<c>&lt;chapter&gt;</c>, <c>&lt;p&gt;</c>, <c>&lt;table&gt;</c>,
1095<c>&lt;author&gt;</c> (set), <c>&lt;pre&gt;</c>, <c>&lt;ul&gt;</c>,
1096<c>&lt;ol&gt;</c>, <c>&lt;warn&gt;</c>, <c>&lt;note&gt;</c> and
1097<c>&lt;impo&gt;</c> (opening tags only).
1098</p>
1099
1100<p>
1101<b>Word-wrapping</b> must be applied at 80 characters except inside
1102<c>&lt;pre&gt;</c>. You may only deviate from this rule when there is no other
1103choice (for instance when a URL exceeds the maximum amount of characters). The
1104editor must then wrap whenever the first whitespace occurs. You should try to
1105keep the <e>rendered</e> content of <c>&lt;pre&gt;</c> elements within 80
1106columns to help console users.
1107</p>
1108
1109<p>
1110<b>Indentation</b> may not be used, except with the XML-constructs of which the
1111parent XML-tags are <c>&lt;tr&gt;</c> (from <c>&lt;table&gt;</c>),
1112<c>&lt;ul&gt;</c>, <c>&lt;ol&gt;</c>, <c>&lt;dl&gt;</c>, and
1113<c>&lt;author&gt;</c>. If indentation is used, it <e>must</e> be two spaces for
1114each indentation. That means <e>no tabs</e> and <e>not</e> more spaces.
1115Besides, tabs are not allowed in GuideXML documents.
1116</p>
1117
1118<p>
1119In case word-wrapping happens in <c>&lt;ti&gt;</c>, <c>&lt;th&gt;</c>,
1120<c>&lt;li&gt;</c> or <c>&lt;dd&gt;</c> constructs, indentation must be used for
1121the content.
1122</p>
1123
1124<p>
1125An example for indentation is:
1126</p>
1127
1128<pre caption="Indentation Example">
1129&lt;table&gt;
1130&lt;tr&gt;
1131 &lt;th&gt;Foo&lt;/th&gt;
1132 &lt;th&gt;Bar&lt;/th&gt;
1133&lt;/tr&gt;
1134&lt;tr&gt;
1135 &lt;ti&gt;This is an example for indentation&lt;/ti&gt;
1136 &lt;ti&gt;
1137 In case text cannot be shown within an 80-character wide line, you
1138 must use indentation if the parent tag allows it
1139 &lt;/ti&gt;
1140&lt;/tr&gt;
1141&lt;/table&gt;
1142
1143&lt;ul&gt;
1144 &lt;li&gt;First option&lt;/li&gt;
1145 &lt;li&gt;Second option&lt;/li&gt;
1146&lt;/ul&gt;
1147</pre>
1148
1149<p>
1150<b>Attributes</b> may not have spaces in between the attribute, the "=" mark,
1151and the attribute value. As an example:
1152</p>
1153
1154<pre caption="Attributes">
1155<comment>Wrong :</comment> &lt;pre caption = "Attributes"&gt;
1156<comment>Correct:</comment> &lt;pre caption="Attributes"&gt;
1157</pre>
1158
1159</body>
1160</section>
1161<section>
1162<title>External Coding Style</title>
1163<body>
1164
1165<p>
1166Inside tables (<c>&lt;table&gt;</c>) and listings (<c>&lt;ul&gt;</c>,
1167<c>&lt;ol&gt;</c>) and <c>&lt;dl&gt;</c>, periods (".") should not be used
1168unless multiple sentences are used. In that case, every sentence should end
1169with a period (or other reading marks).
1170</p>
1171
1172<p>
1173Every sentence, including those inside tables and listings, should start
1174with a capital letter.
1175</p>
1176
1177<pre caption="Periods and capital letters">
1178&lt;ul&gt;
1179 &lt;li&gt;No period&lt;/li&gt;
1180 &lt;li&gt;With period. Multiple sentences, remember?&lt;/li&gt;
1181&lt;/ul&gt;
1182</pre>
1183
1184<p>
1185Code Listings should <e>always</e> have a <c>caption</c>.
1186</p>
1187
1188<p>
1189Try to use <c>&lt;uri&gt;</c> with the <c>link</c> attribute as much as
1190possible. In other words, the <uri link="http://forums.gentoo.org">Gentoo
1191Forums</uri> is preferred over <uri>http://forums.gentoo.org</uri>.
1192</p>
1193
1194<p>
1195When you comment something inside a <c>&lt;pre&gt;</c> construct, use
1196<c>&lt;comment&gt;</c> and parentheses or the comment marker for the language
1197that is being used (<c>#</c> for bash scripts and many other things, <c>//</c>
1198for C code, etc.) Also place the comment <e>before</e> the subject of the
1199comment.
1200</p>
1201
1202<pre caption="Comment example">
1203<comment>(Substitute "john" with your user name)</comment>
1204# <i>id john</i>
1205</pre>
1206
1207</body>
1208</section>
1209</chapter>
1210
354<chapter> 1211<chapter>
355<title>Resources</title> 1212<title>Resources</title>
356<section> 1213<section>
357 <title>Start writing</title> 1214<title>Start writing</title>
358 <body> 1215<body>
1216
1217<p>
359 <p>Guide has been specially designed to be "lean and mean" so that developers 1218GuideXML has been specially designed to be "lean and mean" so that developers
360 can spend more time writing documentation and less time learning the actual XML 1219can spend more time writing documentation and less time learning the actual XML
361 syntax. Hopefully, this will allow developers who aren't unusually "doc-savvy" 1220syntax. Hopefully, this will allow developers who aren't unusually "doc-savvy"
362 to start writing quality Gentoo Linux documentation. If you'd like to help (or have any questions about guide), please 1221to start writing quality Gentoo documentation. You might be interested in our
363 post a message to <mail link="gentoo-dev@gentoo.org">the gentoo-dev mailing list</mail> 1222<uri link="/proj/en/gdp/doc/doc-tipsntricks.xml">Documentation Development Tips
364 stating what you'd like to tackle. 1223&amp; Tricks</uri>. If you'd like to help (or have any questions about
365 Have fun!</p> 1224GuideXML), please post a message to the <uri
1225link="/main/en/lists.xml">gentoo-doc mailing list</uri> stating what you'd like
1226to tackle. Have fun!
1227</p>
1228
366 </body> 1229</body>
367</section> 1230</section>
368</chapter> 1231</chapter>
369</guide> 1232</guide>
370

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.70

  ViewVC Help
Powered by ViewVC 1.1.20