default.pl 10.9 KB
Newer Older
powelld's avatar
powelld committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
<<
# Scandoc template file.
#
# This is an example set of templates that is designed to create several 
# different kinds of index files. It generates a "master index" which intended 
# for use with a frames browser; A "package index" which is the root page of 
# the index, and then "package files" containing documentation for all of the 
# classes within a single package.

######################################################################

## For quick and superficial customization, 
## simply change these variables

$project_name     = '[Apache]';
$company_logo     = '<img src="../images/ScanDocBig.jpg">'; # change this to an image tag.
$copyright        = '&copy 2000 [Apache Software Foundation]';
$image_directory  = "../images/";
$bullet1_image    = $image_directory . "ball1.gif";
$bullet2_image    = $image_directory . "ball2.gif";
$bgcolor1         = "#FFFFFF";
$bgcolor2         = "#FFFFFF";

######################################################################

## Begin generating frame index file.

file "index.html";
>><html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; iso-8859-1">
    <title>$project_name</title>
  </head>
  <frameset cols="190,*">
    <frame src="master.html"  name="Master Index" noresize>
    <frame src="packages.html" name="Documentation">
    <noframes>
      <body bgcolor="$bgcolor2" stylesrc="index.html">
        <p>Some Documentation</p>
      </body>
    </noframes>
  </frameset>
</html>
<<

######################################################################

## Begin generating master index file (left-hand frame).

file "master.html";
>><html>
  <head>
    <title>Master Index</title>
  </head>
  <body bgcolor="$bgcolor1" text=#0000ff link=#0020ff vlink=#0020ff>
    <center><img src="${image_directory}ScanDocSmall.jpg" border="0" /></center>
    <p>
    <a href="packages.html" target="Documentation">Master Index</a>
    </p>
    <p>
      <font size="2">
        <nobr>
<<

## For each package, generate an index entry.

foreach $p (packages()) {
  $_ = $p->url;
  s/\s/%20/g;
  >><a href="$_" target="Documentation"><b>$(p.name)</b></a><br>
    <dir>
  <<
  foreach $e ($p->classes()) {
    $_ = $e->url;
    s/\s/%20/g;
    >><li><a href="$_" target="Documentation">$(e.fullname)</a>
    <<
  }
  foreach $e ($p->globals()) {
    $_ = $e->url;
    s/\s/%20/g;
    >><li><a href="$_" target="Documentation">$(e.fullname)</a>
    <<
  }
  >></dir><<
}

>>
          <a href="to-do.html" target="Documentation"><b>To-Do List</b></a><br>
        </nobr>
      </font>
    </p>
  </body>
</html>
<<

######################################################################

## Begin generating package index file

file "packages.html";
>><html>
  <head>
    <title>$project_name -- Packages</title>
  </head>
  <body bgcolor="$bgcolor2">

    <center>$company_logo
    <h1>Documentation for $project_name</h1>
    </center>
    <h2>Package List</h2>
<<

## For each package, generate an index entry.

foreach $p (packages()) {
  $_ = $p->url;
  s/\s/%20/g;
  >><a href = "$_">$(p.name)</a><br>
  <<
}

>>
    <p>
    <hr size=4>
    $copyright<br>
    Generated by <a href="$scandocURL"><b>ScanDoc $majorVersion.$minorVersion</b></a><br>
    Last Updated: $date<br>
  </body>
</html>

<<

######################################################################

## Generate "To-do list"

file "to-do.html";
>><html>
  <head>
    <title>$project_name -- To-Do list</title>
  </head>
  <body bgcolor="$bgcolor2">

    $company_logo

    <h1>To-do list for $project_name</h1>
<<

if (&todolistFiles()) {
  >><hr size=4><p>
  <<
  foreach $f (&todolistFiles()) {
    my @m = &todolistEntries( $f );
    if ($f =~ /([^\/]+)$/) { $f = $1; }
    >><b>$f:</b><ul>
    <<
    foreach $text (@m) {
      if ($text) {
        print "<li>", &processDescription( $text ), "\n";
      }
    }
    >></ul>
    <<
  }
}

