Changeset 84dee1 in git for doc/doc2tex.pl
- Timestamp:
- Jul 22, 1999, 3:35:12 PM (24 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 71e701495c253cc11e495110cf351fcbf5292bbc
- Parents:
- 0a2ba89accf5ea2b0f3e9b285eb4945f8dad6aba
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/doc2tex.pl
r0a2ba89 r84dee1 1 1 #!/usr/local/bin/perl 2 # $Id: doc2tex.pl,v 1.1 3 1999-07-22 07:21:31 wichmann Exp $2 # $Id: doc2tex.pl,v 1.14 1999-07-22 13:35:12 obachman Exp $ 3 3 ################################################################### 4 4 # Computer Algebra System SINGULAR … … 10 10 # -> the text till the next @c example is feed into Singular, 11 11 # the text is then substituted by 12 # @c computed example $ex ample$doc_file:$line12 # @c computed example $ex_prefix $doc_file:$line 13 13 # <text from the input> 14 14 # @expansion{} <corresponding output> 15 15 # .... 16 # @c end computed example $ex ample$doc_file:$line17 # reuse computed examples if ($reuse && -r $ex ample.inc)16 # @c end computed example $ex_prefix $doc_file:$line 17 # reuse computed examples if ($reuse && -r $ex_prefix.inc) 18 18 # cut absolute directory names from the loaded messages 19 19 # substituted @,{ and } by @@, @{ resp. @} … … 64 64 $doc_subdir = "./d2t_singular"; 65 65 @include_dirs = (".", "../Singular/LIB"); 66 $doc_examples_db = "$doc_subdir/examples";67 66 $make = 0; 67 $make_opts = " --no-print-directory"; 68 68 69 69 # … … 110 110 if (/^-no_e(x)?$/) { $no_ex = 1; next;} 111 111 if (/^-no_fu(n)?$/) { $no_fun = 1;next;} 112 if (/^-m(ake)?$/) { $make = 1;next;}112 if (/^-m(ake)?$/) { $make = shift(@ARGV);next;} 113 113 if (/^-s(ubdir)?$/) { $doc_subdir = shift(@ARGV); next;} 114 114 if (/^-I$/) { unshift(@include_dirs, shift(@ARGV)); next;} … … 118 118 } 119 119 $verbose = ($verbose < 0 ? 0 : $verbose); 120 $make_opts .= " -s" unless $verbose > 1; 120 121 121 122 # … … 144 145 || Error("can't open $doc_file for reading: $!\n" . &Usage); 145 146 open(TEX, ">$tex_file") || Error("can't open $tex_file for writing: $!\n"); 146 print " d2t: Generating $tex_file from $doc_file ...\n" if ($verbose > 1);147 print "(d2t $doc_file==>$tex_file" if ($verbose); 147 148 if (-d $doc_subdir) 148 149 { 149 print "d2t: Using $doc_subdir for intermediate files\n" 150 if ($verbose > 1); 150 print "<subdir: $doc_subdir>" if ($verbose > 1); 151 151 } 152 152 else … … 154 154 mkdir($doc_subdir, oct(755)) 155 155 || Error("can't create directory $doc_subdir: $!\n"); 156 print "d2t: Created $doc_subdir for intermediate files\n" 157 if ($verbose > 1); 158 } 159 160 # dbmopen(%EXAMPLES, $doc_examples_db, oct(755)) || die "$ERROR: can't open examples data base: $!\n"; 156 print "(subdir: $doc_subdir)" if ($verbose > 1); 157 } 161 158 162 159 ####################################################################### … … 173 170 if (/^\@c\s*lib\s+/) {&HandleLib; next;} 174 171 if (/^\@setfilename/) {print TEX "\@setfilename $doc.hlp\n"; next;} 175 172 173 if (/^\@\w*section\s*(\w+)/ || /^\@\w*chapter\s*(\w+)/) 174 { 175 $section = lc(substr($1, 0, 6)); 176 } 177 176 178 print TEX $_; 177 179 … … 183 185 # 184 186 close(TEX); 185 #dbmclose(%EXAMPLES); 186 print "\nd2t: Finished generation of $tex_file \n" if ($verbose > 1); 187 print "\n" if ($verbose == 1); 187 print "==>$tex_file)\n" if ($verbose); 188 188 189 189 … … 192 192 # -> the text till the next @c example is feed into Singular, 193 193 # the text is then substituted by 194 # @c computed example $ex ample$doc_file:$line194 # @c computed example $ex_prefix $doc_file:$line 195 195 # <text from the input> 196 196 # @expansion{} <corresponding output> 197 197 # .... 198 # @c end computed example $ex ample$doc_file:$line199 # reuse computed examples if ($reuse && -r $ex ample.inc)198 # @c end computed example $ex_prefix $doc_file:$line 199 # reuse computed examples if ($reuse && -r $ex_prefix.inc) 200 200 # cut absolute directory names from the loaded messages 201 201 # substituted @,{ and } by @@, @{ resp. @} … … 205 205 sub HandleExample 206 206 { 207 my($ lline, $thisexample, $include, $error_ok);207 my($inc_file, $ex_file, $lline, $thisexample, $error_ok, $cache); 208 208 209 209 $lline = $line; 210 $example++; 210 $section = 'unknown' unless $section; 211 $ex_prefix = $section; 212 $ex_prefix .= "$examples{$section}" if $examples{$section}; 213 $examples{$section}++; 211 214 212 215 if ($no_ex) 213 216 { 214 print "{$ex ample}" if ($verbose);215 print TEX "\@c skipped computation of example $ex ample$doc_file:$lline \n";217 print "{$ex_prefix}" if ($verbose); 218 print TEX "\@c skipped computation of example $ex_prefix $doc_file:$lline \n"; 216 219 220 } 221 else 222 { 223 $inc_file = "$doc_subdir/$doc" . "_$ex_prefix.inc"; 224 $ex_file = "$doc_subdir/$doc" . "_$ex_prefix.tst"; 225 if (-r $inc_file && -r $ex_file && -s $inc_file && -s $ex_file) 226 { 227 $cache = 1; 228 open(TST, "<$ex_file") || ($cache = 0); 229 } 217 230 } 218 231 … … 232 245 else 233 246 { 234 $thisexample .= $_ unless (/^\s*$/); 235 } 236 } 247 $thisexample .= $_; 248 if ($cache && $_ && $_ ne <TST>) 249 { 250 $cache = 0; 251 close(TST); 252 } 253 } 254 } 255 close(TST) if $cache; 237 256 Error("no matching '\@c example' found for $doc_file:$lline\n") 238 257 unless (/^\@c\s*example\s*$/); … … 242 261 243 262 # check whether it can be reused 244 if ($reuse && ($include = $EXAMPLES{$thisexample})) 245 { 246 print "<$example>" if ($verbose); 247 print TEX "\@c reused example $example $doc_file:$lline \n"; 263 if ($reuse && $cache) 264 { 265 print "<$ex_prefix>" if ($verbose); 266 print TEX "\@c reused example $ex_prefix $doc_file:$lline \n"; 267 open(INC, "<$inc_file") || Error("can't open $inc_file for reading: $!\n"); 268 while (<INC>){ print TEX $_;} 269 close(INC); 248 270 } 249 271 else 250 272 { 251 print "($example" if ($verbose == 1); 252 my ($ex_file, $res_file, $inc_file); 253 $inc_file = "$doc_subdir/$doc"."_$example.inc"; 254 $ex_file = "$doc_subdir/$doc"."_$example.tst"; 255 $res_file = "$doc_subdir/$doc"."_$example.res"; 256 257 print TEX "\@c computed example $example $doc_file:$lline \n"; 273 print "($ex_prefix" if ($verbose == 1); 274 my ($res_file); 275 $res_file = "$doc_subdir/$doc" . "_$ex_prefix.res"; 276 277 print TEX "\@c computed example $ex_prefix $doc_file:$lline \n"; 258 278 259 279 # run singular … … 268 288 open(INC, ">$inc_file") || Error("can't open $inc_file for writing: $!\n"); 269 289 270 $include = '';271 290 # get result, manipulate it and put it into inc file 272 291 while (<RES>) … … 274 293 last if (/^$ex_file\s*([0-9]+)..\$/); 275 294 # check for error 276 Error("while running example $ex amplefrom $doc_file:$lline.\nCall: '$Singular $Singular_opts $ex_file > $res_file'\n")295 Error("while running example $ex_prefix from $doc_file:$lline.\nCall: '$Singular $Singular_opts $ex_file > $res_file'\n") 277 296 if (/error occurred/ && ! $error_ok); 278 297 # remove stuff from echo … … 300 319 $_ = "\@expansion{} ".$_; 301 320 } 302 $include .= $_;303 321 print INC $_; 322 print TEX $_; 304 323 } 305 324 close(RES); 306 325 close(INC); 307 326 unlink $ex_file, $res_file, $inc_file if ($clean); 308 $EXAMPLES{$thisexample} = $include; 309 } 310 print TEX $include; 311 print TEX "\@c end example $example $doc_file:$lline\n"; 327 } 328 print TEX "\@c end example $ex_prefix $doc_file:$lline\n"; 312 329 } 313 330 … … 440 457 if ($make) 441 458 { 442 print "<lib $lib" if ($verbose); 443 if ($verbose <= 1) 444 { 445 System("make $tex_file > /dev/null") 446 } 447 else 448 { 449 System("make $tex_file"); 450 } 459 print "<lib $lib " if ($verbose); 460 System("make $make_opts VERBOSE=$verbose $tex_file"); 451 461 } 452 462 … … 456 466 if ($verbose) 457 467 { 458 print "<lib $lib" unless $make; 459 print ":$proc" if $proc; 460 print ">"; 468 print "<lib $lib " unless $make; 469 print "$proc>"; 461 470 } 462 471 } … … 546 555 { 547 556 local($call) = @_; 548 print " \nd2t system:$call\n" if ($verbose > 1);557 print " d2t system:\n$call\n" if ($verbose > 1); 549 558 Error("non-zero exit status of system call: '$call': $!\n") 550 559 if (system($call)); … … 573 582 (default: input_file.tex) 574 583 -clean : delete intermediate files 575 -make : use maketo generate tex files for libraries584 -make cmd : use cmd as make command to generate tex files for libraries 576 585 -no_reuse : don't reuse intermediate files 577 586 -no_ex : skip computation of examples
Note: See TracChangeset
for help on using the changeset viewer.