The guide XML syntax is lightweight yet expressive, so that it is easy to learn yet also provides all the features we need for the creation of web documentation. The number of tags is kept to a minimum -- just those we need. This makes it easy to transform guide into other formats, such as DocBook XML/SGML or web-ready HTML.
The goal is to make it easy to
If you are planning on contributing documentation to Gentoo, or you want to
test GuideXML, please read our
You may want to look at the
Let's start learning the GuideXML syntax. We'll start with the the initial tags used in a GuideXML document:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> <!-- $Header$ --> <guide link="/doc/en/guide.xml" lang="en"> <title>Gentoo Documentation Guide</title> <author title="Author"> <mail link="yourname@gentoo.org">Your Name</mail> </author> <abstract> This guide shows you how to compose web documentation using our new lightweight Gentoo GuideXML syntax. This syntax is the official format for Gentoo web documentation, and this document itself was created using GuideXML. </abstract> <!-- The content of this document is licensed under the CC-BY-SA license --> <!-- See http://creativecommons.org/licenses/by-sa/2.5 --> <license/> <version>1.0</version> <date>2004-12-25</date>
On the first lines, we see the requisite tag that identifies this as an XML
document and specifies its DTD. The
Next, there's a
Then, we come to the
Next, we come to the
This rounds out the tags that should appear at the beginning of a guide
document. Besides the
Finally we have the
Once the initial tags have been specified, you're ready to start adding the
structural elements of the document. Guide documents are divided into
chapters, and each chapter can hold one or more sections. Every chapter and
section has a title. Here's an example chapter with a single section,
consisting of a paragraph. If you append this XML to the XML in the
<chapter> <title>This is my chapter</title> <section> <title>This is section one of my chapter</title> <body> <p> This is the actual text content of my section. </p> </body> </section> </chapter>
Above, I set the chapter title by adding a child
Now, it's time to learn how to mark up actual content. Here's the XML code for
an example
<p> This is a paragraph. <path>/etc/passwd</path> is a file. <uri>http://forums.gentoo.org</uri> is my favorite website. Type <c>ls</c> if you feel like it. I <e>really</e> want to go to sleep now. </p> <pre caption="Code Sample"> This is text output or code. # <i>this is user input</i> Make HTML/XML easier to read by using selective emphasis: <foo><i>bar</i></foo> <comment>(This is how to insert an inline note into the code block)</comment> </pre> <note> This is a note. </note> <warn> This is a warning. </warn> <impo> This is important. </impo>
Now, here's how the
This is a paragraph.
This is text output or code. # this is user input Make HTML/XML easier to read by using selective emphasis: <foo>bar</foo>(This is how to insert an inline note into the code block)
We introduced a lot of new tags in the previous section -- here's what you need
to know. The
<pre caption="Output of uptime"> # <i>uptime</i> 16:50:47 up 164 days, 2:06, 5 users, load average: 0.23, 0.20, 0.25 </pre>
Delegates from the original 13 states formed the Contented Congress. Thomas Jefferson, a Virgin, and Benjamin Franklin were two singers of the Declaration of Independence. Franklin discovered electricity by rubbing two cats backwards and declared, "A horse divided against itself cannot stand." Franklin died in 1790 and is still dead.
Epigraphs are sometimes used at the beginning of chapters to illustrate what is
to follow. It is simply a paragraph with a
<p by="Anonymous student"> Delegates from the original 13 states formed the... </p>
The
The
The
When you want to highlight some text as user input inside a
As you might have guessed,
The
We've taken a look at the
The
Here's how to insert a figure into a document --
Guide supports a simplified table syntax similar to that of HTML. To start a
table, use a
Besides, the table header tag (
| This title spans 4 columns | |||
|---|---|---|---|
| This title spans 3 rows | |||
| Blocky 2x2 title | |||
To create ordered or unordered lists, simply use the XHTML-style
Definition lists (
The following list copied from
Guide makes it really easy to reference other parts of the document using
hyperlinks. You can create a link pointing to
However, some guides change often and using such "counting" can lead to broken
links. In order to cope with this, you can define a name for a
<chapter id="foo"> <title>This is foo!</title> ... <p> More information can be found in the <uri link="#foo">foo chapter</uri> </p>
A
When marking a document as obsolete, you might want to add a link to a new
version. The
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> <!-- $Header$ --> <guide link="/doc/en/gentoo-x86-install.xml" disclaimer="obsolete" redirect="/doc/en/handbook/handbook-x86.xml"> <title>Gentoo x86 Installation Guide</title> <author title="Author"> ...
Since all Gentoo Documentation is a joint effort and several people will most likely change existing documentation, a coding style is needed. A coding style contains two sections. The first one is regarding internal coding - how the XML-tags are placed. The second one is regarding the content - how not to confuse the reader.
Both sections are described next.
Newlines must be placed immediately after
Blank lines must be placed immediately after
Word-wrapping must be applied at 80 characters except inside
Indentation may not be used, except with the XML-constructs of which the
parent XML-tags are
In case word-wrapping happens in
An example for indentation is:
<table>
<tr>
<th>Foo</th>
<th>Bar</th>
</tr>
<tr>
<ti>This is an example for indentation</ti>
<ti>
In case text cannot be shown within an 80-character wide line, you
must use indentation if the parent tag allows it
</ti>
</tr>
</table>
<ul>
<li>First option</li>
<li>Second option</li>
</ul>
Attributes may not have spaces in between the attribute, the "=" mark, and the attribute value. As an example:
Wrong : <pre caption = "Attributes">Correct: <pre caption="Attributes">
Inside tables (
Every sentence, including those inside tables and listings, should start with a capital letter.
<ul> <li>No period</li> <li>With period. Multiple sentences, remember?</li> </ul>
Code Listings should
Try to use
When you comment something inside a
(Substitute "john" with your user name) # id john
For high-volume documentation, such as the
The first change is the need for a "master" document. This document contains no real content, but links to the individual documentation modules. The syntaxis doesn't differ much from GuideXML:
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE book SYSTEM "/dtd/book.dtd"> <!-- $Header$ --> <book link="example.xml"> <title>Example Book Usage</title> <author...> ... </author> <abstract> ... </abstract> <!-- The content of this document is licensed under the CC-BY-SA license --> <!-- See http://creativecommons.org/licenses/by-sa/2.5 --> <license/> <version>...</version> <date>...</date>
So far no real differences (except for the
<part> <title>Part One</title> <abstract> ... </abstract>(Defining the several chapters) </part>
Each part is accompanied by a
Inside each part, you define the individual
<chapter> <title>Chapter One</title> <abstract> This is a small explanation on chapter one. </abstract> <include href="path/to/chapter-one.xml"/> </chapter>
The content of an individual chapter is structured as follows:
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE sections SYSTEM "/dtd/book.dtd"> <!-- $Header$ --> <!-- The content of this document is licensed under the CC-BY-SA license --> <!-- See http://creativecommons.org/licenses/by-sa/2.5 --> <sections> <version>...</version> <date>...</date>(Define the several <section> and <subsection>) </sections>
Inside each chapter you can define
Each individual chapter should have its own date and version elements. The latest date of all chapters and master document will be displayed when a user browses through all parts of the book.
Guide has been specially designed to be "lean and mean" so that developers can
spend more time writing documentation and less time learning the actual XML
syntax. Hopefully, this will allow developers who aren't unusually "doc-savvy"
to start writing quality Gentoo documentation. You might be interested
in our