Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > bbf8b69a7c5792df8049c96b78d19811 > files > 745

doxygen-1.7.4-2.fc14.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Doxygen manual: Documenting the code</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.4 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Doxygen manual</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">Documenting the code </div>  </div>
</div>
<div class="contents">
<div class="textblock"><h2><a class="anchor" id="specialblock"></a>
Special documentation blocks</h2>
<p>A special documentation block is a C or C++ style comment block with some additional markings, so doxygen knows it is a piece of documentation that needs to end up in the generated documentation. For Python and VHDL code there are a different comment conventions, which can be found in section <a class="el" href="docblocks.html#pythonblocks">Special documentation blocks in Python</a> and <a class="el" href="docblocks.html#vhdlblocks">Special documentation blocks in VHDL</a> respectively.</p>
<p>For each code item there are two (or in some cases three) types of descriptions, which together form the documentation: a <em>brief</em> description and <em>detailed</em> description, both are optional. For methods and functions there is also a third type of description, the so called "in body" description, which consists of the concatenation of all comment blocks found within the body of the method or function.</p>
<p>Having more than one brief or detailed description is allowed (but not recommended, as the order in which the descriptions will appear is not specified).</p>
<p>As the name suggest, a brief description is a short one-liner, whereas the detailed description provides longer, more detailed documentation. An "in body" description can also act as a detailed description or can describe a collection of implementation details. For the HTML output brief descriptions are also use to provide tooltips at places where an item is referenced.</p>
<p>There are several ways to mark a comment block as a detailed description: </p>
<ol>
<li>
<p class="startli">You can use the JavaDoc style, which consist of a C-style comment block starting with two *'s, like this:</p>
<div class="fragment"><pre class="fragment">
/**
 * ... text ...
 */
</pre></div><p class="endli"></p>
</li>
<li>
<p class="startli">or you can use the Qt style and add an exclamation mark (!) after the opening of a C-style comment block, as shown in this example:</p>
<div class="fragment"><pre class="fragment">
/*!
 * ... text ...
 */
</pre></div><p>In both cases the intermediate *'s are optional, so</p>
<div class="fragment"><pre class="fragment">
/*!
 ... text ...
*/
</pre></div><p>is also valid.</p>
<p class="endli"></p>
</li>
<li>
<p class="startli">A third alternative is to use a block of <em>at least two</em> C++ comment lines, where each line starts with an additional slash or an exclamation mark. Here are examples of the two cases:</p>
<div class="fragment"><pre class="fragment">
///
/// ... text ...
///
</pre></div><p>or</p>
<div class="fragment"><pre class="fragment">
//!
//!... text ...
//!
</pre></div><p>Note that a blank line ends a documentation block in this case.</p>
<p class="endli"></p>
</li>
<li>
<p class="startli"></p>
<p>Some people like to make their comment blocks more visible in the documentation. For this purpose you can use the following:</p>
<div class="fragment"><pre class="fragment">
/********************************************//**
 *  ... text
 ***********************************************/
</pre></div><p> (note the 2 slashes to end the normal comment block and start a special comment block).</p>
<p>or</p>
<div class="fragment"><pre class="fragment">
/////////////////////////////////////////////////
/// ... text ...
/////////////////////////////////////////////////
</pre></div><p class="endli"></p>
</li>
</ol>
<p>For the brief description there are also several posibilities: </p>
<ol>
<li>
<p class="startli">One could use the <a class="el" href="commands.html#cmdbrief">\brief</a> command with one of the above comment blocks. This command ends at the end of a paragraph, so the detailed description follows after an empty line.</p>
<p>Here is an example:</p>
<div class="fragment"><pre class="fragment">
/*! \brief Brief description.
 *         Brief description continued.
 *
 *  Detailed description starts here.
 */
</pre></div><p class="endli"></p>
</li>
<li>
<p class="startli">If <a class="el" href="config.html#cfg_javadoc_autobrief">JAVADOC_AUTOBRIEF</a> is set to <code>YES</code> in the configuration file, then using JavaDoc style comment blocks will automatically start a brief description which ends at the first dot followed by a space or new line. Here is an example:</p>
<div class="fragment"><pre class="fragment">
/** Brief description which ends at this dot. Details follow
 *  here.
 */
