Wie funktioniert GTK-Doc?

GTK-Doc verwendet Funktionsdokumentationen, die sich in den Quelldateien innerhalb speziell formatierter Kommentarblöcke befinden, oder Dokumentation, die zu den von GTK-Doc verwendeten Vorlagendateien hinzugefügt wurde. Beachten Sie jedoch, dass GTK-Doc nur Funktionen dokumentieren wird, die in den Header-Dateien deklariert sind. Es erstellt keine Ausgaben für statische Funktionen.

GTK-Doc besteht aus einer Anzahl von Perl-Skripten, wovon jedes einen bestimmten Schritt in dem Prozess ausführt.

Dieser Vorgang umfasst fünf Hauptschritte:

  1. Schreiben der Dokumentation. Der Autor ergänzt die Quelldateien um die Dokumentation für jede Funktion, jedes Makro usw. In der Vergangenheit wurden diese Informationen in erstellte Vorlagendateien eingegeben. Dies wird nicht mehr empfohlen.

  2. Gathering information about the code. gtkdoc-scan scans the header files of the code looking for declarations of functions, macros, enums, structs, and unions. It creates the file <module>-decl-list.txt containing a list of the declarations, placing them into sections according to which header file they are in. On the first run this file is copied to <module>-sections.txt. The author can rearrange the sections, and the order of the declarations within them, to produce the final desired order. The second file it generates is <module>-decl.txt. This file contains the full declarations found by the scanner. If for some reason one would like some symbols to show up in the docs, where the full declaration cannot be found by the scanner or the declaration should appear differently, one can place entities similar to the ones in <module>-decl.txt into <module>-overrides.txt.

    gtkdoc-scangobj can also be used to dynamically query a library about any GObject subclasses it exports. It saves information about each object's position in the class hierarchy and about any GObject properties and signals it provides.

    gtkdoc-scanobj should not be used anymore. It was needed in the past when GObject was still GtkObject inside gtk+.

  3. Generating the "template" files. gtkdoc-mktmpl creates a number of files in the tmpl/ subdirectory, using the information gathered in the first step. (Note that this can be run repeatedly. It will try to ensure that no documentation is ever lost.)

    Seit GTK-Doc 1.9 sind diese Vorlagen nicht mehr notwendig. Wir ermutigen die Entwickler, die Dokumentation innerhalb des Codes zu halten. gtkdocize unterstützt nun die Option --flavour no-tmpl, wodurch ein Makefile gewählt wird, welches die Verwendung der Vorlagen komplett umgeht. Falls Sie niemals Dateien im Vorlagenordner manuell bearbeitet oder aus älteren GTK-Doc-Versionen importiert haben, sollten Sie den Ordner löschen, z.B. in der Versionsverwaltung.

  4. Generating the SGML/XML and HTML/PDF. gtkdoc-mkdb turns the template files into SGML or XML files in the sgml/ or xml/ subdirectory. If the source code contains documentation on functions, using the special comment blocks, it gets merged in here. If there are no tmpl files used it only reads docs from sources and introspection data. We recommend to use Docbook XML.

    gtkdoc-mkhtml konvertiert die SGML/XML-Dateien in HTML-Dateien im Unterordner html/. Ebenso konvertiert gtkdoc-mkpdf die SGML/XML-Dateien in ein PDF-Dokument namens <package>.pdf.

    Dateien in sgml/ oder xml/ und html/-Ordnern werden immer überschrieben. Niemand sollte diese direkt bearbeiten.

  5. Fixing up cross-references between documents. After installing the HTML files, gtkdoc-fixxref can be run to fix up any cross-references between separate documents. For example, the GTK+ documentation contains many cross-references to types documented in the GLib manual. When creating the source tarball for distribution, gtkdoc-rebase turns all external links into web-links. When installing distributed (pregenerated) docs the same application will try to turn links back to local links (where those docs are installed).