The guideXML 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
The
The
Next, there's a
Then, we come to the
Next, we come to the
This sums up 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 a comment into a 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 a comment into a 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
As you might have guessed,
The
To improve the readability of code samples, the following tags are allowed
inside
Sample colour-coded
# Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ DESCRIPTION ="Exuberant ctags generates tags files for quick source navigation" HOMEPAGE ="http://ctags.sourceforge.net" SRC_URI ="mirror://sourceforge/ctags/${P}.tar.gz" LICENSE ="GPL-2" SLOT ="0" KEYWORDS ="~mips ~sparc ~x86" IUSE ="" src_compile() {econf --with-posix-regexemake ||die "emake failed" }src_install() {make DESTDIR ="${D}" install ||die "install failed" dodoc FAQ NEWS READMEdohtml EXTENDING.html ctags.html }
We've taken a look at the
Shorter forms make it easier to use names and emails of Gentoo developers. Both
This is particularly useful when you want to name a developer whose name
contains "funny" characters that you can't type.
The
You should not use a
Please avoid the
Here's how to insert a figure into a document --
GuideXML supports a simplified table syntax similar to that of HTML. To start a
table, use a
Besides, both table headers (
Furthermore, table cells (
| This title spans 4 columns | |||
|---|---|---|---|
| This title spans 6 rows | |||
| Blocky 2x2 title | |||
To create ordered or unordered lists, simply use the XHTML-style
Definition lists (
The following list copied from
GuideXML 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 disclaimer="obsolete" redirect="/doc/en/handbook/handbook-x86.xml"> <title>Gentoo x86 Installation Guide</title> <author title="Author"> ...
FAQ documents need to start with a list of questions with links to their
answers. Creating such a list is both time-consuming and error-prone. The list
can be created automatically if you use a
A quick look at a
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 syntax doesn't differ much from GuideXML:
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE book SYSTEM "/dtd/book.dtd"> <!-- $Header$ --> <book> <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> <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> <abstract> This is a small explanation on chapter one. </abstract> <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.
Sometimes, the same values are repeated many times in several parts of a handbook. Global search and replace operations tend to forget some or introduce unwanted changes. Besides, it can be useful to define different values to be used in shared chapters depending on which handbook includes the chapter.
Global values can be defined in a handbook master file and used in all included chapters.
To define global values, add a
The following example defines three values in a handbook master file:
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE book SYSTEM "/dtd/book.dtd"> <!-- $Header$ --> <book> <title>Example Book Usage</title> <values> <key id="arch">x86</key> <key id="min-cd-name">install-x86-minimal-2007.0-r1.iso</key> <key id="min-cd-size">57</key> </values> <author...> ... </author> ...
The defined values can then be used throughout the handbook with the in-line
<p> The Minimal Installation CD is called <c><keyval id="min-cd-name"/></c> and takes up only <keyval id="min-cd-size"/> MB of diskspace. You can use this Installation CD to install Gentoo, but <e>only</e> with a working Internet connection. </p>
To make life easier on our translators, only use actual values, i.e. content
that does not need to be translated. For instance, we defined the
Chapters that are shared by several handbooks such as our
The condition must be an
The following example uses the
<body test="contains('AMD64 x86',func:keyval('arch'))">
<p>
This paragraph applies to both x86 and AMD64 architectures.
</p>
<p test="func:keyval('arch')='x86'">
This paragraph only applies to the x86 architecture.
</p>
<p test="func:keyval('arch')='AMD64'">
This paragraph only applies to the AMD64 architecture.
</p>
<p test="func:keyval('arch')='PPC'">
This paragraph will never be seen!
The whole body is skipped because of the first condition.
</p>
</body>
<body test="contains('AMD64 PPC64',func:keyval('arch'))">
<p>
This paragraph applies to the AMD64, PPC64 and PPC architectures because
the 'AMD64 PPC64' string does contain 'PPC'.
</p>
<note test="func:keyval('arch')='AMD64' or func:keyval('arch')='PPC64'">
This note only applies to the AMD64 and PPC64 architectures.
</note>
</body>
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
GuideXML 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