</pre></div><p> The option has the same effect for multi-line special C++ comments: </p>
<div class="fragment"><pre class="fragment">
/// Brief description which ends at this dot. Details follow
/// here.
</pre></div><p class="endli"></p>
</li>
<li>
<p class="startli">A third option is to use a special C++ style comment which does not span more than one line. Here are two examples: </p>
<div class="fragment"><pre class="fragment">
/// Brief description.
/** Detailed description. */
</pre></div><p>or</p>
<div class="fragment"><pre class="fragment">
//! Brief description.

//! Detailed description 
//! starts here.
</pre></div><p>Note the blank line in the last example, which is required to separate the brief description from the block containing the detailed description. The <a class="el" href="config.html#cfg_javadoc_autobrief">JAVADOC_AUTOBRIEF</a> should also be set to <code>NO</code> for this case.</p>
<p class="endli"></p>
</li>
</ol>
<p>As you can see doxygen is quite flexible. If you have multiple detailed descriptions, like in the following example:</p>
<div class="fragment"><pre class="fragment">
//! Brief description, which is
//! really a detailed description since it spans multiple lines.
/*! Another detailed description!
 */
</pre></div><p>They will be joined. Note that this is also the case if the descriptions are at different places in the code! In this case the order will depend on the order in which doxygen parses the code.</p>
<p>Here is an example of a documented piece of C++ code using the Qt style: </p>
<div class="fragment"><pre class="fragment"><span class="comment">//!  A test class. </span>
<span class="comment"></span><span class="comment">/*!</span>
<span class="comment">  A more elaborate class description.</span>
<span class="comment">*/</span>

<span class="keyword">class </span>Test
{
  <span class="keyword">public</span>:
<span class="comment"></span>
<span class="comment">    //! An enum.</span>
<span class="comment"></span><span class="comment">    /*! More detailed enum description. */</span>
    <span class="keyword">enum</span> TEnum { 
                 TVal1, <span class="comment">/*!&lt; Enum value TVal1. */</span>  
                 TVal2, <span class="comment">/*!&lt; Enum value TVal2. */</span>  
                 TVal3  <span class="comment">/*!&lt; Enum value TVal3. */</span>  
               } <span class="comment"></span>
<span class="comment">         //! Enum pointer.</span>
<span class="comment"></span><span class="comment">         /*! Details. */</span>
         *enumPtr, <span class="comment"></span>
<span class="comment">         //! Enum variable.</span>
<span class="comment"></span><span class="comment">         /*! Details. */</span>
         enumVar;  
    <span class="comment"></span>
<span class="comment">    //! A constructor.</span>
<span class="comment"></span><span class="comment">    /*!</span>
<span class="comment">      A more elaborate description of the constructor.</span>
<span class="comment">    */</span>
    Test();
<span class="comment"></span>
<span class="comment">    //! A destructor.</span>
<span class="comment"></span><span class="comment">    /*!</span>
<span class="comment">      A more elaborate description of the destructor.</span>
<span class="comment">    */</span>
   ~Test();
    <span class="comment"></span>
<span class="comment">    //! A normal member taking two arguments and returning an integer value.</span>
<span class="comment"></span><span class="comment">    /*!</span>
<span class="comment">      \param a an integer argument.</span>
<span class="comment">      \param s a constant character pointer.</span>
<span class="comment">      \return The test results</span>
<span class="comment">      \sa Test(), ~Test(), testMeToo() and publicVar()</span>
<span class="comment">    */</span>
    <span class="keywordtype">int</span> testMe(<span class="keywordtype">int</span> a,<span class="keyword">const</span> <span class="keywordtype">char</span> *s);
       <span class="comment"></span>
<span class="comment">    //! A pure virtual member.</span>
<span class="comment"></span><span class="comment">    /*!</span>
<span class="comment">      \sa testMe()</span>
<span class="comment">      \param c1 the first argument.</span>
<span class="comment">      \param c2 the second argument.</span>
<span class="comment">    */</span>
    <span class="keyword">virtual</span> <span class="keywordtype">void</span> testMeToo(<span class="keywordtype">char</span> c1,<span class="keywordtype">char</span> c2) = 0;
   <span class="comment"></span>
<span class="comment">    //! A public variable.</span>
<span class="comment"></span><span class="comment">    /*!</span>
<span class="comment">      Details.</span>
<span class="comment">    */</span>
    <span class="keywordtype">int</span> publicVar;
       <span class="comment"></span>
<span class="comment">    //! A function variable.</span>
<span class="comment"></span><span class="comment">    /*!</span>
<span class="comment">      Details.</span>
<span class="comment">    */</span>
    int (*handler)(<span class="keywordtype">int</span> a,<span class="keywordtype">int</span> b);
};

