home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / progs / ipldoc.icn < prev    next >
Text File  |  2000-07-29  |  2KB  |  94 lines

  1. ############################################################################
  2. #
  3. #    File:     ipldoc.icn
  4. #
  5. #    Subject:  Program to collect library documentation
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     November 26, 1996
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program collects selected information from documentation headers
  18. #  for Icon procedure files named on the command line.
  19. #
  20. #  The following options are supported:
  21. #
  22. #    -s    skip file headers
  23. #    -f    sort procedure list by file; default sort by procedure
  24. #          name
  25. #
  26. ############################################################################
  27. #
  28. #  Links:  options, sort
  29. #
  30. ############################################################################
  31.  
  32. link options
  33. link sort
  34.  
  35. record ref(proc, file)
  36.  
  37. procedure main(args)
  38.    local procedures, file, program, line, dir, input, max
  39.    local reference, opts, writep, way1, way2
  40.  
  41.    opts := options(args, "sf")
  42.  
  43.    writep := if \opts["s"] then 1 else write
  44.    if \opts["f"] then {
  45.       way1 := 2
  46.       way2 := 1
  47.        }
  48.    else {
  49.       way1 := 1
  50.       way2 := 2
  51.       }
  52.  
  53.  
  54.    procedures := set()
  55.  
  56.    every file := !args do {
  57.  
  58.       program := open(file) | {
  59.          write(&error, "*** cannot open program ", image(file))
  60.          next
  61.          }
  62.  
  63.       writep()
  64.       writep()
  65.  
  66.       while line := read(program) | break do
  67.          if *line = 0 then break else writep(line)
  68.  
  69.       while line := read(program) | break do
  70.          line ? {
  71.             if ="procedure" then {
  72.                tab(many(' \t'))
  73.                if ="main(" then next
  74.                insert(procedures, ref(tab(upto(')') + 1), file))
  75.                }
  76.             }
  77.       close(program)
  78.       }
  79.  
  80.    writep()
  81.    writep(repl("=", 76))
  82.    writep()
  83.    write("Procedure List")
  84.    write()
  85.  
  86.    max := 60
  87.  
  88.    procedures := sortff(procedures, way1, way2)
  89.  
  90.    every reference := !procedures do
  91.       write(left(reference.proc, max), reference.file)
  92.  
  93. end
  94.