>>
    <hr size=4>
    $copyright<br>
    Generated by <a href="$scandocURL"><b>ScanDoc $majorVersion.$minorVersion</b></a><br>
    Last Updated: $date<br>
  </body>
</html>
<<

######################################################################

## Generate individual files for each package.

my $p;
foreach $p (packages()) {
  file $p->name() . ".html";
  >><html>
  <head>
    <title>$project_name -- $(p.name)</title>
  </head>
  <body bgcolor="$bgcolor2">
    <center>
      <font size=6><b>$project_name</b></font>
      <hr size=4><p>
    </center>

    <h2>Package Name: $(p.name)</h2>
    <b>
<<

## Generate class and member index at the top of the file.

foreach $c ($p->classes()) {
  >><h3><img src="$bullet1_image" width=18 height=17 align=texttop>
    <a href="$(c.url)">$(c.fullname)</h3></a>
    <ul>
  <<
  foreach $m ($c->members()) {
    >><li><a href="$(m.url)">$(m.longname)</a>
    <<
  }
  >></ul>
  <<
}

>>
</b>
<<

## Generate detailed class documentation
foreach $c ($p->classes()) {
 ## Output searchable keyword list
 if ($c->keywords()) {
   print "<!-- ", $c->keywords(), " -->\n";
 }

 >><hr size="4">
   <a name="$(c.anchor)"></a>
   <h1>$(c.fullname)</h1>
   <table bgcolor="ffffff" border="0" cellspacing="4">
     <tr>
       <th align=center colspan=2>
       </th>
     </tr>
  <<
  
  # Output author tag
  if ($c->author()) {
    >><tr><th width=20% align=right>Author:</th><<
    >><td>$(c.author)</td></tr><<
  }

  # Output package version
  if ($c->version()) {
    >><tr><th width=20% align=right>Version:</th><<
    >><td>$(c.version)</td></tr><<
  }

  # Output Source file
  if ($c->sourcefile()) {
    >><tr><th width=20% align=right>Source:</th><<
    >><td>$(c.sourcefile)</td></tr><<
  }

  # Output base class list
  if ($c->baseclasses()) {
    >><tr><th width=20% align=right>Base classes:</th>
    <td><<
    my @t = ();
    foreach $b ($c->baseclasses()) {
      my $name = $b->name();
      if ($url = $b->url()) {
        push @t, "<a href=\"$url\">$name</a>";
      }
      else { push @t, $name; }
    }
    print join( ', ', @t );
    >></td></tr>
    <<
  }	

  # Output subclasses list
  if ($c->subclasses()) {
    >><tr><th width=20% align=right>Subclasses:</th>
      <td><<
    my @t = ();
    foreach $s ($c->subclasses()) {
      my $name = $s->name();
      if ($url = $s->url()) {
        push @t, "<a href=\"$url\">$name</a>";
      }
      else { push @t, $name; }
    }
    print join( ', ', @t );
    >></td></tr><<
  }

  # Output main class description
  >></tr>
  </table>
  <p>
  <<
  print &processDescription( $c->description() );
	
  # Output "see also" information
  if ($c->seealso()) {
    >><p><dt><b>See Also</b><dd>
    <<
    my @r = ();
    foreach $a ($c->seealso()) {
      my $name = $a->name();
      if ($url = $a->url()) {
        push @r, "<a href=\"$url\">$name</a>";
      }
      else { push @r, $name; }
    }
    print join( ',', @r );
    >><p>
    <<
  }

  # Output class member index
  if ($c->members()) {
    print "<h2>Member Index</h2>\n";
    print "<ul>";
    foreach $m ($c->members()) {
      >><li><a href="$(m.url)">$(m.fullname)</a>
	<<
    }
    >></ul><<
  }
 
  # Output class member variable documentation
  if ($c->membervars()) {
    print "<h2>Class Variables</h2>\n";
    print "<blockquote>\n";
    foreach $m ($c->membervars()) { &variable( $m ); }
    print "</blockquote>\n";
  }

  # Output class member function documentation
  if ($c->memberfuncs()) {
    print "<h2>Class Methods</h2>\n";
    print "<blockquote>\n";
    foreach $m ($c->memberfuncs()) { &function( $m ); }
    print "</blockquote>\n";
  }
}

# Output global variables
if ($p->globalvars()) {
  >><h2>Global Variables</h2>
    <blockquote>
  <<
  foreach $m ($p->globalvars()) { &variable( $m ); }
  print "</blockquote>\n";
}

# Output global functions
if ($p->globalfuncs()) {
  >><h2>Global Functions</h2>
    <blockquote>
  <<
  foreach $m ($p->globalfuncs()) { &function( $m ); }
  print "</blockquote>\n";
}

>>
    <hr size=4>
    $copyright<br>
    Generated by <a href="$scandocURL"><b>ScanDoc $majorVersion.$minorVersion</b></a><br>
    Last Updated: $date<br>
  </body>
</html>
<<
} # end of foreach (packages) loop

