Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
shorten
[simgrid.git] / tools / doxygen / index_php.pl
1 #!/usr/bin/perl -w
2
3 ($#ARGV >= 2) or die "Usage: index_php.pl <input-php.in-file> <input-html-file> <output-php-file>";
4
5 my(@toc);
6 my($level,$label,$name);
7
8 $inputphp  = $ARGV[0];
9 $inputhtml  = $ARGV[1];
10 $output = $ARGV[2];
11
12 my($onglets) = "";
13 my($body) = "";
14
15 open FILE,$inputhtml;
16 while(defined($line=<FILE>)) {
17     if($line =~/<div class="tabs">/) {
18         $onglets = $line;
19         while(defined($line=<FILE>) && !($line =~/<\/div>/)) {
20             $onglets.=$line;
21         }
22         $onglets.=$line;
23         $onglets.="<center></center><p><br>\n"
24     } 
25     if($line =~/<!-- ______BODY_BEGIN______ --!>(.*)$/) {
26         $tmp=$1;
27         if($tmp =~/(.*)<!-- ______BODY_END______ --!>/) {
28             $body .= $1;
29         } else {
30             $body .= $tmp;
31             while(defined($line=<FILE>) && !($line =~/<!-- ______BODY_END______ --!>/)) {
32                 $body.=$line;
33             }
34             $line =~/^(.*)<!-- ______BODY_END______ --!>/;
35             $body.=$1;
36         }
37     }
38 }
39 close FILE;
40
41 # (?!http) : A zero-width negative look-ahead assertion. 
42 # For example "/foo(?!bar)/" matches any occurrence of "foo" that isn’t followed by "bar".
43
44 $onglets =~ s/href=\"(?!http)/href=\"doc\//gi;
45 $onglets =~ s/src=\"(?!http)/src=\"doc\//gi;
46
47 $body =~ s/href=\"(?!http)/href=\"doc\//gi;
48 $body =~ s/src=\"(?!http)/src=\"doc\//gi;
49
50 open FILE,$inputphp;
51 open OUTPUT,"> $output";
52
53 while(defined($line=<FILE>)) {
54     chomp $line;
55     if($line =~/______ONGLETS______/) {
56         $line =~ s/______ONGLETS______/$onglets/g;
57     } elsif($line =~/______BODY______/) {
58         $line =~ s/______BODY______/$body/g;
59     }
60     print OUTPUT "$line\n";
61 }
62
63 close(FILE);
64 close(OUTPUT);