Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics
[simgrid.git] / tools / doxygen / toc_create.pl
1 #!/usr/bin/perl -w
2
3 ($#ARGV >= 1) or die "Usage: index_create.pl <input-tag-file> <output-doc-file>";
4
5 my(@toc);
6 my($level,$label,$name);
7
8 $input  = $ARGV[0];
9 $output = $ARGV[1];
10 open FILE,$input;
11
12 while($line=<FILE>) {
13     chomp $line;
14     if($line=~/\\section\s*(\S\S*)\s*(.*)$/) {
15 #       print "$line\n";
16         $label = $1;
17         $name = $2;
18         $level=0;
19 #       print "$label : $name\n";
20         push @toc,[$level,$label,$name];
21     } elsif($line=~/\\subsection\s*(\S\S*)\s*(.*)$/) {
22 #       print "$line\n";
23         $label = $1;
24         $name = $2;
25         $level=1;
26 #       print "\t$label : $name\n";
27         push @toc,[$level,$label,$name];
28     } elsif($line=~/\\subsubsection\s*(\S\S*)\s*(.*)$/) {
29 #       print "$line\n";
30         $label = $1;
31         $name = $2;
32         $level=2;
33 #       print "\t\t$label : $name\n";
34         push @toc,[$level,$label,$name];
35     }
36 }
37 close FILE;
38
39 open OUTPUT,"> $output";
40 my($current_level)=-1;
41 my($entry);
42 print OUTPUT "<!-- Automatically generated table of contents --!>\n";
43 foreach $entry (@toc) {
44     ($level,$label,$name) = @$entry;
45
46     if($current_level<$level) {
47         print OUTPUT "<ol type=\"1\">\n";
48     }
49     if($current_level>$level) {
50         print OUTPUT "</ol>\n";
51     }
52     $current_level = $level;
53     foreach (1..$current_level) {
54         print OUTPUT "\t";
55     }
56     print OUTPUT "<li> <a href=\"#$label\">$name</a>\n";
57 }
58
59 $current_level=-1;
60 print OUTPUT "</ol>\n";
61 print OUTPUT "<!-- End of automatically generated table of contents --!>\n";
62
63
64 # foreach $type qw(define enumeration enumvalue function typedef) {
65 #     if(defined $database{$type}) {
66 #       print OUTPUT "<h2>$type</h2> \n  <ul>\n";
67 #       foreach $name (sort keys %{$database{$type}}) {
68 #           if($type eq "function") {
69 #               print OUTPUT "\t<LI> $name()</LI>\n";
70 #           } else {
71 #               print OUTPUT "\t<LI> #$name</LI>\n";
72 #           }
73 #       }
74 #       print OUTPUT "\n  </ul>\n";
75 #     }
76 # }
77 # print OUTPUT "*/";
78 # close OUTPUT;
79