######################################################################

## Subroutine to generate documentation for a member function or global function

sub function {
  local ($f) = @_;
  
  if ($f->keywords()) {
    >><!-- $(f.keywords) -->
      <<
  }
  >>
  <a name="$(f.anchor)"></a>
  <dl>
    <dt>
     <b><img src="$bullet2_image" width=19 height=17 align=texttop>$(f.fullname);</b>
    <dd>
  <<
  print &processDescription( $f->description() );
  >>
  <p><dl>
  <<
  if ($f->params()) {
    >>
      <dt><b>Parameters</b><dd>
	<table width="85%">
    <<
    foreach $a ($f->params()) {
      >><tr valign=top><th align=right>
	$(a.name)</th><td><<
      print &processDescription( $a->description() );
      >></td></tr>
      <<
    }
    >></table>
      <<
  }
	
  if ($f->returnValue()) {
    >><dt><b>Return Value</b>
      <dd><<
    print &processDescription( $f->returnValue() );
    >><p><<
  }
  
  if ($f->exceptions()) {
    >><dt><b>Exceptions</b><dd>
      <table width=85%><tr><td colspan=2><hr size=3></td></tr>
    <<
    foreach $a ($f->exceptions()) {
      >><tr valign=top><th align=right>
	$(a.name)</th><td><<
	  print &processDescription( $a->description() );
      >></td></tr>
      <<
    }
    >><tr><td colspan=2><hr size=3></td></tr></table>
    <<
  }
	
  if ($f->seealso()) {
    >><dt><b>See Also</b><dd>
      <<
    my @r = ();
    foreach $a ($f->seealso()) {
      my $name = $a->name();
      if ($url = $a->url()) {
	push @r, "<a href=\"$url\">$name</a>";
      }
      else { push @r, $name; }
    }
    print join( ',', @r );
    >><p><<
  }
  >></dl></dl>
  <<
}

######################################################################

## Subroutine to generate documentation for a member variable or global variable.

sub variable {
  local ($v) = @_;
  
  if ($v->keywords()) {
    print "<!-- $(v.keywords) -->";
  }

  >>
    <a name="$(v.name)"></a>
      <dl><dt>
	<b><img src="$bullet2_image" width=19 height=17 align=texttop>$(v.fullname);</b>
  <dd>
  <<print &processDescription( $v->description() );>>
  <p><dl>
  <<
  if ($v->seealso()) {
    >><dt><b>See Also</b><dd>
      <<
	$comma = 0;
    foreach $a ($v->seealso()) {
      if ($comma) { print ","; }
      $comma = 1;
      >><a href="$(a.url)">$(a.name)</a>
	<<
    }
    >><p>
    <<
  }
  >></dl></dl>
  <<
}

######################################################################

sub processDescription {
  local ($_) = @_;
  
  s/^\s+//;				# Remove whitespace from beginning
  s/\s+$/\n/;				# Remove whitespace from end
  s/\n\n/<p>\n/g;			# Replace multiple CR's with paragraph markers
  s:\@heading(.*)\n:<p><h2>$1</h2>:;	# Handle heading text
  
  # Handle embedded image tags
  s:\@caution:<p><img src=\"${image_directory}/caution.gif\" align=left>:;
  s:\@warning:<p><img src=\"${image_directory}/warning.gif\" align=left>:;
  s:\@bug:<p><img src=\"${image_directory}/bug.gif\">:;
  s:\@tip:<p><img src=\"${image_directory}/tip.gif\">:;

  return $_;
}