Changeset c04b94 in git for doc/doc2tex.pl
- Timestamp:
- Dec 6, 1999, 5:07:00 PM (23 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
- Children:
- e612312190d9035d6258e7dd6bac20871a42d807
- Parents:
- 4a553b8ad97e5927df9e168f04952d3d3c4d855c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/doc2tex.pl
r4a553b rc04b94 1 1 #!/usr/local/bin/perl 2 # $Id: doc2tex.pl,v 1.2 1 1999-12-03 11:20:44 obachman Exp $2 # $Id: doc2tex.pl,v 1.22 1999-12-06 16:06:54 obachman Exp $ 3 3 ################################################################### 4 4 # Computer Algebra System SINGULAR … … 62 62 $no_fun = 0; 63 63 $doc_subdir = "./d2t_singular"; 64 $ex_subdir = "./examples"; 64 65 @include_dirs = (".", "../Singular/LIB"); 65 66 $make = 0; … … 110 111 if (/^-no_fu(n)?$/) { $no_fun = 1;next;} 111 112 if (/^-m(ake)?$/) { $make = shift(@ARGV);next;} 112 if (/^-s(ubdir)?$/) { $doc_subdir = shift(@ARGV); next;} 113 if (/^-d(ocdir)?$/) { $doc_subdir = shift(@ARGV); next;} 114 if (/^-e(xdir)?$/) { $ex_subdir = shift(@ARGV); next;} 113 115 if (/^-I$/) { unshift(@include_dirs, shift(@ARGV)); next;} 114 116 if (/^-v(erbose)?$/) { $verbose = shift(@ARGV); next;} … … 147 149 if (-d $doc_subdir) 148 150 { 149 print "< subdir:$doc_subdir>" if ($verbose > 1);151 print "<docdir:$doc_subdir>" if ($verbose > 1); 150 152 } 151 153 else … … 153 155 mkdir($doc_subdir, oct(755)) 154 156 || Error("can't create directory $doc_subdir: $!\n"); 155 print "(subdir: $doc_subdir)" if ($verbose > 1); 157 print "(docdir:$doc_subdir)" if ($verbose > 1); 158 } 159 if (-d $ex_subdir) 160 { 161 print "<exdir:$ex_subdir>" if ($verbose > 1); 162 } 163 else 164 { 165 mkdir($ex_subdir, oct(755)) 166 || Error("can't create directory $ex_subdir: $!\n"); 167 print "(exdir:$ex_subdir)" if ($verbose > 1); 156 168 } 157 169 … … 169 181 if (/^\@setfilename/) {print TEX "\@setfilename $doc.hlp\n"; next;} 170 182 171 if (/^\@\w*section\s*(\w+)/ || /^\@\w*chapter\s*(\w+)/) 172 { 173 $section = lc(substr($1, 0, 6)); 183 if (/^\@\w*section\s*/ || /^\@\w*chapter\s*/ || /^\@\w*heading\s*/) 184 { 185 $section = $'; 186 $section =~ s/^\s*(.*)\s*$/$1/; 187 if ($section =~ /\w/) 188 { 189 $section =~ s/\s/_/g 190 } 191 else 192 { 193 $section = "unknown"; 194 } 174 195 } 175 196 … … 218 239 $section = 'unknown' unless $section; 219 240 $ex_prefix = $section; 220 $ex_prefix .= " $examples{$section}" if $examples{$section};241 $ex_prefix .= "_$examples{$section}" if $examples{$section}; 221 242 $examples{$section}++; 222 243 … … 229 250 else 230 251 { 231 $inc_file = "$ doc_subdir/$doc" . "_$ex_prefix.inc";232 $ex_file = "$ doc_subdir/$doc" . "_$ex_prefix.tst";252 $inc_file = "$ex_subdir/$ex_prefix.inc"; 253 $ex_file = "$ex_subdir/$ex_prefix.sing"; 233 254 if (-r $inc_file && -r $ex_file && -s $inc_file && -s $ex_file) 234 255 { 235 256 $cache = 1; 236 open( TST, "<$ex_file") || ($cache = 0);257 open(SING, "<$ex_file") || ($cache = 0); 237 258 } 238 259 } … … 256 277 { 257 278 $thisexample .= $_; 258 if ($cache && $_ && $_ ne < TST>)279 if ($cache && $_ && $_ ne <SING>) 259 280 { 260 281 $cache = 0; 261 close( TST);262 } 263 } 264 } 265 close( TST) if $cache;282 close(SING); 283 } 284 } 285 } 286 close(SING) if $cache; 266 287 Error("no matching '\@c example' found for $doc_file:$lline\n") 267 288 unless (/^\@c\s*example\s*$/); … … 292 313 print "($ex_prefix" if ($verbose == 1); 293 314 my ($res_file); 294 $res_file = "$ doc_subdir/$doc" . "_$ex_prefix.res";315 $res_file = "$ex_subdir/$ex_prefix.res"; 295 316 296 317 print TEX "\@c computed example $ex_prefix $doc_file:$lline \n"; … … 298 319 # run singular 299 320 open(EX, ">$ex_file") || Error("can't open $ex_file for writing: $!\n"); 300 print EX "$thisexample \$\n";321 print EX "$thisexample"; 301 322 close(EX); 302 323 303 &System(" $Singular $Singular_opts $ex_file > $res_file");324 &System("echo '\$' | $Singular $Singular_opts $ex_file > $res_file"); 304 325 print ")" if ($verbose == 1); 305 326 … … 310 331 while (<RES>) 311 332 { 312 last if (/^ $ex_file\s*([0-9]+)..\$/);333 last if (/^STDIN\s*([0-9]+)..\$/); 313 334 # check for error 314 335 Error("while running example $ex_prefix from $doc_file:$lline.\nCall: '$Singular $Singular_opts $ex_file > $res_file'\n") … … 619 640 -no_ex : skip computation of examples 620 641 -no_fun : don't include help for library functions 621 - subdir dir : put intermediatefiles into 'dir'642 -docdir dir : put intermediate doc/tex files into 'dir' 622 643 (default: './d2t_singular') 644 -exdir dir : put example files into 'dir' 645 (default: './examples') 623 646 -I dir : look also into 'dir' for include and lib files 624 647 (default: ".", "../Singular/LIB")
Note: See TracChangeset
for help on using the changeset viewer.