</pre></div>  
 Click <a href="../examples/qtstyle/html/class_test.html">here</a>
 for the corresponding HTML documentation that is generated by doxygen.
 <p>The one-line comments contain a brief description, whereas the multi-line comment blocks contain a more detailed description.</p>
<p>The brief descriptions are included in the member overview of a class, namespace or file and are printed using a small italic font (this description can be hidden by setting <a class="el" href="config.html#cfg_brief_member_desc">BRIEF_MEMBER_DESC</a> to <code>NO</code> in the config file). By default the brief descriptions become the first sentence of the detailed descriptions (but this can be changed by setting the <a class="el" href="config.html#cfg_repeat_brief">REPEAT_BRIEF</a> tag to <code>NO</code>). Both the brief and the detailed descriptions are optional for the Qt style.</p>
<p>By default a JavaDoc style documentation block behaves the same way as a Qt style documentation block. This is not according the JavaDoc specification however, where the first sentence of the documentation block is automatically treated as a brief description. To enable this behavior you should set <a class="el" href="config.html#cfg_javadoc_autobrief">JAVADOC_AUTOBRIEF</a> to YES in the configuration file. If you enable this option and want to put a dot in the middle of a sentence without ending it, you should put a backslash and a space after it. Here is an example: </p>
<div class="fragment"><pre class="fragment">
  /** Brief description (e.g.\ using only a few words). Details follow. */
</pre></div><p>Here is the same piece of code as shown above, this time documented using the JavaDoc style and <a class="el" href="config.html#cfg_javadoc_autobrief">JAVADOC_AUTOBRIEF</a> set to YES: </p>
<div class="fragment"><pre class="fragment"><span class="comment">/**</span>
<span class="comment"> *  A test class. A more elaborate class description.</span>
<span class="comment"> */</span>

<span class="keyword">class </span>Test
{
  <span class="keyword">public</span>:
<span class="comment"></span>
<span class="comment">    /** </span>
<span class="comment">     * An enum.</span>
<span class="comment">     * More detailed enum description.</span>
<span class="comment">     */</span>

    <span class="keyword">enum</span> TEnum { 
          TVal1, <span class="comment">/**&lt; enum value TVal1. */</span>  
          TVal2, <span class="comment">/**&lt; enum value TVal2. */</span>  
          TVal3  <span class="comment">/**&lt; enum value TVal3. */</span>  
         } 
       *enumPtr, <span class="comment">/**&lt; enum pointer. Details. */</span>
       enumVar;  <span class="comment">/**&lt; enum variable. Details. */</span>
       <span class="comment"></span>
<span class="comment">      /**</span>
<span class="comment">       * A constructor.</span>
<span class="comment">       * A more elaborate description of the constructor.</span>
<span class="comment">       */</span>
      Test();
<span class="comment"></span>
<span class="comment">      /**</span>
<span class="comment">       * A destructor.</span>
<span class="comment">       * A more elaborate description of the destructor.</span>
<span class="comment">       */</span>
     ~Test();
    <span class="comment"></span>
<span class="comment">      /**</span>
<span class="comment">       * a normal member taking two arguments and returning an integer value.</span>
<span class="comment">       * @param a an integer argument.</span>
<span class="comment">       * @param s a constant character pointer.</span>
<span class="comment">       * @see Test()</span>
<span class="comment">       * @see ~Test()</span>
<span class="comment">       * @see testMeToo()</span>
<span class="comment">       * @see publicVar()</span>
<span class="comment">       * @return The test results</span>
<span class="comment">       */</span>
       <span class="keywordtype">int</span> testMe(<span class="keywordtype">int</span> a,<span class="keyword">const</span> <span class="keywordtype">char</span> *s);
       <span class="comment"></span>
<span class="comment">      /**</span>
<span class="comment">       * A pure virtual member.</span>
<span class="comment">       * @see testMe()</span>
<span class="comment">       * @param c1 the first argument.</span>
<span class="comment">       * @param c2 the second argument.</span>
<span class="comment">       */</span>
       <span class="keyword">virtual</span> <span class="keywordtype">void</span> testMeToo(<span class="keywordtype">char</span> c1,<span class="keywordtype">char</span> c2) = 0;
   <span class="comment"></span>
<span class="comment">      /** </span>
<span class="comment">       * a public variable.</span>
<span class="comment">       * Details.</span>
<span class="comment">       */</span>
       <span class="keywordtype">int</span> publicVar;
       <span class="comment"></span>
<span class="comment">      /**</span>
<span class="comment">       * a function variable.</span>
<span class="comment">       * Details.</span>
<span class="comment">       */</span>
       int (*handler)(<span class="keywordtype">int</span> a,<span class="keywordtype">int</span> b);
};

