diff options
Diffstat (limited to 'Doc/perl')
-rw-r--r-- | Doc/perl/python.perl | 320 |
1 files changed, 160 insertions, 160 deletions
diff --git a/Doc/perl/python.perl b/Doc/perl/python.perl index cddba8c..c1ebd19 100644 --- a/Doc/perl/python.perl +++ b/Doc/perl/python.perl @@ -1,4 +1,4 @@ -# python.perl by Fred L. Drake, Jr. <fdrake@acm.org> -*- perl -*- +# python.perl by Fred L. Drake, Jr. <fdrake@acm.org> -*- perl -*- # # Heavily based on Guido van Rossum's myformat.perl (now obsolete). # @@ -16,7 +16,7 @@ sub next_argument{ my $param; $param = missing_braces() unless ((s/$next_pair_pr_rx/$param=$2;''/eo) - ||(s/$next_pair_rx/$param=$2;''/eo)); + ||(s/$next_pair_rx/$param=$2;''/eo)); return $param; } @@ -65,20 +65,20 @@ sub do_cmd_let{ my $matched = 0; s/[\\]([a-zA-Z]+)\s*(=\s*)?[\\]([a-zA-Z]*)/$matched=1; ''/e; if ($matched) { - my($new, $old) = ($1, $3); - eval "sub do_cmd_$new { do_cmd_$old" . '(@_); }'; - print "\ndefining handler for \\$new using \\$old\n"; + my($new, $old) = ($1, $3); + eval "sub do_cmd_$new { do_cmd_$old" . '(@_); }'; + print "\ndefining handler for \\$new using \\$old\n"; } else { - s/[\\]([a-zA-Z]+)\s*(=\s*)?([^\\])/$matched=1; ''/es; - if ($matched) { - my($new, $char) = ($1, $3); - eval "sub do_cmd_$new { \"\\$char\" . \$_[0]; }"; - print "\ndefining handler for \\$new to insert '$char'\n"; - } - else { - write_warnings("Could not interpret \\let construct..."); - } + s/[\\]([a-zA-Z]+)\s*(=\s*)?([^\\])/$matched=1; ''/es; + if ($matched) { + my($new, $char) = ($1, $3); + eval "sub do_cmd_$new { \"\\$char\" . \$_[0]; }"; + print "\ndefining handler for \\$new to insert '$char'\n"; + } + else { + write_warnings("Could not interpret \\let construct..."); + } } return $_; } @@ -304,7 +304,7 @@ sub do_cmd_envvar{ # The <tt> here is really to keep buildindex.py from making # the variable name case-insensitive. add_index_entry("environment variables!$envvar@<tt>$envvar</tt>", - $ahref); + $ahref); add_index_entry("$envvar (environment variable)", $ahref); $aname =~ s/<a/<a class="envvar"/; return "$aname$envvar</a>" . $_; @@ -483,7 +483,7 @@ sub do_cmd_makemodindex{ return $_[0]; } open(IDXFILE, '>index.dat') || die "\n$!\n"; open(INTLABELS, '>intlabels.pl') || die "\n$!\n"; print INTLABELS "%internal_labels = ();\n"; -print INTLABELS "1; # hack in case there are no entries\n\n"; +print INTLABELS "1; # hack in case there are no entries\n\n"; # Using \0 for this is bad because we can't use common tools to work with the # resulting files. Things like grep can be useful with this stuff! @@ -522,43 +522,43 @@ sub define_indexing_macro(@){ my $count = @_; my $i = 0; for (; $i < $count; ++$i) { - my $name = $_[$i]; - my $cmd = "idx_cmd_$name"; - die "\nNo function $cmd() defined!\n" - if (!defined &$cmd); - eval ("sub do_cmd_$name { return process_index_macros(" - . "\$_[0], '$name'); }"); - if (length($IndexMacroPattern) == 0) { - $IndexMacroPattern = "$name"; - } - else { - $IndexMacroPattern .= "|$name"; - } + my $name = $_[$i]; + my $cmd = "idx_cmd_$name"; + die "\nNo function $cmd() defined!\n" + if (!defined &$cmd); + eval ("sub do_cmd_$name { return process_index_macros(" + . "\$_[0], '$name'); }"); + if (length($IndexMacroPattern) == 0) { + $IndexMacroPattern = "$name"; + } + else { + $IndexMacroPattern .= "|$name"; + } } } $DEBUG_INDEXING = 0; sub process_index_macros($$){ local($_) = @_; - my $cmdname = $_[1]; # This is what triggered us in the first place; - # we know it's real, so just process it. + my $cmdname = $_[1]; # This is what triggered us in the first place; + # we know it's real, so just process it. my($name, $aname, $ahref) = new_link_info(); my $cmd = "idx_cmd_$cmdname"; print "\nIndexing: \\$cmdname" if $DEBUG_INDEXING; - &$cmd($ahref); # modifies $_ and adds index entries + &$cmd($ahref); # modifies $_ and adds index entries while (/^[\s\n]*\\($IndexMacroPattern)</) { - $cmdname = "$1"; - print " \\$cmdname" - if $DEBUG_INDEXING; - $cmd = "idx_cmd_$cmdname"; - if (!defined &$cmd) { - last; - } - else { - s/^[\s\n]*\\$cmdname//; - &$cmd($ahref); - } + $cmdname = "$1"; + print " \\$cmdname" + if $DEBUG_INDEXING; + $cmd = "idx_cmd_$cmdname"; + if (!defined &$cmd) { + last; + } + else { + s/^[\s\n]*\\$cmdname//; + &$cmd($ahref); + } } if (/^[ \t\r\n]/) { $_ = substr($_, 1); @@ -648,10 +648,10 @@ sub make_mod_index_entry($$){ write_idxfile($ahref, $str); if ($define eq 'DEF') { - # add to the module index + # add to the module index $str =~ /(<tt.*<\/tt>)/; my $nstr = $1; - $Modules{$nstr} .= $ahref; + $Modules{$nstr} .= $ahref; } return "$aname$anchor_invisible_mark2</a>"; } @@ -664,10 +664,10 @@ sub define_module($$){ my($word, $name) = @_; my $section_tag = join('', @curr_sec_id); if ($word ne "built-in" && $word ne "extension" - && $word ne "standard" && $word ne "") { - write_warnings("Bad module type '$word'" - . " for \\declaremodule (module $name)"); - $word = ""; + && $word ne "standard" && $word ne "") { + write_warnings("Bad module type '$word'" + . " for \\declaremodule (module $name)"); + $word = ""; } $word = "$word " if $word; $THIS_MODULE = "$name"; @@ -706,7 +706,7 @@ sub ref_module_index_helper($$){ # these should be adjusted a bit.... define_indexing_macro('refmodindex', 'refbimodindex', - 'refexmodindex', 'refstmodindex'); + 'refexmodindex', 'refstmodindex'); sub idx_cmd_refmodindex($){ return ref_module_index_helper('', $_[0]); } sub idx_cmd_refbimodindex($){ @@ -897,9 +897,9 @@ sub load_refcounts(){ $REFCOUNTS_LOADED = 1; my($myname, $mydir, $myext) = fileparse(__FILE__, '\..*'); - chop $mydir; # remove trailing '/' + chop $mydir; # remove trailing '/' ($myname, $mydir, $myext) = fileparse($mydir, '\..*'); - chop $mydir; # remove trailing '/' + chop $mydir; # remove trailing '/' $mydir = getcwd() . "$dd$mydir" unless $mydir =~ s|^/|/|; local $_; @@ -931,7 +931,7 @@ sub cfuncline_helper($$$){ my $idx = make_str_index_entry( "<tt class=\"cfunction\">$name()</tt>" . get_indexsubitem()); $idx =~ s/ \(.*\)//; - $idx =~ s/\(\)//; # ???? - why both of these? + $idx =~ s/\(\)//; # ???? - why both of these? $args =~ s/(\s|\*)([a-z_][a-z_0-9]*),/$1<var>$2<\/var>,/g; $args =~ s/(\s|\*)([a-z_][a-z_0-9]*)$/$1<var>$2<\/var>/s; return ('<table cellpadding="0" cellspacing="0"><tr valign="baseline">' @@ -1028,7 +1028,7 @@ sub do_env_cvardesc{ my $var_type = next_argument(); my $var_name = next_argument(); my $idx = make_str_index_entry("<tt class=\"cdata\">$var_name</tt>" - . get_indexsubitem()); + . get_indexsubitem()); $idx =~ s/ \(.*\)//; return "<dl><dt>$var_type <b>$idx</b></dt>\n" . '<dd>' @@ -1056,7 +1056,7 @@ sub do_env_funcdesc{ my $arg_list = convert_args(next_argument()); my $idx = make_str_index_entry("<tt class=\"function\">$function_name()" . '</tt>' - . get_indexsubitem()); + . get_indexsubitem()); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)<\/tt>/<\/tt>/; return funcline_helper(1, $idx, $arg_list) . $_ . '</dl>'; @@ -1102,16 +1102,16 @@ sub do_env_opcodedesc{ my $arg_list = next_argument(); my $idx; if ($INDEX_OPCODES) { - $idx = make_str_index_entry("<tt class=\"opcode\">$opcode_name</tt>" + $idx = make_str_index_entry("<tt class=\"opcode\">$opcode_name</tt>" . ' (byte code instruction)'); - $idx =~ s/ \(byte code instruction\)//; + $idx =~ s/ \(byte code instruction\)//; } else { - $idx = "<tt class=\"opcode\">$opcode_name</tt>"; + $idx = "<tt class=\"opcode\">$opcode_name</tt>"; } my $stuff = "<dl><dt><b>$idx</b>"; if ($arg_list) { - $stuff .= " <var>$arg_list</var>"; + $stuff .= " <var>$arg_list</var>"; } return $stuff . "</dt>\n<dd>" . $_ . '</dt></dl>'; } @@ -1123,14 +1123,14 @@ sub do_env_datadesc{ $idx =~ s/ \(.*\)//; return "<dl><dt><b>$idx</b></dt>\n<dd>" . $_ - . '</dd></dl>'; + . '</dd></dl>'; } sub do_env_datadescni{ local($_) = @_; my $idx = next_argument(); if (! $STRING_INDEX_TT) { - $idx = "<tt>$idx</tt>"; + $idx = "<tt>$idx</tt>"; } return "<dl><dt><b>$idx</b></dt>\n<dd>" . $_ . '</dd></dl>'; } @@ -1167,7 +1167,7 @@ sub handle_classlike_descriptor($$){ $THIS_CLASS = next_argument(); my $arg_list = convert_args(next_argument()); $idx = make_str_index_entry( - "<tt class=\"$what\">$THIS_CLASS</tt> ($what in $THIS_MODULE)" ); + "<tt class=\"$what\">$THIS_CLASS</tt> ($what in $THIS_MODULE)" ); $idx =~ s/ \(.*\)//; my $prefix = "$TLSTART$what$TLEND$idx"; return funcline_helper(1, $prefix, $arg_list) . $_ . '</dl>'; @@ -1181,7 +1181,7 @@ sub do_env_classdescstar{ local($_) = @_; $THIS_CLASS = next_argument(); $idx = make_str_index_entry( - "<tt class=\"class\">$THIS_CLASS</tt> (class in $THIS_MODULE)"); + "<tt class=\"class\">$THIS_CLASS</tt> (class in $THIS_MODULE)"); $idx =~ s/ \(.*\)//; my $prefix = "${TLSTART}class$TLEND$idx"; # Can't use funcline_helper() since there is no args list. @@ -1202,7 +1202,7 @@ sub do_env_methoddesc{ my $arg_list = convert_args(next_argument()); my $extra = ''; if ($class_name) { - $extra = " ($class_name method)"; + $extra = " ($class_name method)"; } my $idx = make_str_index_entry( "<tt class=\"method\">$method()</tt>$extra"); @@ -1221,7 +1221,7 @@ sub do_cmd_methodline{ my $arg_list = convert_args(next_argument()); my $extra = ''; if ($class_name) { - $extra = " ($class_name method)"; + $extra = " ($class_name method)"; } my $idx = make_str_index_entry( "<tt class=\"method\">$method()</tt>$extra"); @@ -1383,16 +1383,16 @@ sub do_env_tableii{ my $a2 = $col_aligns[1]; s/\\lineii</\\lineii[$a1|$a2]</g; return '<table border align="center" style="border-collapse: collapse">' - . "\n <thead>" - . "\n <tr class=\"tableheader\">" - . "\n $th1<b>$h1</b>\ </th>" - . "\n $th2<b>$h2</b>\ </th>" - . "\n </tr>" - . "\n </thead>" - . "\n <tbody valign=\"baseline\">" - . $_ - . "\n </tbody>" - . "\n</table>"; + . "\n <thead>" + . "\n <tr class=\"tableheader\">" + . "\n $th1<b>$h1</b>\ </th>" + . "\n $th2<b>$h2</b>\ </th>" + . "\n </tr>" + . "\n </thead>" + . "\n <tbody valign=\"baseline\">" + . $_ + . "\n </tbody>" + . "\n</table>"; } sub do_env_longtableii{ @@ -1415,7 +1415,7 @@ sub do_cmd_lineii{ } return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" . " $c2align$c2</td>" - . $_; + . $_; } sub do_env_tableiii{ @@ -1433,17 +1433,17 @@ sub do_env_tableiii{ my $a3 = $col_aligns[2]; s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g; return '<table border align="center" style="border-collapse: collapse">' - . "\n <thead>" - . "\n <tr class=\"tableheader\">" - . "\n $th1<b>$h1</b>\ </th>" - . "\n $th2<b>$h2</b>\ </th>" - . "\n $th3<b>$h3</b>\ </th>" - . "\n </tr>" - . "\n </thead>" - . "\n <tbody valign=\"baseline\">" - . $_ - . "\n </tbody>" - . "\n</table>"; + . "\n <thead>" + . "\n <tr class=\"tableheader\">" + . "\n $th1<b>$h1</b>\ </th>" + . "\n $th2<b>$h2</b>\ </th>" + . "\n $th3<b>$h3</b>\ </th>" + . "\n </tr>" + . "\n </thead>" + . "\n <tbody valign=\"baseline\">" + . $_ + . "\n </tbody>" + . "\n</table>"; } sub do_env_longtableiii{ @@ -1468,8 +1468,8 @@ sub do_cmd_lineiii{ } return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" . " $c2align$c2</td>\n" - . " $c3align$c3</td>" - . $_; + . " $c3align$c3</td>" + . $_; } sub do_env_tableiv{ @@ -1489,18 +1489,18 @@ sub do_env_tableiv{ my $a4 = $col_aligns[3]; s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g; return '<table border align="center" style="border-collapse: collapse">' - . "\n <thead>" - . "\n <tr class=\"tableheader\">" - . "\n $th1<b>$h1</b>\ </th>" - . "\n $th2<b>$h2</b>\ </th>" - . "\n $th3<b>$h3</b>\ </th>" - . "\n $th4<b>$h4</b>\ </th>" - . "\n </tr>" - . "\n </thead>" - . "\n <tbody valign=\"baseline\">" - . $_ - . "\n </tbody>" - . "\n</table>"; + . "\n <thead>" + . "\n <tr class=\"tableheader\">" + . "\n $th1<b>$h1</b>\ </th>" + . "\n $th2<b>$h2</b>\ </th>" + . "\n $th3<b>$h3</b>\ </th>" + . "\n $th4<b>$h4</b>\ </th>" + . "\n </tr>" + . "\n </thead>" + . "\n <tbody valign=\"baseline\">" + . $_ + . "\n </tbody>" + . "\n</table>"; } sub do_env_longtableiv{ @@ -1511,7 +1511,7 @@ sub do_cmd_lineiv{ local($_) = @_; my $aligns = next_optional_argument(); my $c1 = next_argument(); - my $c2 = next_argument(); + my $c2 = next_argument(); my $c3 = next_argument(); my $c4 = next_argument(); s/[\s\n]+//; @@ -1527,9 +1527,9 @@ sub do_cmd_lineiv{ } return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" . " $c2align$c2</td>\n" - . " $c3align$c3</td>\n" - . " $c4align$c4</td>" - . $_; + . " $c3align$c3</td>\n" + . " $c4align$c4</td>" + . $_; } sub do_env_tablev{ @@ -1551,19 +1551,19 @@ sub do_env_tablev{ my $a5 = $col_aligns[4]; s/\\linev</\\linev[$a1|$a2|$a3|$a4|$a5]</g; return '<table border align="center" style="border-collapse: collapse">' - . "\n <thead>" - . "\n <tr class=\"tableheader\">" - . "\n $th1<b>$h1</b>\ </th>" - . "\n $th2<b>$h2</b>\ </th>" - . "\n $th3<b>$h3</b>\ </th>" - . "\n $th4<b>$h4</b>\ </th>" - . "\n $th5<b>$h5</b>\ </th>" - . "\n </tr>" - . "\n </thead>" - . "\n <tbody valign=\"baseline\">" - . $_ - . "\n </tbody>" - . "\n</table>"; + . "\n <thead>" + . "\n <tr class=\"tableheader\">" + . "\n $th1<b>$h1</b>\ </th>" + . "\n $th2<b>$h2</b>\ </th>" + . "\n $th3<b>$h3</b>\ </th>" + . "\n $th4<b>$h4</b>\ </th>" + . "\n $th5<b>$h5</b>\ </th>" + . "\n </tr>" + . "\n </thead>" + . "\n <tbody valign=\"baseline\">" + . $_ + . "\n </tbody>" + . "\n</table>"; } sub do_env_longtablev{ @@ -1592,10 +1592,10 @@ sub do_cmd_linev{ } return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" . " $c2align$c2</td>\n" - . " $c3align$c3</td>\n" - . " $c4align$c4</td>\n" - . " $c5align$c5</td>" - . $_; + . " $c3align$c3</td>\n" + . " $c4align$c4</td>\n" + . " $c5align$c5</td>" + . $_; } @@ -1620,23 +1620,23 @@ sub do_cmd_linev{ sub make_my_titlepage(){ my $the_title = ""; if ($t_title) { - $the_title .= "\n<h1>$t_title</h1>"; + $the_title .= "\n<h1>$t_title</h1>"; } else { write_warnings("\nThis document has no title."); } if ($t_author) { - if ($t_authorURL) { - my $href = translate_commands($t_authorURL); - $href = make_named_href('author', $href, - "<b><font size=\"+2\">$t_author" + if ($t_authorURL) { + my $href = translate_commands($t_authorURL); + $href = make_named_href('author', $href, + "<b><font size=\"+2\">$t_author" . '</font></b>'); - $the_title .= "\n<p>$href</p>"; - } + $the_title .= "\n<p>$href</p>"; + } else { - $the_title .= ("\n<p><b><font size=\"+2\">$t_author" + $the_title .= ("\n<p><b><font size=\"+2\">$t_author" . '</font></b></p>'); - } + } } else { write_warnings("\nThere is no author for this document."); @@ -1648,24 +1648,24 @@ sub make_my_titlepage(){ $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>"; } if ($t_affil) { - $the_title .= "\n<p><i>$t_affil</i></p>"; + $the_title .= "\n<p><i>$t_affil</i></p>"; } if ($t_date) { - $the_title .= "\n<p>"; - if ($PACKAGE_VERSION) { - $the_title .= ('<strong>Release ' + $the_title .= "\n<p>"; + if ($PACKAGE_VERSION) { + $the_title .= ('<strong>Release ' . "$PACKAGE_VERSION$RELEASE_INFO</strong><br />\n"); } - $the_title .= "<strong>$t_date</strong></p>" + $the_title .= "<strong>$t_date</strong></p>" } if ($t_address) { - $the_title .= "\n<p>$t_address</p>"; + $the_title .= "\n<p>$t_address</p>"; } else { $the_title .= "\n<p></p>"; } if ($t_email) { - $the_title .= "\n<p>$t_email</p>"; + $the_title .= "\n<p>$t_email</p>"; } return $the_title; } @@ -1747,9 +1747,9 @@ sub get_synopsis_table($){ my $chap = $_[0]; my $key; foreach $key (keys %ModuleSynopses) { - if ($key eq $chap) { - return $ModuleSynopses{$chap}; - } + if ($key eq $chap) { + return $ModuleSynopses{$chap}; + } } my $st = SynopsisTable->new(); $ModuleSynopses{$chap} = $st; @@ -1821,11 +1821,11 @@ sub process_localmoduletables_in_file($){ close(MYFILE); # need to get contents of file in $_ while (/<tex2html-localmoduletable><(\d+)>/) { - my $match = $&; - my $chap = $1; - my $st = get_synopsis_table($chap); - my $data = $st->tohtml(); - s/$match/$data/; + my $match = $&; + my $chap = $1; + my $st = get_synopsis_table($chap); + my $data = $st->tohtml(); + s/$match/$data/; } open(MYFILE,">$file"); print MYFILE $_; @@ -1865,7 +1865,7 @@ sub do_cmd_seemodule{ $key = $module unless $key; if ($text =~ /\.$/) { - $period = ''; + $period = ''; } return ('<dl compact class="seemodule">' . "\n <dt>Module <b><tt class=\"module\">" @@ -2007,20 +2007,20 @@ sub do_env_alltt{ local($local_closures, $local_reopens); ($local_closures, $local_reopens,@open_block_tags) = &preserve_open_block_tags - if (@$open_tags_R); + if (@$open_tags_R); $open_tags_R = [ @open_block_tags ]; do { - local($open_tags_R) = [ @open_block_tags ]; - local(@save_open_tags) = (); + local($open_tags_R) = [ @open_block_tags ]; + local(@save_open_tags) = (); - local($cnt) = ++$global{'max_id'}; - $_ = join('',"$O$cnt$C\\tt$O", ++$global{'max_id'}, $C - , $_ , $O, $global{'max_id'}, "$C$O$cnt$C"); + local($cnt) = ++$global{'max_id'}; + $_ = join('',"$O$cnt$C\\tt$O", ++$global{'max_id'}, $C + , $_ , $O, $global{'max_id'}, "$C$O$cnt$C"); - $_ = &translate_environments($_); - $_ = &translate_commands($_) if (/\\/); + $_ = &translate_environments($_); + $_ = &translate_commands($_) if (/\\/); # remove spurious <BR> someone sticks in; not sure where they # actually come from @@ -2029,11 +2029,11 @@ sub do_env_alltt{ # the environment s/<BR>/ /gi; - $_ = join('', $closures, $alltt_start, $local_reopens - , $_ - , &balance_tags() #, $local_closures - , $alltt_end, $reopens); - undef $open_tags_R; undef @save_open_tags; + $_ = join('', $closures, $alltt_start, $local_reopens + , $_ + , &balance_tags() #, $local_closures + , $alltt_end, $reopens); + undef $open_tags_R; undef @save_open_tags; }; $open_tags_R = [ @keep_open_tags ]; $_; @@ -2152,4 +2152,4 @@ sub do_cmd_verbatiminput{ . $_); } -1; # This must be the last line +1; # This must be the last line |