release: update news and date in manual
[gtk-doc.git] / help / manual / C / gtk-doc-manual.xml
blob3cad18afaf00b16db63dd9f598060140a91679d6
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 ============================= -->
10 <book id="index">
11   <bookinfo>
12     <title>GTK-Doc Manual</title>
13     <edition>1.15</edition>
14     <abstract role="description"><para>User manual for developers with instructions of GTK-Doc usage.</para></abstract>
15     <authorgroup>
16       <author>
17         <firstname>Chris</firstname>
18         <surname>Lyttle</surname>
19         <affiliation>
20           <address>
21             <email>chris@wilddev.net</email>
22           </address>
23         </affiliation>
24       </author>
25       <author>
26         <firstname>Dan</firstname>
27         <surname>Mueth</surname>
28         <affiliation>
29           <address>
30             <email>d-mueth@uchicago.edu</email>
31           </address>
32         </affiliation>
33       </author>
34       <author>
35         <firstname>Stefan</firstname>
36         <surname>Kost</surname>
37         <affiliation>
38           <address>
39             <email>ensonic@users.sf.net</email>
40           </address>
41         </affiliation>
42       </author>
43     </authorgroup>
44     <publisher role="maintainer">
45       <publishername>GTK-Doc project</publishername>
46       <address><email>gtk-doc-list@gnome.org</email></address>
47     </publisher>
48     <copyright>
49       <year>2000, 2005, 2007-2009</year>
50       <holder>Dan Mueth and Chris Lyttle and Stefan Kost</holder>
51     </copyright>
53     <!-- translators: uncomment this:
54     <copyright>
55       <year>2000</year>
56       <holder>ME-THE-TRANSLATOR (Latin translation)</holder>
57     </copyright>
58     -->
60     <legalnotice>
61       <para>
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
67         is &FDLlink;.
68       </para>
69       <para>
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
74         or initial caps.
75       </para>
76     </legalnotice>
77     
78     <revhistory>
79       <revision>
80         <revnumber>1.16</revnumber>
81         <date>14 Jan 2011</date>
82         <authorinitials>sk</authorinitials>
83         <revremark>bugfixes, layout improvements</revremark>
84       </revision>
85       <revision>
86         <revnumber>1.15</revnumber>
87         <date>21 May 2010</date>
88         <authorinitials>sk</authorinitials>
89         <revremark>bug and regression fixes</revremark>
90       </revision>
91       <revision>
92         <revnumber>1.14</revnumber>
93         <date>28 March 2010</date>
94         <authorinitials>sk</authorinitials>
95         <revremark>bugfixes and performance improvements</revremark>
96       </revision>
97       <revision>
98         <revnumber>1.13</revnumber>
99         <date>18 December 2009</date>
100         <authorinitials>sk</authorinitials>
101         <revremark>broken tarball update</revremark>
102       </revision>
103       <revision>
104         <revnumber>1.12</revnumber>
105         <date>18 December 2009</date>
106         <authorinitials>sk</authorinitials>
107         <revremark>new tool features and bugfixes</revremark>
108       </revision>
109       <revision>
110         <revnumber>1.11</revnumber>
111         <date>16 Novemebr 2008</date>
112         <authorinitials>mal</authorinitials>
113         <revremark>GNOME doc-utils migration</revremark>
114       </revision>
115     </revhistory>
117   </bookinfo>
119   <!-- ======== Chapter 1: Introduction ======================== -->
121   <chapter id="introduction">
122     <title>Introduction</title>
124     <para>
125       This chapter introduces GTK-Doc and gives an overview of what it is and
126       how it is used.
127     </para>
129     <sect1 id="whatisgtkdoc">
130       <title>What is GTK-Doc?</title>
132       <para>
133         GTK-Doc is used to document C code. It is typically used to document the public
134         API of libraries, such as the GTK+ and GNOME libraries. But it can also be
135         used to document application code.
136       </para>
137     </sect1>
139     <sect1 id="howdoesgtkdocwork">
140       <title>How Does GTK-Doc Work?</title>
142       <para>
143         GTK-Doc works by using documentation of functions placed inside the source files in
144         specially-formatted comment blocks, or documentation added to the template files
145         which GTK-Doc uses (though note that GTK-Doc will only document functions that
146         are declared in header files; it won't produce output for static functions).
147       </para>
149       <para>
150         GTK-Doc consists of a number of perl scripts, each performing a different step
151         in the process.
152       </para>
154       <para>
155         There are 5 main steps in the process:
156       </para>
158       <orderedlist>
160         <listitem>
161           <para>
162             <guilabel>Writing the documentation.</guilabel>
164             The author fills in the source files with the documentation for each
165             function, macro, union etc. (In the past information was entered in
166             generated template files, which is not recommended anymore).
167           </para>
168         </listitem>
170         <listitem>
171           <para>
172             <guilabel>Gathering information about the code.</guilabel>
174             <application>gtkdoc-scan</application> scans the header files of the
175             code looking for declarations of functions, macros, enums, structs, and unions.
176             It creates the file <filename>&lt;module&gt;-decl-list.txt</filename> containg a list of the
177             declarations, placing them into sections according to which header file they
178             are in. On the first run this file is copied to <filename>&lt;module&gt;-sections.txt</filename>.
179             The author can rearrange the sections, and the order of the
180             declarations within them, to produce the final desired order.
181             The second file it generates is <filename>&lt;module&gt;-decl.txt</filename>.
182             This file contains the full declarations found by the scanner. If for
183             some reason one would like some symbols to show up in the docs, where
184             the full declaration cannot be found by the scanner or the declaration
185             should appear differently, one can place enties similar to the ones in
186             <filename>&lt;module&gt;-decl.txt</filename> into <filename>&lt;module&gt;-overrides.txt</filename>.
188             <application>gtkdoc-scanobj</application> can also be used to dynamically query a library about
189             any GtkObject subclasses it exports. It saves information about each
190             object's position in the class hierarchy and about any GTK Args and Signals it
191             provides.
192           </para>
193         </listitem>
195         <listitem>
196           <para>
197             <guilabel>Generating the "template" files.</guilabel>
199             <application>gtkdoc-mktmpl</application> creates a number of files in
200             the <filename class='directory'>tmpl/</filename> subdirectory, using the
201             information gathered in the first step. (Note that this can be run
202             repeatedly. It will try to ensure that no documentation is ever lost.)
203           </para>
204           <note>
205             <para>
206               Since GTK-Doc 1.9 the templates can be avoided. We encourage people to keep
207               documentation in the code. <application>gtkdocize</application> supports now
208               a <option>--flavour no-tmpl</option> option that chooses a makefile that
209               skips tmpl usage totally.
210               If you have never changed file in tmpl by hand, please remove the dir
211               (e.g. from version control system).
212             </para>
213           </note>
214         </listitem>
216         <listitem>
217           <para>
218             <guilabel>Generating the SGML/XML and HTML/PDF.</guilabel>
220             <application>gtkdoc-mkdb</application> turns the template files into
221             SGML or XML files in the <filename class='directory'>sgml/</filename>
222             or <filename class='directory'>xml/</filename> subdirectory.
223             If the source code contains documentation on functions, using the
224             special comment blocks, it gets merged in here. If there are no tmpl files used
225             it only reads docs from sources and introspection data. We recommend
226             to use Docbook XML.
227           </para>
228           <para>
229             <application>gtkdoc-mkhtml</application> turns the SGML/XML files into HTML
230             files in the <filename class='directory'>html/</filename> subdirectory.
231             Likewise <application>gtkdoc-mkpdf</application> turns the SGML/XML files into a PDF
232             document called <filename>&lt;package&gt;.pdf</filename>.
233           </para>
234           <para>
235             Files in <filename class='directory'>sgml/</filename> or
236             <filename class='directory'>xml/</filename> and <filename class='directory'>html/</filename>
237             directories are always overwritten. One should never edit them directly.
238           </para>
239         </listitem>
241         <listitem>
242           <para>
243             <guilabel>Fixing up cross-references between documents.</guilabel>
245             After installing the HTML files, <application>gtkdoc-fixxref</application> can be run to fix up any
246             cross-references between separate documents. For example, the GTK+
247             documentation contains many cross-references to types documented in the GLib manual.
249             When creating the source tarball for distribution, <application>gtkdoc-rebase</application>
250             turns all external links into web-links. When installing distributed (pregenerated) docs
251             the same application will try to turn links back to local links
252             (where those docs are installed).
253           </para>
254         </listitem>
255       </orderedlist>
257     </sect1>
259     <sect1 id="gettinggtkdoc">
260       <title>Getting GTK-Doc</title>
262       <sect2 id="requirements">
263         <title>Requirements</title>
264         <para>
265           <guilabel>Perl v5</guilabel> - the main scripts are in Perl.
266         </para>
267         <para>
268           <guilabel>DocBook DTD v3.0</guilabel> - This is the DocBook SGML DTD.
269           <ulink url="http://www.ora.com/davenport" type="http">http://www.ora.com/davenport</ulink>
270         </para>
271         <para>
272           <guilabel>Jade v1.1</guilabel> - This is a DSSSL processor for converting SGML to various formats.
273           <ulink url="http://www.jclark.com/jade" type="http">http://www.jclark.com/jade</ulink>
274         </para>
275         <para>
276           <guilabel>Modular DocBook Stylesheets</guilabel>
277           This is the DSSSL code to convert DocBook to HTML (and a few other
278           formats). It's used together with jade.
279           I've customized the DSSSL code slightly, in gtk-doc.dsl, to colour
280           the program code listings/declarations, and to support global
281           cross-reference indices in the generated HTML.
282           <ulink url="http://nwalsh.com/docbook/dsssl" type="http">http://nwalsh.com/docbook/dsssl</ulink>
283         </para>
284         <para>
285           <guilabel>docbook-to-man</guilabel> - if you want to create man pages from the DocBook.
286           I've customized the 'translation spec' slightly, to capitalise section
287           headings and add the 'GTK Library' title at the top of the pages and the
288           revision date at the bottom.
289           There is a link to this on <ulink url="http://www.ora.com/davenport" type="http">http://www.ora.com/davenport</ulink>
290           NOTE: This does not work yet.
291         </para>
292       </sect2>
294       <sect2 id="installation">
295         <title>Installation</title>
296         <para>
297           There is no standard place where the DocBook Modular Stylesheets are installed.
298         </para>
299         <para>
300           GTK-Doc's configure script searches these 3 directories automatically:
301         </para>
302         <para>
303           <filename> /usr/lib/sgml/stylesheets/nwalsh-modular   </filename>     (used by RedHat)
304         </para>
305         <para>
306           <filename>  /usr/lib/dsssl/stylesheets/docbook         </filename>     (used by Debian)
307         </para>
308         <para>
309           <filename>  /usr/share/sgml/docbkdsl                   </filename>     (used by SuSE)
310         </para>
311         <para>
312           If you have the stylesheets installed somewhere else, you need to configure
313           GTK-Doc using the option:
314           <command> --with-dsssl-dir=&lt;PATH_TO_TOPLEVEL_STYLESHEETS_DIR&gt; </command>
315         </para>
316       </sect2>
318     </sect1>
320     <!-- not realy worth a section
321     <sect1 id="whentousegtkdoc">
322       <title>When to Use GTK-Doc</title>
324       <para>
325         (What things GTK-Doc should, and shouldn't, be used for.)
326         (- ???)
327         (- non C-based projects)
328         (+ Tutorials)
329       </para>
331     </sect1>
332     -->
334     <sect1 id="aboutgtkdoc">
335       <title>About GTK-Doc</title>
337       <para>
338         (FIXME)
339       </para>
341       <para>
342         (History, authors, web pages, license, future plans,
343         comparison with other similar systems.)
344       </para>
346     </sect1>
348     <sect1 id="aboutthismanual">
349       <title>About this Manual</title>
351       <para>
352         (FIXME)
353       </para>
355       <para>
356         (who it is meant for, where you can get it, license)
357       </para>
359     </sect1>
361   </chapter>
363   <chapter id="settingup">
364     <title>Setting up your project</title>
366     <para>
367       The next sections describe what steps to perform to integrate GTK-Doc into
368       your project. Theses sections assume we work on a project called 'meep'.
369       This project contains a library called 'libmeep' and
370       an end-user app called 'meeper'.
371     </para>
373     <sect1 id="settingup_docfiles">
374       <title>Setting up a skeleton documentation</title>
376       <para>
377         Under your top-level project directory create folders called docs/reference
378         (this way you can also have docs/help for end-user documentation).
379         It is recommended to create another subdirectory with the name of the doc-package.
380         For packages with just one library this step is not necessary.
381       </para>
383       <para>
384         This can then look as shown below:
385         <example><title>Example directory structure</title>
386           <programlisting>
387 <![CDATA[
388 meep/
389   docs/
390     reference/
391       libmeep/
392       meeper/
393   src/
394     libmeep/
395     meeper/
397           </programlisting>
398         </example>
399       </para>
400     </sect1>
402     <sect1 id="settingup_autoconf">
403       <title>Integration with autoconf</title>
405       <para>
406         Very easy! Just add one line to your <filename>configure.ac</filename> script.
407       </para>
409       <para>
410         <example><title>Integration with autoconf</title>
411           <programlisting>
412 <![CDATA[
413 # check for gtk-doc
414 GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
416           </programlisting>
417         </example>
418       </para>
419       
420       <para>
421         This will require all developers to have gtk-doc installed. If it is
422         okay for your project to have optional api-doc build setup, you can
423         solve this as below. Keep it as is, as gtkdocize is looking for
424         <function>GTK_DOC_CHECK</function>  at the start of a line.
425         <example><title>Keep gtk-doc optional</title>
426           <programlisting>
427 <![CDATA[
428 # check for gtk-doc
429 m4_ifdef([GTK_DOC_CHECK], [
430 GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
432 AM_CONDITIONAL([ENABLE_GTK_DOC], false)
435           </programlisting>
436         </example>
437       </para>
438       
439       <para>
440         The first argument is used to check for the gtkdocversion at configure time.
441         The 2nd, optional argument is used by <application>gtkdocize</application>.
442         The <symbol>GTK_DOC_CHECK</symbol> macro also adds several configure switches:
443       </para>
444       <orderedlist>
445         <listitem><para>--with-html-dir=PATH : path to installed docs</para></listitem>
446         <listitem><para>--enable-gtk-doc : use gtk-doc to build documentation [default=no]</para></listitem>
447         <listitem><para>--enable-gtk-doc-html : build documentation in html format [default=yes]</para></listitem>
448         <listitem><para>--enable-gtk-doc-pdf : build documentation in pdf format [default=no]</para></listitem>
449       </orderedlist>
451       <important>
452         <para>
453           GTK-Doc is disabled by default! Remember to pass the option
454           <option>'--enable-gtk-doc'</option> to the next
455           <filename>configure</filename> run. Otherwise pregenerated documentation is installed
456           (which makes sense for users but not for developers).
457         </para>
458       </important>
460       <para>
461         Furthermore it is recommended that you have the following line inside
462         you <filename>configure.ac</filename> script.
463         This allows <application>gtkdocize</application> to automatically copy the
464         macro definition for <function>GTK_DOC_CHECK</function> to your project.
465       </para>
467       <para>
468         <example><title>Preparation for gtkdocize</title>
469           <programlisting>
470 <![CDATA[
471 AC_CONFIG_MACRO_DIR(m4)
473           </programlisting>
474         </example>
475       </para>
476     </sect1>
478     <sect1 id="settingup_automake">
479       <title>Integration with automake</title>
481       <para>
482         First copy the <filename>Makefile.am</filename> from the examples subdirectory of the gtkdoc-sources
483         to your project's API documentation directory (
484         <filename class='directory'>./docs/reference/&lt;package&gt;</filename>).
485         If you have multiple doc-packages repeat this for each one.
486       </para>
488       <para>
489         The next step is to edit the settings inside the <filename>Makefile.am</filename>.
490         All the settings have a comment above that describes their purpose.
491         Most settings are extra flags passed to the respective tools. Every tool
492         has a variable of the form <option>&lt;TOOLNAME&gt;_OPTIONS</option>.
493         All the tools support <option>--help</option> to list the supported
494         parameters.
495       </para>
497       <!-- FIXME: explain options ? -->
499       <para>
500         You may also want to enable GTK-Doc for the distcheck make target. Just
501         add the one line shown in the next example to your top-level
502         <filename>Makefile.am</filename>:
503       </para>
505       <para>
506         <example><title>Enable GTK-Doc during make distcheck</title>
507           <programlisting>
508 <![CDATA[
509 DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc
511           </programlisting>
512         </example>
513       </para>
515     </sect1>
517     <sect1 id="settingup_autogen">
518       <title>Integration with autogen</title>
520       <para>
521         Most projects will have an <filename>autogen.sh</filename> script to
522         setup the build infrastructure after a checkout from version control
523         system (such as cvs/svn/git). GTK-Doc comes with a tool called
524         <application>gtkdocize</application> which can be used in such a script.
525         It should be run before autoheader, automake or autoconf.
526       </para>
528       <para>
529         <example><title>Running gtkdocize from autogen.sh</title>
530           <programlisting>
531 <![CDATA[
532 gtkdocize || exit 1
534           </programlisting>
535         </example>
536       </para>
538       <para>
539         When running <application>gtkdocize</application> it copies
540         <filename>gtk-doc.make</filename> to your project root (or any directory
541         specified by the <option>--docdir</option> option).
542         It also checks you configure script for the <function>GTK_DOC_CHECK</function>
543         invocation. This macro can be used to pass extra parameters to
544         <application>gtkdocize</application>.
545       </para>
547       <para>
548         Historically GTK-Doc was generating template files where developers entered the docs.
549         This turned out to be not so good (e.g. the need for having generated
550         files under version control).
551         Since GTK-Doc 1.9 the tools can get all the information from source comments
552         and thus the templates can be avoided. We encourage people to keep
553         documentation in the code. <application>gtkdocize</application> supports now
554         a <option>--flavour no-tmpl</option> option that chooses a makefile that skips
555         tmpl usage totally. Besides adding the option directly to the command
556         invocation, they can be added also to an environment variable called <symbol>GTKDOCIZE_FLAGS</symbol>
557         or set as a 2nd parameter in <symbol>GTK_DOC_CHECK</symbol> macro in the configure script.
558         If you have never changed file in tmpl by hand and migrating from older gtkdoc versions,
559         please remove the dir (e.g. from version control system).
560       </para>
561     </sect1>
563     <sect1 id="settingup_firstrun">
564       <title>Running the doc build</title>
566       <para>
567         After the previous steps it's time to run the build. First we need to
568         rerun <filename>autogen.sh</filename>. If this script runs configure for
569         you, then give it the <option>--enable-gtk-doc</option> option.
570         Otherwise manually run <filename>configure</filename> with this option
571         afterwards.
572       </para>
573       <para>
574         The first make run generates several additional files in the doc-dirs.
575         The important ones are:
576         <filename>&lt;package&gt;.types</filename>,
577         <filename>&lt;package&gt;-docs.sgml</filename>,
578         <filename>&lt;package&gt;-sections.txt</filename>.
579       </para>
580       <para>
581         <example><title>Running the doc build</title>
582           <programlisting>
583 <![CDATA[
584 ./autogen.sh --enable-gtk-doc
585 make
587           </programlisting>
588         </example>
589       </para>
590       <para>
591         Now you can point your browser to <filename>docs/reference/&lt;package&gt;/index.html</filename>.
592         Yes, it's a bit disappointing still. But hang-on, during the next chapter we
593         tell you how to fill the pages with life.
594       </para>
595     </sect1>
597     <sect1 id="settingup_vcs">
598       <title>Integration with version control systems</title>
600       <para>
601         As a rule of the thumb, it's those files you edit, that should go under
602         version control. For typical projects it's these files:
603         <filename>&lt;package&gt;.types</filename>
604         <filename>&lt;package&gt;-docs.sgml</filename>
605         <filename>&lt;package&gt;-sections.txt</filename>
606         <filename>Makefile.am</filename>
607       </para>
608     </sect1>
610   </chapter>
612   <chapter id="documenting">
613     <title>Documenting the code</title>
615     <para>
616       GTK-Doc uses source code comment with a special syntax for code documentation.
617       Further it retrieves information about your project structure from other
618       sources. During the next section you will find all information about the
619       syntax of the comments.
620     </para>
622     <note>
623       <title>Documentation placement</title>
624       <para>
625         In the past most documentation had to be filled into files residing
626         inside the <filename>tmpl</filename> directory. This has the
627         disadvantages that the information is often not updated and also that
628         the file tend to cause conflicts with version control systems.
629       </para>
630       <para>
631         The avoid the aforementioned problems we suggest putting the
632         documentation inside the sources. This manual will only describe this
633         way of documenting code.
634       </para>
635     </note>
636     
637     <para>
638       The scanner can handle the majority of c headers fine. In the case of
639       receiving warnings from the scanner that look like a special case, one can
640       hint GTK-Doc to skip over them.
641       <example><title>GTK-Doc comment block</title>
642         <programlisting>
643 <![CDATA[
644 #ifndef __GTK_DOC_IGNORE__
645 /* unparseable code here */
646 #endif
648         </programlisting>
649       </example>
650     </para>
652     <!--  -->
654     <sect1 id="documenting_syntax">
655       <title>Documentation comments</title>
657       <para>
658         A multiline comment that starts with an additional '*' marks a
659         documentation block that will be processed by the GTK-Doc tools.
660         <example><title>GTK-Doc comment block</title>
661           <programlisting>
662 <![CDATA[
664  * identifier:
665  * documentation ...
666  */
668           </programlisting>
669         </example>
670       </para>
672       <para>
673         The 'identifier' is one line with the name of the item the comment is
674         related to. The syntax differs a little depending on the item.
675         (TODO add table showing identifiers)
676       </para>
678       <para>
679         The 'documentation' block is also different for each symbol type. Symbol
680         types that get parameters such as functions or macros have the parameter
681         description first followed by a blank line (just a '*').
682         Afterwards follows the detailed description. All lines (outside program-
683         listings and CDATA sections) just containing a ' *' (blank-asterisk) are
684         converted to paragraph breaks.
685         If you don't want a paragraph break, change that into ' *  '
686         (blank-asterisk-blank-blank).
687       </para>
689       <para>
690         One advantage of hyper-text over plain-text is the ability to have links
691         in the document. Writing the correct markup for a link can be tedious
692         though. GTK-Doc comes to help by providing several useful abbreviations.
693         <itemizedlist>
694           <listitem>
695             <para>
696               Use function() to refer to functions or macros which take arguments.
697             </para>
698           </listitem>
699           <listitem>
700             <para>
701               Use @param to refer to parameters. Also use this when referring to
702               parameters of other functions, related to the one being described.
703             </para>
704           </listitem>
705           <listitem>
706             <para>
707               Use %constant to refer to a constant, e.g. %G_TRAVERSE_LEAFS.
708             </para>
709           </listitem>
710           <listitem>
711             <para>
712               Use #symbol to refer to other types of symbol, e.g. structs and
713               enums and macros which don't take arguments.
714             </para>
715           </listitem>
716           <listitem>
717             <para>
718               Use #Object::signal to refer to a GObject signal
719             </para>
720           </listitem>
721           <listitem>
722             <para>
723               Use #Object:property to refer to a GObject property
724             </para>
725           </listitem>
726           <listitem>
727             <para>
728               Use #Struct.field to refer to a field inside a structure.
729             </para>
730           </listitem>
731         </itemizedlist>
732       </para>
734       <tip>
735           <para>
736         If you need to use the special characters '&lt;', '&gt;', '()', '@',
737         '%', or '#' in your documentation without GTK-Doc changing them you
738         can use the XML entities "&amp;lt;", "&amp;gt;", "&amp;lpar;",
739         "&amp;rpar;", "&amp;commat;", "&amp;percnt;" and "&amp;num;"
740         respectively or escape them with a backslash '\'.
741           </para>
742       </tip>
744       <para>
745         DocBook can do more that just links. One can also have lists, tables and
746         examples. To enable the usage of SGML/XML tags inside doc-comments you
747         need to have <option>--xml-mode</option> or <option>--sgml-mode</option>
748         in the variable <symbol>MKDB_OPTIONS</symbol> inside 
749         <filename>Makefile.am</filename>.
750       </para>
752       <tip>
753         <para>
754           As already mentioned earlier GTK-Doc is for documenting public API. Thus
755           one cannot write documentation for static symbols. Nevertheless it is good
756           to comment those symbols too. This helps other to understand you code.
757           Therefore we recommend to comment these using normal comments (without the
758           2nd '*' in the first line).
759           If later the function needs to be made public, all one needs to do is to
760           add another '*' in the comment block and insert the symbol name at the
761           right place inside the sections file.
762         </para>
763       </tip>
764     </sect1>
766     <sect1 id="documenting_sections">
767       <title>Documenting sections</title>
769       <para>
770         Each section of the documentation contains information about one class
771         or module. To introduce the component one can write a section block.
772         The short description is also used inside the table of contents.
773         All the @fields are optional.
774       </para>
776       <para>
777         <example><title>Section comment block</title>
778           <programlisting>
779 <![CDATA[
781  * SECTION:meepapp
782  * @short_description: the application class
783  * @title: Meep application
784  * @section_id:
785  * @see_also: #MeepSettings
786  * @stability: Stable
787  * @include: meep/app.h
788  * @image: application.png
790  * The application class handles ...
791  */
793           </programlisting>
794         </example>
795       </para>
797       <variablelist>
798         <varlistentry>
799           <term>SECTION:&lt;name&gt;</term>
800           <listitem>
801             <para>
802               The name links the section documentation to the respective part in
803               the <filename>&lt;package&gt;-sections.txt</filename> file. The
804               name give here should match the &lt;FILE&gt; tag in the 
805               <filename>&lt;package&gt;-sections.txt</filename> file.
806             </para>
807           </listitem>
808         </varlistentry>
809         <varlistentry>
810           <term>@short_description</term>
811           <listitem>
812             <para>
813               A one line description of the section, that later will appear after
814               the links in the TOC and at the top of the section page.
815             </para>
816           </listitem>
817         </varlistentry>
818         <varlistentry>
819           <term>@title</term>
820           <listitem>
821             <para>
822               The section title defaults to &lt;name&gt; from the SECTION
823               declaration. It can be overridden with the @title field.
824             </para>
825           </listitem>
826         </varlistentry>
827         <varlistentry>
828           <term>@section_id</term>
829           <listitem>
830             <para>
831               Overrides the use of title as a section identifier. For GObjects
832               the &lt;title&gt; is used as a section_id and for other sections
833               it is &lt;MODULE&gt;-&lt;title&gt;.
834             </para>
835           </listitem>
836         </varlistentry>
837         <varlistentry>
838           <term>@see_also</term>
839           <listitem>
840             <para>
841               A list of symbols that are related to this section.
842             </para>
843           </listitem>
844         </varlistentry>
845         <varlistentry>
846           <term>@stability</term>
847           <listitem>
848             <para>
849               A informal description of the stability level this API has.
850               We recommend the use of one of these terms:
851               <itemizedlist>
852                 <listitem>
853                   <para>
854                     Stable
855                     - The intention of a Stable interface is to enable arbitrary
856                     third parties to develop applications to these interfaces,
857                     release them, and have confidence that they will run on all
858                     minor releases of the product (after the one in which the
859                     interface was introduced, and within the same major release).
860                     Even at a major release, incompatible changes are expected
861                     to be rare, and to have strong justifications.
862                   </para>
863                 </listitem>
864                 <listitem>
865                   <para>
866                     Unstable
867                     - Unstable interfaces are experimental or transitional.
868                     They are typically used to give outside developers early
869                     access to new or rapidly changing technology, or to provide
870                     an interim solution to a problem where a more general
871                     solution is anticipated.
872                     No claims are made about either source or binary
873                     compatibility from one minor release to the next.
874                   </para>
875                 </listitem>
876                 <listitem>
877                   <para>
878                     Private
879                     - An interface that can be used within the GNOME stack
880                     itself, but that is not documented for end-users. Such
881                     functions should only be used in specified and documented
882                     ways.
883                   </para>
884                 </listitem>
885                 <listitem>
886                   <para>
887                     Internal
888                     - An interface that is internal to a module and does not
889                     require end-user documentation. Functions that are
890                     undocumented are assumed to be Internal.
891                   </para>
892                 </listitem>
893               </itemizedlist>
894             </para>
895           </listitem>
896         </varlistentry>
897         <varlistentry>
898           <term>@include</term>
899           <listitem>
900             <para>
901               The <literal>#include</literal> files to show in the section
902               synopsis (a comma separated list), overriding the global
903               value from the <link linkend="metafiles_sections">section
904               file</link> or command line.  This item is optional.
905             </para>
906           </listitem>
907         </varlistentry>
908         <varlistentry>
909           <term>@image</term>
910           <listitem>
911             <para>
912               The image to display at the top of the reference page for this
913               section.  This will often be some sort of a diagram to illustrate
914               the visual appearance of a class or a diagram of its relationship
915               to other classes.  This item is optional.
916             </para>
917           </listitem>
918         </varlistentry>
919       </variablelist>
921       <tip>
922         <para>
923           To avoid unnecessary recompilation after doc-changes put the section
924           docs into the c-source where possible.
925         </para>
926       </tip>
928     </sect1>
930     <sect1 id="documenting_symbols">
931       <title>Documenting symbols</title>
933       <para>
934         Each symbol (function, macro, struct, enum, signal and property) is
935         documented in a separate block. The block is best placed close to the
936         definition of the symbols so that it is easy to keep them in sync.
937         Thus functions are usually documented in the c-source and macros,
938         structs and enums in the header file.
939       </para>
941       <sect2><title>General tags</title>
943         <para>
944           You can add versioning information to all documentation elements to tell
945           when an api was introduced, or when it was deprecated.
946         </para>
948         <variablelist><title>Versioning Tags</title>
949           <varlistentry><term>Since:</term>
950             <listitem>
951               <para>
952                 Description since which version of the code the API is available.
953               </para>
954             </listitem>
955           </varlistentry>
956           <varlistentry><term>Deprecated:</term>
957             <listitem>
958               <para>
959                 Paragraph denoting that this function should no be used anymore.
960                 The description should point the reader to the new API.
961               </para>
962             </listitem>
963           </varlistentry>
964         </variablelist>
966           <para>
967             (FIXME : Stability information)
968           </para>
970         <example><title>General tags</title>
971           <programlisting>
972 <![CDATA[
974  * foo_get_bar:
975  * @foo: some foo
977  * Retrieves @foo's bar.
979  * Returns: @foo's bar
981  * Since: 2.6
982  * Deprecated: 2.12: Use foo_baz_get_bar() instead.
983  **/
984 Bar *
985 foo_get_bar(Foo *foo)
989           </programlisting>
990         </example>
991       </sect2>
993       <sect2><title>Function comment block</title>
995         <para>
996           Please remember to:
997           <itemizedlist>
998             <listitem>
999               <para>
1000                 Document whether returned objects, lists, strings, etc, should be
1001                 freed/unrefed/released.
1002               </para>
1003             </listitem>
1004             <listitem>
1005               <para>
1006                 Document whether parameters can be NULL, and what happens if they are.
1007               </para>
1008             </listitem>
1009             <listitem>
1010               <para>
1011                 Mention interesting pre-conditions and post-conditions where appropriate.
1012               </para>
1013             </listitem>
1014           </itemizedlist>
1015         </para>
1017         <para>
1018           Gtk-doc assumes all symbols (macros, functions) starting with '_' are
1019           private. They are treated like static functions.
1020         </para>
1022         <para>
1023           <!-- FIXME: we should ideally link/describe the gobject introspection
1024           annotation tag -->
1025           Also, take a look at gobject introspection annotation tags:
1026           http://live.gnome.org/GObjectIntrospection/Annotations
1027         </para>
1029         <example><title>Function comment block</title>
1030           <programlisting>
1031 <![CDATA[
1033  * function_name:
1034  * @par1:  description of parameter 1. These can extend over more than
1035  * one line.
1036  * @par2:  description of parameter 2
1037  * @...: a %NULL-terminated list of bars
1039  * The function description goes here. You can use @par1 to refer to parameters
1040  * so that they are highlighted in the output. You can also use %constant
1041  * for constants, function_name2() for functions and #GtkWidget for links to
1042  * other declarations (which may be documented elsewhere).
1044  * Returns: an integer.
1046  * Since: 2.2
1047  * Deprecated: 2.18: Use other_function() instead.
1048  */
1050           </programlisting>
1051         </example>
1053         <variablelist><title>Function tags</title>
1054           <varlistentry><term>Returns:</term>
1055             <listitem>
1056               <para>
1057                 Paragraph describing the returned result.
1058               </para>
1059             </listitem>
1060           </varlistentry>
1061           <varlistentry><term>@...:</term>
1062             <listitem>
1063               <para>
1064                 In case the function has variadic arguments, you should use this
1065                 tag (@Varargs: does also work for historic reasons).
1066               </para>
1067             </listitem>
1068           </varlistentry>
1069         </variablelist>
1071       </sect2>
1073       <sect2><title>Property comment block</title>
1075         <example><title>Property comment block</title>
1076           <programlisting>
1077 <![CDATA[
1079  * SomeWidget:some-property:
1081  * Here you can document a property.
1082  */
1083 g_object_class_install_property (object_class, PROP_SOME_PROPERTY, ...);
1085           </programlisting>
1086         </example>
1088       </sect2>
1090       <sect2><title>Signal comment block</title>
1092         <para>
1093           Please remember to:
1094           <itemizedlist>
1095             <listitem>
1096               <para>
1097                 Document when the signal is emitted and whether it is emitted before
1098                 or after other signals.
1099               </para>
1100             </listitem>
1101             <listitem>
1102               <para>
1103                 Document what an application might do in the signal handler.
1104               </para>
1105             </listitem>
1106           </itemizedlist>
1107         </para>
1109         <example><title>Signal comment block</title>
1110           <programlisting>
1111 <![CDATA[
1113  * FooWidget::foobarized:
1114  * @widget: the widget that received the signal
1115  * @foo: some foo
1116  * @bar: some bar
1118  * The ::foobarized signal is emitted each time someone tries to foobarize @widget.
1119  */
1120 foo_signals[FOOBARIZE] =
1121   g_signal_new ("foobarize",
1122                 ...
1124           </programlisting>
1125         </example>
1127       </sect2>
1129       <sect2><title>Struct comment block</title>
1130         <example><title>Struct comment block</title>
1131           <programlisting>
1132 <![CDATA[
1134  * FooWidget:
1135  * @bar: some #gboolean
1137  * This is the best widget, ever.
1138  */
1139 typedef struct _FooWidget {
1140   /*< private >*/
1141   GtkWidget parent;
1143   /*< public >*/
1144   gboolean bar;
1145 } FooWidget;
1147           </programlisting>
1148         </example>
1150         <para>
1151           Use <code>/*&lt; private &gt;*/</code> before the private struct fields
1152           you want to hide. Use <code>/*&lt; public &gt;*/</code> for the reverse
1153           behaviour.
1154         </para>
1155         
1156         <para>
1157           Struct comment blocks can also be used for GObjects and GObjectClasses.
1158           It is usualy a good idea to add a comment blco for a class, if it has
1159           vmethods (as this is how they can be documented). For the GObject
1160           itself one can use the related section docs, having a separate block
1161           for the instance struct would be useful if the instance has public
1162           fields. One disadvantage here is that this creates two index entries
1163           of the same name (the structure and the section).
1164         </para>
1166       </sect2>
1168       <sect2><title>Enum comment block</title>
1169         <example><title>Enum comment block</title>
1170           <programlisting>
1171 <![CDATA[
1173  * Something:
1174  * @SOMETHING_FOO: something foo
1175  * @SOMETHING_BAR: something bar
1177  * Enum values used for the thing, to specify the thing.
1179  **/
1180 typedef enum {
1181   SOMETHING_FOO,
1182   SOMETHING_BAR,
1183   /*< private >*/
1184   SOMETHING_COUNT
1185 } Something;
1187           </programlisting>
1188         </example>
1190         <para>
1191           Use <code>/*&lt; private &gt;*/</code> before the private enum values
1192           you want to hide. Use <code>/*&lt; public &gt;*/</code> for the reverse
1193           behaviour.
1194         </para>
1196       </sect2>
1197     </sect1>
1199     <sect1 id="documenting_docbook">
1200       <title>Useful DocBook tags</title>
1202       <para>
1203         Here are some DocBook tags which are most useful when documenting the
1204         code.
1205       </para>
1207       <para>
1208         To link to another section in the GTK docs:
1210         <informalexample>
1211           <programlisting>
1212 <![CDATA[
1213 <link linkend="glib-Hash-Tables">Hash Tables</link>
1215           </programlisting>
1216         </informalexample>
1217         The linkend is the SGML/XML id on the top item of the page you want to link to.
1218         For most pages this is currently the part ("gtk", "gdk", "glib") and then
1219         the page title ("Hash Tables"). For widgets it is just the class name.
1220         Spaces and underscores are converted to '-' to conform to SGML/XML.
1221       </para>
1223       <para>
1224         To refer to an external function, e.g. a standard C function:
1225         <informalexample>
1226           <programlisting>
1227 <![CDATA[
1228 <function>...</function>
1230           </programlisting>
1231         </informalexample>
1232       </para>
1234       <para>
1235         To include example code:
1236         <informalexample>
1237           <programlisting>
1238 <![CDATA[
1239 <example>
1240   <title>Using a GHashTable.</title>
1241   <programlisting>
1242       ...
1243   </programlisting>
1244 </example>
1246           </programlisting>
1247         </informalexample>
1248         or possibly this, for very short code fragments which don't need a title:
1249         <informalexample>
1250           <programlisting>
1251 <![CDATA[
1252 <informalexample>
1253   <programlisting>
1254   ...
1255   </programlisting>
1256 </informalexample>
1258           </programlisting>
1259         </informalexample>
1260         For the latter GTK-Doc also supports an abbreviation:
1261 <![CDATA[
1263   ...
1266       </para>
1268       <para>
1269         To include bulleted lists:
1270         <informalexample>
1271           <programlisting>
1272 <![CDATA[
1273 <itemizedlist>
1274   <listitem>
1275     <para>
1276       ...
1277     </para>
1278   </listitem>
1279   <listitem>
1280     <para>
1281       ...
1282     </para>
1283   </listitem>
1284 </itemizedlist>
1286           </programlisting>
1287         </informalexample>
1288       </para>
1290       <para>
1291         To include a note which stands out from the text:
1292         <informalexample>
1293           <programlisting>
1294 <![CDATA[
1295 <note>
1296   <para>
1297     Make sure you free the data after use.
1298   </para>
1299 </note>
1301           </programlisting>
1302         </informalexample>
1303       </para>
1305       <para>
1306         To refer to a type:
1307         <informalexample>
1308           <programlisting>
1309 <![CDATA[
1310 <type>unsigned char</type>
1312           </programlisting>
1313         </informalexample>
1314       </para>
1316       <para>
1317         To refer to an external structure (not one described in the GTK docs):
1318         <informalexample>
1319           <programlisting>
1320 <![CDATA[
1321 <structname>XFontStruct</structname>
1323           </programlisting>
1324         </informalexample>
1325       </para>
1327       <para>
1328         To refer to a field of a structure:
1329         <informalexample>
1330           <programlisting>
1331 <![CDATA[
1332 <structfield>len</structfield>
1334           </programlisting>
1335         </informalexample>
1336       </para>
1338       <para>
1339         To refer to a class name, we could possibly use:
1340         <informalexample>
1341           <programlisting>
1342 <![CDATA[
1343 <classname>GtkWidget</classname>
1345           </programlisting>
1346         </informalexample>
1347         but you'll probably be using #GtkWidget instead (to automatically create
1348         a link to the GtkWidget page - see <link linkend="documenting_syntax">the abbreviations</link>).
1349       </para>
1351       <para>
1352         To emphasize text:
1353         <informalexample>
1354           <programlisting>
1355 <![CDATA[
1356 <emphasis>This is important</emphasis>
1358           </programlisting>
1359         </informalexample>
1360       </para>
1362       <para>
1363         For filenames use:
1364         <informalexample>
1365           <programlisting>
1366 <![CDATA[
1367 <filename>/home/user/documents</filename>
1369           </programlisting>
1370         </informalexample>
1371       </para>
1373       <para>
1374         To refer to keys use:
1375         <informalexample>
1376           <programlisting>
1377 <![CDATA[
1378 <keycombo><keycap>Control</keycap><keycap>L</keycap></keycombo>
1380           </programlisting>
1381         </informalexample>
1382       </para>
1384     </sect1>
1385   </chapter>
1387   <chapter id="metafiles">
1388     <title>Filling the extra files</title>
1390     <para>
1391       There are a couple of extra files, that need to be maintained along with
1392       the inline source code comments:
1393       <filename>&lt;package&gt;.types</filename>,
1394       <filename>&lt;package&gt;-docs.sgml</filename>,
1395       <filename>&lt;package&gt;-sections.txt</filename>.
1396     </para>
1398     <sect1 id="metafiles_types">
1399       <title>Editing the types file</title>
1401       <para>
1402         If your library or application includes GtkObjects/GObjects, you want
1403         their signals, arguments/parameters and position in the hierarchy to be
1404         shown in the documentation. All you need to do, is to list the
1405         <function>xxx_get_type</function> functions together with their include
1406         inside the <filename>&lt;package&gt;.types</filename> file.
1407       </para>
1409       <para>
1410         <example><title>Example types file snippet</title>
1411           <programlisting>
1412 <![CDATA[
1413 #include <gtk/gtk.h>
1415 gtk_accel_label_get_type
1416 gtk_adjustment_get_type
1417 gtk_alignment_get_type
1418 gtk_arrow_get_type
1420           </programlisting>
1421         </example>
1422       </para>
1424       <para>
1425         Since GTK-Doc 1.8 <application>gtkdoc-scan</application> can generate this list for you.
1426         Just add "--rebuild-types" to SCAN_OPTIONS in <filename>Makefile.am</filename>. If you
1427         use this approach you should not dist the types file nor have it under version control.
1428       </para>
1430     </sect1>
1432     <sect1 id="metafiles_master">
1433       <title>Editing the master document</title>
1435       <para>
1436         GTK-Doc produces documentation in DocBook SGML/XML. When processing the
1437         inline source comments, the GTK-Doc tools generate one documentation
1438         page per class or module as a separate file. The master document
1439         includes them and place them in an order.
1440       </para>
1442       <para>
1443         While GTK-Doc creates a template master document for you, later run will
1444         not touch it again. This means that one can freely structure the
1445         documentation. That includes grouping pages and adding extra pages.
1446         GTK-Doc has now a test suite, where also the master-document is recreated from scratch.
1447         Its a good idea to look at this from time to time to see if there are some new goodies
1448         introduced there.
1449       </para>
1451       <tip>
1452         <para>
1453           Do not create tutorials as extra documents. Just write extra chapters.
1454           The benefit of directly embedding the tutorial for your library into
1455           the API documentation is that it is easy to link for the tutorial to
1456           symbol documentation. Apart chances are higher that the tutorial gets
1457           updates along with the library.
1458         </para>
1459       </tip>
1461       <para>
1462         So what are the things to change inside the master document? For a start
1463         is only a little. There are some placeholders (text in square brackets)
1464         there which you should take care of.
1465       </para>
1467       <para>
1468         <example><title>Master document header</title>
1469           <programlisting>
1470 <![CDATA[
1471 <bookinfo>
1472   <title>MODULENAME Reference Manual</title>
1473   <releaseinfo>
1474     for MODULENAME [VERSION]
1475     The latest version of this documentation can be found on-line at
1476     <ulink role="online-location" url="http://[SERVER]/MODULENAME/index.html">http://[SERVER]/MODULENAME/</ulink>.
1477   </releaseinfo>
1478 </bookinfo>
1480 <chapter>
1481   <title>[Insert title here]</title>
1483           </programlisting>
1484         </example>
1485       </para>
1487     </sect1>
1489     <sect1 id="metafiles_sections">
1490       <title>Editing the section file</title>
1492       <para>
1493         The section file is used to organise the documentation output by
1494         GTK-Doc. Here one specifies which symbol belongs to which module or
1495         class and control the visibility (public or private).
1496       </para>
1498       <para>
1499         The section file is a plain test file with xml like syntax (using tags).
1500         Blank lines are ignored and lines starting with a '#' are treated as
1501         comment lines.
1502       </para>
1504       <para>
1505         The &lt;FILE&gt; ... &lt;/FILE&gt; tag is used to specify the file name,
1506         without any suffix. For example, using '&lt;FILE&gt;gnome-config&lt;/FILE&gt;'
1507         will result in the section declarations being output in the template
1508         file <filename>tmpl/gnome-config.sgml</filename>, which will be
1509         converted into the DocBook SGML/XML file <filename>sgml/gnome-config.sgml</filename>
1510         or .DocBook XML file <filename>xml/gnome-config.xml</filename>.
1511         (The name of the html file is based on the module name and the section
1512         title, or for gobjects it is based on the gobjects class name converted
1513         to lower case).
1514       </para>
1516       <para>
1517         The &lt;TITLE&gt; ... &lt;/TITLE&gt; tag is used to specify the title of
1518         the section. It is only useful before the templates (if used) are
1519         initially created, since the title set in the template file overrides
1520         this. Also if one uses SECTION comment in the sources, this is obsolete.
1521       </para>
1523       <para>
1524         You can group items in the section by using the &lt;SUBSECTION&gt; tag.
1525         Currently it outputs a blank line between subsections in the synopsis
1526         section.
1527         You can also use &lt;SUBSECTION Standard&gt; for standard GObject
1528         declarations (e.g. the functions like g_object_get_type and macros like
1529         G_OBJECT(), G_IS_OBJECT() etc.).
1530         Currently these are left out of the documentation.
1531         You can also use &lt;SUBSECTION Private&gt; for private declarations
1532         which will not be output (It is a handy way to avoid warning messages
1533         about unused declarations.).
1534         If your library contains private types which you don't want to appear in
1535         the object hierarchy and the list of implemented or required interfaces,
1536         add them to a Private subsection.
1537         Wheter you would place GObject and GObjectClass like structs in public
1538         or Standard section depends if they have public entries (variables,
1539         vmethods).
1540       </para>
1542       <para>
1543         You can also use &lt;INCLUDE&gt; ... &lt;/INCLUDE&gt; to specify the
1544         #include files which are shown in the synopsis sections.
1545         It contains a comma-separate list of #include files, without the angle
1546         brackets. If you set it outside of any sections, it acts for all
1547         sections until the end of the file. If you set it within a section, it
1548         only applies to that section.
1549       </para>
1551     </sect1>
1553   </chapter>
1555   <chapter id="reports">
1556     <title>Controlling the result</title>
1558     <para>
1559       A GTK-Doc run generates report files inside the documentation directory.
1560       The generated files are named:
1561       <filename>&lt;package&gt;-undocumented.txt</filename>,
1562       <filename>&lt;package&gt;-undeclared.txt</filename> and
1563       <filename>&lt;package&gt;-unused.txt</filename>.
1564       All those are plain text files that can be viewed and postprocessed easily.
1565     </para>
1567     <para>
1568       The <filename>&lt;package&gt;-undocumented.txt</filename> file starts with
1569       the documentation coverage summary. Below are two sections divided by
1570       blank lines. The first section lists undocumented or incomplete symbols.
1571       The second section does the same for section docs. Incomplete entries are
1572       those, which have documentation, but where e.g. a new parameter has been
1573       added.
1574     </para>
1576     <para>
1577       The <filename>&lt;package&gt;-undeclared.txt</filename> file lists symbols
1578       given in the <filename>&lt;package&gt;-sections.txt</filename> but not
1579       found in the sources. Check if they have been removed or if they are
1580       misspelled.
1581     </para>
1583     <para>
1584       The <filename>&lt;package&gt;-unused.txt</filename> file lists symbol
1585       names, where the GTK-Doc scanner has found documentation, but does not
1586       know where to put it. This means that the symbol has not yet been added to
1587       the <filename>&lt;package&gt;-sections.txt</filename> file.
1588     </para>
1590     <tip>
1591       <para>
1592         Enable or add the <option>TESTS=$(GTKDOC_CHECK)</option> line in Makefile.am.
1593         If at least GTK-Doc 1.9 is installed, this will run sanity checks during
1594         <command>make check</command> run.
1595       </para>
1596     </tip>
1597     
1598     <para>
1599       One can also look at the files produced by the source code scanner:
1600       <filename>&lt;package&gt;-decl-list.txt</filename> and
1601       <filename>&lt;package&gt;-decl.txt</filename>. The first one can be
1602       compared with the section file if that is manualy maintained. The second
1603       lists all declarations fromt he headers If a symbol is missing one could
1604       check if this file contains it.
1605     </para>
1607     <para>
1608       If the project is GObject based, one can also look into the files produced
1609       by the object scanner:
1610       <filename>&lt;package&gt;.args.txt</filename>,
1611       <filename>&lt;package&gt;.hierarchy.txt</filename>,
1612       <filename>&lt;package&gt;.interfaces.txt</filename>,
1613       <filename>&lt;package&gt;.prerequisites.txt</filename> and
1614       <filename>&lt;package&gt;.signals.txt</filename>. If there are missing
1615       symbols in any of those, one can ask gtkdoc to keep the intermedia scanner
1616       file for further analysis, but running it as 
1617       <command>GTK_DOC_KEEP_INTERMEDIATE=1 make</command>.
1618     </para>
1619   </chapter>
1620   
1621   <chapter id="documenting-others">
1622     <title>Documenting other interfaces</title>
1623     
1624     <para>
1625       So far we have been using GTK-Doc to document the API of code. The next
1626       sections contain suggestions how the tools can be used to document other
1627       interfaces too.
1628     </para>
1629     
1630     <sect1 id="commandline-interfaces">
1631       <title>Commandline options and man pages</title>
1632       
1633       <para>
1634         As one can generate man pages for a docbook refentry as well, it sounds
1635         like a good idea to use it for that purpose. This way the interface is
1636         part of the reference and one gets the man-page for free.
1637       </para>
1639       <sect2 id="commandline-interfaces-file">
1640         <title>Document the tool</title>
1642         <para>
1643           Create one refentry file per tool. Following 
1644           <link linkend="settingup_docfiles">our example</link> we would call it
1645           <filename>meep/docs/reference/meeper/meep.xml</filename>. For the xml
1646           tags that should be used and can look at generated file in the xml
1647           subdirectory as well as examples e.g. in glib.
1648         </para>
1649       </sect2>
1651       <sect2 id="commandline-interfaces-configure">
1652         <title>Adding the extra configure check</title>
1654         <para>
1655           <example><title>Extra configure checks</title>
1656             <programlisting>
1657 <![CDATA[
1658 AC_ARG_ENABLE(man,
1659               [AC_HELP_STRING([--enable-man],
1660                               [regenerate man pages from Docbook [default=no]])],enable_man=yes,
1661               enable_man=no)
1663 AC_PATH_PROG([XSLTPROC], [xsltproc])
1664 AM_CONDITIONAL(ENABLE_MAN, test x$enable_man != xno)
1666             </programlisting>
1667           </example>
1668         </para>
1669       </sect2>
1670       
1671       <sect2 id="commandline-interfaces-make">
1672         <title>Adding the extra makefile rules</title>
1673       
1674         <para>
1675           <example><title>Extra configure checks</title>
1676             <programlisting>
1677 <![CDATA[
1678 man_MANS = \
1679        meeper.1
1681 if ENABLE_GTK_DOC
1682 if ENABLE_MAN
1684 %.1 : %.xml
1685         @XSLTPROC@ -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
1687 endif
1688 endif
1690 BUILT_EXTRA_DIST = $(man_MANS)
1691 EXTRA_DIST += meep.xml
1693             </programlisting>
1694           </example>
1695         </para>
1696       </sect2>
1697     </sect1>
1698     
1699     <sect1 id="dbus-interfaces">
1700       <title>DBus interfaces</title>
1702       <para>
1703         (FIXME: http://hal.freedesktop.org/docs/DeviceKit/DeviceKit.html,
1704 http://cgit.freedesktop.org/DeviceKit/DeviceKit/tree/doc/dbus)
1705       </para>
1706     </sect1>
1708   </chapter>
1710   <chapter id="faq">
1711     <title>Frequently asked questions</title>
1713     <segmentedlist>
1714       <?dbhtml list-presentation="list"?>
1715       <segtitle>Question</segtitle>
1716       <segtitle>Answer</segtitle>
1717       <seglistitem>
1718         <seg>No class hierarchy.</seg>
1719         <seg>
1720           The objects <function>xxx_get_type()</function> function has not been
1721           entered into the <filename>&lt;package&gt;.types</filename> file.
1722         </seg>
1723       </seglistitem>
1724       <seglistitem>
1725         <seg>Still no class hierarchy.</seg>
1726         <seg>
1727           Missing or wrong naming in <filename>&lt;package&gt;-sections.txt</filename>
1728           file (see <ulink url="http://mail.gnome.org/archives/gtk-doc-list/2003-October/msg00006.html">explanation</ulink>).
1729         </seg>
1730       </seglistitem>
1731       <seglistitem>
1732         <seg>Damn, I have still no class hierarchy.</seg>
1733         <seg>
1734           Is the object name (name of the instance struct, e.g. <type>GtkWidget</type>)
1735           part of the normal section (don't put this into Standard or Private
1736           subsections).
1737         </seg>
1738       </seglistitem>
1739       <seglistitem>
1740         <seg>No symbol index.</seg>
1741         <seg>
1742           Does the <filename>&lt;package&gt;-docs.{xml,sgml}</filename> contain a
1743           index that xi:includes the generated index?
1744         </seg>
1745       </seglistitem>
1746       <seglistitem>
1747         <seg>Symbols are not linked to their doc-section.</seg>
1748         <seg>
1749           Is the doc-comment using the correct markup (added #,% or ())?
1750           Check if the gtkdoc-fixxref warns about unresolvable xrefs.
1751         </seg>
1752       </seglistitem>
1753       <seglistitem>
1754         <seg>A new class does not appear in the docs.</seg>
1755         <seg>
1756           Is the new page xi:included from 
1757           <filename>&lt;package&gt;-docs.{xml,sgml}</filename>.
1758         </seg>
1759       </seglistitem>
1760       <seglistitem>
1761         <seg>A new symbol does not appear in the docs.</seg>
1762         <seg>
1763           Is the doc-comment properly formatted. Check for spelling mistakes in
1764           the begin of the comment. Check if the gtkdoc-fixxref warns about
1765           unresolvable xrefs. Check if the symbol is correctly listed in the
1766           <filename>&lt;package&gt;-sections.txt</filename> in a public subsection.
1767         </seg>
1768       </seglistitem>
1769       <seglistitem>
1770         <seg>A type is missing from the class hierarchy.</seg>
1771         <seg>
1772           If the type is listed in <filename>&lt;package&gt;.hierarchy</filename>
1773           but not in <filename>xml/tree_index.sgml</filename> then double check
1774           that the type is correctly placed in the <filename>&lt;package&gt;-sections.txt</filename>.
1775           If the type instance (e.g. <type>GtkWidget</type>) is not listed or
1776           incidentialy makred private it will not be shown.
1777         </seg>
1778       </seglistitem>
1779       <seglistitem>
1780         <seg>I get foldoc links for all gobject annotations.</seg>
1781         <seg>
1782           Check that <filename>xml/annotation-glossary.xml</filename> is
1783           xi:included from <filename>&lt;package&gt;-docs.{xml,sgml}</filename>.
1784         </seg>
1785       </seglistitem>
1787       <!-- gtk-doc warnings: -->
1788       <seglistitem>
1789         <seg>Parameter described in source code comment block but does not exist</seg>
1790         <seg>Check if the prototype in the header has different parameter names as in the source.</seg>
1791       </seglistitem>
1793       <!-- docbook warnings: -->
1794       <seglistitem>
1795         <seg>multiple "IDs" for constraint linkend: XYZ</seg>
1796         <seg>Symbol XYZ appears twice in <filename>&lt;package&gt;-sections.txt</filename> file.</seg>
1797       </seglistitem>
1798       <seglistitem>
1799         <seg>Element typename in namespace '' encountered in para, but no template matches.</seg>
1800         <seg />
1801       </seglistitem>
1802     </segmentedlist>
1803   </chapter>
1804     
1805   <!-- ======== Appendix: FDL ================================== -->
1806   &FDL;
1808 </book>