home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / summary_man / gen.man.page next >
Encoding:
Text File  |  1992-02-03  |  3.7 KB  |  138 lines

  1. # /bin/csh
  2. #This is a script file designed to generate a man page which contains the names
  3. #and synopses of a list of man pages.  The script features the option of adding 
  4. #a preamble and postamble to the man page.  The nroff file generated for the
  5. #resulting man page uses the -man macro package.
  6. #
  7. #To use this script, edit the following variables:
  8. #
  9. #outfile:  Man page output file name
  10. #prefile:  Preamble text file (NOTE:  This file and the postamble file MUST 
  11. #                   use the -man macro package, and this file must
  12. #                   begin with .TH)
  13. #postfile:  Postamble text file
  14. #DIRS: Directory or directories where man page files are found
  15. #
  16. #Then type the name of this file ("gen.man.page")
  17. #
  18. #After copying the preamble file to the eventual output file,  this script 
  19. #file will search the directory or directories for all man files
  20. #designated by ".n, .l, or .0-9" suffixes.  It then writes the name of all
  21. #man files found to a temporary file ("temp2.intro") and writes an
  22. #alphabetically sorted version of the list to a second temporary file
  23. #("temp3.intro").  This file then uses an awk script to put the list of man
  24. #page files into a variable ("fnames") which is used as a final list for
  25. #taking man pages and writing their names and synopses to the last temporary
  26. #("temp.intro").  This file is then cleaned of excess spaces and appended to
  27. #the final output file.  Finally, the postamble file is appended.
  28. #NOTE:  If SYSOPSIS or DESCRIPTION are misspelled in any of the man pages found
  29. # then this script will fail.  To circumvent this more sed commands must be
  30. # added, as shown by the example in the man page reading section.
  31. #
  32. #Assign variables
  33. #
  34. set echo
  35. set verify
  36. set sdir=$cwd/
  37. set prefile=summary.intro
  38. set postfile=post.intro
  39. set outfile=hips2_intro.n
  40. set temp=temp.intro
  41. set temp2=temp2.intro
  42. set temp3=temp3.intro
  43. #
  44. # Prepare files
  45. #
  46. rm $sdir$outfile
  47. rm $sdir$temp
  48. rm $sdir$temp2
  49. rm $sdir$temp3
  50. cat /dev/null > $sdir$temp
  51. cat /dev/null > $sdir$temp2
  52. #
  53. # Add preamble file
  54. #
  55. cat $sdir/$prefile > $sdir$outfile
  56. #
  57. echo 'This is a synopsis of all HIPS modules written at' >> $sdir$temp
  58. echo 'Lawrence Berkeley Laboratory.' >> $sdir$temp
  59. #
  60. # Place man file names in first file listing
  61. #
  62. # list of directories containing man pages
  63. #
  64. set DIRS = (/home/itg1/src/HIPS2/sun4/man)
  65. #
  66. foreach dir ($DIRS)
  67.    pushd $dir
  68.    set names = (*.n \
  69.         *.l \
  70.         *.[0-9])
  71.    foreach man_file ($names)
  72.          echo $man_file >> $sdir$temp2
  73.       end
  74.    popd
  75. end
  76. #
  77. # Sort man page listing
  78. #
  79. sort -f -o $sdir$temp3 $sdir$temp2
  80. #
  81. # Put file listing into file listing variable
  82. #
  83. set fnames = `awk '{print $1}' $sdir$temp3`
  84. #
  85. # Pull name and synopses from file and append to temp file
  86. #
  87. foreach dir ($DIRS)
  88.    pushd $dir
  89.    foreach man_file ($names)
  90.    # get everything from NAME to SYNOPSIS
  91.    #   then delete NAME and SYNOPSIS
  92.     sed -n -e '/SH NAME/,/SH DESCRIPTION/p' $man_file | \
  93. #
  94. # if description is misspelled, add alternative lines in case of error
  95. # for example:
  96. #  sed -n -e '/SH NAME/,/SH "DESCRIPTION"/p' $man_file | \
  97. #  sed -n -e '/SH NAME/,/SH DESCRIPTIO/p' $man_file | \
  98. #
  99.     sed 's/.SH NAME//' | \
  100.     sed 's/.SH SYNOPSIS//' >> $sdir/$temp
  101. #
  102. # if synopsis is misspelled, add alternative lines in case of error
  103. # for example:
  104. #  sed  's/.SH "SYNOPSIS"//' | \
  105. #  sed  's/.SH SYNOPSES//' | \
  106. #
  107.    end
  108.    popd
  109. end
  110. #
  111. # Finish off file
  112. #
  113. echo '.nf' >> $sdir$outfile
  114. echo '.na' >> $sdir$outfile
  115. #
  116. # Remove spaces
  117. #
  118. sed '/^$/d' $sdir$temp >> $sdir$outfile
  119. #
  120. # Add postamble file
  121. #
  122. foreach var ($postfile)
  123.    echo '.fi' >> $sdir$outfile
  124.    echo '.ad b' >> $sdir$outfile
  125.    cat $sdir/$postfile >> $sdir$outfile
  126. end
  127. #
  128. # Finish man page
  129. #
  130. echo '.SH "SEE ALSO"' >> $sdir$outfile
  131. echo 'All of these programs have their own man page.' >> $sdir$outfile
  132. #
  133. # Remove temporary files
  134. #
  135. rm $sdir$temp
  136. rm $sdir$temp2
  137. rm $sdir$temp3
  138.