home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Add-Ons / MPW / MPW noweb 2.7 / src / perl / noweave < prev    next >
Encoding:
Text File  |  1995-10-04  |  4.2 KB  |  144 lines  |  [TEXT/MPS ]

  1. Perl -Sx "{0}" {"Parameters"}>"{TempFolder}"noweb.run
  2. "{TempFolder}"noweb.run
  3. Exit
  4.  
  5. #!perl
  6. # Copyright 1991 by Norman Ramsey.  All rights reserved.
  7. # See file COPYRIGHT for more information.
  8.  
  9. $noquote    = "-noquote";
  10. $noindex    = "-noindex";
  11. $markup     = "markup";
  12.  
  13. @SAVEARGV = @ARGV;
  14.  
  15. while ($arg = shift @ARGV) {
  16.     if ($arg eq "-latex") {
  17.         $wrapper = "latex" unless ($wrapper eq "none");
  18.     } elsif ($arg eq "-tex") {
  19.         $wrapper = "tex";
  20.     } elsif ($arg eq "-html") {
  21.         $wrapper = "html" unless ($wrapper eq "none");
  22.         $backend = "tohtml -localindex";
  23.         $noquote = "";
  24.         $docanchor = "-docanchor 10";
  25.     } elsif ($arg eq "-latex+html") {
  26.         $wrapper = "latex" unless ($wrapper eq "none");
  27.         $backend = "tohtml -localindex -raw";
  28.         $noquote = "";
  29.         $docanchor = "-docanchor 10";
  30.     } elsif ($arg eq "-n") {
  31.         $wrapper = "none";
  32.     } elsif ($arg eq "-backend") {
  33.         $backend = shift @ARGV;
  34.     } elsif ($arg eq "-markup") {
  35.         $markup = shift @ARGV;
  36.     } elsif ($arg eq "-filter") {
  37.         shift @ARGV;
  38.     } elsif ($arg eq "-x") {
  39.     } elsif ($arg eq "-index") {
  40.         $noindex = "";
  41.     } elsif ($arg eq "-indexfrom") {
  42.         shift @ARGV;
  43.         $noindex = "";
  44.     } elsif ($arg eq "-autodefs") {
  45.         $defs      = shift @ARGV;
  46.         $autodefs = "autodefs.$defs";
  47.         die "noweave: don't know how to find definitions for '$defs'" 
  48.             unless (-r "||LIB||$autodefs");
  49.         push(@filters, $autodefs);
  50.     } elsif ($arg eq "-showautodefs") {
  51.         opendir(LIB, "||LIB||");
  52.         @defs = grep(s/^autodefs\.//, readdir(LIB));
  53.         closedir(LIB);
  54.         if ($#defs) {
  55.             print "Echo \"This noweave supports -autodefs [ ";
  56.             print join(" ", @defs);
  57.             print "]\"\n";
  58.         } else {
  59.             print "Echo \"This noweave does not support -autodefs [ ";
  60.         }
  61.     } elsif ($arg eq "-autodefs") {
  62.         $newopt      = shift @ARGV;
  63.         $noweboptions = $noweboptions ? "$noweboptions,$newopt" : $newopt;
  64.     } elsif ($arg eq "-delay") {
  65.         $delay      = $arg;
  66.         $wrapper  = "none";
  67.     } elsif ($arg =~ /^-t/) {
  68.         $markopts .= " $arg";
  69.     } elsif ($arg eq "-v") {
  70.         $verbose  = 1;
  71.     } elsif ($arg =~ /^-/) {
  72.         die <<USAGE;
  73. Usage: noweb [options] [files]
  74. Options recognized are:" 1>&2
  75. -latex            Use LaTeX headers and trailers (default).
  76. -tex              Use TeX headers and trailers.
  77. -html             Use HTML headers and trailers.
  78. -latex+html       Assume LaTeX in documentation, but use HTML in code.
  79.  -n               Don't use any header or trailer.
  80. -markup frontend  Parse input with frontend (e.g., numarkup).
  81. -x                Use the default cross-referencer (needs LaTeX or HTML).
  82. -index            Create index using identifiers defined in input files.
  83. -indexfrom defs   Create index of identifers listed in file defs.
  84. -filter cmd       Filter through 'cmd' before weaving; cmd could prettyprint
  85.                   or perform other functions.
  86. -autodefs lang    Source is in language 'lang'; find definitions automatically.
  87. -showautodefs     List languages that can be used with -autodefs
  88. -option opt       Add \noweboptions{opt} to header (latex only)
  89. -delay            Delay markup until after first documentation chunk.
  90. -tk               Expand tab stops every k columns
  91. -t                Copy tabs to the output
  92. -v                Print pipeline on standard error
  93. USAGE
  94.     } else {
  95.         $args .= " $arg";
  96.     }
  97. }
  98.  
  99. $wrapper || ($wrapper = "latex");
  100. @ARGV = @SAVEARGV;
  101.  
  102. while ($arg = shift @ARGV) {
  103.     if ($arg eq "-filter") {
  104.         push(@filters, shift @ARGV);
  105.     } elsif ($arg eq "-x") {
  106.         push(@filters, "noidx $docanchor $delay");
  107.     } elsif ($arg eq "-index") {
  108.         push(@filters, "finduses $noquote");
  109.         push(@filters, "noidx $docanchor $delay");
  110.     } elsif ($arg eq "-indexfrom") {
  111.         push(@filters, "finduses $noquote" . shift @ARGV);
  112.         push(@filters, "noidx $docanchor $delay");
  113.     }
  114. }
  115.  
  116. print "Set Commands \"||LIB||," . $ENV{Commands} ."\"; Export Commands\n";
  117. print "Begin\n";
  118.  
  119. if ($wrapper eq "none") {
  120. } elsif ($wrapper eq "latex") {
  121.     print "echo \"\@header $wrapper $noweboptions\"\n";
  122. } else {
  123.     print "echo \"\@header $wrapper $args\"\n";
  124. }
  125. if ($verbose) {
  126.     print STDERR "$markup $markopts $args |\n";
  127.     for (@filters) {
  128.         print "\t$_ |\n";
  129.     }
  130. }
  131.  
  132. unshift(@filters, "$markup $markopts $args");
  133. print join(" | ", @filters), "\n";
  134.  
  135. if ($wrapper ne "none") {
  136.     print "echo \"\@trailer $wrapper\"\n";
  137. }
  138.  
  139. print "End | $backend $noindex $delay\n";
  140.  
  141. if ($verbose) {
  142.     print STDERR "$backend $noindex $delay\n";
  143. }
  144.