• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# This script is obsolete. It would need to change to generate TOC.html
2# in the new format and link to .html instead of .xml files.
3
4#!/usr/bin/perl
5
6sub Usage {
7print
8"Usage: maketoc xhtmldir xmldir
9   where xhtmldir contains a directory full of OpenGL .xml XHTML man pages -AND-
10   where xmldir contains a directory full of OpenGL .xml source XML man pages
11
12   probably want to redirect output into a file like
13   ./maketoc.pl . .. > ./toc.html
14"
15}
16
17sub PrintHeader {
18print '<html>
19<head>
20<title>EGL Reference Pages</title>
21<style type="text/css">
22
23html, body, table
24{   color: #000;
25	padding: 4px 4px;
26	margin: 0px 0 0 0;
27	text-align: center;
28	font-family: Arial, Lucida, sans-serif;
29	font-size: 10pt;
30
31}
32
33#container {
34	margin: 10px;
35	font-size: 14pt;
36	text-decoration:none;
37}
38
39table.sample {
40	border-width: 1px;
41	border-spacing: 5px;
42	border-style: dotted;
43	border-color: black;
44	border-collapse: separate;
45	background-color: #F0F0F0;
46}
47table.sample th {
48	border-width: 1px;
49	padding: 5px;
50	border-style: none;
51}
52table.sample td {
53	border-width: 1px;
54	padding: 1px;
55	border-style: none;
56}
57</style>
58
59</head>
60<body>
61<a name="top"></a>
62<h1>EGL Reference Pages</h1>
63<br/><br/>
64
65';
66}
67
68sub PrintFooter {
69print '
70</body>
71</html>
72';
73}
74
75sub TableElementForFilename {
76	my $name = shift;
77
78	my $strippedname = $name;
79	$strippedname =~ s/\.xml//;
80	print "\t";
81	print '<tr><td><a target="pagedisp" href="' , $name , '">';
82	print "$strippedname";
83	print "</a></td></tr>\n";
84}
85
86sub BeginTable {
87	my $letter = shift;
88	print "<a name=\"$letter\"></a><br/><br/>\n";
89	print '<table width="220" align="center" class="sample">';
90	print "\t<th>";
91	print "$letter</th>\n";
92}
93
94sub EndTable {
95	print "\t";
96	print '<tr><td><center><a href="#top">Top</a></center></td></tr>';
97	print "\n</table>\n\n";
98}
99
100
101
102##############
103#  main
104##############
105
106if (@ARGV != 2)
107{
108	Usage();
109	die;
110}
111
112# grab list of generated XHTML files
113opendir(DIR,$ARGV[0]) or die "couldn't open directory";
114
115@files = readdir(DIR);
116close(DIR);
117@files = sort @files;
118
119PrintHeader();
120
121my @glX;
122my @glut;
123my @glu;
124my @egl;
125my @gl;
126
127my @realEntrypoints;
128my @pageNames;
129
130#pre-create list of all true entrypoint names
131
132foreach (@files)
133{
134	if (/xml/)
135	{
136		$parentName = $ARGV[1] . '/' . $_;
137		if (open(PARENT, $parentName))
138		{
139			@funcs = <PARENT>;
140			@funcs = grep(/<funcdef>/, @funcs);
141			foreach (@funcs)
142			{
143				$func = $_;
144				$func =~ s/.*<function>//;
145				$func =~ s/<\/function>.*\n//;
146
147				push (@realEntrypoints, $func);
148			}
149			close(PARENT);
150		}
151	}
152}
153
154#pre-create list of page names
155
156foreach (@files)
157{
158	if (/xml/)
159	{
160		$parentName = $ARGV[1] . '/' . $_;
161		if (open(PARENT, $parentName))
162		{
163			my $entrypoint = $_;
164			$entrypoint =~ s/\.xml//;
165
166			push (@pageNames, $entrypoint);
167
168			close(PARENT);
169		}
170	}
171}
172
173#sort the files into gl, glut, glu, EGL, and glX
174
175foreach (@files)
176{
177	if (/xml/)
178	{
179		# filter out entrypoint variations that don't have their own man pages
180		my $needIndexEntry = 0;
181
182		# continue only if parent page exists (e.g. glColor) OR
183		# different parent page exists with matching entrypoint (e.g. glEnd)
184		my $entrypoint = $_;
185		$entrypoint =~ s/\.xml//;
186
187		foreach (@pageNames)
188		{
189			if ($_ eq $entrypoint)
190			{
191				# it has its own man page
192				$needIndexEntry = 1;
193			}
194		}
195
196		if ($needIndexEntry == 0)
197		{
198			foreach (@realEntrypoints)
199			{
200				if ($_ eq $entrypoint)
201				{
202					# it's a real entrypoint, but make sure not a variation
203					$needIndexEntry = 1;
204
205					foreach (@pageNames)
206					{
207						my $alteredEntrypoint = $entrypoint;
208						$alteredEntrypoint =~ s/$_//;
209
210						if (!($alteredEntrypoint eq $entrypoint))
211						{
212							$needIndexEntry = 0;
213						}
214					}
215				}
216			}
217		}
218
219		if ($needIndexEntry)
220		{
221			if (/^glX/)
222			{
223				push (@glX, $_);
224			}
225			elsif (/^glut/)
226			{
227				push (@glut, $_);
228			}
229			elsif (/^glu/)
230			{
231				push (@glu, $_);
232			}
233			elsif (/^egl/)
234			{
235				push (@egl, $_);
236			}
237			elsif (/^gl/)
238			{
239				push (@gl, $_);
240			}
241		}
242	}
243}
244
245
246#output the table of contents
247
248my @toc;
249
250if ($#gl > 0)
251{
252	$currentletter = "";
253	$opentable = 0;
254
255	foreach (@gl)
256	{
257		$name = $_;
258		$name =~ s/^gl//;
259		$firstletter = substr($name, 0, 1);
260		if ($firstletter ne $currentletter)
261		{
262			push (@toc, $firstletter);
263			$currentletter = $firstletter;
264		}
265	}
266	if ($#egl > 0) { push (@toc, "egl"); }
267	if ($#glu > 0) { push (@toc, "glu"); }
268	if ($#glut > 0) { push (@toc, "glut"); }
269	if ($#glX > 0) { push (@toc, "glX"); }
270}
271
272
273print '<div id="container">';
274foreach (@toc)
275{
276	print '<b><a href="#';
277	print $_;
278	print '" style="text-decoration:none"> ';
279	print $_;
280	print " </a></b> &nbsp; ";
281}
282print "</div>\n\n\n";
283
284# output the tables
285
286if ($#gl > 0)
287{
288	$currentletter = "";
289	$opentable = 0;
290
291	foreach (@gl)
292	{
293		$name = $_;
294		$name =~ s/^gl//;
295		$firstletter = substr($name, 0, 1);
296		if ($firstletter ne $currentletter)
297		{
298			if ($opentable == 1)
299			{
300				EndTable();
301			}
302			BeginTable($firstletter);
303			$opentable =1;
304			$currentletter = $firstletter;
305		}
306		TableElementForFilename($_);
307	}
308	if ($opentable)
309	{
310		EndTable();
311	}
312}
313
314if ($#egl > 0)
315{
316	BeginTable("egl");
317	foreach (@egl)
318	{
319		TableElementForFilename($_);
320	}
321	EndTable();
322}
323
324if ($#glu > 0)
325{
326	BeginTable("glu");
327	foreach (@glu)
328	{
329		TableElementForFilename($_);
330	}
331	EndTable();
332}
333
334if ($#glut > 0)
335{
336	BeginTable("glut");
337	foreach (@glut)
338	{
339		TableElementForFilename($_);
340	}
341	EndTable();
342}
343
344if ($#glX > 0)
345{
346	BeginTable("glX");
347	foreach (@glX)
348	{
349		TableElementForFilename($_);
350	}
351	EndTable();
352}
353
354PrintFooter();
355