</pre></div>  
 Click <a href="../examples/jdstyle/html/class_test.html">here</a>
 for the corresponding HTML documentation that is generated by doxygen.
 <p>Similarly, if one wishes the first sentence of a Qt style documentation block to automatically be treated as a brief description, one may set <a class="el" href="config.html#cfg_qt_autobrief">QT_AUTOBRIEF</a> to YES in the configuration file.</p>
<p>Unlike most other documentation systems, doxygen also allows you to put the documentation of members (including global functions) in front of the <em>definition</em>. This way the documentation can be placed in the source file instead of the header file. This keeps the header file compact, and allows the implementer of the members more direct access to the documentation. As a compromise the brief description could be placed before the declaration and the detailed description before the member definition.</p>
<h2><a class="anchor" id="memberdoc"></a>
Putting documentation after members</h2>
<p>If you want to document the members of a file, struct, union, class, or enum, and you want to put the documentation for these members inside the compound, it is sometimes desired to place the documentation block after the member instead of before. For this purpose you have to put an additional &lt; marker in the comment block. Note that this also works for the parameters of a function.</p>
<p>Here are some examples: </p>
<div class="fragment"><pre class="fragment">
int var; /*!&lt; Detailed description after the member */
</pre></div><p> This block can be used to put a Qt style detailed documentation block <em>after</em> a member. Other ways to do the same are: </p>
<div class="fragment"><pre class="fragment">
int var; /**&lt; Detailed description after the member */
</pre></div><p> or </p>
<div class="fragment"><pre class="fragment">
int var; //!&lt; Detailed description after the member
         //!&lt; 
</pre></div><p> or </p>
<div class="fragment"><pre class="fragment">
int var; ///&lt; Detailed description after the member
         ///&lt; 
</pre></div><p>Most often one only wants to put a brief description after a member. This is done as follows: </p>
<div class="fragment"><pre class="fragment">
int var; //!&lt; Brief description after the member
</pre></div><p> or </p>
<div class="fragment"><pre class="fragment">
int var; ///&lt; Brief description after the member
</pre></div><p>For functions one can use @param to document the parameters and then use <code>[in]</code>, <code>[out]</code>, <code>[in,out]</code> to document the direction. For inline documentation this is also possible by starting with the direction attribute, e.g. </p>
<div class="fragment"><pre class="fragment">
void foo(int v /**&lt; [in] docs for input parameter v. */);
</pre></div><p>Note that these blocks have the same structure and meaning as the special comment blocks in the previous section only the &lt; indicates that the member is located in front of the block instead of after the block.</p>
<p>Here is an example of the use of these comment blocks: </p>
<div class="fragment"><pre class="fragment"><span class="comment">/*! A test class */</span>

