File: create_index.pl

package info (click to toggle)
bacula-doc 15.0.3%2Bdebian1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 45,036 kB
  • sloc: perl: 908; makefile: 684; javascript: 182; sh: 67
file content (38 lines) | stat: -rwxr-xr-x 880 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl -w
#
# This file is used to redirect bweb to the exact file of the documentation
#
use strict;
use CGI;
use JSON qw( encode_json );

# Creation mode, put the directory to scan in argument
if (scalar(@ARGV) > 0) {
    my %index;
    my $dir = $ARGV[0];
    # Index this directory
    open(FP, ">docs.json") or die "ERROR: unable to open index file";

    chdir($dir) or die "ERROR: Unable to chdir to $dir";

    foreach my $l (`grep -i '<a name="' *.html`) {

        # Monitor_Configuration.html:<A NAME="MonitorResource"></A>
	my $file;
	if ($l =~ m/^([^:]+):/) {
	   $file = $1;	
	} else {
	   next;
	}
        while ($l =~ m/<A NAME="(.+?)">/ig) {
            my $key = $1;
            if ($key !~ /^(tex2html|\d|SECTION|fig)/) {
                $index{$key} = $file;
            }
        }
    }

    print FP encode_json(\%index);
    close(FP);
    exit;
}