Added entries about removal of some bare except clauses from logging.
[python.git] / Doc / perl / SynopsisTable.pm
blob3c65a67d11347ea450c4fdbe488c86cb019543a7
1 package SynopsisTable;
3 sub new{
4 return bless {names=>'', info=>{}, file=>''};
7 sub declare{
8 my($self,$name,$key,$type) = @_;
9 if ($self->{names}) {
10 $self->{names} .= ",$name";
12 else {
13 $self->{names} .= "$name";
15 $self->{info}{$name} = "$key,$type,";
18 # The 'file' attribute is used to store the filename of the node in which
19 # the table will be presented; this assumes that each table will be presented
20 # only once, which works for the current use of this object.
22 sub set_file{
23 my($self, $filename) = @_;
24 $self->{file} = "$filename";
27 sub get_file{
28 my $self = shift;
29 return $self->{file};
32 sub set_synopsis{
33 my($self,$name,$synopsis) = @_;
34 my($key,$type,$unused) = split ',', $self->{info}{$name}, 3;
35 $self->{info}{$name} = "$key,$type,$synopsis";
38 sub get{
39 my($self,$name) = @_;
40 return split /,/, $self->{info}{$name}, 3;
43 sub show{
44 my $self = shift;
45 my $name;
46 print "names: ", $self->{names}, "\n\n";
47 foreach $name (split /,/, $self->{names}) {
48 my($key,$type,$synopsis) = $self->get($name);
49 print "$name($key) is $type: $synopsis\n";
53 sub tohtml{
54 my $self = shift;
55 my $oddrow = 1;
56 my $data = "<table class='synopsistable' valign='baseline'>\n";
57 my $name;
58 foreach $name (split /,/, $self->{names}) {
59 my($key,$type,$synopsis) = $self->get($name);
60 my $link = "<a href='module-$key.html'>";
61 $synopsis =~ s/<tex2html_percent_mark>/%/g;
62 $synopsis =~ s/<tex2html_ampersand_mark>/\&amp;/g;
63 $data .= (' <tr'
64 . ($oddrow ? " class='oddrow'>\n " : '>')
65 . "<td><b><tt class='module'>$link$name</a></tt></b></td>\n"
66 . " <td>\&nbsp;</td>\n"
67 . " <td class='synopsis'>$synopsis</td></tr>\n");
68 $oddrow = !$oddrow;
70 $data .= "</table>\n";
71 $data;
75 package testSynopsisTable;
77 sub test{
78 # this little test is mostly to debug the stuff above, since this is
79 # my first Perl "object".
80 my $st = SynopsisTable->new();
81 $st->declare("sample", "sample", "standard");
82 $st->set_synopsis("sample", "This is a little synopsis....");
83 $st->declare("copy_reg", "copyreg", "standard");
84 $st->set_synopsis("copy_reg", "pickle support stuff");
85 $st->show();
87 print "\n\n";
89 my $st2 = SynopsisTable->new();
90 $st2->declare("st2module", "st2module", "built-in");
91 $st2->set_synopsis("st2module", "silly little synopsis");
92 $st2->show();
95 1; # This must be the last line -- Perl is bogus!