source: git/doc/doc2idx.pl @ 087946

fieker-DuValspielwiese
Last change on this file since 087946 was 341696, checked in by Hans Schönemann <hannes@…>, 15 years ago
Adding Id property to all files git-svn-id: file:///usr/local/Singular/svn/trunk@12231 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.9 KB
Line 
1#!/usr/local/bin/perl
2# $Id$
3###################################################################
4#  Computer Algebra System SINGULAR
5#
6#  doc2idx.pl: utility to index file for singular manual
7#
8#  Prints to stdout lines of the following form
9#
10#  $indexentry\t$nodename\t$url\t$chksum
11#
12#  where $indexentry: entries of index (all lower case)
13#        $nodename  : name of node where index entry occured
14#        $url       : url of node
15#        $chksum    : checksum of help text, if library proc node
16# lines are sorted alphabetically w.r.t. $indexentry
17
18####
19$Usage = <<EOT;
20Usage: 
21$0 singular-index-file html-index-file chksum-db
22Outputs sorted lines of the form $indexentry\t$nodename\t$url\t$chksum
23EOT
24
25###################################################################
26# parse command line options
27#
28die "Need 3 arguments:\n $Usage" unless (scalar(@ARGV) == 3);
29
30# open files
31open (HLP, "<$ARGV[0]") || die "Can't open $ARGV[0]: $!\n";
32open (URL, "<$ARGV[1]") || die "Can't open $ARGV[1]: $!\n";
33$db_file = $ARGV[2];
34unless ($return = do $db_file)
35{
36  die "couldn't parse $db_file: $@" if $@;
37  die "couldn't do $db_file: $!"    unless defined $return;
38  die "couldn't run $db_file"       unless $return;
39} 
40
41# fill hashes
42# first: HLP
43while (<HLP>)
44{
45  if (/Node: Index/)
46  {
47    while (<HLP>)
48    {
49      last if /\* Menu:/;
50    }
51    <HLP>;
52    while (<HLP>)
53    {
54      last if /^\s*$/;
55      if (/^\* (.*?): (.*)\.$/)
56      {
57        $entry = $1;
58        $node = $2;
59      }
60      $entry =~ s/\s*(.*) <\d+>\s*$/$1/;
61      $node =~ s/^\s*(.*)\s*$/$1/;
62      $index->{$entry}->{Node} = $node unless $entry eq $prev;
63      $prev = $entry;
64    }
65    last;
66  }
67}
68close(HLP);
69
70while (<URL>)
71{
72  ($entry, $url) = split(/\t/);
73  $url =~ s/^\s*(.*)\s*$/$1/;
74  $index->{$entry}->{Url} = $url;
75}
76close(URL);
77
78for $entry (sort keys %$index)
79{
80  print "$entry\t$index->{$entry}->{Node}\t$index->{$entry}->{Url}\t$CHECKSUMS{$entry}\n";
81}
82
83
Note: See TracBrowser for help on using the repository browser.