X-Git-Url: http://git.hcoop.net/clinton/guile-figl.git/blobdiff_plain/b002944dd992dc5a273e0067504beb48e1ae3d1c..a6a00658f26c164551287799b194cc2f07eb78be:/upstream-doc/man4/xhtml/makeindex.pl diff --git a/upstream-doc/man4/xhtml/makeindex.pl b/upstream-doc/man4/xhtml/makeindex.pl new file mode 100644 index 0000000..a909123 --- /dev/null +++ b/upstream-doc/man4/xhtml/makeindex.pl @@ -0,0 +1,300 @@ +#!/usr/bin/perl + +sub Usage { +print +"Usage: makeindex xhtmldir xmldir + where xhtmldir contains a directory full of OpenGL .xml XHTML man pages -AND- + where xmldir contains a directory full of OpenGL .xml source XML man pages + + probably want to redirect output into a file like + ./makeindex.pl . .. > ./index.html +" +} + +sub PrintHeader { +print ' + + +OpenGL Documentation + + + +

OpenGL 4 Reference Pages

+

+ +'; +} + +sub PrintFooter { +print ' + + +'; +} + +sub TableElementForFilename { + my $name = shift; + + my $strippedname = $name; + $strippedname =~ s/\.xml//; + print "\t"; + print ''; + print "$strippedname"; + print "\n"; +} + +sub BeginTable { + my $letter = shift; + print "

\n"; + print ''; + print "\t\n"; +} + +sub EndTable { + print "\t"; + print ''; + print "\n
"; + print "$letter
Top
\n\n"; +} + + + +############## +# main +############## + +if (@ARGV != 2) +{ + Usage(); + die; +} + +# grab list of generated XHTML files +opendir(DIR,$ARGV[0]) or die "couldn't open directory"; + +@files = readdir(DIR); +close(DIR); +@files = sort @files; + +PrintHeader(); + +my @glX; +my @glut; +my @glu; +my @gl; + +my @realEntrypoints; +my @pageNames; + +#pre-create list of all true entrypoint names + +foreach (@files) +{ + if (/xml/) + { + $parentName = $ARGV[1] . '/' . $_; + if (open(PARENT, $parentName)) + { + @funcs = ; + @funcs = grep(//, @funcs); + foreach (@funcs) + { + $func = $_; + $func =~ s/.*//; + $func =~ s/<\/function>.*\n//; + + push (@realEntrypoints, $func); + } + close(PARENT); + } + } +} + +#pre-create list of page names + +foreach (@files) +{ + if (/xml/) + { + $parentName = $ARGV[1] . '/' . $_; + if (open(PARENT, $parentName)) + { + my $entrypoint = $_; + $entrypoint =~ s/\.xml//; + + push (@pageNames, $entrypoint); + + close(PARENT); + } + } +} + +#sort the files into gl, glut, glu, and glX + +foreach (@files) +{ + if (/xml/) + { + # filter out entrypoint variations that don't have their own man pages + my $needIndexEntry = 0; + + # continue only if parent page exists (e.g. glColor) OR + # different parent page exists with matching entrypoint (e.g. glEnd) + my $entrypoint = $_; + $entrypoint =~ s/\.xml//; + + foreach (@pageNames) + { + if ($_ eq $entrypoint) + { + # it has its own man page + $needIndexEntry = 1; + } + } + + if ($needIndexEntry == 0) + { + foreach (@realEntrypoints) + { + if ($_ eq $entrypoint) + { + # it's a real entrypoint, but make sure not a variation + $needIndexEntry = 1; + + foreach (@pageNames) + { + my $alteredEntrypoint = $entrypoint; + $alteredEntrypoint =~ s/$_//; + + if (!($alteredEntrypoint eq $entrypoint)) + { + $needIndexEntry = 0; + } + } + } + } + } + + if ($needIndexEntry) + { + if (/^glX/) + { + push (@glX, $_); + } + elsif (/^glut/) + { + push (@glut, $_); + } + elsif (/^glu/) + { + push (@glu, $_); + } + elsif (/^gl/) + { + push (@gl, $_); + } + } + } +} + + +#output the table of contents + +my @toc; + +if ($#gl > 0) +{ + $currentletter = ""; + $opentable = 0; + + foreach (@gl) + { + $name = $_; + $name =~ s/^gl//; + $firstletter = substr($name, 0, 1); + if ($firstletter ne $currentletter) + { + push (@toc, $firstletter); + $currentletter = $firstletter; + } + } + if ($#glu > 0) { push (@toc, "glu"); } + if ($#glut > 0) { push (@toc, "glut"); } + if ($#glX > 0) { push (@toc, "glX"); } +} + + +print '
'; +print '
'; +foreach (@toc) +{ + print ' '; + print $_; + print "   "; +} +print "
\n\n\n"; +print '
'; + +# output the tables + +if ($#gl > 0) +{ + $currentletter = ""; + $opentable = 0; + + foreach (@gl) + { + $name = $_; + $name =~ s/^gl//; + $firstletter = substr($name, 0, 1); + if ($firstletter ne $currentletter) + { + if ($opentable == 1) + { + EndTable(); + } + BeginTable($firstletter); + $opentable =1; + $currentletter = $firstletter; + } + TableElementForFilename($_); + } + if ($opentable) + { + EndTable(); + } +} + +if ($#glu > 0) +{ + BeginTable("glu"); + foreach (@glu) + { + TableElementForFilename($_); + } + EndTable(); +} + +if ($#glut > 0) +{ + BeginTable("glut"); + foreach (@glut) + { + TableElementForFilename($_); + } + EndTable(); +} + +if ($#glX > 0) +{ + BeginTable("glX"); + foreach (@glX) + { + TableElementForFilename($_); + } + EndTable(); +} + +PrintFooter();