3 # srctoman - extract manual page from source file comment
5 # @(#) srctoman.sh 1.2 11/4/89 15:56:22
15 -) LANG
=$1; B
='[#:]';;
16 -awk) LANG
=$1; B
='#';;
17 -c) LANG
=$1; B
='\/\*';;
18 -f) LANG
=$1; B
='[Cc]';;
20 -n|
-t) LANG
=$1; B
='\\"';;
23 -C) LANG
=$1; B
=$2; shift;;
24 -*) ERROR
="unknown option: $1"; break;;
25 "") ERROR
="missing file argument"; break;;
35 *) echo "$0: $ERROR" 1>&2
36 echo "usage: $0 [-|-awk|-c|-f|-mk|-n|-p|-t|-r|-C] [section] file(s)" 1>&2; exit 1;;
39 # set up for file suffix processing
42 "") sh
='[:#]'; r
='#'; rh
=$r; awk='#'; mk
='#';
43 c
='\/\*'; h
=$c; y
=$c; l
=$c;
44 f
='[Cc]'; fh
=$f; p
='{'; ph
=$p;
45 ms
='\\"'; nr
=$ms; mn
=$ms; man
=$ms;
53 "") eval B\
="\$`expr $i : '.*\.\([^.]*\)$'`"
54 test "$B" ||
{ echo "$0: unknown suffix: $i; assuming c" 1>&2; B
=$c; }
57 /^'"$B"'++/,/^'"$B"'--/!d
67 y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
68 s/^.*$/.TH & '"$SECT"'\
81 /^DESCRIPTION/s//.SH &\
87 /^DIAGNOSTICS/s//.SH &\
90 /^[A-Z][A-Z][A-Z][^a-z]*$/s//.SH "&"\
109 # extract manual page from source file comment
113 # srctoman [-|-awk|-c|-f|-mk|-m|-n|-p|-t|-r|-C] [section] file(s)
115 # \fIsrctoman\fR converts comments in various programming languages to
116 # UNIX-style manual pages.
117 # The command processes comments in the style of newsrc(1);
118 # its standard output is suitable for formatting with nroff(1) or
119 # troff(1) using the "-man" macro package.
120 # Typically, srctoman is invoked from make(1) scripts.
122 # Source files are processed in the indicated order; if no
123 # files are specified the command produces no output.
125 # The source file language can be specified through a command-line
126 # option, or can be implied by the filename suffix.
127 # The expected start-of-comment symbol is shown in the last column.
131 option language comment
142 -C any language next argument
144 suffix language comment
167 # The required format of comments is discussed below, where SOC
168 # stands for the start-of-comment symbol of the language being used.
170 # Start of manual: SOC, followed by `++'.
172 # Section heading: SOC, blank, section name in upper case.
174 # All other text: SOC and subsequent blanks or tabs are removed.
175 # Lines that do not start with SOC are left unchanged (useful for
176 # inclusion of program text).
178 # End of manual: SOC, followed by `--'.
179 # An end-of-comment may follow if the source file language requires this.
181 # The following manual sections receive a special treatment:
182 # NAME and SUMMARY should appear at the beginning and in
183 # this order; DESCRIPTION, DIAGNOSTICS and BUGS will be
184 # right-margin adjusted.
185 # Other sections may be added freely without confusing srctoman.
187 # sh(1), sed(1), expand(1)
191 # The program complains if an unknown language is specified
192 # of if the language cannot be deduced from the file suffix.
195 # Eindhoven University of Technology
196 # Department of Mathematics and Computer Science
197 # Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
199 # Fri Jan 17 22:59:27 MET 1986
201 # srctoman.sh 1.2 11/4/89 15:56:22 (draft)