summaryrefslogtreecommitdiffstats
path: root/doc/tools/index-python
blob: 2a91e37240b6522969c08df7737c7ba6e89a051f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl

use Getopt::Long;

my $prefix = '';
GetOptions( 'prefix=s' => \$prefix ) || die "Wrong options\n";

$file = $ARGV[0];
open(FILE, "$file") || die "File not found: $file\n";

print "<conceptindex>\n";

$ingroup = 0;
while (<FILE>) {

      if (/\<dt\>\<a href=\'(.+)'\>(.+)\<\/a\>/) {
#              print "Index: $1, $2, $ingroup\n";
               if ($ingroup) {
                       $name = "$ingroup, $2";
               } else {
                       $name = $2;
               }
               $url = "$prefix/$1";
               print "<entry name=\"$name\" url=\"$url\"/>\n";
      } elsif (/\<dt\>(.+)/) {
#              print "Ingroup: $1\n";
              $ingroup = $1;
      } elsif (/\s+\<\/dl>/) {
              $ingroup = 0;
      }
}

print "</conceptindex>\n";
close(FILE);


sub dehtml
{
        my ( $str ) = @_;

        $str =~ s/\<CODE\>//g;
        $str =~ s/\<\/CODE\>//g;
        $str =~ s/\<TT\>//g;
        $str =~ s/\<\/TT\>//g;

        return $str;
}