home *** CD-ROM | disk | FTP | other *** search
- #!/usr/local/bin/perl -w
- #
- # generate_man_page list_of_commands
- #
- # Use the output from Display Command Information to create a
- # man page template. Output written on list_of_commands.man.
- #
- # SOL, LUCC. 92/12/11
- # SOL, LUCC. 93/03/05. Fix for public distribution with xodmeter.
- # Thanks to Larry W. Virden and Ti Kan.
-
-
- while ( ($command = shift( @ARGV )) ) {
- @path_elements = split( /\//, $command );
- $basename = $path_elements[$#path_elements];
-
- open( U, "$command -usage_help |" );
- @u = <U>;
- close ( U );
- @u = grep( s/Usage: //, @u );
- @tokens = split( ' ', $u[0] );
- $u[0] = $basename . ' ' . join( ' ', @tokens[1 .. $#tokens] );
-
- open( D, "$command -full_help |" );
-
- $_ = <D>; # skip command source
- $_ = <D>;
- $_ = <D>; # skip message module name
- die "$command.mm does not appear to be an evaluate_parameters message_module.\nCannot create your man pages: $!"
- if $_ !~ /Message Module Name/;
-
- open( M, ">$basename.man" );
-
- while ( <D> ) { # skip leading blank lines
- last if $_ ne "\n";
- }
- chop( $command = $_ );
- @commands = split( /,/, $command );
- $command = $commands[$#commands];
- chop( $date = `date` );
- $date = substr( $date, 4, 6 ) . ', ' . substr( $date, 24, 4 );
-
- print M ".TH \"$command\" 1 \"$date\"\n";
- print M ".SH NAME\n";
- print M join( ', ', @commands), "\n";
- print M ".SH SYNOPSIS\n";
- print M $u[0], "\n";
- print M ".SH DESCRIPTION\n";
- while ( <D> ) {
- s/\t/ /;
- last if /^Parameters/;
- if ( /CALIBRATION/ ) {
- print M ".SH CALIBRATION\n";
- next;
- }
- if ( /TESTED CONFIGURATIONS/ ) {
- print M ".SH TESTED CONFIGURATIONS\n";
- next;
- }
- if ( length( $_ ) < 8 ) {
- print M "\n";
- } else {
- print M substr( $_, 8);
- }
- }
- $_ = <D>; # skip one blank line
- print M ".SH OPTIONS\n";
- while ( <D> ) {
- s/\t//;
- if ( /^-/ ) {
- print M "\n$_\n";
- } else {
- print M " $_";
- }
-
- }
- print M "\n.SH AUTHOR\n";
- print M "Stephen O. Lidie, lusol@Lehigh.EDU\n\n";
- print M "Copyright (C) 1993 - 1993, Lehigh University.\n";
- print M "All rights reserved.\n";
-
- close ( M );
- close ( D );
-
- } # whilend
-
-