blob: c4dc0ddf39808970c2e95d62087daa5569ee7760 [file] [log] [blame]
Fred Drake7313b031998-07-24 20:34:59 +00001package SynopsisTable;
2
3sub new{
4 return bless {names=>'', info=>{}};
5}
6
7sub declare{
8 my($self,$name,$key,$type) = @_;
9 if ($self->{names}) {
10 $self->{names} .= ",$name";
11 }
12 else {
13 $self->{names} .= "$name";
14 }
15 $self->{info}{$name} = "$key,$type,";
16}
17
18sub set_synopsis{
19 my($self,$name,$synopsis) = @_;
20 my($key,$type,$unused) = split ',', $self->{info}{$name}, 3;
21 $self->{info}{$name} = "$key,$type,$synopsis";
22}
23
24sub get{
25 my($self,$name) = @_;
26 return split /,/, $self->{info}{$name}, 3;
27}
28
29sub show{
30 my $self = shift;
31 my $name;
32 print "names: ", $self->{names}, "\n\n";
33 foreach $name (split /,/, $self->{names}) {
34 my($key,$type,$synopsis) = $self->get($name);
35 print "$name($key) is $type: $synopsis\n";
36 }
37}
38
39sub tohtml{
40 my $self = shift;
Fred Draked05177f1998-07-29 04:45:23 +000041 my $data = "<table>\n";
Fred Drake7313b031998-07-24 20:34:59 +000042 my $name;
43 foreach $name (split /,/, $self->{names}) {
44 my($key,$type,$synopsis) = $self->get($name);
Fred Draked05177f1998-07-29 04:45:23 +000045 my $link = "<a href=\"module-$key.html\">";
46 $data .= (" <tr><td><b><tt>$link$name</a></tt></b></td>\n"
47 . " <td>$synopsis</td></tr>\n");
Fred Drake7313b031998-07-24 20:34:59 +000048 }
Fred Draked05177f1998-07-29 04:45:23 +000049 $data .= "</table>\n";
Fred Drake7313b031998-07-24 20:34:59 +000050 $data;
51}
52
53
54package testSynopsisTable;
55
56sub test{
57 # this little test is mostly to debug the stuff above, since this is
58 # my first Perl "object".
59 my $st = SynopsisTable->new();
60 $st->declare("sample", "sample", "standard");
61 $st->set_synopsis("sample", "This is a little synopsis....");
62 $st->declare("copy_reg", "copyreg", "standard");
63 $st->set_synopsis("copy_reg", "pickle support stuff");
64 $st->show();
65
66 print "\n\n";
67
68 my $st2 = SynopsisTable->new();
69 $st2->declare("st2module", "st2module", "built-in");
70 $st2->set_synopsis("st2module", "silly little synopsis");
71 $st2->show();
72}
73
741; # This must be the last line -- Perl is bogus!