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)
11 ### Get the module definitions
14 open IN, "html/modules.html" || die "Cannot parse html/modules.html. Did you really run doxygen?\n";
18 last if /group__SimGrid__API.html/;
26 $current->{'label'}="ROOT";
27 push @{$top->{'down'}},$current;
30 print "Push $current as child of $top\n" if $debug{'parse'};
34 print "DOWN: $current -> " if $debug{'parse'};
35 $current = $current->{'down'}[scalar @{$current->{'down'}} - 1];
36 print "$current\n" if $debug{'parse'};
40 $current = $current->{'up'};
41 print "UP\n" if $debug{'parse'};
48 m|href="([^"]*)">([^<]*)</a>|; #"
51 $entry->{'file'} = $1;
52 $entry->{'label'} = $2;
53 $entry->{'up'} = $current;
54 push @{$current->{'down'}},$entry;
55 print "Push $1 $2 as child of $current\n" if $debug{'parse'};
59 # Check each file for extra information (short name, extra childs)
63 if (defined($current->{'file'})) {
64 open IN, "html/$current->{'file'}";
66 if (/DOXYGEN_NAVBAR_LABEL/) {
67 if (/DOXYGEN_NAVBAR_LABEL="([^"]*)"/) {#"
68 $current->{'label'}=$1;
70 die "Malformated DOXYGEN_NAVBAR_LABEL line in $current->{'file'}";
73 if (/DOXYGEN_NAVBAR_CHILD/) {
74 if (/DOXYGEN_NAVBAR_CHILD *"([^"]*)"=([^ ]*)/) {#"
76 $entry->{'label'} = $1;
77 $entry->{'file'} = $2;
78 chomp($entry->{'file'});
79 $entry->{'up'} = $current;
80 push @{$current->{'down'}},$entry;
82 die "Malformated DOXYGEN_NAVBAR_CHILD line in $current->{'file'}";
88 foreach my $entry (@{$current->{'down'}}) {
99 print "$current: ".$current->{'label'}." ($current->{'file'})\n";
100 foreach my $entry (@{$current->{'down'}}) {
101 display($entry,$level+1);
105 display($top,0) if $debug{'input'};
108 ### Generate the navbar
111 # the root deserves some special handling
112 open IN,"html/modules.html" || die;
113 open OUT,">html/modules.new.html" || die;
115 while ($line = <IN>) {
116 last if $line =~ /<h1>SimGrid Modules</;
120 print OUT "<div class=\"tabs\">\n <ul>\n";
121 foreach $current (@{ ${$top->{'down'}}[0]->{'down'} }) {
122 print OUT " <li><a href=\"$current->{'file'}\"><span>$current->{'label'}</span></a></li>\n";
124 print OUT " </ul></div>\n";
132 rename("html/modules.new.html","html/modules.html") unless $debug{'rename'};
134 # Operate the recursion
139 # we generate the tabs bottom up begining from where we are in the tree
140 # and display them top down, as it should in a file
143 if (defined ($current->{'label'}) and $current->{'label'} ne 'ROOT') {
144 # print "handle $current->{'file'}, at level $level\n";
146 my $iterator = $current;
148 while ($lvl_it >= 0) {
149 my $father = $iterator->{'up'};
150 $tabs[$lvl_it] = "<div class=\"tabs\">\n <ul>\n";
151 foreach my $bro (@{$father->{'down'}}) {
152 $tabs[$lvl_it] .= " <li".($bro==$iterator?" id=\"current\"":"")."> <a href=\"$bro->{'file'}\"><span>$bro->{'label'}</span></a></li>\n";
154 $tabs[$lvl_it] .= " </ul></div>\n";
158 if (defined $current->{'down'}) { # there's some kid. Display them too
159 $tabs[$level+1] = "<div class=\"tabs\">\n <ul>\n";
160 foreach my $kid (@{$current->{'down'}}) {
161 $tabs[$level+1] .= " <li> <a href=\"$kid->{'file'}\"><span>$kid->{'label'}</span></a></li>\n";
163 $tabs[$level+1] .= " </ul></div>\n";
167 open FROM,"html/$current->{'file'}" || die;
168 my $newname="html/$current->{'file'}";
169 $newname =~ s/.html/.new.html/;
170 open TO,">$newname" || die;
172 # add "current" to the module API granfather page
173 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>|;
176 last if m|</ul></div>|;
186 rename("$newname","html/$current->{'file'}") unless $debug{'rename'};
190 foreach my $entry (@{$current->{'down'}}) {
191 handle_page($entry,$level+1);
195 handle_page($top,-2);# skip roots (we have 2 roots) in level counting