Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Also post-process pages.html. I'm gonna kill it, but it's not done yet
[simgrid.git] / tools / doxygen / toc_create.pl
index 52fbd09..c5b2b46 100755 (executable)
@@ -1,15 +1,17 @@
 #!/usr/bin/perl -w
 
-($#ARGV >= 1) or die "Usage: index_create.pl <input-tag-file> <output-doc-file>";
+use strict;
 
-my(@toc);
-my($level,$label,$name);
+($#ARGV >= 1) or die "Usage: toc_create.pl <input-doc-file>+";
 
-$input  = $ARGV[0];
-$output = $ARGV[1];
-open FILE,$input;
+sub handle_file {
+  my $infile = shift;
+  open FILE,$infile;
 
-while($line=<FILE>) {
+  my(@toc);
+  my($level,$label,$name);
+
+  while(my $line=<FILE>) {
     chomp $line;
     if($line=~/\\section\s*(\S\S*)\s*(.*)$/) {
 #      print "$line\n";
@@ -33,47 +35,42 @@ while($line=<FILE>) {
 #      print "\t\t$label : $name\n";
        push @toc,[$level,$label,$name];
     }
-}
-close FILE;
-
-open OUTPUT,"> $output";
-my($current_level)=-1;
-my($entry);
-print OUTPUT "<!-- Automatically generated table of contents --!>\n";
-foreach $entry (@toc) {
-    ($level,$label,$name) = @$entry;
+  }
+  close FILE;
 
-    if($current_level<$level) {
-       print OUTPUT "<ol type=\"1\">\n";
-    }
-    if($current_level>$level) {
-       print OUTPUT "</ol>\n";
-    }
-    $current_level = $level;
-    foreach (1..$current_level) {
-       print OUTPUT "\t";
-    }
-    print OUTPUT "<li> <a href=\"#$label\">$name</a>\n";
-}
+  my $outfile = ".$infile.toc";
+  $outfile =~ s|\.\./||g;
+  $outfile =~ s|/|_|g;
+  open OUTPUT,"> $outfile";
+  my($current_level)=-1;
+  my($entry);
+  print OUTPUT "<!-- Automatically generated table of contents --!>\n";
+  print OUTPUT "<div class=\"toc\">\n";
+  print OUTPUT "<div class=\"tocTitle\">Table of content</div>\n";
+  foreach $entry (@toc) {
+      ($level,$label,$name) = @$entry;
 
-$current_level=-1;
-print OUTPUT "</ol>\n";
-print OUTPUT "<!-- End of automatically generated table of contents --!>\n";
+      while($current_level<$level) {
+         print OUTPUT "<ol type=\"1\">\n";
+         $current_level++;
+      }        
+      while($current_level>$level) {
+         print OUTPUT "</ol>\n";
+         $current_level--;
+      }
+      foreach (1..$current_level) {
+         print OUTPUT "\t";
+      }
+      print OUTPUT "<li> <a href=\"#$label\">$name</a>\n";
+  }
 
+  while($current_level>-1) {
+      print OUTPUT "</ol>\n";
+      $current_level--;
+  }
+  print OUTPUT "</div>\n";
+  print OUTPUT "<!-- End of automatically generated table of contents --!>\n";
+} # sub handle_file
 
-# foreach $type qw(define enumeration enumvalue function typedef) {
-#     if(defined $database{$type}) {
-#      print OUTPUT "<h2>$type</h2> \n  <ul>\n";
-#      foreach $name (sort keys %{$database{$type}}) {
-#          if($type eq "function") {
-#              print OUTPUT "\t<LI> $name()</LI>\n";
-#          } else {
-#              print OUTPUT "\t<LI> #$name</LI>\n";
-#          }
-#      }
-#      print OUTPUT "\n  </ul>\n";
-#     }
-# }
-# print OUTPUT "*/";
-# close OUTPUT;
 
+map { handle_file($_) } @ARGV;
\ No newline at end of file