home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
GENMAN.ZIP
/
README
< prev
next >
Wrap
Text File
|
1993-03-13
|
7KB
|
207 lines
Genman Version 2.0
The purpose of the genman.awk program is to generate man page style
documentation about a C++ class from its include file.
Features include:
a) Outputs either troff -man input data or plain human readable text.
b) The output is in a consistent format which is independent of
the format used in the include file.
c) Requires minimal modifications to include files.
d) Adding support for other types of output such as latex
or HP LaserJet II should be simple.
e) Public domain.
The distribution includes the following files:
README This file.
genman.awk The awk program that generates the document.
genman A shell script to make it easier to use awk.
genman.tpl A template to use to create include files.
strloc.h An example include file.
strloc.cxx An example source file.
strloc.man The output of the command "genman strloc.h"
gmtime.c A program that prints the modify time of a file.
Example usage:
genman strloc.h > strloc.man
or
awk -f genman.awk strloc.h > strloc.man
Genman.awk scans the specified include file for various keywords and
collects all of the information associated with them. It then outputs
the data in an order it thinks is reasonable. Then if any source
files where specified with the "// .FILE" keyword it scans them for
descriptions of functions and outputs the descriptions.
Genman.awk scans for the following "genman" keywords in the specified
include file. Each of these keywords must start in the first column.
// .NAME
// .LIBRARY
// .HEADER
// .INCLUDE
// .FILE
// .SECTION
Genman.awk scans for the following "C++" keywords in the specified
include file. Each of these keywords must start in the first column.
#define
#include
const
typedef
enum
struct
class
extern
Genman.awk discards all input not associated with one of the above
keywords.
// .NAME
This keyword is used to specify the sentence that appears
in the NAME section of the man page. The first word of the
sentence also appears in the upper corners of the man page.
Example:
// .NAME foo - a class to manage foo objects
If this keyword does not appear in the include file then
one is made up from the include filename and some question marks.
// .LIBRARY
This keyword is used to specify the word that appears in the
upper corners of the man page between the parens. In a real
man page this is the section indicator such as 3 or 3s. I
use it as a library indicator.
Example:
// .LIBRARY base
If this keyword does not appear in the include file then
the word "c++" is used.
// .HEADER
This keyword is used to specify the sentence that appears
on the top line of the man page, centered. In a real man
page this is a description of the type of functions provided.
Example:
// .HEADER c++ library functions
If this keyword does not appear in the include file then
the word "C++" is used.
// .INCLUDE
The first line of the SYNOPSIS section is always
#include <filename>
where filename is the name of the include file specified to
genman. This can be overridden using the // .INCLUDE
keyword.
Example:
// .INCLUDE base/foo.h
// .FILE
This keyword is used to specify the names of the source
files for the class described in the include file.
After processing the include file specified to genman,
all files specified with the // .FILE keyword are scanned.
When it finds the line:
// Description:
in a source file it starts saving the lines that follow up to
the first line that contains an open curley brace. Lines that
begin with // are considered part of the description of the
function. Non-blank lines that do not begin with // are
considered to be part of the function definition. Also
commented lines that end in a colon are discarded.
The function descriptions found are outputted in the SUMMARY
section.
Example:
// .FILE strloc.cxx
// .FILE strloc.h
If the include file contains inline functions then it should
also be specified as a source file. Do not declare inline
functions with the class declaration. Break them out and use
the inline keyword.
// .SECTION
Because genman.awk discards everything including text not
associated with one of the keywords, a keyword is needed
to output paragraphs of text. Use the // .SECTION keyword
to do this. All non-blank lines that begin with // in the
first column are part of the section. A blank line terminates
the section. In traditional man pages there is usually at
least a "DESCRIPTION" section and very often others like,
"CAVEATS", "BUGS", and "AUTHORS".
Example:
// .SECTION Description
// The foo class manages lists of widgets using neural
// networks. Blah blah blah...
#define
All #define macros are placed under the section heading of
"DEFINED MACROS".
#include
All #include files are placed under the section heading of
"INCLUDED FILES".
const
All const variables are placed under the section heading of
"CONSTANTS".
typedef
All type definitions are placed under the section heading of
"TYPE DEFINITIONS".
enum
All enum definitions are placed under the section heading of
"ENUMERATIONS".
struct
All structure declarations are placed under the section heading of
"STRUCTURES".
class
All class declarations are placed under the section heading of
"SYNOPSIS".
extern
All externs are placed under the section heading of
"SYNOPSIS" after any classes.
Genman.awk works with gawk 2.10beta on Unix and mks awkl.exe on MS-DOS.
Genman.awk uses "ls -l" by default to get the modify time of the file.
The problem with ls(1) is that it prints out the time of day instead
of the year for recently modified files. The source code gmtime.c is
included which when compiled takes a single argument which is a
filename and prints to stdout the modify time of the file in the
format, "mmm dd, yyyy". Use the "-s" option of the genman shell
script to use this program instead of ls(1) to get the modify time of
the file.
Genman.awk generates human readable text output by default. Use
the "-t" option of the genman shell script to generate troff format.
The genman shell script also includes a "-o" switch to specify the
output file.
KNOWN PROBLEMS
If tabs are used to line up end of line comments in the
include file then the comments will probably not be perfectly
aligned in the output. This is because the indentation is
changed in the output. A workaround is to use spaces instead
of tabs.
FUTURE WORK
Write an awk routine that converts a line with tabs in it to
spaces. This can be used to fix the problem mentioned above.
Move the device specific routines into separate files and use
multiple -f options to get the desired output.
Write a device driver that generates latex input.
Write a device drive that generates HP LaserJet II input.
Need a set of include files that test all of the features.
I am interested in any bug fixes or enhancement requests that people
might have for this program.
Bob Mastors
Epoch Systems, Westboro MA (508) 836-4711 x317 (voice)
(508) 836-4884 (fax)
{uunet!epochsys, harvard!cfisun!palladium}!mastors