|Line 1:||Line 1:|
If you're worried about having to learn a lot of new tools and procedures in order to write documentation, you don't need to, because the information we've covered so far is everything you need to know to be able to contribute. Although we do have some tools we use and procedures we follow, it's not vital that everyone knows them in detail, especially when starting out.
For example, all KDE documentation is written in DocBook XML, but we're very happy to receive documentation written in plain text. There are people on the documentation team who are very familiar with DocBook, and can easily add the markup if the content is there.
Another example: if you are starting to document an application from scratch, you don't need to get the sources of the current documentation. But if you are starting from existing documentation, you don't need to know about how to get the sources, there are other means to do that.
Of course, if you want to learn about DocBook, you can. After a little practice, you will probably find that it's not as hard as it looks. And if you learn about dealing with a svn repository, you will be able to integrate yourself to the regular KDE development process (upload your changes, work together with other developers, etc.)
|If you are starting your document from scratch, you probably do not need to read this section, and may start working right now.|
You are welcome to use plain text to contribute to KDE documentation. It is a great way to start, and we strongly encourage it. If you will miss the power of the DocBook format as you improve your documentation skills, then you can learn it. In the mean time, someone will manually edit the plain text to add the DocBook markup and commit it to KDE svn or git repository, removing the burden of doing most of the more complex stuff covered in this very guide. We'll take a look at writing in DocBook and using svn or git later in this document, so if you're interested, read on, but if you want to use plain text, you can go directly to #Working with plain text sources.
Documentation for KDE, like the rest of the source code, is kept in a svn or git repository. svn and git provide a way for many developers to work on the same source code (or in our case, the same documentation), and has many useful features to help with this. For example, previous versions of every file are saved so that any mistakes can be quickly backed out, if they cannot be easily corrected.
The basic principle behind svn is simple: one server stores a definitive copy of the files making up a project. This is known as the repository. Each developer can download the files to make their own private copy, named working copy or sandbox. Using svn, the developers can upload their modifications to the main repository (a process called "committing") or update their own copy to reflect recent changes made by others.
There are two main ways edit the contents of a KDE document you want to improve: using plain text or DocBook.
The docs.kde.org website displays most of the KDE documentation in HTML format, updated weekly from the svn and git repositories. There are two versions available in the website: the stable version and the KDE development version. You will always use the latest version of the documentation, i.e. the KDE development version.
The docs.kde.org website presents a quick and easy method of retrieving the latest version of the KDE documentation. Clicking the name of the application you want to document in the list will open the documentation in your web browser. Simply copy the text from the website to your favorite text editor, edit it, and submit the results in plain text to the KDE Documentation mailing list. Please note that not all KDE applications are listed there. If you cannot find the documentation of the application you want to work with, then you can request it by sending a message to the KDE Documentation mailing list.
The latest DocBook sources are located inside the KDE repository. Now you need to find and retrieve them.
The software inside the KDE repository is divided into modules, which are used to organize the different software projects inside the repository. Modules are the top-level folders in the svn repository folder tree, and each one contains a group of related applications. These modules are sometimes released in binary form as packages. If you know the name of the package your application belongs to, you probably know the module name as well, as they are frequently the same. You need to know in which module your application is, to retrieve its DocBook sources. For instance, KMix is in the kdemultimedia module, Lokalize in the kdesdk module and so on. If you need any help in this process, don't hesitate to ask. Each module contains a folder named "doc", and inside it, you can find the DocBook sources.
To access the svn repository, you can use the kdesvn or browse the KDE WebSVN website (websvn.kde.org).
Retrieving your own working copy of the repository has many advantages. You will be able to use your working copy to create files containing the changes you made, to update your copy with changes made by other documenters, and if you get a KDE svn account, to upload your changes directly to the repository. But this is out of the scope of this section. Here we will show you simply how to retrieve the sources using svn the easiest way we can.
Retrieving documentation sources using WebSVN
We use Lokalize's documentation sources as example in the following procedures.
Retrieving documentation sources using svn
svnin the terminal screen). If not, install the svn package using the tools provided by your distribution.
mkdir path/to/working/folder cd path/to/working/folder svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/module/doc/application
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdesdk/doc/lokalize
Note that only applications which are part of a regular KDE release are under trunk/KDE/. Amarok docs, for instance, is in the multimedia module of extragear. Extragear contains mature applications which are not part of a KDE release. To get KMyMoney docs, type in the terminal:
svn checkout svn://anonsvn.kde.org/home/kde/trunk/extragear/office/doc/kmymoney
Kate is an extensible and powerful text editor which is part of the kdebase module. Kate can syntax highlight DocBook documents out of the box, and is generally a very powerful editor, but you can get even more XML specific functionality installing the XML plugin for Kate.
Installing the XML plugin for Kate
With the XML plugin for Kate installed, you will have autocompletion, autoclosing for DocBook tags and entities. Since KDE documentation uses entities widely, this is a very welcome feature. Additional XML tools will be available trough themenu (in special, trough the menu item, which will allow you to check your DocBook documents). The output of this action will appear in the button in the side bar located in the lower part of Kate's main window.
The venerable Emacs editor has a powerful SGML and XML editing mode called psgml. The price of this power is a steeper learning curve than the other editors, so if you haven't used Emacs before, you will probably want to try the other editors first. If, on the other hand, you're already familiar with Emacs, then psgml is your best choice.
Installation of psgml is beyond the scope of this document, but it should simply be a case of installing appropriate packages for your distribution. The relevant configuration for KDE-related documentation is simple. Just tell psgml where the KDE catalog files are located with the following line in your .emacs file:
(setq sgml-catalog-files (list "CATALOG" "KDEDIR/share/apps/ksgmltools2/customization/catalog"))
where you should replace KDEDIR with the path to your KDE installation. You might also want to use the following line to instruct Emacs to use psgml to open all .docbook files:
(setq auto-mode-alist (cons '("\\.docbook$" . sgml-mode) auto-mode-alist))
There are of course plenty of other settings in psgml mode which you can change to your taste: see the psgml
info documentation for more details.
Some basic keystrokes in psgml are:
One particularly useful psgml feature that isn't well documented is the sgml-parent-document variable. Setting this variable appropriately tells psgml that this file is part of a larger document. This enables the full range of psgml features for this file, such as context-sensitive element completion. To use this feature, place the following in a comment at the end of the child file (with the arguments adjusted appropriately):
Local Variables: sgml-parent-document:("index.docbook" "book" "chapter") End:
The first argument is the name of the parent file (which will almost always be index.docbook in KDE documentation). The second argument is the top-level (or "root") element of the whole document (i.e., in the parent file). The third argument is the top-level element in this file.
There are a couple of KDE-specific tools for manipulating DocBook files, namely meinproc4 and checkxml. checkxml (as the name suggests) is used to check that documents are valid, well-formed XML, and meinproc4 converts DocBook files to HTML. Here's some hints on using each of them:
checkXML is a simple command with only one argument: the file to check. However, the output can be a bit daunting, since one small mistake can cause a cascade of errors. The trick is to look at the first error, fix that error, save the file, and run checkXML again. Often, fixing that one error will get rid of all the other error messages. When running meinproc4, the same procedure applies. Most errors in DocBook sources fall into one of a few categories. Here are descriptions of some of the most common errors and their solutions:
index.docbook:880: parser error : Opening and ending tag mismatch: para line 879 and sect2 </sect2> ^
This is possibly the most common type of error. It's caused either by an element that hasn't been closed, or by tags that overlap. The error above was generated by the following markup:
<sect2> ... 878: running &meinproc;, the same procedure applies. 879: &checkxml; is a simple command with 880: </sect2> ...
para tag on line 879 has not been closed before the
sect2 on line 880, causing the error. The simple fix in this case is to add a
para before the closing
index.docbook:932: element qandaentry: validity error : Element qandaentry content does not follow the DTD, expecting (blockinfo? , revhistory? , question , answer*), got (answer) </para></answer></qandaentry> ^
This error is caused by an element in the document not matching the requirements of the DocBook DTD (Document Type Definition). The DTD specifies what each element must contain. This list is shown after expecting in the error message. This so-called "content model" is quite difficult to understand at first: refer to the Duck Book and the section "Understanding Content Models" for full information.
The text after got shows the content actually found in the document.
In the example above, we have a
qandaentry which is missing the required
question element. This was generated by the following input:
<qandaset> <qandaentry><answer>An answer </answer></qandaentry> </qandaset>
question element before the
answer fixes the problem.
An easy mistake to make is to forget to put a
para element around text in, for example, a
listitem or a
sectn. This will be shown as CDATA in the got section of the error.
The most common way to run meinproc4 is simply as
where docbook-file is usually index.docbook. This command creates HTML pages from the DocBook file. Note that these pages are only viewable in KDE-based browsers (like Konqueror). If you need to view the HTML output in another browser (for example, if you're placing it on line), use
meinproc4 --stylesheet stylesheet-name docbook-file
where stylesheet-name is the full path to one of the XSL stylesheets in $KDEDIR/share/apps/ksgmltools/customization. To produce output suitable for the web, you can use kde-web.xsl or kde-chunk-online.xsl. See the README file in that folder for more details.