Debian Codegraph @

tools/create_index.pl

raw
1 #!/usr/bin/perl -w
2 #
3 # This file is used to redirect bweb to the exact file of the documentation
4 #
5 use strict;
6 use CGI;
7 use JSON qw( encode_json );
8
9 # Creation mode, put the directory to scan in argument
10 if (scalar(@ARGV) > 0) {
11 my %index;
12 my $dir = $ARGV[0];
13 # Index this directory
14 open(FP, ">docs.json") or die "ERROR: unable to open index file";
15
16 chdir($dir) or die "ERROR: Unable to chdir to $dir";
17
18 foreach my $l (`grep -i '<a name="' *.html`) {
19
20 # Monitor_Configuration.html:<A NAME="MonitorResource"></A>
21 my $file;
22 if ($l =~ m/^([^:]+):/) {
23 $file = $1;
24 } else {
25 next;
26 }
27 while ($l =~ m/<A NAME="(.+?)">/ig) {
28 my $key = $1;
29 if ($key !~ /^(tex2html|\d|SECTION|fig)/) {
30 $index{$key} = $file;
31 }
32 }
33 }
34
35 print FP encode_json(\%index);
36 close(FP);
37 exit;
38 }