#!/usr/bin/perl

## Copyright (c) 2002, 2003 Simon Josefsson                      ##
##                    added -texinfo, -listfunc                  ##
##                    man page revamp                            ##
##                    various improvements                       ##
## Copyright (c) 1998 Michael Zucchi, All Rights Reserved        ##
##                    hacked to allow -tex option --nmav         ##
##                                                               ##
## This software falls under the GNU Public License. Please read ##
##              the COPYING file for more information            ##

#
# This will read a 'c' file and scan for embedded comments in the
# style of gnome comments (+minor extensions - see below).
#
# This program is modified by Nikos Mavroyanopoulos, for the gnutls
# project.

# Note: This only supports 'c'.

# usage:
# gdoc [ -docbook | -html | -text | -man | -tex | -texinfo | -listfunc ]
#      [ -sourceversion verno ] [ -includefuncprefix ] [ -bugsto address ]
#      [ -seeinfo infonode ] [ -copyright notice ] [ -verbatimcopying ]
#      [ -function funcname [ -function funcname ...] ] c file(s)s > outputfil
e
#
#  Set output format using one of -docbook, -html, -text, -man, -tex,
#  -texinfo, or -listfunc.  Default is man.
#
#  -sourceversion
#       Version number for source code, e.g. '1.0.4'.  Used in 'man' headers.
#       Defaults to using current date.
#
#  -includefuncprefix
#       For man pages, generate a #include <FILE.h> based on the function
#       prefix.  For example, a function gss_init_sec_context will generate
#       an include statement of #include <gss.h>.
#
#  -bugsto address
#       For man pages, include a section about reporting bugs and mention
#       the given e-mail address, e.g '[email protected]'.
#
#  -seeinfo infonode
#       For man pages, include a section that point to an info manual
#       for more information.
#
#  -copyright notice
#       For man pages, include a copyright section with the given
#       notice after a preamble.  Use, e.g., '2002, 2003 Simon Josefsson'.
#
#  -verbatimcopying
#       For man pages, and when the -copyright parameter is used,
#       add a licensing statement that say verbatim copying is permitted.
#
#  -function funcname
#       If set, then only generate documentation for the given function(s).  A
ll
#       other functions are ignored.
#
#  c files - list of 'c' files to process
#
#  All output goes to stdout, with errors to stderr.

#
# format of comments.
# In the following table, (...)? signifies optional structure.
#                         (...)* signifies 0 or more structure elements
# /**
#  * function_name(:)? (- short description)?
# (* @parameterx: (description of parameter x)?)*
# (* a blank line)?
#  * (Description:)? (Description of function)?
#  * (Section header: (section description)? )*
#  (*)?*/
#
# So .. the trivial example would be:
#
# /**
#  * my_function
#  **/
#
# If the Description: header tag is ommitted, then there must be a blank line
# after the last parameter specification.
# e.g.
# /**
#  * my_function - does my stuff
#  * @my_arg: its mine damnit
#  *
#  * Does my stuff explained.
#  */
#
#  or, could also use:
# /**
#  * my_function - does my stuff
#  * @my_arg: its mine damnit
#  * Description: Does my stuff explained.
#  */
# etc.
#
# All descriptions can be multiline, apart from the short function description