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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.57 - (show annotations) (download) (as text)
Mon Jan 9 14:44:14 2006 UTC (8 years, 7 months ago) by neysx
Branch: MAIN
Changes since 1.56: +2 -2 lines
File MIME type: application/xml
Typo: added missing space

1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/xml-guide.xml,v 1.56 2005/12/31 17:17:13 neysx Exp $ -->
3 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
4
5 <guide link="/doc/en/xml-guide.xml">
6 <title>Gentoo XML Guide</title>
7
8 <author title="Author">
9 <mail link="drobbins@gentoo.org">Daniel Robbins</mail>
10 </author>
11 <author title="Author"><!-- zhen@gentoo.org -->
12 John P. Davis
13 </author>
14 <author title="Editor">
15 <mail link="peesh@gentoo.org">Jorge Paulo</mail>
16 </author>
17 <author title="Editor">
18 <mail link="swift@gentoo.org">Sven Vermeulen</mail>
19 </author>
20 <author title="Editor">
21 <mail link="neysx@gentoo.org">Xavier Neys</mail>
22 </author>
23
24 <abstract>
25 This guide shows you how to compose web documentation using the new lightweight
26 Gentoo GuideXML syntax. This syntax is the official format for Gentoo
27 documentation, and this document itself was created using GuideXML. This guide
28 assumes a basic working knowledge of XML and HTML.
29 </abstract>
30
31 <!-- The content of this document is licensed under the CC-BY-SA license -->
32 <!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
33 <license/>
34
35 <version>2.29</version>
36 <date>2005-10-13</date>
37
38 <chapter>
39 <title>Guide basics</title>
40 <section>
41 <title>Guide XML design goals</title>
42 <body>
43
44 <p>
45 The guide XML syntax is lightweight yet expressive, so that it is easy to
46 learn yet also provides all the features we need for the creation of web
47 documentation. The number of tags is kept to a minimum -- just those we need.
48 This makes it easy to transform guide into other formats, such as DocBook
49 XML/SGML or web-ready HTML.
50 </p>
51
52 <p>
53 The goal is to make it easy to <e>create</e> and <e>transform</e> guide XML
54 documents.
55 </p>
56
57 </body>
58 </section>
59 <section>
60 <title>Further Resources</title>
61 <body>
62
63 <p>
64 If you are planning on contributing documentation to Gentoo, or you want to
65 test GuideXML, please read our <uri
66 link="/proj/en/gdp/doc/doc-tipsntricks.xml">Doc Tips 'n' Tricks</uri> guide
67 which contains tips and tricks for documentation development.
68 </p>
69
70 <p>
71 You may want to look at the <uri link="?passthru=1">XML source</uri> of this
72 document while you read it.
73 </p>
74
75 </body>
76 </section>
77 </chapter>
78
79 <chapter>
80 <title>Guide XML</title>
81 <section>
82 <title>Basic structure</title>
83 <body>
84
85 <p>
86 Let's start learning the GuideXML syntax. We'll start with the the initial
87 tags used in a GuideXML document:
88 </p>
89
90 <pre caption="The initial part of a guide XML document">
91 &lt;?xml version="1.0" encoding="UTF-8"?&gt;
92 &lt;!DOCTYPE guide SYSTEM "/dtd/guide.dtd"&gt;
93 &lt;!-- &#36;Header&#36; --&gt;
94
95 &lt;guide link="<i>/doc/en/guide.xml</i>" lang="<i>en</i>"&gt;
96 &lt;title&gt;<i>Gentoo Documentation Guide</i>&lt;/title&gt;
97
98 &lt;author title="<i>Author</i>"&gt;
99 &lt;mail link="<i>yourname@gentoo.org</i>"&gt;<i>Your Name</i>&lt;/mail&gt;
100 &lt;/author&gt;
101
102 &lt;abstract&gt;
103 <i>This guide shows you how to compose web documentation using
104 our new lightweight Gentoo GuideXML syntax. This syntax is the official
105 format for Gentoo web documentation, and this document itself was created
106 using GuideXML.</i>
107 &lt;/abstract&gt;
108
109 &lt;!-- The content of this document is licensed under the CC-BY-SA license --&gt;
110 &lt;!-- See http://creativecommons.org/licenses/by-sa/2.5 --&gt;
111 &lt;license/&gt;
112
113 &lt;version&gt;<i>1.0</i>&lt;/version&gt;
114 &lt;date&gt;<i>2004-12-25</i>&lt;/date&gt;
115 </pre>
116
117 <p>
118 On the first lines, we see the requisite tag that identifies this as an XML
119 document and specifies its DTD. The <c>&lt;!-- &#36;Header&#36; --&gt;</c> line
120 will be automatically modified by the CVS server and helps to track revisions.
121 Next, there's a <c>&lt;guide&gt;</c> tag -- the entire guide document is
122 enclosed within a <c>&lt;guide&gt; &lt;/guide&gt;</c> pair. The <c>link</c>
123 attribute is compulsory and should preferably contain the absolute path to the
124 document relatively to the document root even though the file name alone will
125 work. It is mainly used to generate a link to a printer-friendly version of
126 your document. If you use a wrong value, the link to the printable version will
127 either not work or point to a wrong document. Translated documents <e>must</e>
128 specify the full path because it is also used to check whether a more recent
129 original document exists. The <c>lang</c> attribute should be used to specify
130 the language code of your document. It is used to format the date and insert
131 strings like "<e>Note</e>", "<e>Content</e>", etc. in the specified language.
132 The default is English.
133 </p>
134
135 <p>
136 Next, there's a <c>&lt;title&gt;</c> tag, used to set the title for the entire
137 guide document.
138 </p>
139
140 <p>
141 Then, we come to the <c>&lt;author&gt;</c> tags, which contain information
142 about the various authors of the document. Each <c>&lt;author&gt;</c> tag
143 allows for an optional <c>title</c> element, used to specify the author's
144 relationship to the document (author, co-author, editor, etc.). In this
145 particular example, the authors' names are enclosed in another tag -- a
146 <c>&lt;mail&gt;</c> tag, used to specify an email address for this particular
147 person. The <c>&lt;mail&gt;</c> tag is optional and can be omitted, and no
148 more than one <c>&lt;author&gt;</c> element is required per guide document.
149 </p>
150
151 <p>
152 Next, we come to the <c>&lt;abstract&gt;</c>, <c>&lt;version&gt;</c> and
153 <c>&lt;date&gt;</c> tags, used to specify a summary of the document, the
154 current version number, and the current version date (in YYYY-MM-DD format)
155 respectively. Dates that are invalid or not in the YYYY-MM-DD format will
156 appear verbatim in the rendered document.
157 </p>
158
159 <p>
160 This rounds out the tags that should appear at the beginning of a guide
161 document. Besides the <c>&lt;title&gt;</c> and <c>&lt;mail&gt;</c> tags, these
162 tags shouldn't appear anywhere else except immediately inside the
163 <c>&lt;guide&gt;</c> tag, and for consistency it's recommended (but not
164 required) that these tags appear before the content of the document.
165 </p>
166
167 <p>
168 Finally we have the <c>&lt;license/&gt;</c> tag, used to publish the document
169 under the <uri link="http://creativecommons.org/licenses/by-sa/2.5/">Creative
170 Commons - Attribution / Share Alike</uri> license as required by the <uri
171 link="/proj/en/gdp/doc/doc-policy.xml">Documentation Policy</uri>.
172 </p>
173
174 </body>
175 </section>
176 <section>
177 <title>Chapters and sections</title>
178 <body>
179
180 <p>
181 Once the initial tags have been specified, you're ready to start adding the
182 structural elements of the document. Guide documents are divided into
183 chapters, and each chapter can hold one or more sections. Every chapter and
184 section has a title. Here's an example chapter with a single section,
185 consisting of a paragraph. If you append this XML to the XML in the <uri
186 link="#doc_chap2_pre1">previous excerpt</uri> and append a
187 <c>&lt;/guide&gt;</c> to the end of the file, you'll have a valid (if minimal)
188 guide document:
189 </p>
190
191 <pre caption="Minimal guide example">
192 &lt;chapter&gt;
193 &lt;title&gt;<i>This is my chapter</i>&lt;/title&gt;
194 &lt;section&gt;
195 &lt;title&gt;<i>This is section one of my chapter</i>&lt;/title&gt;
196 &lt;body&gt;
197
198 &lt;p&gt;
199 <i>This is the actual text content of my section.</i>
200 &lt;/p&gt;
201
202 &lt;/body&gt;
203 &lt;/section&gt;
204 &lt;/chapter&gt;
205 </pre>
206
207 <p>
208 Above, I set the chapter title by adding a child <c>&lt;title&gt;</c>
209 element to the <c>&lt;chapter&gt;</c> element. Then, I created a section by
210 adding a <c>&lt;section&gt;</c> element. If you look inside the
211 <c>&lt;section&gt;</c> element, you'll see that it has two child elements -- a
212 <c>&lt;title&gt;</c> and a <c>&lt;body&gt;</c>. While the <c>&lt;title&gt;</c>
213 is nothing new, the <c>&lt;body&gt;</c> is -- it contains the actual text
214 content of this particular section. We'll look at the tags that are allowed
215 inside a <c>&lt;body&gt;</c> element in a bit.
216 </p>
217
218 <note>
219 A <c>&lt;guide&gt;</c> element can contain multiple <c>&lt;chapter&gt;</c>
220 elements, and a <c>&lt;chapter&gt;</c> can contain multiple
221 <c>&lt;section&gt;</c> elements. However, a <c>&lt;section&gt;</c>
222 element can only contain one <c>&lt;body&gt;</c> element.
223 </note>
224
225 </body>
226 </section>
227 <section>
228 <title>An example &lt;body&gt;</title>
229 <body>
230
231 <p>
232 Now, it's time to learn how to mark up actual content. Here's the XML code for
233 an example <c>&lt;body&gt;</c> element:
234 </p>
235
236 <pre caption="Example of a body element">
237 &lt;p&gt;
238 This is a paragraph. &lt;path&gt;/etc/passwd&lt;/path&gt; is a file.
239 &lt;uri&gt;http://forums.gentoo.org&lt;/uri&gt; is my favorite website.
240 Type &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.
241 &lt;/p&gt;
242
243 &lt;pre caption="Code Sample"&gt;
244 This is text output or code.
245 # &lt;i&gt;this is user input&lt;/i&gt;
246
247 Make HTML/XML easier to read by using selective emphasis:
248 &lt;foo&gt;&lt;i&gt;bar&lt;/i&gt;&lt;/foo&gt;
249
250 &lt;comment&gt;(This is how to insert an inline note into the code block)&lt;/comment&gt;
251 &lt;/pre&gt;
252
253 &lt;note&gt;
254 This is a note.
255 &lt;/note&gt;
256
257 &lt;warn&gt;
258 This is a warning.
259 &lt;/warn&gt;
260
261 &lt;impo&gt;
262 This is important.
263 &lt;/impo&gt;
264 </pre>
265
266 <p>
267 Now, here's how the <c>&lt;body&gt;</c> element above is rendered:
268 </p>
269
270 <p>
271 This is a paragraph. <path>/etc/passwd</path> is a file.
272 <uri>http://forums.gentoo.org</uri> is my favorite web site.
273 Type <c>ls</c> if you feel like it. I <e>really</e> want to go to sleep now.
274 </p>
275
276 <pre caption="Code Sample">
277 This is text output or code.
278 # <i>this is user input</i>
279
280 Make HTML/XML easier to read by using selective emphasis:
281 &lt;foo&gt;<i>bar</i>&lt;/foo&gt;
282
283 <comment>(This is how to insert an inline note into the code block)</comment>
284 </pre>
285
286 <note>
287 This is a note.
288 </note>
289
290 <warn>
291 This is a warning.
292 </warn>
293
294 <impo>
295 This is important.
296 </impo>
297
298 </body>
299 </section>
300 <section>
301 <title>The &lt;body&gt; tags</title>
302 <body>
303
304 <p>
305 We introduced a lot of new tags in the previous section -- here's what you need
306 to know. The <c>&lt;p&gt;</c> (paragraph), <c>&lt;pre&gt;</c> (code block),
307 <c>&lt;note&gt;</c>, <c>&lt;warn&gt;</c> (warning) and <c>&lt;impo&gt;</c>
308 (important) tags all can contain one or more lines of text. Besides the
309 <c>&lt;table&gt;</c>, <c>&lt;ul&gt;</c>, <c>&lt;ol&gt;</c> and
310 <c>&lt;dl&gt;</c> elements (which we'll cover in just a bit), these are the
311 only tags that should appear immediately inside a <c>&lt;body&gt;</c> element.
312 Another thing -- these tags <e>should not</e> be stacked -- in other words,
313 don't put a <c>&lt;note&gt;</c> element inside a <c>&lt;p&gt;</c> element. As
314 you might guess, the <c>&lt;pre&gt;</c> element preserves its whitespace
315 exactly, making it well-suited for code excerpts. You must name the
316 <c>&lt;pre&gt;</c> tag with a <c>caption</c> attribute:
317 </p>
318
319 <pre caption="Named &lt;pre&gt;">
320 &lt;pre caption="Output of uptime"&gt;
321 # &lt;i&gt;uptime&lt;/i&gt;
322 16:50:47 up 164 days, 2:06, 5 users, load average: 0.23, 0.20, 0.25
323 &lt;/pre&gt;
324 </pre>
325
326 </body>
327 </section>
328 <section>
329 <title>Epigraphs</title>
330 <body>
331
332 <p by="Anonymous student">
333 Delegates from the original 13 states formed the Contented Congress. Thomas
334 Jefferson, a Virgin, and Benjamin Franklin were two singers of the Declaration
335 of Independence. Franklin discovered electricity by rubbing two cats backwards
336 and declared, "A horse divided against itself cannot stand." Franklin died in
337 1790 and is still dead.
338 </p>
339
340 <p>
341 Epigraphs are sometimes used at the beginning of chapters to illustrate what is
342 to follow. It is simply a paragraph with a <c>by</c> attribute that contains
343 the signature.
344 </p>
345
346 <pre caption="Short epigraph">
347 &lt;p by="Anonymous student"&gt;
348 Delegates from the original 13 states formed the...
349 &lt;/p&gt;
350 </pre>
351
352 </body>
353 </section>
354 <section>
355 <title>
356 &lt;path&gt;, &lt;c&gt;, &lt;i&gt;, &lt;b&gt;, &lt;e&gt;, &lt;sub&gt; and &lt;sup&gt;
357 </title>
358 <body>
359
360 <p>
361 The <c>&lt;path&gt;</c>, <c>&lt;c&gt;</c>, <c>&lt;b&gt;</c>, <c>&lt;e&gt;</c>,
362 <c>&lt;sub&gt;</c> and <c>&lt;sup&gt;</c> elements can be used inside any child
363 <c>&lt;body&gt;</c> tag, except for <c>&lt;pre&gt;</c>. The <c>&lt;i&gt;</c>
364 element can only be used inside <c>&lt;pre&gt;</c>.
365 </p>
366
367 <p>
368 The <c>&lt;path&gt;</c> element is used to mark text that refers to an
369 <e>on-disk file</e> -- either an <e>absolute or relative path</e>, or a
370 <e>simple filename</e>. This element is generally rendered with a mono spaced
371 font to offset it from the standard paragraph type.
372 </p>
373
374 <p>
375 The <c>&lt;c&gt;</c> element is used to mark up a <e>command</e> or <e>user
376 input</e>. Think of <c>&lt;c&gt;</c> as a way to alert the reader to something
377 that they can type in that will perform some kind of action. For example, all
378 the XML tags displayed in this document are enclosed in a <c>&lt;c&gt;</c>
379 element because they represent something that the user could type in that is
380 not a path. By using <c>&lt;c&gt;</c> elements, you'll help your readers
381 quickly identify commands that they need to type in. Also, because
382 <c>&lt;c&gt;</c> elements are already offset from regular text, <e>it is rarely
383 necessary to surround user input with double-quotes</e>. For example, don't
384 refer to a "<c>&lt;c&gt;</c>" element like I did in this sentence. Avoiding
385 the use of unnecessary double-quotes makes a document more readable -- and
386 adorable!
387 </p>
388
389 <p>
390 When you want to highlight some text as user input inside a <c>&lt;pre&gt;</c>,
391 use <c>&lt;i&gt;</c> instead.
392 </p>
393
394 <p>
395 As you might have guessed, <c>&lt;b&gt;</c> is used to <b>boldface</b> some
396 text.
397 </p>
398
399 <p>
400 <c>&lt;e&gt;</c> is used to apply emphasis to a word or phrase; for example:
401 I <e>really</e> should use semicolons more often. As you can see, this text is
402 offset from the regular paragraph type for emphasis. This helps to give your
403 prose more <e>punch</e>!
404 </p>
405
406 <p>
407 The <c>&lt;sub&gt;</c> and <c>&lt;sup&gt;</c> elements are used to specify
408 <sub>subscript</sub> and <sup>superscript</sup>.
409 </p>
410
411 </body>
412 </section>
413 <section>
414 <title>&lt;mail&gt; and &lt;uri&gt;</title>
415 <body>
416
417 <p>
418 We've taken a look at the <c>&lt;mail&gt;</c> tag earlier; it's used to link
419 some text with a particular email address, and takes the form <c>&lt;mail
420 link="foo@bar.com"&gt;Mr. Foo Bar&lt;/mail&gt;</c>. If you want to display the
421 email address, you can use <c>&lt;mail&gt;foo@bar.com&lt;/mail&gt;</c>, this
422 would be displayed as <mail>foo@bar.com</mail>.
423 </p>
424
425 <p>
426 The <c>&lt;uri&gt;</c> tag is used to point to files/locations on the Internet.
427 It has two forms -- the first can be used when you want to have the actual URI
428 displayed in the body text, such as this link to
429 <uri>http://forums.gentoo.org</uri>. To create this link, I typed
430 <c>&lt;uri&gt;http://forums.gentoo.org&lt;/uri&gt;</c>. The alternate form is
431 when you want to associate a URI with some other text -- for example, <uri
432 link="http://forums.gentoo.org">the Gentoo Forums</uri>. To create <e>this</e>
433 link, I typed <c>&lt;uri link="http://forums.gentoo.org"&gt;the Gentoo
434 Forums&lt;/uri&gt;</c>. You don't need to write <c>http://www.gentoo.org/</c>
435 to link to other parts of the Gentoo web site. For instance, a link to the <uri
436 link="/doc/en/">documentation main index</uri> should be simply <c>&lt;uri
437 link="/doc/en/index.xml"&gt;documentation main index&lt;/uri&gt;</c>. You can
438 even omit <c>index.xml</c> when you link to a directory index, e.g. <c>&lt;uri
439 link="/doc/en/"&gt;documentation main index&lt;/uri&gt;</c>.
440 </p>
441
442 </body>
443 </section>
444 <section>
445 <title>Figures</title>
446 <body>
447
448 <p>
449 Here's how to insert a figure into a document -- <c>&lt;figure
450 link="mygfx.png" short="my picture" caption="my favorite picture of all
451 time"/&gt;</c>. The <c>link</c> attribute points to the actual graphic image,
452 the <c>short</c> attribute specifies a short description (currently used for
453 the image's HTML <c>alt</c> attribute), and a caption. Not too difficult
454 :) We also support the standard HTML-style &lt;img src="foo.gif"/&gt; tag
455 for adding images without captions, borders, etc.
456 </p>
457
458 </body>
459 </section>
460 <section>
461 <title>Tables</title>
462 <body>
463
464 <p>
465 Guide supports a simplified table syntax similar to that of HTML. To start a
466 table, use a <c>&lt;table&gt;</c> tag. Start a row with a <c>&lt;tr&gt;</c>
467 tag. However, for inserting actual table data, we <e>don't</e> support the
468 HTML &lt;td&gt; tag; instead, use the <c>&lt;th&gt;</c> if you are inserting a
469 header, and <c>&lt;ti&gt;</c> if you are inserting a normal informational
470 block. You can use a <c>&lt;th&gt;</c> anywhere you can use a <c>&lt;ti&gt;</c>
471 -- there's no requirement that <c>&lt;th&gt;</c> elements appear only in the
472 first row.
473 </p>
474
475 <p>
476 Besides, the table header tag (<c>&lt;th&gt;</c>) accepts the <c>colspan</c>
477 and <c>rowspan</c> attributes to span titles across rows, columns or both as
478 shown below:
479 </p>
480
481 <table>
482 <tr>
483 <th colspan="4">This title spans 4 columns</th>
484 </tr>
485 <tr>
486 <th rowspan="3">This title spans 3 rows</th>
487 <ti>Item A1</ti>
488 <ti>Item A2</ti>
489 <ti>Item A3</ti>
490 </tr>
491 <tr>
492 <ti>Item B1</ti>
493 <th colspan="2" rowspan="2">Blocky 2x2 title</th>
494 </tr>
495 <tr>
496 <ti>Item C1</ti>
497 </tr>
498 </table>
499
500 </body>
501 </section>
502 <section>
503 <title>Lists</title>
504 <body>
505
506 <p>
507 To create ordered or unordered lists, simply use the XHTML-style
508 <c>&lt;ol&gt;</c>, <c>&lt;ul&gt;</c> and <c>&lt;li&gt;</c> tags. Lists may only
509 appear inside the <c>&lt;body&gt;</c> and <c>&lt;li&gt;</c> tags which means
510 that you can have lists inside lists. Don't forget that you are writing XML and
511 that you must close all tags including list items unlike in HTML.
512 </p>
513
514 <p>
515 Definition lists (<c>&lt;dl&gt;</c>) are also supported. Please note that
516 neither the definition term tag (<c>&lt;dt&gt;</c>) nor the definition data tag
517 (<c>&lt;dd&gt;</c>) accept any other block level tag such as paragraphs or
518 admonitions. A definition list comprises:
519 </p>
520
521 <dl>
522 <dt><c>&lt;dl&gt;</c></dt>
523 <dd>A <b>D</b>efinition <b>L</b>ist Tag containing</dd>
524 <dt><c>&lt;dt&gt;</c></dt>
525 <dd>Pairs of <b>D</b>efinition <b>T</b>erm Tags</dd>
526 <dt><c>&lt;dd&gt;</c></dt>
527 <dd>and <b>D</b>efinition <b>D</b>ata Tags</dd>
528 </dl>
529
530 <p>
531 The following list copied from <uri
532 link="http://www.w3.org/TR/REC-html40/struct/lists.html">w3.org</uri> shows
533 that a definition list can contain ordered and unordered lists. It may not
534 contain another definition list though.
535 </p>
536
537 <dl>
538 <dt><b>The ingredients:</b></dt>
539 <dd>
540 <ul>
541 <li>100 g. flour</li>
542 <li>10 g. sugar</li>
543 <li>1 cup water</li>
544 <li>2 eggs</li>
545 <li>salt, pepper</li>
546 </ul>
547 </dd>
548 <dt><b>The procedure:</b></dt>
549 <dd>
550 <ol>
551 <li>Mix dry ingredients thoroughly</li>
552 <li>Pour in wet ingredients</li>
553 <li>Mix for 10 minutes</li>
554 <li>Bake for one hour at 300 degrees</li>
555 </ol>
556 </dd>
557 <dt><b>Notes:</b></dt>
558 <dd>The recipe may be improved by adding raisins</dd>
559 </dl>
560
561 </body>
562 </section>
563 <section>
564 <title>Intra-document references</title>
565 <body>
566
567 <p>
568 Guide makes it really easy to reference other parts of the document using
569 hyperlinks. You can create a link pointing to <uri link="#doc_chap1">Chapter
570 One</uri> by typing <c>&lt;uri link="#doc_chap1"&gt;Chapter
571 One&lt;/uri&gt;</c>. To point to <uri link="#doc_chap1_sect2">section two of
572 Chapter One</uri>, type <c>&lt;uri link="#doc_chap1_sect2"&gt;section two of
573 Chapter One&lt;/uri&gt;</c>. To refer to figure 3 in chapter 1, type <c>&lt;uri
574 link="#doc_chap1_fig3"&gt;figure 1.3&lt;/uri&gt;</c>. Or, to refer to <uri
575 link="#doc_chap2_pre2">code listing 2 in chapter 2</uri>, type <c>&lt;uri
576 link="#doc_chap2_pre2"&gt;code listing 2.2&lt;/uri&gt;</c>.
577 </p>
578
579 <p>
580 However, some guides change often and using such "counting" can lead to broken
581 links. In order to cope with this, you can define a name for a
582 <c>&lt;chapter&gt;</c>, <c>&lt;section&gt;</c> or a <c>&lt;tr&gt;</c> by using
583 the <c>id</c> attribute, and then point to that attribute, like this:
584 </p>
585
586 <pre caption="Using the id attribute">
587 &lt;chapter id="foo"&gt;
588 &lt;title&gt;This is foo!&lt;/title&gt;
589 ...
590 &lt;p&gt;
591 More information can be found in the &lt;uri link="#foo"&gt;foo chapter&lt;/uri&gt;
592 &lt;/p&gt;
593 </pre>
594
595 </body>
596 </section>
597 <section>
598 <title>Disclaimers and obsolete documents</title>
599 <body>
600
601 <p>
602 A <c>disclaimer</c> attribute can be applied to guides and handbooks to display
603 a predefined disclaimer at the top of the document. The available disclaimers
604 are:
605 </p>
606
607 <ul>
608 <li>
609 <b>articles</b> is used for <uri link="/doc/en/articles/">republished
610 articles</uri>
611 </li>
612 <li>
613 <b>draft</b> is used to indicate a document is still being worked on and
614 should not be considered official
615 </li>
616 <li>
617 <b>oldbook</b> is used on old handbooks to indicate they are not maintained
618 anymore
619 </li>
620 <li><b>obsolete</b> is used to mark a document as obsolete.</li>
621 </ul>
622
623 <p>
624 When marking a document as obsolete, you might want to add a link to a new
625 version. The <c>redirect</c> attribute does just that. The user might be
626 automatically redirected to the new page but you should not rely on that
627 behaviour.
628 </p>
629
630 <pre caption="Disclaimer sample">
631 &lt;?xml version="1.0" encoding="UTF-8"?&gt;
632 &lt;!DOCTYPE guide SYSTEM "/dtd/guide.dtd"&gt;
633 &lt;!-- &#36;Header&#36; --&gt;
634
635 &lt;guide link="/doc/en/gentoo-x86-install.xml" disclaimer="obsolete" redirect="/doc/en/handbook/handbook-x86.xml"&gt;
636 &lt;title>Gentoo x86 Installation Guide&lt;/title&gt;
637
638 &lt;author title="Author"&gt;
639 ...
640 </pre>
641
642 </body>
643 </section>
644 </chapter>
645
646 <chapter>
647 <title>Coding Style</title>
648 <section>
649 <title>Introduction</title>
650 <body>
651
652 <p>
653 Since all Gentoo Documentation is a joint effort and several people will
654 most likely change existing documentation, a coding style is needed.
655 A coding style contains two sections. The first one is regarding
656 internal coding - how the XML-tags are placed. The second one is
657 regarding the content - how not to confuse the reader.
658 </p>
659
660 <p>
661 Both sections are described next.
662 </p>
663
664 </body>
665 </section>
666 <section>
667 <title>Internal Coding Style</title>
668 <body>
669
670 <p>
671 <b>Newlines</b> must be placed immediately after <e>every</e>
672 GuideXML-tag (both opening as closing), except for:
673 <c>&lt;version&gt;</c>, <c>&lt;date&gt;</c>, <c>&lt;title&gt;</c>,
674 <c>&lt;th&gt;</c>, <c>&lt;ti&gt;</c>,
675 <c>&lt;li&gt;</c>, <c>&lt;i&gt;</c>, <c>&lt;e&gt;</c>,
676 <c>&lt;uri&gt;</c>, <c>&lt;path&gt;</c>, <c>&lt;b&gt;</c>, <c>&lt;c&gt;</c>,
677 <c>&lt;comment&gt;</c>, <c>&lt;mail&gt;</c>.
678 </p>
679
680 <p>
681 <b>Blank lines</b> must be placed immediately after <e>every</e>
682 <c>&lt;body&gt;</c> (opening tag only) and before <e>every</e>
683 <c>&lt;chapter&gt;</c>, <c>&lt;p&gt;</c>, <c>&lt;table&gt;</c>,
684 <c>&lt;author&gt;</c> (set), <c>&lt;pre&gt;</c>, <c>&lt;ul&gt;</c>,
685 <c>&lt;ol&gt;</c>, <c>&lt;warn&gt;</c>, <c>&lt;note&gt;</c> and
686 <c>&lt;impo&gt;</c> (opening tags only).
687 </p>
688
689 <p>
690 <b>Word-wrapping</b> must be applied at 80 characters except inside
691 <c>&lt;pre&gt;</c>. You may only deviate from this rule when there is no other
692 choice (for instance when a URL exceeds the maximum amount of characters). The
693 editor must then wrap whenever the first whitespace occurs. You should try to
694 keep the <e>rendered</e> content of <c>&lt;pre&gt;</c> elements within 80
695 columns to help console users.
696 </p>
697
698 <p>
699 <b>Indentation</b> may not be used, except with the XML-constructs of which the
700 parent XML-tags are <c>&lt;tr&gt;</c> (from <c>&lt;table&gt;</c>),
701 <c>&lt;ul&gt;</c>, <c>&lt;ol&gt;</c>, <c>&lt;dl&gt;</c>, and
702 <c>&lt;author&gt;</c>. If indentation is used, it <e>must</e> be two spaces for
703 each indentation. That means <e>no tabs</e> and <e>not</e> more spaces.
704 Besides, tabs are not allowed in GuideXML documents.
705 </p>
706
707 <p>
708 In case word-wrapping happens in <c>&lt;ti&gt;</c>, <c>&lt;th&gt;</c>,
709 <c>&lt;li&gt;</c> or <c>&lt;dd&gt;</c> constructs, indentation must be used for
710 the content.
711 </p>
712
713 <p>
714 An example for indentation is:
715 </p>
716
717 <pre caption="Indentation Example">
718 &lt;table&gt;
719 &lt;tr&gt;
720 &lt;th&gt;Foo&lt;/th&gt;
721 &lt;th&gt;Bar&lt;/th&gt;
722 &lt;/tr&gt;
723 &lt;tr&gt;
724 &lt;ti&gt;This is an example for indentation&lt;/ti&gt;
725 &lt;ti&gt;
726 In case text cannot be shown within an 80-character wide line, you
727 must use indentation if the parent tag allows it
728 &lt;/ti&gt;
729 &lt;/tr&gt;
730 &lt;/table&gt;
731
732 &lt;ul&gt;
733 &lt;li&gt;First option&lt;/li&gt;
734 &lt;li&gt;Second option&lt;/li&gt;
735 &lt;/ul&gt;
736 </pre>
737
738 <p>
739 <b>Attributes</b> may not have spaces in between the attribute, the "=" mark,
740 and the attribute value. As an example:
741 </p>
742
743 <pre caption="Attributes">
744 <comment>Wrong :</comment> &lt;pre caption = "Attributes"&gt;
745 <comment>Correct:</comment> &lt;pre caption="Attributes"&gt;
746 </pre>
747
748 </body>
749 </section>
750 <section>
751 <title>External Coding Style</title>
752 <body>
753
754 <p>
755 Inside tables (<c>&lt;table&gt;</c>) and listings (<c>&lt;ul&gt;</c>,
756 <c>&lt;ol&gt;</c>) and <c>&lt;dl&gt;</c>, periods (".") should not be used
757 unless multiple sentences are used. In that case, every sentence should end
758 with a period (or other reading marks).
759 </p>
760
761 <p>
762 Every sentence, including those inside tables and listings, should start
763 with a capital letter.
764 </p>
765
766 <pre caption="Periods and capital letters">
767 &lt;ul&gt;
768 &lt;li&gt;No period&lt;/li&gt;
769 &lt;li&gt;With period. Multiple sentences, remember?&lt;/li&gt;
770 &lt;/ul&gt;
771 </pre>
772
773 <p>
774 Code Listings should <e>always</e> have a <c>caption</c>.
775 </p>
776
777 <p>
778 Try to use <c>&lt;uri&gt;</c> with the <c>link</c> attribute as much as
779 possible. In other words, the <uri link="http://forums.gentoo.org">Gentoo
780 Forums</uri> is preferred over <uri>http://forums.gentoo.org</uri>.
781 </p>
782
783 <p>
784 When you comment something inside a <c>&lt;pre&gt;</c> construct, use
785 <c>&lt;comment&gt;</c> and parentheses or the comment marker for the language
786 that is being used (<c>#</c> for bash scripts and many other things, <c>//</c>
787 for C code, etc.) Also place the comment <e>before</e> the subject of the
788 comment.
789 </p>
790
791 <pre caption="Comment example">
792 <comment>(Substitute "john" with your user name)</comment>
793 # <i>id john</i>
794 </pre>
795
796 </body>
797 </section>
798 </chapter>
799
800 <chapter>
801 <title>Handbook Format</title>
802 <section>
803 <title>Guide vs Book</title>
804 <body>
805
806 <p>
807 For high-volume documentation, such as the <uri
808 link="/doc/en/handbook/handbook-x86.xml?part=1">Installation Instructions</uri>, a
809 broader format was needed. We designed a GuideXML-compatible enhancement that
810 allows us to write modular and multi-page documentation.
811 </p>
812
813 </body>
814 </section>
815 <section>
816 <title>Main File</title>
817 <body>
818
819 <p>
820 The first change is the need for a "master" document. This document contains no
821 real content, but links to the individual documentation modules. The syntaxis
822 doesn't differ much from GuideXML:
823 </p>
824
825 <pre caption="Example book usage">
826 &lt;?xml version='1.0' encoding='UTF-8'?&gt;
827 &lt;!DOCTYPE book SYSTEM "/dtd/book.dtd"&gt;
828 &lt;!-- &#36;Header&#36; --&gt;
829
830 &lt;<i>book</i> link="example.xml"&gt;
831 &lt;title&gt;Example Book Usage&lt;/title&gt;
832
833 &lt;author...&gt;
834 ...
835 &lt;/author&gt;
836
837 &lt;abstract&gt;
838 ...
839 &lt;/abstract&gt;
840
841 &lt;!-- The content of this document is licensed under the CC-BY-SA license --&gt;
842 &lt;!-- See http://creativecommons.org/licenses/by-sa/2.5 --&gt;
843 &lt;license/&gt;
844
845 &lt;version&gt;...&lt;/version&gt;
846 &lt;date&gt;...&lt;/date&gt;
847 </pre>
848
849 <p>
850 So far no real differences (except for the <c>&lt;book&gt;</c> instead of
851 <c>&lt;guide&gt;</c> tag). Instead of starting with the individual
852 <c>&lt;chapter&gt;</c>s, you define a <c>&lt;part&gt;</c>, which is the
853 equivalent of a separate part in a book:
854 </p>
855
856 <pre caption="Defining a part">
857 &lt;part&gt;
858 &lt;title&gt;Part One&lt;/title&gt;
859 &lt;abstract&gt;
860 ...
861 &lt;/abstract&gt;
862
863 <comment>(Defining the several chapters)</comment>
864 &lt;/part&gt;
865 </pre>
866
867 <p>
868 Each part is accompanied by a <c>&lt;title&gt;</c> and an
869 <c>&lt;abstract&gt;</c> which gives a small introduction to the part.
870 </p>
871
872 <p>
873 Inside each part, you define the individual <c>&lt;chapter&gt;</c>s. Each
874 chapter <e>must</e> be a separate document. As a result it is no surprise that
875 a special tag (<c>&lt;include&gt;</c>) is added to allow including the separate
876 document.
877 </p>
878
879 <pre caption="Defining a chapter">
880 &lt;chapter&gt;
881 &lt;title&gt;Chapter One&lt;/title&gt;
882 &lt;abstract&gt;
883 This is a small explanation on chapter one.
884 &lt;/abstract&gt;
885
886 &lt;include href="path/to/chapter-one.xml"/&gt;
887
888 &lt;/chapter&gt;
889 </pre>
890
891 </body>
892 </section>
893 <section>
894 <title>Designing the Individual Chapters</title>
895 <body>
896
897 <p>
898 The content of an individual chapter is structured as follows:
899 </p>
900
901 <pre caption="Chapter Syntax">
902 &lt;?xml version='1.0' encoding='UTF-8'?&gt;
903 &lt;!DOCTYPE sections SYSTEM "/dtd/book.dtd"&gt;
904 &lt;!-- &#36;Header&#36; --&gt;
905
906 &lt;!-- The content of this document is licensed under the CC-BY-SA license --&gt;
907 &lt;!-- See http://creativecommons.org/licenses/by-sa/2.5 --&gt;
908
909 &lt;sections&gt;
910
911 &lt;version&gt;...&lt;/version&gt;
912 &lt;date&gt;...&lt;/date&gt;
913
914 <comment>(Define the several &lt;section&gt; and &lt;subsection&gt;)</comment>
915
916 &lt;/sections&gt;
917 </pre>
918
919 <p>
920 Inside each chapter you can define <c>&lt;section&gt;</c>s (equivalent of
921 <c>&lt;chapter&gt;</c> in a Guide) and <c>&lt;subsection&gt;</c>s (equivalent
922 of <c>&lt;section&gt;</c> in a Guide).
923 </p>
924
925 <p>
926 Each individual chapter should have its own date and version elements. The
927 latest date of all chapters and master document will be displayed when a user
928 browses through all parts of the book.
929 </p>
930
931 </body>
932 </section>
933 </chapter>
934
935 <chapter>
936 <title>Resources</title>
937 <section>
938 <title>Start writing</title>
939 <body>
940
941 <p>
942 Guide has been specially designed to be "lean and mean" so that developers can
943 spend more time writing documentation and less time learning the actual XML
944 syntax. Hopefully, this will allow developers who aren't unusually "doc-savvy"
945 to start writing quality Gentoo documentation. You might be interested
946 in our <uri link="/proj/en/gdp/doc/doc-tipsntricks.xml">Documentation
947 Development Tips &amp; Tricks</uri>. If you'd like to help (or have any
948 questions about guide), please post a message to the <mail
949 link="gentoo-doc@gentoo.org">gentoo-doc mailing list</mail> stating what you'd
950 like to tackle. Have fun!
951 </p>
952
953 </body>
954 </section>
955 </chapter>
956 </guide>

  ViewVC Help
Powered by ViewVC 1.1.20