<span class="keyword">class </span>Test
{
  <span class="keyword">public</span>:<span class="comment"></span>
<span class="comment">    /** An enum type. </span>
<span class="comment">     *  The documentation block cannot be put after the enum! </span>
<span class="comment">     */</span>
    <span class="keyword">enum</span> EnumType
    {
      <span class="keywordtype">int</span> EVal1,     <span class="comment">/**&lt; enum value 1 */</span>
      <span class="keywordtype">int</span> EVal2      <span class="comment">/**&lt; enum value 2 */</span>
    };
    <span class="keywordtype">void</span> member();   <span class="comment">//!&lt; a member function.</span>
<span class="comment"></span>    
  <span class="keyword">protected</span>:
    <span class="keywordtype">int</span> value;       <span class="comment">/*!&lt; an integer value */</span>
};
</pre></div>  
 Click <a href="../examples/afterdoc/html/class_test.html">here</a>
 for the corresponding HTML documentation that is generated by doxygen.
 <dl class="warning"><dt><b>Warning:</b></dt><dd>These blocks can only be used to document <em>members</em> and <em>parameters</em>. They cannot be used to document files, classes, unions, structs, groups, namespaces and enums themselves. Furthermore, the structural commands mentioned in the next section (like <code>\class</code>) are not allowed inside these comment blocks.</dd></dl>
<h2><a class="anchor" id="structuralcommands"></a>
Documentation at other places</h2>
<p>So far we have assumed that the documentation blocks are always located <em>in</em> <em>front</em> of the declaration or definition of a file, class or namespace or in front or after one of its members. Although this is often comfortable, there may sometimes be reasons to put the documentation somewhere else. For documenting a file this is even required since there is no such thing as "in front of a file".</p>
<p>Doxygen allows you to put your documentation blocks practically anywhere (the exception is inside the body of a function or inside a normal C style comment block).</p>
<p>The price you pay for not putting the documentation block directly before (or after) an item is the need to put a structural command inside the documentation block, which leads to some duplication of information. So in practice you should <em>avoid</em> the use of structural commands <em>unless</em> other requirements force you to do so.</p>
<p>Structural commands (like all other commands) start with a backslash (<code>\</code>), or an at-sign (<code>@</code>) if you prefer JavaDoc style, followed by a command name and one or more parameters. For instance, if you want to document the class <code>Test</code> in the example above, you could have also put the following documentation block somewhere in the input that is read by doxygen: </p>
<div class="fragment"><pre class="fragment">
/*! \class Test
    \brief A test class.

    A more detailed class description.
*/
</pre></div><p>Here the special command <code>\class</code> is used to indicate that the comment block contains documentation for the class <code>Test</code>. Other structural commands are: </p>
<ul>
<li>
<code>\struct</code> to document a C-struct. </li>
<li>
<code>\union</code> to document a union. </li>
<li>
<code>\enum</code> to document an enumeration type. </li>
<li>
<code>\fn</code> to document a function. </li>
<li>
<code>\var</code> to document a variable or typedef or enum value. </li>
<li>
<code>\def</code> to document a #define. </li>
<li>
<code>\typedef</code> to document a type definition. </li>
<li>
<code>\file</code> to document a file. </li>
<li>
<code>\namespace</code> to document a namespace. </li>
<li>
<code>\package</code> to document a Java package. </li>
<li>
<code>\interface</code> to document an IDL interface. </li>
</ul>
<p>See section <a class="el" href="commands.html">Special Commands</a> for detailed information about these and many other commands.</p>
<p>To document a member of a C++ class, you must also document the class itself. The same holds for namespaces. To document a global C function, typedef, enum or preprocessor definition you must first document the file that contains it (usually this will be a header file, because that file contains the information that is exported to other source files).</p>
<p>Let's repeat that, because it is often overlooked: to document global objects (functions, typedefs, enum, macros, etc), you <em>must</em> document the file in which they are defined. In other words, there <em>must</em> at least be a </p>
<div class="fragment"><pre class="fragment">/*! \file */ </pre></div><p> or a </p>
<div class="fragment"><pre class="fragment">/** @file */ </pre></div><p> line in this file.</p>
<p>Here is an example of a C header named <code>structcmd.h</code> that is documented using structural commands: </p>
<div class="fragment"><pre class="fragment"><span class="comment">/*! \file structcmd.h</span>
<span class="comment">    \brief A Documented file.</span>
<span class="comment">    </span>
<span class="comment">    Details.</span>
<span class="comment">*/</span>
<span class="comment"></span>
<span class="comment">/*! \def MAX(a,b)</span>
<span class="comment">    \brief A macro that returns the maximum of \a a and \a b.</span>
<span class="comment">   </span>
<span class="comment">    Details.</span>
<span class="comment">*/</span>
<span class="comment"></span>
<span class="comment">/*! \var typedef unsigned int UINT32</span>
<span class="comment">    \brief A type definition for a .</span>
<span class="comment">    </span>
<span class="comment">    Details.</span>
<span class="comment">*/</span>
<span class="comment"></span>
<span class="comment">/*! \var int errno</span>
<span class="comment">    \brief Contains the last error code.</span>
<span class="comment"></span>
<span class="comment">    \warning Not thread safe!</span>
<span class="comment">*/</span>
<span class="comment"></span>
<span class="comment">/*! \fn int open(const char *pathname,int flags)</span>
<span class="comment">    \brief Opens a file descriptor.</span>
<span class="comment"></span>
<span class="comment">    \param pathname The name of the descriptor.</span>
<span class="comment">    \param flags Opening flags.</span>
<span class="comment">*/</span>
<span class="comment"></span>
<span class="comment">/*! \fn int close(int fd)</span>
<span class="comment">    \brief Closes the file descriptor \a fd.</span>
<span class="comment">    \param fd The descriptor to close.</span>
<span class="comment">*/</span>
<span class="comment"></span>
<span class="comment">/*! \fn size_t write(int fd,const char *buf, size_t count)</span>
<span class="comment">    \brief Writes \a count bytes from \a buf to the filedescriptor \a fd.</span>
<span class="comment">    \param fd The descriptor to write to.</span>
<span class="comment">    \param buf The data buffer to write.</span>
<span class="comment">    \param count The number of bytes to write.</span>
<span class="comment">*/</span>
<span class="comment"></span>
<span class="comment">/*! \fn int read(int fd,char *buf,size_t count)</span>
<span class="comment">    \brief Read bytes from a file descriptor.</span>
<span class="comment">    \param fd The descriptor to read from.</span>
<span class="comment">    \param buf The buffer to read into.</span>
<span class="comment">    \param count The number of bytes to read.</span>
<span class="comment">*/</span>

