6 $debug{'parse'} = 0; # show how we parse the module tree
7 $debug{'input'} = 0; # display the resulting tree
8 $debug{'rename'}= 0; # do not overwrite the files (allows several debuging runs without rerunning doxygen)
12 ### Get the module definitions
15 open IN, "html/modules.html" || die "Cannot parse html/modules.html. Did you really run doxygen?\n";
19 last if /group__SimGrid__API.html/;
27 $current->{'label'}="ROOT";
28 push @{$top->{'down'}},$current;
31 print "Push $current as child of $top\n" if $debug{'parse'};
35 print "DOWN: $current -> " if $debug{'parse'};
36 $current = $current->{'down'}[scalar @{$current->{'down'}} - 1];
37 print "$current\n" if $debug{'parse'};
41 $current = $current->{'up'};
42 print "UP\n" if $debug{'parse'};
49 m|href="([^"]*)">([^<]*)</a>|; #"
52 $entry->{'file'} = $1;
53 $entry->{'label'} = $2;
54 $entry->{'up'} = $current;
55 push @{$current->{'down'}},$entry;
56 print "Push $1 $2 as child of $current\n" if $debug{'parse'};
61 # Check each file for extra information (short name, extra childs)
65 if (defined($current->{'file'})) {
66 open IN, "html/$current->{'file'}";
68 if (/DOXYGEN_NAVBAR_LABEL/) {
69 if (/DOXYGEN_NAVBAR_LABEL="([^"]*)"/) {#"
70 $current->{'label'}=$1;
72 die "Malformated DOXYGEN_NAVBAR_LABEL line in $current->{'file'}";
75 if (/DOXYGEN_NAVBAR_CHILD/) {
76 if (/DOXYGEN_NAVBAR_CHILD *"([^"]*)"=([^ ]*)/) {#"
78 $entry->{'label'} = $1;
79 $entry->{'file'} = $2;
80 chomp($entry->{'file'});
81 $entry->{'up'} = $current;
82 push @{$current->{'down'}},$entry;
84 die "Malformated DOXYGEN_NAVBAR_CHILD line in $current->{'file'}";
90 foreach my $entry (@{$current->{'down'}}) {
101 print "$current: ".$current->{'label'}." ($current->{'file'})\n";
102 foreach my $entry (@{$current->{'down'}}) {
103 display($entry,$level+1);
107 display($top,0) if $debug{'input'};
110 ### Generate the navbar
113 # the root deserves some special handling
114 open IN,"html/modules.html" || die;
115 open OUT,">html/modules.new.html" || die;
117 while ($line = <IN>) {
118 last if $line =~ /<h1>SimGrid Modules</;
122 print OUT "<div class=\"tabs\">\n <ul>\n";
123 foreach $current (@{ ${$top->{'down'}}[0]->{'down'} }) {
124 print OUT " <li><a href=\"$current->{'file'}\"><span>$current->{'label'}</span></a></li>\n";
126 print OUT " </ul></div>\n";
134 rename("html/modules.new.html","html/modules.html") unless $debug{'rename'};
136 # Operate the recursion
141 # we generate the tabs bottom up begining from where we are in the tree
142 # and display them top down, as it should in a file
145 if (defined ($current->{'label'}) and $current->{'label'} ne 'ROOT') {
146 # print "handle $current->{'file'}, at level $level\n";
148 my $iterator = $current;
150 while ($lvl_it >= 0) {
151 my $father = $iterator->{'up'};
152 $tabs[$lvl_it] = "<div class=\"tabs\">\n <ul>\n";
153 foreach my $bro (@{$father->{'down'}}) {
154 $tabs[$lvl_it] .= " <li".($bro==$iterator?" id=\"current\"":"")."> <a href=\"$bro->{'file'}\"><span>$bro->{'label'}</span></a></li>\n";
156 $tabs[$lvl_it] .= " </ul></div>\n";
160 if (defined $current->{'down'}) { # there's some kid. Display them too
161 $tabs[$level+1] = "<div class=\"tabs\">\n <ul>\n";
162 foreach my $kid (@{$current->{'down'}}) {
163 $tabs[$level+1] .= " <li> <a href=\"$kid->{'file'}\"><span>$kid->{'label'}</span></a></li>\n";
165 $tabs[$level+1] .= " </ul></div>\n";
169 open FROM,"html/$current->{'file'}" || die;
170 my $newname="html/$current->{'file'}";
171 $newname =~ s/.html/.new.html/;
172 open TO,">$newname" || die;
174 # add "current" to the module API granfather page
175 s|<li><a href="modules.html"><span>Modules API</span></a></li>|<li id="current"><a href="modules.html"><span>Modules API</span></a></li>|;
178 last if m|</ul></div>|;
188 rename("$newname","html/$current->{'file'}") unless $debug{'rename'};
192 foreach my $entry (@{$current->{'down'}}) {
193 handle_page($entry,$level+1);
200 ### Post-processsing common to all pages
202 map {push @allfiles,$_} qw(html/index.html html/faq.html html/publis.html);
204 foreach my $file (@allfiles) {
205 open FROM,"$file" || die;
206 my $outfile = "$file";
207 $outfile =~ s/.html/.new.html/;
208 open TO,">$outfile" || die;
210 # Add the simgrid css, just in case
211 print TO '<link href="simgrid.css" rel="stylesheet" type="text/css">'."\n"
215 if (m,<li><a href="index.html"><span>Main\ Page</span></a></li>,) {
216 print TO '<li><a href="index.html"><span>Overview</span></a></li>';
217 print TO '<li><a href="faq.html"><span>FAQ</span></a></li>';
220 if (m,<li><a href="annotated.html"><span>Data\ Structures</span></a></li>,) {
221 print TO '<li><a href="publis.html"><span>Publications</span></a></li>';
224 s|<span>Modules</span>|<span>Modules API</span>|g;
225 s|<li><a href="dirs.html"><span>Directories</span></a></li>||g;
231 rename("$outfile", "$file") unless $debug{'rename'};
235 ### Launch the modules navbar reworking
237 handle_page($top,-2);# skip roots (we have 2 roots) in level counting