Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Generate correctly index.php
[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 id=".*" class="tabs">/) {
18         $onglets = $line;
19         while(defined($line=<FILE>) && !($line =~/<\/div>/)) {
20                 $line =~ s/ class="current"//g;
21             $onglets.=$line;
22         }
23         $onglets.=$line;
24         #$onglets.="<center></center><p><br>\n"
25     } 
26     if($line =~/<!-- ______BODY_BEGIN______ --!>(.*)$/) {
27         $tmp=$1;
28         if($tmp =~/(.*)<!-- ______BODY_END______ --!>/) {
29             $body .= $1;
30         } else {
31             $body .= $tmp;
32             while(defined($line=<FILE>) && !($line =~/<!-- ______BODY_END______ --!>/)) {
33                 $body.=$line;
34             }
35             $line =~/^(.*)<!-- ______BODY_END______ --!>/;
36             $body.=$1;
37         }
38     }
39 }
40 close FILE;
41
42 # (?!http) : A zero-width negative look-ahead assertion. 
43 # For example "/foo(?!bar)/" matches any occurrence of "foo" that isn’t followed by "bar".
44
45 $onglets =~ s/href=\"(?!http)/href=\"doc\//gi;
46 $onglets =~ s/src=\"(?!http)/src=\"doc\//gi;
47
48 $body =~ s/href=\"(?!http)/href=\"doc\//gi;
49 $body =~ s/src=\"(?!http)/src=\"doc\//gi;
50
51 open FILE,$inputphp;
52 open OUTPUT,"> $output";
53
54 while(defined($line=<FILE>)) {
55     chomp $line;
56     if($line =~/______ONGLETS______/) {
57         $line =~ s/______ONGLETS______/$onglets/g;
58     } elsif($line =~/______BODY______/) {
59         $line =~ s/______BODY______/$body/g;
60     }
61     print OUTPUT "$line\n";
62 }
63
64 close(FILE);
65 close(OUTPUT);