<span class="preprocessor">#define MAX(a,b) (((a)&gt;(b))?(a):(b))</span>
<span class="preprocessor"></span><span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> UINT32;
<span class="keywordtype">int</span> errno;
<span class="keywordtype">int</span> open(<span class="keyword">const</span> <span class="keywordtype">char</span> *,<span class="keywordtype">int</span>);
<span class="keywordtype">int</span> close(<span class="keywordtype">int</span>);
<span class="keywordtype">size_t</span> write(<span class="keywordtype">int</span>,<span class="keyword">const</span> <span class="keywordtype">char</span> *, <span class="keywordtype">size_t</span>);
<span class="keywordtype">int</span> read(<span class="keywordtype">int</span>,<span class="keywordtype">char</span> *,<span class="keywordtype">size_t</span>);
</pre></div>  
 Click <a href="../examples/structcmd/html/structcmd_8h.html">here</a>
 for the corresponding HTML documentation that is generated by doxygen.
 <p>Because each comment block in the example above contains a structural command, all the comment blocks could be moved to another location or input file (the source file for instance), without affecting the generated documentation. The disadvantage of this approach is that prototypes are duplicated, so all changes have to be made twice! Because of this you should first consider if this is really needed, and avoid structural commands if possible. I often receive examples that contain \fn command in comment blocks which are place in front of a function. This is clearly a case where the \fn command is redundant and will only lead to problems.</p>
<h2><a class="anchor" id="pythonblocks"></a>
Special documentation blocks in Python</h2>
<p>For Python there is a standard way of documenting the code using so called documentation strings. Such strings are stored in <code>__doc__</code> and can be retrieved at runtime. Doxygen will extract such comments and assume they have to be represented in a preformatted way.</p>
<div class="fragment"><pre class="fragment"><span class="stringliteral">&quot;&quot;&quot;@package docstring</span>
<span class="stringliteral">Documentation for this module.</span>
<span class="stringliteral"></span>
<span class="stringliteral">More details.</span>
<span class="stringliteral">&quot;&quot;&quot;</span>

<span class="keyword">def </span>func():
    <span class="stringliteral">&quot;&quot;&quot;Documentation for a function.</span>
