home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume19 / xodometer / part01 / evap / genmp.skl < prev    next >
Encoding:
Text File  |  1993-04-28  |  2.1 KB  |  87 lines

  1. #!/usr/local/bin/perl -w
  2. #
  3. # generate_man_page list_of_commands
  4. #
  5. # Use the output from Display Command Information to create a
  6. # man page template. Output written on list_of_commands.man.
  7. #
  8. # SOL, LUCC.  92/12/11
  9. # SOL, LUCC.  93/03/05.  Fix for public distribution with xodmeter.
  10. #    Thanks to Larry W. Virden and Ti Kan.
  11.  
  12.  
  13. while ( ($command = shift( @ARGV )) ) {
  14.     @path_elements = split( /\//, $command );
  15.     $basename = $path_elements[$#path_elements];
  16.  
  17.     open( U, "$command -usage_help |" );
  18.     @u = <U>;
  19.     close ( U );
  20.     @u = grep( s/Usage: //, @u );
  21.     @tokens = split( ' ', $u[0] );
  22.     $u[0] = $basename . ' ' . join( ' ', @tokens[1 .. $#tokens] );
  23.  
  24.     open( D, "$command -full_help |" );
  25.  
  26.     $_ = <D>;            # skip command source
  27.     $_ = <D>;
  28.     $_ = <D>;            # skip message module name
  29.     die "$command.mm does not appear to be an evaluate_parameters message_module.\nCannot create your man pages:  $!"
  30.     if $_ !~ /Message Module Name/;
  31.  
  32.     open( M, ">$basename.man" );
  33.  
  34.     while ( <D> ) {        # skip leading blank lines
  35.     last if $_ ne "\n";
  36.     }
  37.     chop( $command = $_ );
  38.     @commands = split( /,/, $command );
  39.     $command = $commands[$#commands];
  40.     chop( $date = `date` );
  41.     $date = substr( $date, 4, 6 ) . ', ' . substr( $date, 24, 4 );
  42.  
  43.     print M ".TH \"$command\" 1 \"$date\"\n";
  44.     print M ".SH NAME\n";
  45.     print M join( ', ', @commands), "\n";
  46.     print M ".SH SYNOPSIS\n";
  47.     print M $u[0], "\n";
  48.     print M ".SH DESCRIPTION\n";
  49.     while ( <D> ) {
  50.     s/\t/        /;
  51.     last if /^Parameters/;
  52.     if ( /CALIBRATION/ ) {
  53.         print M ".SH CALIBRATION\n";
  54.         next;
  55.     }    
  56.     if ( /TESTED CONFIGURATIONS/ ) {
  57.         print M ".SH TESTED CONFIGURATIONS\n";
  58.         next;
  59.     }    
  60.     if ( length( $_ ) < 8 ) {
  61.         print M "\n";
  62.     } else {
  63.         print M substr( $_, 8);
  64.     }
  65.     }
  66.     $_ = <D>;            # skip one blank line
  67.     print M ".SH OPTIONS\n";
  68.     while ( <D> ) {
  69.     s/\t//;
  70.     if ( /^-/ ) {
  71.         print M "\n$_\n";
  72.     } else {
  73.         print M "  $_";  
  74.     }
  75.  
  76.     }
  77.     print M "\n.SH AUTHOR\n";
  78.     print M "Stephen O. Lidie, lusol@Lehigh.EDU\n\n";
  79.     print M "Copyright (C) 1993 - 1993, Lehigh University.\n";
  80.     print M "All rights reserved.\n";
  81.  
  82.     close ( M );
  83.     close ( D );
  84.  
  85. } # whilend
  86.  
  87.