Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics to java documentation
[simgrid.git] / tools / doxygen / doxygen_postprocesser.pl
index 16425d0..22b3d7d 100755 (executable)
@@ -2,9 +2,24 @@
 
 use strict;
 
+# Add here the pages of the documentation generated by a @page doxygen macro
+my @extra_files = qw(html/index.html html/faq.html html/history.html html/people.html
+                     html/publis.html html/publis_core.html html/publis_extern.html html/publis_intra.html
+                     html/pages.html html/modules.html html/contrib.html index.php 
+                     html/GRAS_tut.html);
+
+# GRAS tutorial
+map {push @extra_files, "html/GRAS_tut_$_.html"} qw (intro 
+                                                     tour tour_install tour_setup tour_simpleexchange tour_args tour_callbacks tour_globals 
+                                                          tour_logs tour_timers tour_exceptions tour_rpc);
+
+# GRAS examples
+map {push @extra_files, "html/GRAS_ex_$_.html"} qw (ping mmrpc token timer);
+
 my %debug;
 $debug{'parse'} = 0; # show how we parse the module tree
 $debug{'input'} = 0; # display the resulting tree
+$debug{'handle'}= 0; # Be verbose on the post-processing
 $debug{'rename'}= 0; # do not overwrite the files (allows several debuging runs without rerunning doxygen)
 
 my @allfiles;
@@ -26,9 +41,9 @@ my $entry;
 
 $current->{'label'}="ROOT";
 push @{$top->{'down'}},$current;
+print "Push $current as child of $top\n" if $debug{'parse'};
 $current=$top;
 