<span class="stringliteral"></span>
<span class="stringliteral">    More details.</span>
<span class="stringliteral">    &quot;&quot;&quot;</span>
    <span class="keywordflow">pass</span>

<span class="keyword">class </span>PyClass:
    <span class="stringliteral">&quot;&quot;&quot;Documentation for a class.</span>
<span class="stringliteral"></span>
<span class="stringliteral">    More details.</span>
<span class="stringliteral">    &quot;&quot;&quot;</span>
   
    <span class="keyword">def </span>__init__(self):
        <span class="stringliteral">&quot;&quot;&quot;The constructor.&quot;&quot;&quot;</span>
        self._memVar = 0;
   
    <span class="keyword">def </span>PyMethod(self):
        <span class="stringliteral">&quot;&quot;&quot;Documentation for a method.&quot;&quot;&quot;</span>
        <span class="keywordflow">pass</span>
     
</pre></div>  
 Click <a href="../examples/docstring/html/index.html">here</a>
 for the corresponding HTML documentation that is generated by doxygen.
 <p>Note that in this case none of doxygen's <a class="el" href="commands.html#cmd_intro">special commands</a> are supported.</p>
<p>There is also another way to document Python code using comments that start with "##". These type of comment blocks are more in line with the way documentation blocks work for the other languages supported by doxygen and this also allows the use of special commands.</p>
<p>Here is the same example again but now using doxygen style comments:</p>
<div class="fragment"><pre class="fragment"><span class="comment">## @package pyexample</span>
<span class="comment">#  Documentation for this module.</span>
<span class="comment">#</span>
<span class="comment">#  More details.</span>

<span class="comment">## Documentation for a function.</span>
<span class="comment">#</span>
<span class="comment">#  More details.</span>
<span class="keyword">def </span>func():
    <span class="keywordflow">pass</span>

<span class="comment">## Documentation for a class.</span>
<span class="comment">#</span>
<span class="comment">#  More details.</span>
<span class="keyword">class </span>PyClass:
   
    <span class="comment">## The constructor.</span>
    <span class="keyword">def </span>__init__(self):
        self._memVar = 0;
   
    <span class="comment">## Documentation for a method.</span>
    <span class="comment">#  @param self The object pointer.</span>
    <span class="keyword">def </span>PyMethod(self):
        <span class="keywordflow">pass</span>
     
    <span class="comment">## A class variable.</span>
    classVar = 0;

    <span class="comment">## @var _memVar</span>
    <span class="comment">#  a member variable</span>
</pre></div>  
 Click <a href="../examples/pyexample/html/index.html">here</a>
 for the corresponding HTML documentation that is generated by doxygen.
 <p>Since python looks more like Java than like C or C++, you should set <a class="el" href="config.html#cfg_optimize_output_java">OPTMIZE_OUTPUT_JAVA</a> to <code>YES</code> in the config file.</p>
 
Go to the <a href="lists.html">next</a> section or return to the
 <a href="index.html">index</a>.
<h2><a class="anchor" id="vhdlblocks"></a>
Special documentation blocks in VHDL</h2>
<p>For VHDL a comment normally start with "--". Doxygen will extract comments starting with "--!". There are only two types of comment blocks in VHDL; a one line --! comment representing a brief description, and a multi-line --! comment (where the --! prefix is repeated for each line) representing a detailed description.</p>
<p>Comments are always located in front of the item that is being documented with one exception: for ports the comment can also be after the item and is then treated as a brief description for the port.</p>
<p>Here is an example VHDL file with doxygen comments:</p>
<div class="fragment"><pre class="fragment"><span class="comment">-------------------------------------------------------</span><span class="comment"></span>
<span class="comment">--! @file</span><span class="comment"></span>
<span class="comment">--! @brief </span><span class="vhdllogic">2</span>:<span class="vhdllogic">1</span> Mux using with-select<span class="comment"></span>
<span class="comment">-------------------------------------------------------</span>
<span class="comment"></span>
<span class="comment">--! Use standard library</span>
<span class="vhdlkeyword">library </span><span class="keywordflow">ieee</span>;<span class="comment"></span>
<span class="comment">--! Use logic elements</span>
<span class="vhdlkeyword">    use </span>ieee.std_logic_1164.all;
<span class="comment"></span>
<span class="comment">--! Mux entity brief description</span>
<span class="comment"></span>
<span class="comment">--! Detailed description of this </span><span class="comment"></span>
<span class="comment">--! mux design element.</span>
<span class="keywordflow">entity </span>mux_using_with <span class="vhdlchar">is</span>
    <span class="vhdlchar">port</span> <span class="vhdlchar">(</span>
        <span class="vhdlchar">din_0</span>   <span class="vhdlchar">:</span> <span class="vhdlchar">in</span>  <span class="vhdlchar">std_logic</span>;<span class="comment"> --! Mux first input</span>
        <span class="vhdlchar">din_1</span>   <span class="vhdlchar">:</span> <span class="vhdlchar">in</span>  <span class="vhdlchar">std_logic</span>;<span class="comment"> --! Mux Second input</span>
        <span class="vhdlchar">sel</span>     <span class="vhdlchar">:</span> <span class="vhdlchar">in</span>  <span class="vhdlchar">std_logic</span>;<span class="comment"> --! Select input</span>
        <span class="vhdlchar">mux_out</span> <span class="vhdlchar">:</span> <span class="vhdlchar">out</span> <span class="vhdlchar">std_logic</span><span class="comment">  --! Mux output</span>
    <span class="vhdlchar">)</span>;
