6.2. Developer Documentation

6.2.1. Work Setup

You don't need much on you host system to generate or modify GPE documentation. If you intend to help documenting a library which has documentation stuff in CVS you only need your favourite text editor and CVS.

To add documentation support or build the documentation from source you will need make, gtk-doc and the packages these depend on (perl, jade and some docbook stuff). Running Debian just run 'apt-get install gtk-doc-tools'. It is a useful to have latest gtk-doc-tools package installed to test the documentation build and verify the results.

If you intend to work on this manual you need some additional tools to convert the SGML sources into HTML or some other target format. Using docbook2html from the Debian docbook-utils package is a good choice.

6.2.2. Documentation in GPE Sources

Deverloper documentation consists of several tasks - the most important one is a proper documentation of all library interfaces to make libraries easy to use for other developers. Another very important task is to add comments in your source code to make it easier to understand. In particular sections which are not obvious or subject of frequent changes should be documented with comments. How to do this should be pretty obvious and so this section only deals with the documentation of library interfaces.

There are two ways to place documentation in the source:

These files are located in the doc/tmpl/ subdirectory of each library after adding documentation support. You should prefer to keep the major part of the documentation in the source code to make it easier to keep it up to date. Use the external files for generic which is not related to a particular entitiy in the code (e.g. a function). The Gnome project has a very nice description on how to use gtk-doc here: http://developer.gnome.org/arch/doc/authors.html

Adding documentation support to library source is really easy:

To add gtk-doc support to a piece of software without autotools do as follows: First add a section to the main Makefile adding the "doc" target:


        doc:
	make -C doc PACKAGE=$(PACKAGE)

        .PHONY: doc
        
       
Create the 'doc' subdirectory and add a Makefile to it. This file may look similar to this:

        all: doc
        doc:
		gtkdoc-scan --module=$(PACKAGE) --source-dir=../gpe --output-dir=.
		gtkdoc-mktmpl --module=$(PACKAGE)
		gtkdoc-mkdb --module=$(PACKAGE) --source-dir=../gpe --tmpl-dir=tmpl --output-format=xml --main-sgml-file=$(PACKAGE)-docs.sgml --sgml-mode
		gtkdoc-mkhtml $(PACKAGE) $(PACKAGE)-docs.sgml
        clean:
		rm -f *.html sgml/* xml/* *.stamp

        
       
This should be sufficient in most cases. Only the location of the header sources that contain the declarations to document need to be set correctly.

Now you are ready to run 'make doc' the first time. Note: With this simple Makefile running make in the doc subdirectory itself will fail. Run 'make doc' in the toplevel directory only. It is a good idea to start documenting with the toplevel sgml file gtk-doc creates in 'doc'. If you are unsure what to add there look at the file libgpewidget-docs.sgml in libgpewidget source.