<?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.4</edition>
    <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>
    <copyright>
      <year>2000, 2005</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>

  </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>Gathering information about the code.</guilabel>

            gtkdoc-scan scans the header files of the code looking for declarations of
            functions, macros, enums, structs, and unions. It creates a list of the
            declarations, placing them into sections according to which header file they
            are in. The author can rearrange the sections, and the order of the
            declarations within them, to produce the final desired order.
            
            gtkdoc-scanobj 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>

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

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

            The author fills in the template files with the documentation for each
            function, macro, union etc.
          </para>
        </listitem>

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

            gtkdoc-mkdb turns the template files into SGML files in the sgml/
            subdirectory.(If the source code contains documentation on functions, using the special
            comment blocks, it gets merged in here.)
            
            gtkdoc-mkhtml turns the SGML files into HTML files in the html/
            subdirectory.
          </para>
        </listitem>

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

            After installing the HTML files, gtkdoc-fixxref can be run to fix up any
            cross-references between separate documents. For example, the GTK+
            documentation
            contains many cross-references to types documented in the GLib manual.
          </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 skelleton 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 neccesary.
      </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.4)
]]>
          </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.
	</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 desribes 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>.       
      </para>
      
      <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 intfrastructure 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.
        Finally the tool understand common parameters such as --help or --version.
      </para>
    </sect1>

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

      <para>
        After the previous steps its 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>
        The second make run also generates a mast document template
	(<filename>&lt;package&gt;-docs.sgml</filename>) for us.
      </para>
      <para>
        <example><title>Running the doc build</title>
          <programlisting>
<![CDATA[
./autogen.sh --enable-gtk-doc
make
make
]]>
          </programlisting>
        </example>
      </para>
      <para>
        Now you can point your browser to <filename>docs/reference/&lt;package&gt;/index.html</filename>.
	Yes, its a bit disapoint 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 thum, its those files you edit, that should go under 
        version control. For typical projects its 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 manaul 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 aditional '*' marks a
        documentation block that will be processed by the Gtk-Doc tools.
        <example><title>Gtk-Doc comment block</title>
          <programlisting>
<![CDATA[
/**
 * identifier:
 * documenation ...
 */
]]>
          </programlisting>
        </example>
      </para>
      
      <para>
        The 'identifier' is one line with the name of the item the comment is
	related to. The	syntax differes 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-asterist-blank) are converted to paragraph breaks.
        If you don't want a break (e.g. in preformated 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 descrbed.
            </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>

      <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
 *
 * 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 stabillity level this API has.
              We reccomend 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>
      </variablelist>
      
      <para>
        FIXME
        having @title here, would put this title into a newly generated section
        file, but later would be osolete (right?)
      </para>
      
      <tip>
        <para>
          To avoid uneccesary 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 sybols 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>Symbol 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)
        (stabillity)
        (signals, glib-enums, properties, ...)
      </para>
      
    </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>
      </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>

    </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.
      </para>

      <tip>
        <para>
          Do not create tutorials as extra documents. Just write extra chapters.
          The benefit of directly embeding the tutorial for your library into
          the API documentation is that it is easy to link fro 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 two placeholders for the package-name and
        one for chapter title.
      </para>

      <para>
        <example><title>Master document header</title>
          <programlisting>
<![CDATA[
<bookinfo>
  <title>[Insert name here] Reference Manual</title>
</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 visibillity (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> and
      <filename>&lt;package&gt;-unused.txt</filename>.
      Both are plain text files that can be viewed and portprocessed easily.
    </para>
    
    <para>
      The <filename>&lt;package&gt;-undocumented.txt</filename> file starts with
      the documentation cooverage sumary. Below are two sections divided by
      blank lines. The first section lists undocumneted 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;-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>

  </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>
    
      <!-- 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>
      <seglistitem>
	<seg>multiple "IDs" for constraint linkend: XYZ</seg>
	<seg>Symbol XYZ appears twice in -section.txt file</seg>
      </seglistitem>
    </segmentedlist>
  </chapter>
  
  <!-- ======== Appendix: FDL ================================== -->
  &FDL;

</book>