<span class="vhdlchar">end</span> <span class="vhdlchar">entity</span>;
<span class="comment"></span>
<span class="comment">--! @brief Architure definition of the MUX</span><span class="comment"></span>
<span class="comment">--! @details More details about this mux element.</span>
architecture behavior of mux_using_with is
<span class="vhdlkeyword">begin</span>
    <span class="vhdlchar">with</span> <span class="vhdlchar">(</span><span class="vhdlchar">sel</span><span class="vhdlchar">)</span> <span class="vhdlchar">select</span>
    <span class="vhdlchar">mux_out</span> <span class="vhdlchar">&lt;=</span> <span class="vhdlchar">din_0</span> <span class="vhdlchar">when</span> <span class="vhdlchar">&#39;</span><span class="vhdllogic"></span><span class="vhdllogic">0</span><span class="vhdlchar">&#39;</span><span class="vhdlchar">,</span>
               <span class="vhdlchar">din_1</span> <span class="vhdlchar">when</span> <span class="vhdlchar">others</span>;
<span class="vhdlchar">end</span> <span class="vhdlchar">architecture</span>;

</pre></div>  
 Click <a href="../examples/mux/html/index.html">here</a>
 for the corresponding HTML documentation that is generated by doxygen.
 <p>To get proper looking output you need to set <a class="el" href="config.html#cfg_optimize_output_vhdl">OPTIMIZE_OUTPUT_VHDL</a> to <code>YES</code> in the config file. This will also affect a number of other settings. When they were not already set correctly doxygen will produce a warning telling which settings where overruled.</p>
<h2><a class="anchor" id="fortranblocks"></a>
Special documentation blocks in Fortran</h2>
<p>When using doxygen for Fortran code you should set <a class="el" href="config.html#cfg_optimize_for_fortran">OPTIMIZE_FOR_FORTRAN</a> to <code>YES</code>.</p>
<p>For Fortran "!&gt;" or "!&lt;" starts a comment and "!!" or "!&gt;" can be used to continuate a one line comment into a multi-line comment.</p>
<p>Here is an example of a documented Fortran subroutine: </p>
<div class="fragment"><pre class="fragment">
  !&gt; Build the restriction matrix for the aggregation 
  !! method.
  !! @param aggr information about the aggregates
  !! @todo Handle special case
  subroutine IntRestBuild(A,aggr,Restrict,A_ghost)
    implicit none
    Type(SpMtx), intent(in) :: A !&lt; our fine level matrix
    Type(Aggrs), intent(in) :: aggr
    Type(SpMtx), intent(out) :: Restrict !&lt; Our restriction matrix
</pre></div><p>As a alternative you can also use comments in fixed format code:</p>
<div class="fragment"><pre class="fragment">
C&gt; Function comment
C&gt; another line of comment
      function A(i)
C&gt; input parameter
        integer i
      end function A
</pre></div> </div></div>
<hr class="footer"/><address class="footer"><small>Generated on Mon Jun 27 2011 for Doxygen manual by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>