Changeset c04b94 in git for doc/doc2tex.pl


Ignore:
Timestamp:
Dec 6, 1999, 5:07:00 PM (23 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
Children:
e612312190d9035d6258e7dd6bac20871a42d807
Parents:
4a553b8ad97e5927df9e168f04952d3d3c4d855c
Message:
* example on kernel commands implemented


git-svn-id: file:///usr/local/Singular/svn/trunk@3959 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/doc2tex.pl

    r4a553b rc04b94  
    11#!/usr/local/bin/perl
    2 # $Id: doc2tex.pl,v 1.21 1999-12-03 11:20:44 obachman Exp $
     2# $Id: doc2tex.pl,v 1.22 1999-12-06 16:06:54 obachman Exp $
    33###################################################################
    44#  Computer Algebra System SINGULAR
     
    6262$no_fun = 0;
    6363$doc_subdir = "./d2t_singular";
     64$ex_subdir = "./examples";
    6465@include_dirs = (".", "../Singular/LIB");
    6566$make = 0;
     
    110111  if (/^-no_fu(n)?$/)    { $no_fun = 1;next;}
    111112  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;}
    113115  if (/^-I$/)            { unshift(@include_dirs, shift(@ARGV)); next;}
    114116  if (/^-v(erbose)?$/)   { $verbose = shift(@ARGV); next;}
     
    147149if (-d $doc_subdir)
    148150{
    149   print "<subdir: $doc_subdir>"  if ($verbose > 1);
     151  print "<docdir:$doc_subdir>"  if ($verbose > 1);
    150152}
    151153else
     
    153155  mkdir($doc_subdir, oct(755))
    154156    || 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}
     159if (-d $ex_subdir)
     160{
     161  print "<exdir:$ex_subdir>"  if ($verbose > 1);
     162}
     163else
     164{
     165  mkdir($ex_subdir, oct(755))
     166    || Error("can't create directory $ex_subdir: $!\n");
     167  print "(exdir:$ex_subdir)"  if ($verbose > 1);
    156168}
    157169
     
    169181  if (/^\@setfilename/)     {print TEX "\@setfilename $doc.hlp\n"; next;}
    170182
    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    }
    174195  }
    175196 
     
    218239  $section = 'unknown' unless $section;
    219240  $ex_prefix = $section;
    220   $ex_prefix .= "$examples{$section}" if $examples{$section};
     241  $ex_prefix .= "_$examples{$section}" if $examples{$section};
    221242  $examples{$section}++;
    222243
     
    229250  else
    230251  {
    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";
    233254    if (-r $inc_file && -r $ex_file && -s $inc_file && -s $ex_file)
    234255    {
    235256      $cache = 1;
    236       open(TST, "<$ex_file") || ($cache = 0);
     257      open(SING, "<$ex_file") || ($cache = 0);
    237258    }
    238259  }
     
    256277    {
    257278      $thisexample .= $_;
    258       if ($cache && $_ && $_ ne <TST>)
     279      if ($cache && $_ && $_ ne <SING>)
    259280      {
    260281        $cache = 0;
    261         close(TST);
    262       }
    263     }
    264   }
    265   close(TST) if $cache;
     282        close(SING);
     283      }
     284    }
     285  }
     286  close(SING) if $cache;
    266287  Error("no matching '\@c example' found for $doc_file:$lline\n")
    267288    unless (/^\@c\s*example\s*$/);
     
    292313    print "($ex_prefix" if ($verbose == 1);
    293314    my ($res_file);
    294     $res_file = "$doc_subdir/$doc" . "_$ex_prefix.res";
     315    $res_file = "$ex_subdir/$ex_prefix.res";
    295316
    296317    print TEX "\@c computed example $ex_prefix $doc_file:$lline \n";
     
    298319    # run singular
    299320    open(EX, ">$ex_file") || Error("can't open $ex_file for writing: $!\n");
    300     print EX "$thisexample\$\n";
     321    print EX "$thisexample";
    301322    close(EX);
    302323
    303     &System("$Singular $Singular_opts $ex_file > $res_file");
     324    &System("echo '\$' | $Singular $Singular_opts $ex_file > $res_file");
    304325    print ")" if ($verbose == 1);
    305326
     
    310331    while (<RES>)
    311332    {
    312       last if (/^$ex_file\s*([0-9]+)..\$/);
     333      last if (/^STDIN\s*([0-9]+)..\$/);
    313334      # check for error
    314335      Error("while running example $ex_prefix from $doc_file:$lline.\nCall: '$Singular $Singular_opts $ex_file > $res_file'\n")
     
    619640  -no_ex        : skip computation of examples
    620641  -no_fun       : don't include help for library functions
    621   -subdir  dir  : put intermediate files into 'dir'
     642  -docdir  dir  : put intermediate doc/tex files into 'dir'
    622643                          (default: './d2t_singular')
     644  -exdir   dir  : put example files into 'dir'
     645                          (default: './examples')
    623646  -I dir        : look also into 'dir' for include  and lib files
    624647                          (default: ".", "../Singular/LIB")
Note: See TracChangeset for help on using the changeset viewer.