Next: , Up: Complete Examples


D.1 Documentation in Source Code

     Example: documentation.txt  
      1  Package: MyPkg
      2  ##############
      3
      4  $include 'myunit.pas'
      5
      6  End Package: MyPkg
      7  ##################

     Example: myunit.pas  
      1  {**
      2    Unit: MyUnit
      3    ------------
      4
      5    ``MyUnit`` contains some essential routines.
      6
      7    This routines are the result of many years of **hard work**.
      8
      9    I hope they will help to save mankind.
     10  }
     11  unit MyUnit;
     12
     13  interface
     14
     15  {**
     16    Function: Max -- Return largest of two values.
     17
     18    ``Max`` returns the maximum of ``A`` and ``B``.
     19
     20    Parameters:
     21      - A -- first value
     22      - B -- second value
     23
     24    See Also: <<Min>>
     25  }
     26  function Max(A, B: Integer) : Integer;
     27
     28  {**
     29    Function: Min -- Return smallest of two values.
     30
     31    ``Min`` returns the minimum of ``A`` and ``B``.
     32
     33    Parameters:
     34      - A -- first value
     35      - B -- second value
     36
     37    See Also: <<Max>>
     38  }
     39  function Min(A, B: Integer) : Integer;
     40
     41  {**
     42    Function: Multiply -- Multiplies 2 integers.
     43
     44    Parameters:
     45      - A -- first integer
     46      - B -- second integer
     47
     48    Result:
     49
     50      The two integers multiplied together.
     51  }
     52  function Multiply(A, B: Integer) : Integer;
     53
     54  implementation
     55  end. {** End Unit: MyUnit }

     Example: Building documentation  
     ~$ txt2fpdoc -o documentation.xml documentation.txt
     ~$ fpdoc --package=mypkg --descr=documentation.xml --dont-trim \
          --format=html --output=out --input=myunit.pas