1 <?xml version="1.0" standalone="no"?>
2 <?xml-stylesheet type="text/xml" href="params.xsl"?>
3 <!-- vim: set ai tw=80 ts=3 sw=3: -->
4 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "
5 http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
7 <!ENTITY FDL SYSTEM "fdl-appendix.xml">
8 <!ENTITY FDLlink "<link linkend='fdl'>included</link>">
9 ]><!-- =============Document Header ============================= -->
12 <title>GTK-Doc Manual</title>
13 <edition>1.12</edition>
14 <abstract role="description"><para>User manual for developers with instructions of GTK-Doc usage.</para></abstract>
17 <firstname>Chris</firstname>
18 <surname>Lyttle</surname>
21 <email>chris@wilddev.net</email>
26 <firstname>Dan</firstname>
27 <surname>Mueth</surname>
30 <email>d-mueth@uchicago.edu</email>
35 <firstname>Stefan</firstname>
36 <surname>Kost</surname>
39 <email>ensonic@users.sf.net</email>
44 <publisher role="maintainer">
45 <publishername>GTK-Doc project</publishername>
46 <address><email>gtk-doc-list@gnome.org</email></address>
49 <year>2000, 2005, 2007-2009</year>
50 <holder>Dan Mueth and Chris Lyttle and Stefan Kost</holder>
53 <!-- translators: uncomment this:
56 <holder>ME-THE-TRANSLATOR (Latin translation)</holder>
62 Permission is granted to copy, distribute and/or modify this
63 document under the terms of the <citetitle>GNU Free Documentation
64 License</citetitle>, Version 1.1 or any later version published
65 by the Free Software Foundation with no Invariant Sections, no
66 Front-Cover Texts, and no Back-Cover Texts. A copy of the license
70 Many of the names used by companies to distinguish their products and
71 services are claimed as trademarks. Where those names appear in any
72 GNOME documentation, and those trademarks are made aware to the members
73 of the GNOME Documentation Project, the names have been printed in caps
80 <revnumber>1.14</revnumber>
81 <date>19 December 2009</date>
82 <authorinitials>sk</authorinitials>
83 <revremark>development version</revremark>
86 <revnumber>1.13</revnumber>
87 <date>18 December 2009</date>
88 <authorinitials>sk</authorinitials>
89 <revremark>broken tarball update</revremark>
92 <revnumber>1.12</revnumber>
93 <date>18 December 2009</date>
94 <authorinitials>sk</authorinitials>
95 <revremark>new tool features and bugfixes</revremark>
98 <revnumber>1.11</revnumber>
99 <date>16 Novemebr 2008</date>
100 <authorinitials>mal</authorinitials>
101 <revremark>GNOME doc-utils migration</revremark>
107 <!-- ======== Chapter 1: Introduction ======================== -->
109 <chapter id="introduction">
110 <title>Introduction</title>
113 This chapter introduces GTK-Doc and gives an overview of what it is and
117 <sect1 id="whatisgtkdoc">
118 <title>What is GTK-Doc?</title>
121 GTK-Doc is used to document C code. It is typically used to document the public
122 API of libraries, such as the GTK+ and GNOME libraries. But it can also be
123 used to document application code.
127 <sect1 id="howdoesgtkdocwork">
128 <title>How Does GTK-Doc Work?</title>
131 GTK-Doc works by using documentation of functions placed inside the source files in
132 specially-formatted comment blocks, or documentation added to the template files
133 which GTK-Doc uses (though note that GTK-Doc will only document functions that
134 are declared in header files; it won't produce output for static functions).
138 GTK-Doc consists of a number of perl scripts, each performing a different step
143 There are 5 main steps in the process:
150 <guilabel>Writing the documentation.</guilabel>
152 The author fills in the source files with the documentation for each
153 function, macro, union etc. (In the past information was entered in
154 generated template files, which is not recommended anymore).
160 <guilabel>Gathering information about the code.</guilabel>
162 <application>gtkdoc-scan</application> scans the header files of the
163 code looking for declarations of functions, macros, enums, structs, and unions.
164 It creates the file <filename><module>-decl-list.txt</filename> containg a list of the
165 declarations, placing them into sections according to which header file they
166 are in. On the first run this file is copied to <filename><module>-sections.txt</filename>
167 The author can rearrange the sections, and the order of the
168 declarations within them, to produce the final desired order.
169 The second file it generates is <filename><module>-decl.txt</filename>.
170 This file contains the full declarations found by the scanner. If for
171 some reason one would like some sybols to show up in the docs, where
172 the full declaration cannot be found by th scanner or the declaration
173 should appear differently, one can place enties similar to the ones in
174 <filename><module>-decl.txt</filename> into <filename><module>-overrides.txt</filename>.
176 <application>gtkdoc-scanobj</application> can also be used to dynamically query a library about
177 any GtkObject subclasses it exports. It saves information about each
178 object's position in the class hierarchy and about any GTK Args and Signals it
185 <guilabel>Generating the "template" files.</guilabel>
187 <application>gtkdoc-mktmpl</application> creates a number of files in
188 the <filename class='directory'>tmpl/</filename> subdirectory, using the
189 information gathered in the first step. (Note that this can be run
190 repeatedly. It will try to ensure that no documentation is ever lost.)
194 Since gtk-doc 1.9 the templates can be avoided. We encourage people to keep
195 documentation in the code. <application>gtkdocize</application> supports now
196 a <option>--flavour no-tmpl</option> option that chooses a makefile that
197 skips tmpl usage totally.
198 If you have never changed file in tmpl by hand, please remove the dir once.
205 <guilabel>Generating the SGML/XML and HTML/PDF.</guilabel>
207 <application>gtkdoc-mkdb</application> turns the template files into
208 SGML or XML files in the <filename class='directory'>sgml/</filename>
209 or <filename class='directory'>xml/</filename> subdirectory.
210 If the source code contains documentation on functions, using the
211 special comment blocks, it gets merged in here. If there are no tmpl files used
212 it only reads takes docs from sources and introspection data.
215 <application>gtkdoc-mkhtml</application> turns the SGML/XML files into HTML
216 files in the <filename class='directory'>html/</filename> subdirectory.
217 Likewise <application>gtkdoc-mkpdf</application> turns the SGML/XML files into a PDF
218 docuemnt called <filename><package>.pdf</filename>.
221 Files in <filename class='directory'>sgml/</filename> or
222 <filename class='directory'>xml/</filename> and <filename class='directory'>html/</filename>
223 directories are always overwritten. One should never edit them directly.
229 <guilabel>Fixing up cross-references between documents.</guilabel>
231 After installing the HTML files, <application>gtkdoc-fixxref</application> can be run to fix up any
232 cross-references between separate documents. For example, the GTK+
233 documentation contains many cross-references to types documented in the GLib manual.
235 When creating the source tarball for distribution, <application>gtkdoc-rebase</application>
236 turns all external links into web-links. When installing distributed (pregenerated) docs
237 the same application will try to turn links back to local links
238 (where those docs are installed).
245 <sect1 id="gettinggtkdoc">
246 <title>Getting GTK-Doc</title>
248 <sect2 id="requirements">
249 <title>Requirements</title>
251 <guilabel>Perl v5</guilabel> - the main scripts are in Perl.
254 <guilabel>DocBook DTD v3.0</guilabel> - This is the DocBook SGML DTD.
255 <ulink url="http://www.ora.com/davenport" type="http">http://www.ora.com/davenport</ulink>
258 <guilabel>Jade v1.1</guilabel> - This is a DSSSL processor for converting SGML to various formats.
259 <ulink url="http://www.jclark.com/jade" type="http">http://www.jclark.com/jade</ulink>
262 <guilabel>Modular DocBook Stylesheets</guilabel>
263 This is the DSSSL code to convert DocBook to HTML (and a few other
264 formats). It's used together with jade.
265 I've customized the DSSSL code slightly, in gtk-doc.dsl, to colour
266 the program code listings/declarations, and to support global
267 cross-reference indices in the generated HTML.
268 <ulink url="http://nwalsh.com/docbook/dsssl" type="http">http://nwalsh.com/docbook/dsssl</ulink>
271 <guilabel>docbook-to-man</guilabel> - if you want to create man pages from the DocBook.
272 I've customized the 'translation spec' slightly, to capitalise section
273 headings and add the 'GTK Library' title at the top of the pages and the
274 revision date at the bottom.
275 There is a link to this on <ulink url="http://www.ora.com/davenport" type="http">http://www.ora.com/davenport</ulink>
276 NOTE: This does not work yet.
280 <sect2 id="installation">
281 <title>Installation</title>
283 There is no standard place where the DocBook Modular Stylesheets are installed.
286 gtk-doc's configure script searches these 3 directories automatically:
289 <filename> /usr/lib/sgml/stylesheets/nwalsh-modular </filename> (used by RedHat)
292 <filename> /usr/lib/dsssl/stylesheets/docbook </filename> (used by Debian)
295 <filename> /usr/share/sgml/docbkdsl </filename> (used by SuSE)
298 If you have the stylesheets installed somewhere else, you need to configure
299 gtk-doc using the option:
300 <command> --with-dsssl-dir=<PATH_TO_TOPLEVEL_STYLESHEETS_DIR> </command>
306 <!-- not realy worth a section
307 <sect1 id="whentousegtkdoc">
308 <title>When to Use GTK-Doc</title>
311 (What things GTK-Doc should, and shouldn't, be used for.)
319 <sect1 id="aboutgtkdoc">
320 <title>About GTK-Doc</title>
327 (History, authors, web pages, license, future plans,
328 comparison with other similar systems.)
333 <sect1 id="aboutthismanual">
334 <title>About this Manual</title>
341 (who it is meant for, where you can get it, license)
348 <chapter id="settingup">
349 <title>Setting up your project</title>
352 The next sections describe what steps to perform to integrate GTK-Doc into
353 your project. Theses section assume we work on a project called 'meep'.
354 This project contains a library called 'libmeep' and
355 an end-user app called 'meeper'.
358 <sect1 id="settingup_docfiles">
359 <title>Setting up a skeleton documentation</title>
362 Under your top-level project directory create folders called docs/reference
363 (this way you can also have docs/help for end-user documentation).
364 It is recommended to create another subdirectory with the name of the doc-package.
365 For packages with just one library this step is not necessary.
369 This can then look as show below:
370 <example><title>Example directory structure</title>
387 <sect1 id="settingup_autoconf">
388 <title>Integration with autoconf</title>
391 Very easy! Just add one line to your <filename>configure.ac</filename> script.
395 <example><title>Integration with autoconf</title>
406 Besides checking for the required Gtk-Doc version, this adds two configure
410 <listitem><para>--with-html-dir=PATH : path to installed docs</para></listitem>
411 <listitem><para>--enable-gtk-doc : use gtk-doc to build documentation</para></listitem>
416 Gtk-Doc is disabled by default! Remember to pass the option
417 <option>'--enable-gtk-doc'</option> to the next
418 <filename>configure</filename> run. Otherwise pregenerated documentation is installed
419 (which makes sense for users but not for developers).
424 Furthermore it is recommended that you have the following line inside
425 you <filename>configure.ac</filename> script.
426 This allows <filename>gtkdocize</filename> to automatically copy the
427 macro definition for <function>GTK_DOC_CHECK</function> to your project.
431 <example><title>Preparation for gtkdocize</title>
434 AC_CONFIG_MACRO_DIR(m4)
441 <sect1 id="settingup_automake">
442 <title>Integration with automake</title>
445 First copy the <filename>Makefile.am</filename> from the examples subdirectory of the gtkdoc-sources
446 to your project's API documentation directory (
447 <filename class='directory'>./docs/reference/<package></filename>).
448 If you have multiple doc-packages repeat this for each one.
452 The next step is to edit the setting inside the <filename>Makefile.am</filename>.
453 All the settings have a comment above that describes their purpose.
454 Most settings are extra flags passed to the respective tools. Every tool
455 has a variable of the form <option><TOOLNAME>_OPTIONS</option>.
456 All the tools support <option>--help</option> to list the supported
460 <!-- FIXME: explain options ? -->
463 You may also want to enable gtk-doc for the distcheckmake target. Just
464 add then one-liner show in the next example to you top-level
465 <filename>Makefile.am</filename>:
469 <example><title>Enable gtk-doc during make distcheck</title>
472 DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc
480 <sect1 id="settingup_autogen">
481 <title>Integration with autogen</title>
484 Most projects will have an <filename>autogen.sh</filename> script to
485 setup the build infrastructure after a checkout from version control
486 system (such as cvs). Gtk-Doc comes with a tool called
487 <filename>gtkdocize</filename> which can be used in such a script.
488 It should be run before autoheader, automake or autoconf.
492 <example><title>Running gtkdocize from autogen.sh</title>
502 When running <filename>gtkdocize</filename> it copies
503 <filename>gtk-doc.make</filename> to you project root (or any directory
504 specified by the --docdir option). If also check you configure script
505 for the <function>GTK_DOC_CHECK</function> invocation.
509 Historically gtk-doc was gerating template files where developers entered the docs.
510 this turned out to be not so good. Since a few version gtk-doc could also get all
511 the information from source comments.
512 Since gtk-doc 1.9 the templates can be avoided. We encourage people to keep
513 documentation in the code. <application>gtkdocize</application> supports now
514 a <option>--flavour no-tmpl</option> option that chooses a makefile that skips
516 If you have never changed file in tmpl by hand, please remove the dir once.
520 <sect1 id="settingup_firstrun">
521 <title>Running the doc build</title>
524 After the previous steps it's time to run the build. First we need to
525 rerun <filename>autogen.sh</filename>. If this script runs configure for
526 you, then give it the <option>--enable-gtk-doc</option> option.
527 Otherwise manually run <filename>configure</filename> with this option
531 The first make run generates several additional files in the doc-dirs.
532 The important ones are:
533 <filename><package>.types</filename>,
534 <filename><package>-docs.sgml</filename>,
535 <filename><package>-sections.txt</filename>.
538 <example><title>Running the doc build</title>
541 ./autogen.sh --enable-gtk-doc
548 Now you can point your browser to <filename>docs/reference/<package>/index.html</filename>.
549 Yes, it's a bit disappointing still. But hang-on, during the next chapter we
550 tell you how to fill the pages with life.
554 <sect1 id="settingup_vcs">
555 <title>Integration with version control systems</title>
558 As a rule of the thumb, it's those files you edit, that should go under
559 version control. For typical projects it's these files:
560 <filename><package>.types</filename>
561 <filename><package>-docs.sgml</filename>
562 <filename><package>-sections.txt</filename>
563 <filename>Makefile.am</filename>
569 <chapter id="documenting">
570 <title>Documenting the code</title>
573 GTK-Doc uses source code comment with a special syntax for code documentation.
574 Further it retrieves information about your project structure from other
575 sources. During the next section you find all information about the syntax
580 <title>Documentation placement</title>
582 In the past most documentation had to be filled into files residing
583 inside the <filename>tmpl</filename> directory. This has the
584 disadvantages that the information is often not updated and also that
585 the file tend to cause conflicts with version control systems.
588 The avoid the aforementioned problems we suggest putting the
589 documentation inside the sources. This manual will only describe this
590 way of documenting code.
596 <sect1 id="documenting_syntax">
597 <title>Documentation comments</title>
600 A multiline comment that starts with an additional '*' marks a
601 documentation block that will be processed by the Gtk-Doc tools.
602 <example><title>Gtk-Doc comment block</title>
615 The 'identifier' is one line with the name of the item the comment is
616 related to. The syntax differs a little depending on the item.
617 (TODO add table showing identifiers)
621 The 'documentation' block is also different for each symbol type. Symbol
622 types that get parameters such as functions or macros have the parameter
623 description first followed by a blank line (just a '*').
624 Afterwards follows the detailed description. All lines (outside program-
625 listings and CDATA sections) just containing a ' *' (blank-asterisk) are
626 converted to paragraph breaks.
627 If you don't want a paragraph break, change that into ' * '
628 (blank-asterisk-blank-blank).
632 One advantage of hyper-text over plain-text is the ability to have links
633 in the document. Writing the correct markup for a link can be tedious
634 though. Gtk-Doc comes to help by providing several useful abbreviations.
638 Use function() to refer to functions or macros which take arguments.
643 Use @param to refer to parameters. Also use this when referring to
644 parameters of other functions, related to the one being described.
649 Use %constant to refer to a constant, e.g. %G_TRAVERSE_LEAFS.
654 Use #symbol to refer to other types of symbol, e.g. structs and
655 enums and macros which don't take arguments.
660 Use #Object::signal to refer to a GObject signal
665 Use #Object:property to refer to a GObject property
670 Use #Struct.field to refer to a field inside a structure.
678 If you need to use the special characters '<', '>', '()', '@',
679 '%', or '#' in your documentation without gtk-doc changing them you
680 can use the XML entities "&lt;", "&gt;", "&lpar;",
681 "&rpar;", "&commat;", "&percnt;" and "&num;"
682 respectively or escape them with a backslash '\'.
687 DocBook can do more that just links. One can also have lists, tables and
688 examples. To enable the usage of SGML/XML tags inside doc-comments you
689 need to have <option>--sgml-mode</option> in the variable
690 <symbol>MKDB_OPTIONS</symbol> inside <filename>Makefile.am</filename>.
695 As already mentioned earlier Gtk-Doc is for documenting public API. Thus
696 one cannot write documentation for static symbols. Nevertheless it is good
697 to comment those symbols too. This helps other to understand you code.
698 Therefore we recommend to comment these using normal comments (without the
699 2nd '*' in the first line).
700 If later the function needs to be made public, all one needs to do is to
701 add another '*' in the comment block and insert the symbol name at the
702 right place inside the sections file.
707 <sect1 id="documenting_sections">
708 <title>Documenting sections</title>
711 Each section of the documentation contains information about one class
712 or module. To introduce the component one can write a section block.
713 The short description is also used inside the table of contents.
714 All the @fields are optional.
718 <example><title>Section comment block</title>
723 * @short_description: the application class
724 * @title: Meep application
726 * @see_also: #MeepSettings
728 * @include: meep/app.h
730 * The application class handles ...
739 <term>SECTION:<name></term>
742 The name links the section documentation to the respective part in
743 the <filename><package>-sections.txt</filename> file. The
744 name give here should match the <FILE> tag in the
745 <filename><package>-sections.txt</filename> file.
750 <term>@short_description</term>
753 A one line description of the section, that later will appear after
754 the links in the TOC and at the top of the section page.
762 The section title defaults to <name> from the SECTION
763 declaration. It can be overridden with the @title field.
768 <term>@section_id</term>
771 Overrides the use of title as a section identifier. For GObjects
772 the <title> is used as a section_id and for other section it
773 is <MODULE>-<title>.
778 <term>@see_also</term>
781 A list of symbols that are related to this section..
786 <term>@stability</term>
789 A informal description of the stability level this API has.
790 We recommend the use of one of these terms:
795 - The intention of a Stable interface is to enable arbitrary
796 third parties to develop applications to these interfaces,
797 release them, and have confidence that they will run on all
798 minor releases of the product (after the one in which the
799 interface was introduced, and within the same major release).
800 Even at a major release, incompatible changes are expected
801 to be rare, and to have strong justifications.
807 - Unstable interfaces are experimental or transitional.
808 They are typically used to give outside developers early
809 access to new or rapidly changing technology, or to provide
810 an interim solution to a problem where a more general
811 solution is anticipated.
812 No claims are made about either source or binary
813 compatibility from one minor release to the next.
819 - An interface that can be used within the GNOME stack
820 itself, but that is not documented for end-users. Such
821 functions should only be used in specified and documented
828 - An interface that is internal to a module and does not
829 require end-user documentation. Functions that are
830 undocumented are assumed to be Internal.
838 <term>@include</term>
841 The <literal>#include</literal> files to show in the section
842 synopsis (a comma separated list), overriding the global
843 value from the <link linkend="metafiles_sections">section
844 file</link> or command line. This item is optional.
852 To avoid unnecessary recompilation after doc-changes put the section
853 docs into the c-source where possible.
859 <sect1 id="documenting_symbols">
860 <title>Documenting symbols</title>
863 Each symbol (function, macro, struct, enum, signal and property) is
864 documented in a separate block. The block is best placed close to the
865 definition of the symbols so that it is easy to keep them in sync.
866 Thus function are usually documented in the c-source and macros, struct
867 and enum in the header file.
871 <example><title>Function comment block</title>
876 * @par1: description of parameter 1. These can extend over more than
878 * @par2: description of parameter 2
880 * The function description goes here. You can use @par1 to refer to parameters
881 * so that they are highlighted in the output. You can also use %constant
882 * for constants, function_name2() for functions and #GtkWidget for links to
883 * other declarations (which may be documented elsewhere).
885 * Returns: an integer.
888 * Deprecated: 2.18: Use other_function() instead.
897 <term>Returns:</term>
900 Paragraph describing the returned result.
905 <term>Deprecated:</term>
908 Paragraph denoting that this function should no be used anymore.
909 The description should point the reader to the new API.
917 Description since which version of the code the API is available.
924 Gtk-doc assumes all symbols (macros, functions) starting with '_' are
925 private. They are treated like static functions.
934 <example><title>Property comment block</title>
938 * SomeWidget:some-property:
940 * Here you can document a property.
942 g_object_class_install_property (object_class, PROP_SOME_PROPERTY, ...);
946 <example><title>Signal comment block</title>
950 * FooWidget::foobarized:
951 * @widget: the widget that received the signal
955 * The ::foobarized signal is emitted each time someone tries to foobarize @widget.
957 foo_signals[FOOBARIZE] =
958 g_signal_new ("foobarize",
963 <example><title>Struct comment block</title>
968 * @bar: some #gboolean
970 * This is the best widget, ever.
972 typedef struct _FooWidget {
982 Use <code>/*< private >*/</code> before the private struct fields you
983 you want to hide. Use <code>/*< public >*/</code> for the reverse
988 <example><title>Enum comment block</title>
993 * @SOMETHING_FOO: something foo
994 * @SOMETHING_BAR: something bar
996 * Enum values used for the thing, to specify the thing.
1009 <sect1 id="documenting_docbook">
1010 <title>Useful DocBook tags</title>
1013 Here are some DocBook tags which are most useful when documenting the
1018 To link to another section in the GTK docs:
1023 <link linkend="glib-Hash-Tables">Hash Tables</link>
1027 The linkend is the SGML/XML id on the top item of the page you want to link to.
1028 For most pages this is currently the part ("gtk", "gdk", "glib") and then
1029 the page title ("Hash Tables"). For widgets it is just the class name.
1030 Spaces and underscores are converted to '-' to conform to SGML/XML.
1034 To refer to an external function, e.g. a standard C function:
1038 <function>...</function>
1045 To include example code:
1050 <title>Using a GHashTable.</title>
1058 or possibly this, for very short code fragments which don't need a title:
1070 For the latter gtk-doc also supports an abbreviation:
1079 To include bulleted lists:
1101 To include a note which stands out from the text:
1107 Make sure you free the data after use.
1120 <type>unsigned char</type>
1127 To refer to an external structure (not one described in the GTK docs):
1131 <structname>XFontStruct</structname>
1138 To refer to a field of a structure:
1142 <structfield>len</structfield>
1149 To refer to a class name, we could possibly use:
1153 <classname>GtkWidget</classname>
1157 but you'll probably be using #GtkWidget instead (to automatically create
1158 a link to the GtkWidget page - see <link linkend="documenting_syntax">the abbreviations</link>).
1166 <emphasis>This is important</emphasis>
1177 <filename>/home/user/documents</filename>
1184 To refer to keys use:
1188 <keycombo><keycap>Control</keycap><keycap>L</keycap></keycombo>
1197 <chapter id="metafiles">
1198 <title>Filling the extra files</title>
1201 There are a couple of extra files, that need to be maintained along with
1202 the inline source code comments:
1203 <filename><package>.types</filename>,
1204 <filename><package>-docs.sgml</filename>,
1205 <filename><package>-sections.txt</filename>.
1208 <sect1 id="metafiles_types">
1209 <title>Editing the types file</title>
1212 If your library or application includes GtkObjects/GObjects, you want
1213 their signals, arguments/parameters and position in the hierarchy to be
1214 shown in the documentation. All you need to do, is to list the
1215 <function>xxx_get_type</function> functions together with their include
1216 inside the <filename><package>.types</filename> file.
1220 <example><title>Example types file snippet</title>
1223 #include <gtk/gtk.h>
1225 gtk_accel_label_get_type
1226 gtk_adjustment_get_type
1227 gtk_alignment_get_type
1235 Since gtk-doc 1.8 <application>gtkdoc-scan</application> can generate this list for you.
1236 Just add "--rebuild-types" to SCAN_OPTIONS in <filename>Makefile.am</filename>. If you
1237 use this approach you should not dist the types file nor have it under version control.
1242 <sect1 id="metafiles_master">
1243 <title>Editing the master document</title>
1246 Gtk-Doc produces documentation in DocBook SGML/XML. When processing the
1247 inline source comments, the Gtk-Doc tools generate one documentation
1248 page per class or module as a separate file. The master document
1249 includes them and place them in a order.
1253 While Gtk-Doc creates a template master document for you, later run will
1254 not touch it again. This means that one can freely structure the
1255 documentation. That includes grouping pages and adding extra pages.
1256 Gtk-doc has now a test suite, where also the master-document is recreated from scratch.
1257 Its a good idea to look at this from time to time to see if there are some new goodies
1263 Do not create tutorials as extra documents. Just write extra chapters.
1264 The benefit of directly embedding the tutorial for your library into
1265 the API documentation is that it is easy to link for the tutorial to
1266 symbol documentation. Apart chances are higher that the tutorial gets
1267 updates along with the library.
1272 So what are the things to change inside the master document? For a start
1273 is only a little. There are some placeholders (text in square brackets)
1274 there which you should take care of.
1278 <example><title>Master document header</title>
1282 <title>MODULENAME Reference Manual</title>
1284 for MODULENAME [VERSION]
1285 The latest version of this documentation can be found on-line at
1286 <ulink role="online-location" url="http://[SERVER]/MODULENAME/index.html">http://[SERVER]/MODULENAME/</ulink>.
1291 <title>[Insert title here]</title>
1299 <sect1 id="metafiles_sections">
1300 <title>Editing the section file</title>
1303 The section file is used to organise the documentation output by
1304 Gtk-Doc. Here one specifies which symbol belongs to which module or
1305 class and control the visibility (public or private).
1309 The section file is a plain test file with xml like syntax (using tags).
1310 Blank lines are ignored and lines starting with a '#' are treated as
1315 The <FILE> ... </FILE> tag is used to specify the file name,
1316 without any suffix. For example, using '<FILE>gnome-config</FILE>'
1317 will result in the section declarations being output in the template
1318 file <filename>tmpl/gnome-config.sgml</filename>, which will be
1319 converted into the DocBook SGML/XML file <filename>sgml/gnome-config.sgml</filename>
1320 or .DocBook XML file <filename>xml/gnome-config.xml</filename>.
1321 (The name of the html file is based on the module name and the section
1322 title, or for gobjects it is based on the gobjects class name converted
1327 The <TITLE> ... </TITLE> tag is used to specify the title of
1328 the section. It is only useful before the templates (if used) are
1329 initially created, since the title set in the template file overrides
1330 this. Also if one uses SECTION comment in the sources, this is obsolete.
1334 You can group items in the section by using the <SUBSECTION> tag.
1335 Currently it outputs a blank line between subsections in the synopsis
1337 You can also use <SUBSECTION Standard> for standard GObject
1338 declarations (e.g. the functions like g_object_get_type and macros like
1339 G_OBJECT(), G_IS_OBJECT() etc.).
1340 Currently these are left out of the documentation.
1341 You can also use <SUBSECTION Private> for private declarations
1342 which will not be output (It is a handy way to avoid warning messages
1343 about unused declarations.).
1344 If your library contains private types which you don't want to appear in
1345 the object hierarchy and the list of implemented or required interfaces,
1346 add them to a Private subsection.
1350 You can also use <INCLUDE> ... </INCLUDE> to specify the
1351 #include files which are shown in the synopsis sections.
1352 It contains a comma-separate list of #include files, without the angle
1353 brackets. If you set it outside of any sections, it acts for all
1354 sections until the end of the file. If you set it within a section, it
1355 only applies to that section.
1362 <chapter id="reports">
1363 <title>Controlling the result</title>
1366 A Gtk-Doc run generates report files inside the documentation directory.
1367 The generated files are named:
1368 <filename><package>-undocumented.txt</filename>,
1369 <filename><package>-undeclared.txt</filename> and
1370 <filename><package>-unused.txt</filename>.
1371 All those are plain text files that can be viewed and postprocessed easily.
1375 The <filename><package>-undocumented.txt</filename> file starts with
1376 the documentation coverage summary. Below are two sections divided by
1377 blank lines. The first section lists undocumented or incomplete symbols.
1378 The second section does the same for section docs. Incomplete entries are
1379 those, which have documentation, but where e.g. a new parameter has been
1384 The <filename><package>-undeclared.txt</filename> file lists symbols
1385 given in the <filename><package>-sections.txt</filename> but not
1386 found in the sources. Check if they have been removed or if they are
1391 The <filename><package>-unused.txt</filename> file lists symbol
1392 names, where the Gtk-Doc scanner has found documentation, but does not
1393 know where to put it. This means that the symbol has not yet been added to
1394 the <filename><package>-sections.txt</filename> file.
1399 Enable or add the <option>TESTS=$(GTKDOC_CHECK)</option> line in Makefile.am.
1400 If at least gtk-doc 1.9 is installed, this will run sanity checks during
1401 <command>make check</command> run.
1406 One can also look at the files produced by the source code scanner:
1407 <filename><package>-decl-list.txt</filename> and
1408 <filename><package>-decl.txt</filename>. The first and can be
1409 compared with the section file if that is manualy maintained. The second
1410 lists all declarations fromt he headers If a symbol is missing one could
1411 check if this file contains it.
1415 If the project is GObject based, one can also look into the files produced
1416 by the object scanner:
1417 <filename><package>.args.txt</filename>,
1418 <filename><package>.hierarchy.txt</filename>,
1419 <filename><package>.interfaces.txt</filename>,
1420 <filename><package>.prerequisites.txt</filename> and
1421 <filename><package>.signals.txt</filename>. If there are missing
1422 symbols in any of those, one can ask gtkdoc to keep the intermedia scanner
1423 file for further analysis, but running it as
1424 <command>GTK_DOC_KEEP_INTERMEDIATE=1 make</command>.
1429 <title>Frequently asked question</title>
1432 <?dbhtml list-presentation="list"?>
1433 <segtitle>Question</segtitle>
1434 <segtitle>Answer</segtitle>
1436 <seg>No class hierarchy.</seg>
1438 The objects <function>xxx_get_type()</function> function has not been
1439 entered into the <filename><package>.types</filename> file.
1443 <seg>Still no class hierarchy.</seg>
1445 Missing or wrong naming in <filename><package>-sections.txt</filename>
1446 file (see <ulink url="http://mail.gnome.org/archives/gtk-doc-list/2003-October/msg00006.html">explanation</ulink>).
1450 <seg>Damn, I have still no class hierarchy.</seg>
1452 Is the object name (name of the instance struct, e.g. <type>GtkWidget</type>)
1453 part of the normal section (don't put this into Standard or Private
1458 <seg>No symbol index.</seg>
1460 Does the <filename><package>-docs.{xml,sgml}</filename> contain a
1461 index that xi:includes the generated index?
1465 <seg>Symbols are not linked to their doc-section.</seg>
1467 Is the doc-comment using the correct markup (added #,% or ())?
1468 Check if the gtkdoc-fixxref warns about unresolvable xrefs.
1472 <seg>A new class does not appear in the docs.</seg>
1474 Is the new page xi:included from
1475 <filename><package>-docs.{xml,sgml}</filename>.
1479 <seg>A new symbol does not appear in the docs.</seg>
1481 Is the doc-comment properly formatted. Check for spelling mistakes in
1482 the begin of the comment. Check if the gtkdoc-fixxref warns about
1483 unresolvable xrefs. Check if the symbol is correctly listed in the
1484 <filename><package>-sections.txt</filename> in a public subsection.
1488 <seg>A type is missing from the class hierarchy.</seg>
1490 If the type is listed in <filename><package>.hierarchy</filename>
1491 but not in <filename>xml/tree_index.sgml</filename> then double check
1492 that the type is correctly placed in the <filename><package>-sections.txt</filename>.
1493 If the type instance (e.g. <type>GtkWidget</type>) is not listed or
1494 incidentialy makred private it will not be shown.
1498 <seg>I get foldoc links for all gobject annotations.</seg>
1500 Check that <filename>xml/annotation-glossary.xml</filename> is
1501 xi:included from <filename><package>-docs.{xml,sgml}</filename>.
1505 <!-- gtk-doc warnings: -->
1507 <seg>Parameter described in source code comment block but does not exist</seg>
1508 <seg>Check if the prototype in the header has different parameter names as in the source.</seg>
1511 <!-- docbook warnings: -->
1513 <seg>multiple "IDs" for constraint linkend: XYZ</seg>
1514 <seg>Symbol XYZ appears twice in <filename><package>-sections.txt</filename> file.</seg>
1517 <seg>Element typename in namespace '' encountered in para, but no template matches.</seg>
1523 <!-- ======== Appendix: FDL ================================== -->