<?xml version="1.0" standalone="no"?>
<?xml-stylesheet type="text/xml" href="params.xsl"?>
<!-- vim: set ai tw=80 ts=3 sw=3: -->
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "
              http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [

<!ENTITY FDL SYSTEM "fdl-appendix.xml">
<!ENTITY FDLlink "<link linkend='fdl'>included</link>">
]><!-- =============Document Header ============================= -->
<book id="index">
  <bookinfo>
    <title>GTK-Doc Manual</title>
    <edition>1.11</edition>
    <abstract role="description"><para>User manual for developers with instructions of GTK-Doc usage.</para></abstract>
    <authorgroup>
      <author>
        <firstname>Chris</firstname>
        <surname>Lyttle</surname>
        <affiliation>
          <address>
            <email>chris@wilddev.net</email>
          </address>
        </affiliation>
      </author>
      <author>
        <firstname>Dan</firstname>
        <surname>Mueth</surname>
        <affiliation>
          <address>
            <email>d-mueth@uchicago.edu</email>
          </address>
        </affiliation>
      </author>
      <author>
        <firstname>Stefan</firstname>
        <surname>Kost</surname>
        <affiliation>
          <address>
            <email>ensonic@users.sf.net</email>
          </address>
        </affiliation>
      </author>
    </authorgroup>
    <publisher role="maintainer">
      <publishername>GTK-Doc project</publishername>
      <address><email>gtk-doc-list@gnome.org</email></address>
    </publisher>
    <copyright>
      <year>2000, 2005, 2007-2008</year>
      <holder>Dan Mueth and Chris Lyttle and Stefan Kost</holder>
    </copyright>

    <!-- translators: uncomment this:
    <copyright>
      <year>2000</year>
      <holder>ME-THE-TRANSLATOR (Latin translation)</holder>
    </copyright>
    -->

    <legalnotice>
      <para>
        Permission is granted to copy, distribute and/or modify this
        document under the terms of the <citetitle>GNU Free Documentation
        License</citetitle>, Version 1.1 or any later version published
        by the Free Software Foundation with no Invariant Sections, no
        Front-Cover Texts, and no Back-Cover Texts. A copy of the license
        is &FDLlink;.
      </para>
      <para>
        Many of the names used by companies to distinguish their products and
        services are claimed as trademarks. Where those names appear in any
        GNOME documentation, and those trademarks are made aware to the members
        of the GNOME Documentation Project, the names have been printed in caps
        or initial caps.
      </para>
    </legalnotice>
    
    <revhistory>
      <revision>
	<revnumber>1.11</revnumber>
	<date>22 March 2008</date>
	<authorinitials>mal</authorinitials>
	<revremark>GNOME doc-utils migration</revremark>
      </revision>
    </revhistory>

  </bookinfo>

  <!-- ======== Chapter 1: Introduction ======================== -->

  <chapter id="introduction">
    <title>Introduction</title>

    <para>
      This chapter introduces GTK-Doc and gives an overview of what it is and
      how it is used.
    </para>

    <sect1 id="whatisgtkdoc">
      <title>What is GTK-Doc?</title>

      <para>
        GTK-Doc is used to document C code. It is typically used to document the public
        API of libraries, such as the GTK+ and GNOME libraries. But it can also be
        used to document application code.
      </para>
    </sect1>

    <sect1 id="howdoesgtkdocwork">
      <title>How Does GTK-Doc Work?</title>

      <para>
        GTK-Doc works by using documentation of functions placed inside the source files in
        specially-formatted comment blocks, or documentation added to the template files
        which GTK-Doc uses (though note that GTK-Doc will only document functions that
        are declared in header files; it won't produce output for static functions).
      </para>

      <para>
        GTK-Doc consists of a number of perl scripts, each performing a different step
        in the process.
      </para>

      <para>
        There are 5 main steps in the process:
      </para>

      <orderedlist>

        <listitem>
          <para>
            <guilabel>Writing the documentation.</guilabel>

            The author fills in the source files with the documentation for each
            function, macro, union etc. (In the past information was entered in
            generated template files, which is not recommanded anymore).
          </para>
        </listitem>

        <listitem>
          <para>
            <guilabel>Gathering information about the code.</guilabel>

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

            <application>gtkdoc-scanobj</application> can also be used to dynamically query a library about
            any GtkObject subclasses it exports. It saves information about each
            object's position in the class hierarchy and about any GTK Args and Signals it
            provides.
          </para>
        </listitem>

        <listitem>
          <para>
            <guilabel>Generating the "template" files.</guilabel>

            <application>gtkdoc-mktmpl</application> creates a number of files in
            the <filename class='directory'>tmpl/</filename> subdirectory, using the
            information gathered in the first step. (Note that this can be run
            repeatedly. It will try to ensure that no documentation is ever lost.)
          </para>
          <note>
            <para>
              Since gtk-doc 1.9 the templates can be avoided. We encourage people to keep
              documentation in the code. <application>gtkdocize</application> supports now
              a <command>--flavour no-tmpl</command> option that chooses a makefile that skips tmpl usage totally.
              If you have never changed file in tmpl by hand, please remove the dir once.
            </para>
          </note>
        </listitem>

        <listitem>
          <para>
            <guilabel>Generating the SGML/XML and HTML.</guilabel>

            <application>gtkdoc-mkdb</application> turns the template files into
            SGML or XML files in the <filename class='directory'>sgml/</filename>
            or <filename class='directory'>xml/</filename> subdirectory.
            If the source code contains documentation on functions, using the
            special comment blocks, it gets merged in here. If there are no tmpl files used
            it only reads takes docs from sources and introspection data.

            <application>gtkdoc-mkhtml</application> turns the SGML files into HTML
            files in the <filename class='directory'>html/</filename>  subdirectory.

            Files in <filename class='directory'>sgml/</filename> or
            <filename class='directory'>xml/</filename> and <filename class='directory'>html/</filename>
            directories are always overwritten. One should never edit them directly.
          </para>
        </listitem>

        <listitem>
          <para>
            <guilabel>Fixing up cross-references between documents.</guilabel>

            After installing the HTML files, <application>gtkdoc-fixxref</application> can be run to fix up any
            cross-references between separate documents. For example, the GTK+
            documentation contains many cross-references to types documented in the GLib manual.

            When creating the source tarball for distribution, <application>gtkdoc-rebase</application>
            turns all external links into web-links. When installing distributed (pregenerated) docs
            the same application will try to turn links back to local links
            (where those docs are installed).
          </para>
        </listitem>
      </orderedlist>

    </sect1>

    <sect1 id="gettinggtkdoc">
      <title>Getting GTK-Doc</title>

      <sect2 id="requirements">
        <title>Requirements</title>
        <para>
          <guilabel>Perl v5</guilabel> - the main scripts are in Perl.
        </para>
        <para>
          <guilabel>DocBook DTD v3.0</guilabel> - This is the DocBook SGML DTD.
          <ulink url="http://www.ora.com/davenport" type="http">http://www.ora.com/davenport</ulink>
        </para>
        <para>
          <guilabel>Jade v1.1</guilabel> - This is a DSSSL processor for converting SGML to various formats.
          <ulink url="http://www.jclark.com/jade" type="http">http://www.jclark.com/jade</ulink>
        </para>
        <para>
          <guilabel>Modular DocBook Stylesheets</guilabel>
          This is the DSSSL code to convert DocBook to HTML (and a few other
          formats). It's used together with jade.
          I've customized the DSSSL code slightly, in gtk-doc.dsl, to colour
          the program code listings/declarations, and to support global
          cross-reference indices in the generated HTML.
          <ulink url="http://nwalsh.com/docbook/dsssl" type="http">http://nwalsh.com/docbook/dsssl</ulink>
        </para>
        <para>
          <guilabel>docbook-to-man</guilabel> - if you want to create man pages from the DocBook.
          I've customized the 'translation spec' slightly, to capitalise section
          headings and add the 'GTK Library' title at the top of the pages and the
          revision date at the bottom.
          There is a link to this on <ulink url="http://www.ora.com/davenport" type="http">http://www.ora.com/davenport</ulink>
          NOTE: This does not work yet.
        </para>
      </sect2>

      <sect2 id="installation">
        <title>Installation</title>
        <para>
          There is no standard place where the DocBook Modular Stylesheets are installed.
        </para>
        <para>
          gtk-doc's configure script searches these 3 directories automatically:
        </para>
        <para>
          <filename> /usr/lib/sgml/stylesheets/nwalsh-modular   </filename>     (used by RedHat)
        </para>
        <para>
          <filename>  /usr/lib/dsssl/stylesheets/docbook         </filename>     (used by Debian)
        </para>
        <para>
          <filename>  /usr/share/sgml/docbkdsl                   </filename>     (used by SuSE)
        </para>
        <para>
          If you have the stylesheets installed somewhere else, you need to configure
          gtk-doc using the option:
          <command> --with-dsssl-dir=&lt;PATH_TO_TOPLEVEL_STYLESHEETS_DIR&gt; </command>
        </para>
      </sect2>

    </sect1>

    <!-- not realy worth a section
    <sect1 id="whentousegtkdoc">
      <title>When to Use GTK-Doc</title>

      <para>
        (What things GTK-Doc should, and shouldn't, be used for.)
        (- ???)
        (+ Tutorials)
      </para>

    </sect1>
    -->

    <sect1 id="aboutgtkdoc">
      <title>About GTK-Doc</title>

      <para>
        (FIXME)
      </para>

      <para>
        (History, authors, web pages, license, future plans,
        comparison with other similar systems.)
      </para>

    </sect1>

    <sect1 id="aboutthismanual">
      <title>About this Manual</title>

      <para>
        (FIXME)
      </para>

      <para>
        (who it is meant for, where you can get it, license)
      </para>

    </sect1>

  </chapter>

  <chapter id="settingup">
    <title>Setting up your project</title>

    <para>
      The next sections describe what steps to perform to integrate GTK-Doc into
      your project. Theses section assume we work on a project called 'meep'.
      This project contains alibrary called 'libmeep' and
      an end-user app called 'meeper'.
    </para>

    <sect1 id="settingup_docfiles">
      <title>Setting up a skeleton documentation</title>

      <para>
        Under your top-level project directory create folders called docs/reference
        (this way you can also have docs/help for end-user documentation).
        It is recommended to create another subdirectory with the name of the doc-package.
        For packages with just one library this step is not necessary.
      </para>

      <para>
        This can then look as show below:
        <example><title>Example directory structure</title>
          <programlisting>
<![CDATA[
meep/
  docs/
    reference/
      libmeep/
      meeper/
  src/
    libmeep/
    meeper/
]]>
          </programlisting>
        </example>
      </para>
    </sect1>

    <sect1 id="settingup_autoconf">
      <title>Integration with autoconf</title>

      <para>
        Very easy! Just add one line to your <filename>configure.ac</filename> script.
      </para>

      <para>
        <example><title>Integration with autoconf</title>
          <programlisting>
<![CDATA[
# check for gtk-doc
GTK_DOC_CHECK(1.9)
]]>
          </programlisting>
        </example>
      </para>

      <para>
        Besides checking for the required Gtk-Doc version, this adds two configure
        switches:
      </para>
      <orderedlist>
        <listitem><para>--with-html-dir=PATH : path to installed docs</para></listitem>
        <listitem><para>--enable-gtk-doc : use gtk-doc to build documentation</para></listitem>
      </orderedlist>

      <important>
      	<para>
          Gtk-Doc is disabled by default! Remember to pass the option
          <option>'--enable-gtk-doc'</option> to the next
          <filename>configure</filename> run. Otherwise pregenerated documentation is installed
          (which makes sense for users but not for developers).
        </para>
      </important>

      <para>
        Furthermore it is recommended that you have the following line inside
        you <filename>configure.ac</filename> script.
        This allows <filename>gtkdocize</filename> to automatically copy the
        macro definition for <function>GTK_DOC_CHECK</function> to your project.
      </para>

      <para>
        <example><title>Preparation for gtkdocize</title>
          <programlisting>
<![CDATA[
AC_CONFIG_MACRO_DIR(m4)
]]>
          </programlisting>
        </example>
      </para>
    </sect1>

    <sect1 id="settingup_automake">
      <title>Integration with automake</title>

      <para>
        First copy the <filename>Makefile.am</filename> from the examples subdirectory of the gtkdoc-sources
        to your project's API documentation directory (
        <filename class='directory'>./docs/reference/&lt;package&gt;</filename>).
        If you have multiple doc-packages repeat this for each one.
      </para>

      <para>
        The next step is to edit the setting inside the <filename>Makefile.am</filename>.
        All the settings have a comment above that describes their purpose.
        Most settings are extra flags passed to the respective tools. Every tool
        has a variable of the form <option>&lt;TOOLNAME&gt;_OPTIONS</option>.
        All the tools support <option>--help</option> to list the supported
        parameters.
      </para>

      <!-- FIXME: explain options ? -->

      <para>
        You may also want to enable gtk-doc for the distcheckmake target. Just
        add then one-liner show in the next example to you top-level
        <filename>Makefile.am</filename>:
      </para>

      <para>
        <example><title>Enable gtk-doc during make distcheck</title>
          <programlisting>
<![CDATA[
DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc
]]>
          </programlisting>
        </example>
      </para>

    </sect1>

    <sect1 id="settingup_autogen">
      <title>Integration with autogen</title>

      <para>
        Most projects will have an <filename>autogen.sh</filename> script to
        setup the build infrastructure after a checkout from version control
        system (such as cvs). Gtk-Doc comes with a tool called
        <filename>gtkdocize</filename> which can be used in such a script.
        It should be run before autoheader, automake or autoconf.
      </para>

      <para>
        <example><title>Running gtkdocize from autogen.sh</title>
          <programlisting>
<![CDATA[
gtkdocize || exit 1
]]>
          </programlisting>
        </example>
      </para>

      <para>
        When running <filename>gtkdocize</filename> it copies
        <filename>gtk-doc.make</filename> to you project root (or any directory
        specified by the --docdir option). If also check you configure script
        for the <function>GTK_DOC_CHECK</function> invocation.
      </para>

      <para>
        Historically gtk-doc was gerating template files where developers entered the docs.
        this turned out to be not so good. Since a few version gtk-doc could also get all
        the information from source comments.
        Since gtk-doc 1.9 the templates can be avoided. We encourage people to keep
        documentation in the code. <application>gtkdocize</application> supports now
        a --flavour=no-tmpl option that chooses a makefile that skips tmpl usage totally.
        If you have never changed file in tmpl by hand, please remove the dir once.
      </para>
    </sect1>

    <sect1 id="settingup_firstrun">
      <title>Running the doc build</title>

      <para>
        After the previous steps it's time to run the build. First we need to
	rerun <filename>autogen.sh</filename>. If this script runs configure for
	you, then give it the <option>--enable-gtk-doc</option> option.
	Otherwise manually run <filename>configure</filename> with this option
	afterwards.
      </para>
      <para>
        The first make run generates several additional files in the doc-dirs.
        The important ones are:
        <filename>&lt;package&gt;.types</filename>,
        <filename>&lt;package&gt;-docs.sgml</filename>,
        <filename>&lt;package&gt;-sections.txt</filename>.
      </para>
      <para>
        <example><title>Running the doc build</title>
          <programlisting>
<![CDATA[
./autogen.sh --enable-gtk-doc
make
]]>
          </programlisting>
        </example>
      </para>
      <para>
        Now you can point your browser to <filename>docs/reference/&lt;package&gt;/index.html</filename>.
	Yes, it's a bit disappointing still. But hang-on, during the next chapter we
	tell you how to fill the pages with life.
      </para>
    </sect1>

    <sect1 id="settingup_vcs">
      <title>Integration with version control systems</title>

      <para>
        As a rule of the thumb, it's those files you edit, that should go under
        version control. For typical projects it's these files:
        <filename>&lt;package&gt;.types</filename>
        <filename>&lt;package&gt;-docs.sgml</filename>
        <filename>&lt;package&gt;-sections.txt</filename>
        <filename>Makefile.am</filename>
      </para>
    </sect1>

  </chapter>

  <chapter id="documenting">
    <title>Documenting the code</title>

    <para>
      GTK-Doc uses source code comment with a special syntax for code documentation.
      Further it retrieves information about your project structure from other
      sources. During the next section you find all information about the syntax
      of the comments.
    </para>

    <note>
      <title>Documentation placement</title>
      <para>
        In the past most documentation had to be filled into files residing
	inside the <filename>tmpl</filename> directory. This has the
	disadvantages that the information is often not updated and also that
	the file tend to cause conflicts with version control systems.
      </para>
      <para>
        The avoid the aforementioned problems we suggest putting the
	documentation inside the sources. This manual will only describe this
	way of documenting code.
      </para>
    </note>

    <!--  -->

    <sect1 id="documenting_syntax">
      <title>Documentation comments</title>

      <para>
        A multiline comment that starts with an additional '*' marks a
        documentation block that will be processed by the Gtk-Doc tools.
        <example><title>Gtk-Doc comment block</title>
          <programlisting>
<![CDATA[
/**
 * identifier:
 * documentation ...
 */
]]>
          </programlisting>
        </example>
      </para>

      <para>
        The 'identifier' is one line with the name of the item the comment is
        related to. The	syntax differs a little depending on the item.
        (TODO add table showing identifiers)
      </para>

      <para>
        The 'documentation' block is also different for each symbol type. Symbol
        types that get parameters such as functions or macros have the parameter
        description first followed by a blank line (just a '*').
        Afterwards follows the detailed description. All lines just containing a
        ' * ' (blank-asterisk-blank) are converted to paragraph breaks.
        If you don't want a break (e.g. in preformatted example listings) add
        another space at the end of line.
      </para>

      <para>
        One advantage of hyper-text over plain-text is the ability to have links
        in the document. Writing the correct markup for a link can be tedious
        though. Gtk-Doc comes to help by providing several useful abbreviations.
        <itemizedlist>
          <listitem>
            <para>
              Use function() to refer to functions or macros which take arguments.
            </para>
          </listitem>
          <listitem>
            <para>
              Use @param to refer to parameters. Also use this when referring to
              parameters of other functions, related to the one being described.
            </para>
          </listitem>
          <listitem>
            <para>
              Use %constant to refer to a constant, e.g. %G_TRAVERSE_LEAFS.
            </para>
          </listitem>
          <listitem>
            <para>
              Use #symbol to refer to other types of symbol, e.g. structs and
              enums and macros which don't take arguments.
            </para>
          </listitem>
          <listitem>
            <para>
              Use #Object::signal to refer to a GObject signal
            </para>
          </listitem>
          <listitem>
            <para>
              Use #Object:property to refer to a GObject property
            </para>
          </listitem>
        </itemizedlist>
      </para>

      <tip>
	<para>
	  If you need to use the special characters '()', '@', '%', or '#'
	  in your documentation without gtk-doc changing them you can use the
	  XML entities
	  "&amp;lpar;", "&amp;rpar;", "&amp;commat;", "&amp;percnt;" and
	  "&amp;num;" respectively.
	</para>
      </tip>

      <para>
        DocBook can do more that just links. One can also have lists, tables and
        examples. To enable the usage of SGML/XML tags inside doc-comments you
        need to have <option>--sgml-mode</option> in the variable
        <symbol>MKDB_OPTIONS</symbol> inside <filename>Makefile.am</filename>.
      </para>

      <tip>
	<para>
	  As already mentioned earlier Gtk-Doc is for documenting public API. Thus
	  one cannot write documentation for static symbols. Nevertheless it is good
	  to comment those symbols too. This helps other to understand you code.
	  Therefore we recommend to comment these using normal comments (without the
	  2nd '*' in the first line).
	  If later the function needs to be made public, all one needs to do is to
	  add another '*' in the comment block and insert the symbol name at the
	  right place inside the sections file.
	</para>
      </tip>
    </sect1>

    <sect1 id="documenting_sections">
      <title>Documenting sections</title>

      <para>
        Each section of the documentation contains information about one class
        or module. To introduce the component one can write a section block.
        The short description is also used inside the table of contents.
      </para>

      <para>
        <example><title>Section comment block</title>
          <programlisting>
<![CDATA[
/**
 * SECTION:meepapp
 * @short_description: the application class
 * @see_also: #MeepSettings
 * @stability: Stable
 * @include: meep/app.h
 *
 * The application class handles ...
 */
]]>
          </programlisting>
        </example>
      </para>

      <variablelist>
        <varlistentry>
          <term>@short_description</term>
          <listitem>
            <para>
              A one line description of the section, that later will appear after
              the links in the TOC and at the top of the section page.
            </para>
          </listitem>
        </varlistentry>
        <varlistentry>
          <term>@see_also</term>
          <listitem>
            <para>
              A list of symbols that are related to this section..
            </para>
          </listitem>
        </varlistentry>
        <varlistentry>
          <term>@stability</term>
          <listitem>
            <para>
              A informal description of the stability level this API has.
              We recommend the use of one of these terms:
              <itemizedlist>
                <listitem>
                  <para>
                    Stable
                    - The intention of a Stable interface is to enable arbitrary
                    third parties to develop applications to these interfaces,
                    release them, and have confidence that they will run on all
                    minor releases of the product (after the one in which the
                    interface was introduced, and within the same major release).
                    Even at a major release, incompatible changes are expected
                    to be rare, and to have strong justifications.
                  </para>
                </listitem>
                <listitem>
                  <para>
                    Unstable
                    - Unstable interfaces are experimental or transitional.
                    They are typically used to give outside developers early
                    access to new or rapidly changing technology, or to provide
                    an interim solution to a problem where a more general
                    solution is anticipated.
                    No claims are made about either source or binary
                    compatibility from one minor release to the next.
                  </para>
                </listitem>
                <listitem>
                  <para>
                    Private
                    - An interface that can be used within the GNOME stack
                    itself, but that is not documented for end-users. Such
                    functions should only be used in specified and documented
                    ways.
                  </para>
                </listitem>
                <listitem>
                  <para>
                    Internal
                    - An interface that is internal to a module and does not
                    require end-user documentation. Functions that are
                    undocumented are assumed to be Internal.
                  </para>
                </listitem>
              </itemizedlist>
            </para>
          </listitem>
        </varlistentry>
        <varlistentry>
          <term>@include</term>
          <listitem>
            <para>
              The <literal>#include</literal> files to show in the section
              synopsis (a comma separated list), overriding the global
              value from the <link linkend="metafiles_sections">section
              file</link> or command line.  This item is optional.
            </para>
          </listitem>
        </varlistentry>
      </variablelist>

      <para>
        FIXME
        having @title here, would put this title into a newly generated section
        file, but later would be obsolete (right?)
      </para>

      <tip>
        <para>
          To avoid unnecessary recompilation after doc-changes put the section
          docs into the c-source where possible.
        </para>
      </tip>

    </sect1>

    <sect1 id="documenting_symbols">
      <title>Documenting symbols</title>

      <para>
        Each symbol (function, macro, struct, enum, signal and property) is
        documented in a separate block. The block is best placed close to the
        definition of the symbols so that it is easy to keep them in sync.
        Thus function are usually documented in the c-source and macros, struct
        and enum in the header file.
      </para>

      <para>
        <example><title>Function comment block</title>
          <programlisting>
<![CDATA[
/**
 * function_name:
 * @par1:  description of parameter 1. These can extend over more than
 * one line.
 * @par2:  description of parameter 2
 *
 * The function description goes here. You can use @par1 to refer to parameters
 * so that they are highlighted in the output. You can also use %constant
 * for constants, function_name2() for functions and #GtkWidget for links to
 * other declarations (which may be documented elsewhere).
 *
 * Returns: an integer.
 */
]]>
          </programlisting>
        </example>
      </para>

      <variablelist>
        <varlistentry>
          <term>Returns:</term>
          <listitem>
            <para>
              Paragraph describing the returned result.
            </para>
          </listitem>
        </varlistentry>
        <varlistentry>
          <term>Deprecated:</term>
          <listitem>
            <para>
              Paragraph denoting that this function should no be used anymore.
              The description should point the reader to the new API.
            </para>
          </listitem>
        </varlistentry>
        <varlistentry>
          <term>Since:</term>
          <listitem>
            <para>
              Description since which version of the code the API is available.
            </para>
          </listitem>
        </varlistentry>
      </variablelist>

      <para>
        Gtk-doc assumes all symbols (macros, functions) starting with '_' are
        private. They are treated like static functions.
      </para>

      <para>
        (FIXME)
        (stability)
        (glib-enums, ...)
      </para>

      <example><title>Property comment block</title>
        <programlisting>
<![CDATA[
/**
 * SomeWidget:some-property:
 *
 * Here you can document a property.
 */
g_object_class_install_property (object_class, PROP_SOME_PROPERTY, ...);
]]></programlisting>
      </example>

      <example><title>Signal comment block</title>
        <programlisting>
<![CDATA[
/**
 * FooWidget::foobarized:
 * @widget: the widget that received the signal
 * @foo: some foo
 * @bar: some bar
 *
 * The ::foobarized signal is emitted each time someone tries to foobarize @widget.
 */
foo_signals[FOOBARIZE] =
  g_signal_new ("foobarize",
                ...
]]></programlisting>
      </example>

         <example><title>Struct comment block</title>
        <programlisting>
<![CDATA[
/**
 * FooWidget:
 * @bar: some #gboolean
 *
 * This is the best widget, ever.
 */
typedef struct _FooWidget {
  GtkWidget parent;
  /*< public >*/
  gboolean bar;
} FooWidget;
]]></programlisting>
      </example>
    </sect1>

    <sect1 id="documenting_docbook">
      <title>Useful DocBook tags</title>

      <para>
        Here are some DocBook tags which are most useful when documenting the
        code.
      </para>

      <para>
        To link to another section in the GTK docs:

        <informalexample>
          <programlisting>
<![CDATA[
<link linkend="glib-Hash-Tables">Hash Tables</link>
]]>
          </programlisting>
        </informalexample>
        The linkend is the SGML id on the top item of the page you want to link to.
        For most pages this is currently the part ("gtk", "gdk", glib") and then
        the page title ("Hash Tables"). For widgets it is just the class name.
        Spaces and underscores are converted to '-' to conform to SGML.
      </para>

      <para>
        To refer to an external function, e.g. a standard C function:
        <informalexample>
          <programlisting>
<![CDATA[
<function>...</function>
]]>
          </programlisting>
        </informalexample>
      </para>

      <para>
        To include example code:
        <informalexample>
          <programlisting>
<![CDATA[
<example>
  <title>Using a GHashTable.</title>
  <programlisting>
      ...
  </programlisting>
</example>
]]>
          </programlisting>
        </informalexample>
        or possibly this, for very short code fragments which don't need a title:
        <informalexample>
          <programlisting>
<![CDATA[
<informalexample>
  <programlisting>
  ...
  </programlisting>
</informalexample>
]]>
          </programlisting>
        </informalexample>
        For the latter gtk-doc also supports an abbreviation:
<![CDATA[
|[
  ...
]|
]]>
      </para>

      <para>
        To include bulleted lists:
        <informalexample>
          <programlisting>
<![CDATA[
<itemizedlist>
  <listitem>
    <para>
      ...
    </para>
  </listitem>
  <listitem>
    <para>
      ...
    </para>
  </listitem>
</itemizedlist>
]]>
          </programlisting>
        </informalexample>
      </para>

      <para>
        To include a note which stands out from the text:
        <informalexample>
          <programlisting>
<![CDATA[
<note>
  <para>
    Make sure you free the data after use.
  </para>
</note>
]]>
          </programlisting>
        </informalexample>
      </para>

      <para>
        To refer to a type:
        <informalexample>
          <programlisting>
<![CDATA[
<type>unsigned char</type>
]]>
          </programlisting>
        </informalexample>
      </para>

      <para>
        To refer to an external structure (not one described in the GTK docs):
        <informalexample>
          <programlisting>
<![CDATA[
<structname>XFontStruct</structname>
]]>
          </programlisting>
        </informalexample>
      </para>

      <para>
        To refer to a field of a structure:
        <informalexample>
          <programlisting>
<![CDATA[
<structfield>len</structfield>
]]>
          </programlisting>
        </informalexample>
      </para>

      <para>
        To refer to a class name, we could possibly use:
        <informalexample>
          <programlisting>
<![CDATA[
<classname>GtkWidget</classname>
]]>
          </programlisting>
        </informalexample>
        but you'll probably be using #GtkWidget instead (to automatically create
        a link to the GtkWidget page - see <link linkend="documenting_syntax">the abbreviations</link>).
      </para>

      <para>
        To emphasize text:
        <informalexample>
          <programlisting>
<![CDATA[
<emphasis>This is important</emphasis>
]]>
          </programlisting>
        </informalexample>
      </para>

      <para>
        For filenames use:
        <informalexample>
          <programlisting>
<![CDATA[
<filename>/home/user/documents</filename>
]]>
          </programlisting>
        </informalexample>
      </para>

    </sect1>
  </chapter>

  <chapter id="metafiles">
    <title>Filling the extra files</title>

    <para>
      There are a couple of extra file, that need to be maintained along with
      the inline source code comments:
      <filename>&lt;package&gt;.types</filename>,
      <filename>&lt;package&gt;-docs.sgml</filename>,
      <filename>&lt;package&gt;-sections.txt</filename>.
    </para>

    <sect1 id="metafiles_types">
      <title>Editing the types file</title>

      <para>
        If your library or application includes GtkObjects/GObjects, you want
        their signals, arguments/parameters and position in the hierarchy to be
        shown in the documentation. All you need to do, is to list the
        <function>xxx_get_type</function> functions together with their include
        inside the <filename>&lt;package&gt;.types</filename> file.
      </para>

      <para>
        <example><title>Example types file snippet</title>
          <programlisting>
<![CDATA[
#include <gtk/gtk.h>

gtk_accel_label_get_type
gtk_adjustment_get_type
gtk_alignment_get_type
gtk_arrow_get_type
]]>
          </programlisting>
        </example>
      </para>

      <para>
        Since gtk-doc 1.8 <application>gtkdoc-scan</application> can generate this list for you.
        Just add "--rebuild-types" to SCAN_OPTIONS in <filename>Makefile.am</filename>. If you
        use this approach you should not dist the types file nor have it under version control.
      </para>

    </sect1>

    <sect1 id="metafiles_master">
      <title>Editing the master document</title>

      <para>
        Gtk-Doc produces documentation in DocBook SGML/XML. When processing the
        inline source comments, the Gtk-Doc tools generate one documentation
        page per class or module as a separate file. The master document
        includes them and place them in a order.
      </para>

      <para>
        While Gtk-Doc creates a template master document for you, later run will
        not touch it again. This means that one can freely structure the
        documentation. That includes grouping pages and adding extra pages.
        Gtk-doc has now a test suite, where also the master-document is recreated from scratch.
        Its a good idea to look at this from time to time to see if there are some new goodies
        introduced there.
      </para>

      <tip>
        <para>
          Do not create tutorials as extra documents. Just write extra chapters.
          The benefit of directly embedding the tutorial for your library into
          the API documentation is that it is easy to link for the tutorial to
          symbol documentation. Apart chances are higher that the tutorial gets
          updates along with the library.
        </para>
      </tip>

      <para>
        So what are the things to change inside the master document? For a start
        is only a little. There are some placeholders (text in square brackets)
        there which you should take care of.
      </para>

      <para>
        <example><title>Master document header</title>
          <programlisting>
<![CDATA[
<bookinfo>
  <title>MODULENAME Reference Manual</title>
  <releaseinfo>
    for MODULENAME [VERSION]
    The latest version of this documentation can be found on-line at
    <ulink role="online-location" url="http://[SERVER]/MODULENAME/index.html">http://[SERVER]/MODULENAME/</ulink>.
  </releaseinfo>
</bookinfo>

<chapter>
  <title>[Insert title here]</title>
]]>
          </programlisting>
        </example>
      </para>

    </sect1>

    <sect1 id="metafiles_sections">
      <title>Editing the section file</title>

      <para>
        The section file is used to organise the documentation output by
        Gtk-Doc. Here one specifies which symbol belongs to which module or
        class and control the visibility (public or private).
      </para>

      <para>
        The section file is a plain test file with xml like syntax (using tags).
        Blank lines are ignored and lines starting with a '#' are treated as
        comment lines.
      </para>

      <para>
        The &lt;FILE&gt; ... &lt;/FILE&gt; tag is used to specify the file name,
        without any suffix. For example, using '&lt;FILE&gt;gnome-config&lt;/FILE&gt;'
        will result in the section declarations being output in the template
        file <filename>tmpl/gnome-config.sgml</filename>, which will be
        converted into the DocBook SGML file <filename>sgml/gnome-config.sgml</filename>
        or .DocBook XML file <filename>xml/gnome-config.xml</filename>.
        (The name of the html file is based on the module name and the section
        title, or for gobjects it is based on the gobjects class name converted
        to lower case).
      </para>

      <para>
        The &lt;TITLE&gt; ... &lt;/TITLE&gt; tag is used to specify the title of
        the section. It is only useful before the templates are initially
        created, since the title set in the template file overrides this.
      </para>

      <para>
        You can group items in the section by using the &lt;SUBSECTION&gt; tag.
        Currently it outputs a blank line between subsections in the synopsis
        section.
        You can also use &lt;SUBSECTION Standard&gt; for standard GObject
        declarations (e.g. the functions like g_object_get_type and macros like
        G_OBJECT(), G_IS_OBJECT() etc.).
        Currently these are left out of the documentation.
        You can also use &lt;SUBSECTION Private&gt; for private declarations
        which will not be output (It is a handy way to avoid warning messages
        about unused declarations.).
        If your library contains private types which you don't want to appear in
        the object hierarchy and the list of implemented or required interfaces,
        add them to a Private subsection.
      </para>

      <para>
        You can also use &lt;INCLUDE&gt; ... &lt;/INCLUDE&gt; to specify the
        #include files which are shown in the synopsis sections.
        It contains a comma-separate list of #include files, without the angle
        brackets. If you set it outside of any sections, it acts for all
        sections until the end of the file. If you set it within a section, it
        only applies to that section.
      </para>

    </sect1>

  </chapter>

  <chapter id="reports">
    <title>Controlling the result</title>

    <para>
      A Gtk-Doc run generates report files inside the documentation directory.
      The generated files are named:
      <filename>&lt;package&gt;-undocumented.txt</filename>,
      <filename>&lt;package&gt;-undeclared.txt</filename> and
      <filename>&lt;package&gt;-unused.txt</filename>.
      All those are plain text files that can be viewed and postprocessed easily.
    </para>

    <para>
      The <filename>&lt;package&gt;-undocumented.txt</filename> file starts with
      the documentation coverage summary. Below are two sections divided by
      blank lines. The first section lists undocumented or incomplete symbols.
      The second section does the same for section docs. Incomplete entries are
      those, which have documentation, but where e.g. a new parameter has been
      added.
    </para>

    <para>
      The <filename>&lt;package&gt;-undeclared.txt</filename> file lists symbols
      given in the <filename>&lt;package&gt;-section.txt</filename> but not
      found in the sources. Check if they have been removed or if they are
      misspelled.
    </para>

    <para>
      The <filename>&lt;package&gt;-unused.txt</filename> file lists symbol
      names, where the Gtk-Doc scanner has found documentation, but does not
      know where to put it. This means that the symbol has not yet been added to
      the <filename>&lt;package&gt;-section.txt</filename> file.
    </para>

    <tip>
      <para>
        Enable or add the <option>TESTS=($GTKDOC_CHECK)</option> line in Makefile.am.
        If at least gtk-doc 1.9 is installed, this will run sanity checks during
        make check run.
      </para>
    </tip>

  </chapter>

  <chapter id="faq">
    <title>Frequently asked question</title>

    <segmentedlist>
      <?dbhtml list-presentation="list"?>
      <segtitle>Question</segtitle>
      <segtitle>Answer</segtitle>
      <seglistitem>
	<seg>No class hierarchy.</seg>
	<seg>The objects _get_type() function has not been entered into the <filename>.types</filename> file.</seg>
      </seglistitem>
      <seglistitem>
	<seg>Still no class hierarchy.</seg>
	<seg>Wrong naming in section file (see <ulink url="http://mail.gnome.org/archives/gtk-doc-list/2003-October/msg00006.html">explanation</ulink>)</seg>
      </seglistitem>
      <seglistitem>
	<seg>Damn, I have still no class hierarchy.</seg>
	<seg>Is the object name (name of the instance struct) part of the normal section (don't put this into Standard or Private).</seg>
      </seglistitem>
      <seglistitem>
	<seg>No symbol index.</seg>
	<seg>FIXME (&lt;index&gt; tag in main sgml file)</seg>
      </seglistitem>
      <seglistitem>
	<seg>Symbols are not linked to their doc-section.</seg>
	<seg>FIXME (added #,% or () ?)</seg>
      </seglistitem>
      <seglistitem>
	<seg>A new class does not appear in the docs.</seg>
	<seg>FIXME (section file, types file, main-sgml file)</seg>
      </seglistitem>
      <seglistitem>
	<seg>A new symbol does not appear in the docs.</seg>
	<seg>FIXME (section file, proper doc comment)</seg>
      </seglistitem>

      <!-- gtk-doc warnings: -->
      <seglistitem>
	<seg>Parameter described in source code comment block but does not exist</seg>
	<seg>Check if the prototype in the header has different parameter names as in the source.</seg>
      </seglistitem>
      <!-- docbook warnings: -->
      <seglistitem>
	<seg>multiple "IDs" for constraint linkend: XYZ</seg>
	<seg>Symbol XYZ appears twice in -section.txt file.</seg>
      </seglistitem>
      <seglistitem>
	<seg>Element typename in namespace '' encountered in para, but no template matches.</seg>
        <seg />
      </seglistitem>
    </segmentedlist>
  </chapter>

  <!-- ======== Appendix: FDL ================================== -->
  &FDL;

</book>

