Extracting documentation from C code.

Bruce Barnett barnett at grymoire.crd.ge.com
Fri May 17 06:39:26 AEST 1991


In article <BENNY.91May15185447 at dimona.vlss.amdahl.com> benny at vlss.amdahl.com (Benny Schnaider) writes:
>   I am looking for a utility to extract documentation from a "C"
>   program. I want to have the documentation source as part of the "C" code
>   (comments) which can be easily extracted in a troff (man page)
>   format. The output should be similar to man 3 output format.

I suggest you use the convention that comments always have a "*" as
the second character on the line:
/* This is a comment
 * more ...
 */


etc.

Then if you want to include nroff code in a program, use another
convention,
say - If the second character is a "*", and the third is a "|", then
it's nroff text:

/* nroff document
 *|.\"	@(#)ease.l	(FLUKE) 25-feb-87
 *|.\"
 *|.TH EASE LOCAL "Feb 13, 1991"
 */

Then you can use grep/sed to get the documents:

	grep '^.\*|' file | sed 's/^.\*|//' >file.man

You can get fancier, but you have to set up these policies yourself
ahead of time. 

--
Bruce G. Barnett	barnett at crdgw1.ge.com	uunet!crdgw1!barnett



More information about the Comp.unix.programmer mailing list