-print "Push $current as child of $top\n" if $debug{'parse'};
 
 while (<IN>) {
   if (/<ul>/) {
@@ -54,7 +69,7 @@ while (<IN>) {
   $entry->{'up'} = $current;
   push @{$current->{'down'}},$entry;
   print "Push $1 $2 as child of $current\n" if $debug{'parse'};
-  push @allfiles,$1;
+  push @allfiles,"html/$1";
 }
 close IN;
 
@@ -67,6 +82,7 @@ sub extra_info {
     while (<IN>) {
       if (/DOXYGEN_NAVBAR_LABEL/) {
         if (/DOXYGEN_NAVBAR_LABEL="([^"]*)"/) {#"
+          print "Extra info from $current->{'file'}: label=$1, not $current->{'label'}\n" if $debug{'parse'};
           $current->{'label'}=$1;
         } else {
           die "Malformated DOXYGEN_NAVBAR_LABEL line in $current->{'file'}";
@@ -80,6 +96,7 @@ sub extra_info {
           chomp($entry->{'file'});
           $entry->{'up'} = $current;
           push @{$current->{'down'}},$entry;
+          print "Extra info from $current->{'file'}: New child $entry->{'label'}=$entry->{'file'}\n"  if $debug{'parse'};
         } else {
           die "Malformated DOXYGEN_NAVBAR_CHILD line in $current->{'file'}";
         }
@@ -133,11 +150,52 @@ close OUT;
 close IN;
 rename("html/modules.new.html","html/modules.html") unless $debug{'rename'};
 
+# the publication pages deserves some special handling too
+my %pub_tabs = ("publis.html"       =>"Reference publications",
+                "publis_core.html"  =>"Other publication about SimGrid",
+                "publis_extern.html"=>"External papers using SimGrid",
+                "publis_intra.html"=>"Internal papers using SimGrid");
+# force ordering
+my @pub_titles = ("publis.html", "publis_core.html", "publis_extern.html", "publis_intra.html");
+sub handle_pub{
+    my $oldname = shift;
+    my $newname = $oldname;
+    $newname =~ s/\.html$/.new.html/;
+#    print "Handle_pub($oldname -> $newname)\n";
+    
+    open IN,"html/$oldname" || die "Cannot open $oldname";
+    open OUT,">html/$newname" || die "Cannot open $newname";
+    my $line;
+    while ($line = <IN>) {
+       last if $line =~ /<h1>/;
+       print OUT $line;
+    }
+
+    print OUT "<div class=\"tabs\">\n  <ul>\n";
+    foreach my $page (@pub_titles) {
+       print OUT "         <li".($page eq $oldname? " class=\"current\"":"" )."> <a href=\"$page\"><span>".($pub_tabs{$page})."</span></a></li>\n";
+    }
+
+    print OUT "  </ul></div>\n";
+    print OUT $line;
+    while ($line = <IN>) {
+       print OUT $line;
+    }
+    close OUT;
+    close IN;
+    rename("html/$newname","html/$oldname") unless $debug{'rename'};
+}
+map {handle_pub($_)} @pub_titles;
+
+
 # Operate the recursion
 sub handle_page {
   my $current=shift;
   my $level=shift;
 
+  print "Handle $current->{'file'} at level $level\n" if $debug{'handle'};
+    
   # we generate the tabs bottom up begining from where we are in the tree
   # and display them top down, as it should in a file
   my @tabs = ();
@@ -151,7 +209,7 @@ sub handle_page {
       my $father = $iterator->{'up'};
       $tabs[$lvl_it] = "<div class=\"tabs\">\n  <ul>\n";
       foreach my $bro (@{$father->{'down'}}) {
-        $tabs[$lvl_it] .= "  <li".($bro==$iterator?" id=\"current\"":"")."> <a href=\"$bro->{'file'}\"><span>$bro->{'label'}</span></a></li>\n";      
+        $tabs[$lvl_it] .= "  <li".($bro==$iterator?" class=\"current\"":"")."> <a href=\"$bro->{'file'}\"><span>$bro->{'label'}</span></a></li>\n";      
       }
       $tabs[$lvl_it] .= "  </ul></div>\n";
       $iterator = $father;
@@ -168,20 +226,34 @@ sub handle_page {
     # put them in place
     open FROM,"html/$current->{'file'}" || die;
     my $newname="html/$current->{'file'}";
-    $newname =~ s/.html/.new.html/;
+    $newname =~ s/.html/.handlepage.html/;
     open TO,">$newname" || die;
+#    print "XXX Deal with html/$current->{'file'}  ->  $newname\n";
     while (<FROM>) {
-      # add "current" to the module API granfather page
-      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>|;
-      
-      print TO $_;
-      last if m|</ul></div>|;
+#      print "--Read  $_";
+      # add "current" to the module API granfather page
+      s|<li><a href="modules.html"><span>[^<]*</span></a></li>|<li class="current"><a href="modules.html"><span>Modules&nbsp;API</span></a></li>|;
+#      print "++Write $_";
+      print TO "$_";
+      last if (m|</div>|);
     }
     foreach (@tabs) {
-      print TO $_;
+#      print "TAB: $_";
+      print TO "$_";
+    }
+    if ($current->{'file'} =~ m/^class/) {
+       while (<FROM>) {
+           last if (m|</div>|);
+       }
+      print TO "$_";   
     }
     while (<FROM>) {
-      print TO $_;
+      if (m/The documentation for/) {
+         while (<FROM>) {
+             last if (m/<p>/);
+         }
+      }
+      print TO "$_";
     }    
     close FROM;
     close TO;
@@ -194,35 +266,45 @@ sub handle_page {
   }
 }
 
+###
+### Launch the modules navbar reworking
+###
+handle_page($top,-2);# skip roots (we have 2 roots) in level counting
 
 
 ###
 ### Post-processsing common to all pages
 ###
-map {push @allfiles,$_} qw(html/index.html html/faq.html html/publis.html html/pages.html);
+map {push @allfiles,$_} @extra_files;
+print "All files: ".(join(", ",@allfiles))."\n" if $debug{'parse'};
 
 foreach my $file (@allfiles) {
+    $file =~ s/.html/.handlepage.html/ if $debug{'rename'}; # Take right name if debugging
+       
     open FROM,"$file" || die;
     my $outfile = "$file";
-    $outfile =~ s/.html/.new.html/;
+    $outfile =~ s/.(html|php)$/.new.$1/;
     open TO,">$outfile" || die;
+#    print "POSTPROCESSING $file (tmp=$outfile)\n";
     while (<FROM>) {
       # Add the simgrid css, just in case
       print TO '<link href="simgrid.css" rel="stylesheet" type="text/css">'."\n"
         if (m|</head>|);
 
       # Rework the navbar
-      if (m,<li><a href="index.html"><span>Main\&nbsp;Page</span></a></li>,) {
-        print TO '<li><a href="index.html"><span>Overview</span></a></li>';
-        print TO '<li><a href="faq.html"><span>FAQ</span></a></li>';
+      if (m,<li><a href="(doc/)?index.html"><span>Main\&nbsp;Page</span></a></li>,) {
+        print TO '    <li'.($file =~ m,(doc/)?index.html, ? " class='current'" :"").'><a href="'.$1.'index.html"><span>Overview</span></a></li>'."\n";
+        print TO '    <li'.($file =~ m,(doc/)?faq.html, ? " class='current'" :"").'><a href="'.$1.'faq.html"><span>FAQ</span></a></li>'."\n";
         next;
       }
-      if (m,<li><a href="annotated.html"><span>Data\&nbsp;Structures</span></a></li>,) {
-        print TO '<li><a href="publis.html"><span>Publications</span></a></li>';
+      if (m,<li><a href="(doc/)?annotated.html"><span>Data\&nbsp;Structures</span></a></li>,) {
+        print TO '    <li'.($file =~ m,(doc/)?publis(_[^.]*)?.html, ? " class='current'" :"").'><a href="'.$1.'publis.html"><span>Publications</span></a></li>'."\n";
+        print TO '    <li'.($file =~ m,(doc/)?people.html, ? " class='current'" :"").'><a href="'.$1.'people.html"><span>People</span></a></li>'."\n";
+        print TO '    <li'.($file =~ m,(doc/)?history.html, ? " class='current'" :"").'><a href="'.$1.'history.html"><span>History</span></a></li>'."\n";
         next;
       }
       s|<span>Modules</span>|<span>Modules API</span>|g;
-      s|<li><a href="dirs.html"><span>Directories</span></a></li>||g;
+      s|<span>Related&nbsp;Pages</span>|<span>Site&nbsp;Plan</span>|g;
                                                                                                  
       print TO $_;
     }
@@ -231,9 +313,5 @@ foreach my $file (@allfiles) {
     rename("$outfile", "$file") unless $debug{'rename'};
 }
 
-###
-### Launch the modules navbar reworking
-###
-handle_page($top,-2);# skip roots (we have 2 roots) in level counting