Oops -- Lib/Test should be Lib/test, of course!
[python/dscho.git] / Doc / perl / python.perl
blobd9ea19ffdcfcfc6e0b8121e4c10facf2417e4410
1 # python.perl by Fred L. Drake, Jr. <fdrake@acm.org> -*- perl -*-
3 # Heavily based on Guido van Rossum's myformat.perl (now obsolete).
5 # Extension to LaTeX2HTML for documents using myformat.sty.
6 # Subroutines of the form do_cmd_<name> here define translations
7 # for LaTeX commands \<name> defined in the corresponding .sty file.
9 package main;
12 # words typeset in a special way (not in HTML though)
14 sub do_cmd_ABC{ 'ABC' . @_[0]; }
15 sub do_cmd_UNIX{ 'Unix'. @_[0]; }
16 sub do_cmd_ASCII{ 'ASCII' . @_[0]; }
17 sub do_cmd_POSIX{ 'POSIX' . @_[0]; }
18 sub do_cmd_C{ 'C' . @_[0]; }
19 sub do_cmd_Cpp{ 'C++' . @_[0]; }
20 sub do_cmd_EOF{ 'EOF' . @_[0]; }
21 sub do_cmd_NULL{ '<tt>NULL</tt>' . @_[0]; }
23 sub do_cmd_e{ '&#92;' . @_[0]; }
25 $AUTHOR_ADDRESS = '';
26 $PYTHON_VERSION = '';
28 sub do_cmd_version{ $PYTHON_VERSION . @_[0]; }
29 sub do_cmd_release{
30 local($_) = @_;
31 s/$next_pair_pr_rx//;
32 $PYTHON_VERSION = "$2";
33 $_;
36 sub do_cmd_authoraddress{
37 local($_) = @_;
38 s/$next_pair_pr_rx//;
39 $AUTHOR_ADDRESS = "$2";
40 $_;
43 sub do_cmd_hackscore{
44 local($_) = @_;
45 s/$next_pair_pr_rx/_/;
46 $_;
49 sub do_cmd_optional{
50 local($_) = @_;
51 s|$next_pair_pr_rx|</var><big>\[</big><var>\2</var><big>\]</big><var>|;
52 $_;
55 sub do_cmd_varvars{
56 local($_) = @_;
57 s|$next_pair_pr_rx|<var>\2</var>|;
58 $_;
61 sub use_current{
62 local($_) = @_;
63 s|$next_pair_pr_rx|\2|;
64 $_;
67 sub do_cmd_pytype{ use_current(@_); }
68 sub do_cmd_makevar{ use_current(@_); }
70 # Logical formatting (some based on texinfo), needs to be converted to
71 # minimalist HTML. The "minimalist" is primarily to reduce the size of
72 # output files for users that read them over the network rather than
73 # from local repositories.
75 sub do_cmd_code{
76 local($_) = @_;
77 s|$next_pair_pr_rx|<tt>\2</tt>|;
78 $_;
81 sub use_sans_serif{
82 local($_) = @_;
83 s|$next_pair_pr_rx|<font face=sans-serif>\2</font>|;
84 $_;
87 sub use_italics{
88 local($_) = @_;
89 s|$next_pair_pr_rx|<i>\2</i>|;
90 $_;
93 sub do_cmd_sectcode{ &do_cmd_code(@_); }
94 sub do_cmd_module{ &do_cmd_code(@_); }
95 sub do_cmd_keyword{ &do_cmd_code(@_); }
96 sub do_cmd_exception{ &do_cmd_code(@_); }
97 sub do_cmd_class{ &do_cmd_code(@_); }
98 sub do_cmd_function{ &do_cmd_code(@_); }
99 sub do_cmd_constant{ &do_cmd_code(@_); }
100 sub do_cmd_member{ &do_cmd_code(@_); }
101 sub do_cmd_method{ &do_cmd_code(@_); }
102 sub do_cmd_cfunction{ &do_cmd_code(@_); }
103 sub do_cmd_cdata{ &do_cmd_code(@_); }
104 sub do_cmd_ctype{ &do_cmd_code(@_); }
105 sub do_cmd_regexp{ &do_cmd_code(@_); }
106 sub do_cmd_key{ &do_cmd_code(@_); }
108 sub do_cmd_character{ &do_cmd_samp(@_); }
110 sub do_cmd_program{ &do_cmd_strong(@_); }
112 sub do_cmd_email{ &use_sans_serif(@_); }
113 sub do_cmd_mimetype{ &use_sans_serif(@_); }
115 sub do_cmd_var{ &use_italics(@_); }
116 sub do_cmd_dfn{ &use_italics(@_); } # make an index entry?
117 sub do_cmd_emph{ &use_italics(@_); }
119 sub do_cmd_newsgroup{
120 local($_) = @_;
121 s/$next_pair_pr_rx//o;
122 my $newsgroup = $2;
123 my $stuff = "<a href=\"news:$newsgroup\"><font face=sans-serif>"
124 . "$newsgroup</font></a>";
125 $stuff . $_;
128 sub do_cmd_envvar{
129 local($_) = @_;
130 s/$next_pair_pr_rx//;
131 my($br_id,$envvar) = ($1, $2);
132 my($name,$aname,$ahref) = link_info($br_id);
133 # The <tt> here is really to keep buildindex.py from making
134 # the variable name case-insensitive.
135 add_index_entry("environment variables!$envvar@<tt>\$$envvar</tt>",
136 $ahref);
137 add_index_entry("$envvar@\$$envvar", $ahref);
138 "$aname\$$envvar</a>" . $_;
141 sub do_cmd_url{
142 # use the URL as both text and hyperlink
143 local($_) = @_;
144 s/$next_pair_pr_rx//;
145 my $url = $2;
146 $url =~ s/~/&#126;/g;
147 "<a href=\"$url\"><font face=sans-serif>$url</font></a>" . $_;
150 sub do_cmd_manpage{
151 # two parameters: \manpage{name}{section}
152 local($_) = @_;
153 my $rx = "$next_pair_pr_rx$any_next_pair_pr_rx3";
154 s|$rx|<i>\2</i>(\4)|;
158 sub do_cmd_rfc{
159 local($_) = @_;
160 s/$next_pair_pr_rx//;
161 my($br_id,$rfcnumber) = ($1, $2);
163 # Save the reference
164 my $nstr = &gen_index_id("RFC!RFC $rfcnumber", '');
165 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
166 "<a name=$br_id>RFC $rfcnumber</a>" .$_;
169 sub do_cmd_kbd{
170 local($_) = @_;
171 s|$next_pair_pr_rx|<kbd>\2</kbd>|;
175 sub do_cmd_strong{
176 local($_) = @_;
177 s|$next_pair_pr_rx|<b>\2</b>|;
181 sub do_cmd_deprecated{
182 # two parameters: \deprecated{version}{whattodo}
183 local($_) = @_;
184 my $rx = "$next_pair_pr_rx$any_next_pair_pr_rx3";
185 s|$rx|<b>Deprecated since release \2.</b>\n\4<p>|;
189 # file and samp are at the end of this file since they screw up fontlock.
191 # index commands
193 $INDEX_SUBITEM = "";
195 sub get_indexsubitem{
196 #$INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
200 sub do_cmd_setindexsubitem{
201 local($_) = @_;
202 s/$next_pair_pr_rx//;
203 $INDEX_SUBITEM = $2;
207 sub do_cmd_withsubitem{
208 # We can't really do the right right thing, because LaTeX2HTML doesn't
209 # do things in the right order, but we need to at least strip this stuff
210 # out, and leave anything that the second argument expanded out to.
212 local($_) = @_;
213 my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
214 s/$next_pair_pr_rx$any_next_pair_pr_rx3/\4/;
215 $INDEX_SUBITEM = $2;
219 sub do_cmd_makemodindex{ @_[0]; }
221 # We're in the document subdirectory when this happens!
223 open(IDXFILE, ">index.dat") || die "\n$!\n";
224 open(INTLABELS, ">intlabels.pl") || die "\n$!\n";
225 print INTLABELS "%internal_labels = ();\n";
226 print INTLABELS "1; # hack in case there are no entries\n\n";
228 # Using \0 for this is bad because we can't use common tools to work with the
229 # resulting files. Things like grep can be useful with this stuff!
231 $IDXFILE_FIELD_SEP = "\1";
234 sub gen_target_name{
235 "l2h-" . @_[0];
238 sub gen_target{
239 "<a name=\"" . @_[0] . "\">";
242 sub gen_link{
243 my($node,$target) = @_;
244 print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
245 "<a href=\"$node#$target\">";
248 sub make_index_entry{
249 my($br_id,$str) = @_;
250 my($name,$aname,$ahref) = link_info($br_id);
251 add_index_entry($str, $ahref);
252 "$aname$anchor_invisible_mark</a>";
255 sub add_index_entry{
256 # add an entry to the index structures; ignore the return value
257 my($str,$ahref) = @_;
258 $str = gen_index_id($str, '');
259 $index{$str} .= $ahref;
260 print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n";
263 sub link_info{
264 my $name = gen_target_name(@_[0]);
265 my $aname = gen_target($name);
266 my $ahref = gen_link($CURRENT_FILE, $name);
267 return ($name, $aname, $ahref);
270 sub do_cmd_index{
271 local($_) = @_;
272 s/$next_pair_pr_rx[\n]?//o;
273 my($br_id,$str) = ($1, $2);
275 my($name,$aname,$ahref) = link_info($br_id);
276 add_index_entry("$str", $ahref);
277 "$aname$anchor_invisible_mark</a>" . $_;
280 sub do_cmd_indexii{
281 local($_) = @_;
282 s/$next_pair_pr_rx//o;
283 my($br_id1,$str1) = ($1, $2);
284 s/$next_pair_pr_rx[\n]?//o;
285 my($br_id2,$str2) = ($1, $2);
287 my($name,$aname,$ahref) = link_info($br_id1);
288 add_index_entry("$str1!$str2", $ahref);
289 add_index_entry("$str2!$str1", $ahref);
290 "$aname$anchor_invisible_mark</a>" . $_;
293 sub do_cmd_indexiii{
294 local($_) = @_;
295 s/$next_pair_pr_rx//o;
296 my($br_id1,$str1) = ($1, $2);
297 s/$next_pair_pr_rx//o;
298 my($br_id2,$str2) = ($1, $2);
299 s/$next_pair_pr_rx[\n]?//o;
300 my($br_id3,$str3) = ($1, $2);
302 my($name,$aname,$ahref) = link_info($br_id1);
303 add_index_entry("$str1!$str2 $str3", $ahref);
304 add_index_entry("$str2!$str3, $str1", $ahref);
305 add_index_entry("$str3!$str1 $str2", $ahref);
306 "$aname$anchor_invisible_mark</a>" . $_;
309 sub do_cmd_indexiv{
310 local($_) = @_;
311 s/$next_pair_pr_rx//o;
312 my($br_id1,$str1) = ($1, $2);
313 s/$next_pair_pr_rx//o;
314 my($br_id2,$str2) = ($1, $2);
315 s/$next_pair_pr_rx//o;
316 my($br_id3,$str3) = ($1, $2);
317 s/$next_pair_pr_rx[\n]?//o;
318 my($br_id4,$str4) = ($1, $2);
320 my($name,$aname,$ahref) = link_info($br_id1);
321 add_index_entry("$str1!$str2 $str3 $str4", $ahref);
322 add_index_entry("$str2!$str3 $str4, $str1", $ahref);
323 add_index_entry("$str3!$str4, $str1 $str2", $ahref);
324 add_index_entry("$str4!$$str1 $str2 $str3", $ahref);
325 "$aname$anchor_invisible_mark</a>" . $_;
328 sub do_cmd_ttindex{
329 local($_) = @_;
330 s/$next_pair_pr_rx[\n]?//;
331 my($br_id,$str) = ($1, $2);
332 &make_index_entry($br_id, $str . &get_indexsubitem) . $_;
335 sub my_typed_index_helper{
336 local($word,$_) = @_;
337 s/$next_pair_pr_rx[\n]?//o;
338 my($br_id,$str) = ($1, $2);
340 my($name,$aname,$ahref) = link_info($br_id1);
341 add_index_entry("$str $word", $ahref);
342 add_index_entry("$word!$str", $ahref);
343 "$aname$anchor_invisible_mark</a>" . $_;
346 sub do_cmd_stindex{ &my_typed_index_helper('statement', @_); }
347 sub do_cmd_opindex{ &my_typed_index_helper('operator', @_); }
348 sub do_cmd_exindex{ &my_typed_index_helper('exception', @_); }
349 sub do_cmd_obindex{ &my_typed_index_helper('object', @_); }
351 sub my_parword_index_helper{
352 local($word,$_) = @_;
353 s/$next_pair_pr_rx[\n]?//o;
354 my($br_id,$str) = ($1, $2);
355 make_index_entry($br_id, "$str ($word)") . $_;
359 sub make_mod_index_entry{
360 my($br_id,$str,$define) = @_;
361 my($name,$aname,$ahref) = link_info($br_id);
362 # equivalent of add_index_entry() using $define instead of ''
363 $str = gen_index_id($str, $define);
364 $index{$str} .= $ahref;
365 print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n";
367 if ($define eq 'DEF') {
368 # add to the module index
369 my($nstr,$garbage) = split / /, $str, 2;
370 $Modules{$nstr} .= $ahref;
372 "$aname$anchor_invisible_mark</a>";
375 $THIS_MODULE = '';
376 $THIS_CLASS = '';
378 sub my_module_index_helper{
379 local($word, $_) = @_;
380 s/$next_pair_pr_rx[\n]*//o;
381 my($br_id, $str) = ($1, $2);
382 my $section_tag = join('', @curr_sec_id);
383 $word = "$word " if $word;
384 $THIS_MODULE = "$str";
385 make_mod_index_entry("SECTION$section_tag",
386 "<tt>$str</tt> (${word}module)", 'DEF') . $_;
389 sub ref_module_index_helper{
390 local($word, $_) = @_;
391 s/$next_pair_pr_rx[\n]?//o;
392 my($br_id, $str) = ($1, $2);
393 $word = "$word " if $word;
394 make_mod_index_entry($br_id, "<tt>$str</tt> (${word}module)", 'REF') . $_;
397 sub do_cmd_bifuncindex{
398 local($_) = @_;
399 s/$next_pair_pr_rx[\n]?//o;
400 my($br_id,$str,$fname) = ($1, $2, "<tt>$2()</tt>");
401 make_index_entry($br_id, "$fname (built-in function)") . $_;
404 sub do_cmd_modindex{ my_module_index_helper('', @_); }
405 sub do_cmd_bimodindex{ my_module_index_helper('built-in', @_); }
406 sub do_cmd_exmodindex{ my_module_index_helper('extension', @_); }
407 sub do_cmd_stmodindex{ my_module_index_helper('standard', @_); }
409 # these should be adjusted a bit....
410 sub do_cmd_refmodindex{ ref_module_index_helper('', @_); }
411 sub do_cmd_refbimodindex{ ref_module_index_helper('built-in', @_); }
412 sub do_cmd_refexmodindex{ ref_module_index_helper('extension', @_); }
413 sub do_cmd_refstmodindex{ ref_module_index_helper('standard', @_); }
415 sub do_cmd_nodename{ do_cmd_label(@_); }
417 sub init_myformat{
418 # XXX need some way for this to be called after &initialise; ???
419 $anchor_mark = '';
420 $icons{'anchor_mark'} = '';
421 my $cmark = "(?:$comment_mark)?";
422 # <<2>>...<<2>>
423 $next_pair_rx = "^[\\s\n%]*$O(\\d+)$C([\\s\\S]*)$O\\1$C";
424 $any_next_pair_rx3 = "[\\s\n%]*$O(\\d+)$C([\\s\\S]*)$O\\3$C";
425 $any_next_pair_rx5 = "[\\s\n%]*$O(\\d+)$C([\\s\\S]*)$O\\5$C";
426 $any_next_pair_rx7 = "[\\s\n%]*$O(\\d+)$C([\\s\\S]*)$O\\7$C";
427 $any_next_pair_rx9 = "[\\s\n%]*$O(\\d+)$C([\\s\\S]*)$O\\9$C";
428 # <#2#>...<#2#>
429 $next_pair_pr_rx = "^[\\s\n%]*$OP(\\d+)$CP([\\s\\S]*)$OP\\1$CP$cmark";
430 $any_next_pair_pr_rx3 = "[\\s\n%]*$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP$cmark";
431 $any_next_pair_pr_rx5 = "[\\s\n%]*$OP(\\d+)$CP([\\s\\S]*)$OP\\5$CP$cmark";
432 $any_next_pair_pr_rx7 = "[\\s\n%]*$OP(\\d+)$CP([\\s\\S]*)$OP\\7$CP$cmark";
433 $any_next_pair_pr_rx9 = "[\\s\n%]*$OP(\\d+)$CP([\\s\\S]*)$OP\\9$CP$cmark";
435 init_myformat();
437 # similar to make_index_entry(), but includes the string in the result
438 # instead of the dummy filler.
440 sub make_str_index_entry{
441 my($br_id,$str) = @_;
442 my($name,$aname,$ahref) = link_info($br_id);
443 add_index_entry($str, $ahref);
444 "$aname$str</a>";
447 sub do_env_cfuncdesc{
448 local($_) = @_;
449 my($return_type,$function_name,$arg_list,$idx) = ('', '', '', '');
450 my $any_next_pair_rx3 = "$O(\\d+)$C([\\s\\S]*)$O\\3$C";
451 my $any_next_pair_rx5 = "$O(\\d+)$C([\\s\\S]*)$O\\5$C";
452 my $cfuncdesc_rx = "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5";
453 if (/$cfuncdesc_rx/o) {
454 $return_type = "$2";
455 $function_name = "$4";
456 $arg_list = "$6";
457 $idx = make_str_index_entry($3,
458 "<tt>$function_name()</tt>" . &get_indexsubitem);
459 $idx =~ s/ \(.*\)//;
460 $idx =~ s/\(\)//;
462 "<dl><dt>$return_type <b>$idx</b>"
463 . "(<var>$arg_list</var>)\n<dd>$'</dl>"
466 sub do_env_ctypedesc{
467 local($_) = @_;
468 my $type_name = ('');
469 my $cfuncdesc_rx = "$next_pair_rx";
470 if (/$cfuncdesc_rx/o) {
471 $type_name = "$2";
472 $idx = make_str_index_entry($1,
473 "<tt>$type_name</tt>" . &get_indexsubitem);
474 $idx =~ s/ \(.*\)//;
476 "<dl><dt><b>$idx</b>\n<dd>$'</dl>"
479 sub do_env_cvardesc{
480 local($_) = @_;
481 my($var_type,$var_name,$idx) = ('', '', '');
482 my $cfuncdesc_rx = "$next_pair_rx$any_next_pair_rx3";
483 if (/$cfuncdesc_rx/o) {
484 $var_type = "$2";
485 $var_name = "$4";
486 $idx = make_str_index_entry($3,
487 "<tt>$var_name</tt>" . &get_indexsubitem);
488 $idx =~ s/ \(.*\)//;
490 "<dl><dt>$var_type <b>$idx</b>\n"
491 . "<dd>$'</dl>";
494 sub do_env_funcdesc{
495 local($_) = @_;
496 my($function_name,$arg_list,$idx) = ('', '', '');
497 my $funcdesc_rx = "$next_pair_rx$any_next_pair_rx3";
498 if (/$funcdesc_rx/o) {
499 $function_name = "$2";
500 $arg_list = "$4";
501 $idx = make_str_index_entry($3, "<tt>$function_name()</tt>"
502 . &get_indexsubitem);
503 $idx =~ s/ \(.*\)//;
504 $idx =~ s/\(\)//;
506 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'</dl>";
509 sub do_env_funcdescni{
510 local($_) = @_;
511 my($function_name,$arg_list,$idx) = ('', '', '');
512 my $funcdesc_rx = "$next_pair_rx$any_next_pair_rx3";
513 if (/$funcdesc_rx/o) {
514 $function_name = "$2";
515 $arg_list = "$4";
516 $idx = "<tt>$function_name</tt>";
518 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'</dl>";
521 sub do_cmd_funcline{
522 local($_) = @_;
523 my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
525 s/$next_pair_pr_rx//o;
526 my $function_name = $2;
527 s/$next_pair_pr_rx//o;
528 my($br_id,$arg_list) = ($1, $2);
529 my $idx = make_str_index_entry($br_id, "<tt>$function_name()</tt>"
530 . &get_indexsubitem);
531 $idx =~ s/\(\)//;
533 "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_;
536 # Change this flag to index the opcode entries. I don't think it's very
537 # useful to index them, since they're only presented to describe the dis
538 # module.
540 $INDEX_OPCODES = 0;
542 sub do_env_opcodedesc{
543 local($_) = @_;
544 my($opcode_name,$arg_list,$stuff,$idx) = ('', '', '', '');
545 my $opcodedesc_rx = "$next_pair_rx$any_next_pair_rx3";
546 if (/$opcodedesc_rx/o) {
547 $opcode_name = "$2";
548 $arg_list = "$4";
549 if ($INDEX_OPCODES) {
550 $idx = make_str_index_entry($3,
551 "<tt>$opcode_name</tt> (byte code instruction)");
552 $idx =~ s/ \(byte code instruction\)//;
554 else {
555 $idx = "<tt>$opcode_name</tt>";
558 $stuff = "<dl><dt><b>$idx</b>";
559 if ($arg_list) {
560 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
562 $stuff . "\n<dd>$'</dl>";
565 sub do_env_datadesc{
566 local($_) = @_;
567 my $idx = '';
568 if (/$next_pair_rx/o) {
569 $idx = make_str_index_entry($1, "<tt>$2</tt>" . &get_indexsubitem);
570 $idx =~ s/ \(.*\)//;
572 "<dl><dt><b>$idx</b>\n<dd>$'</dl>"
575 sub do_env_datadescni{
576 local($_) = @_;
577 my $idx = '';
578 if (/$next_pair_rx/o) {
579 if ($STRING_INDEX_TT) {
580 $idx = "$2"; }
581 else {
582 $idx = "<tt>$2</tt>"; }
584 "<dl><dt><b>$idx</b>\n<dd>$'</dl>"
587 sub do_cmd_dataline{
588 local($_) = @_;
590 s/$next_pair_pr_rx//o;
591 my($br_id, $data_name) = ($1, $2);
592 my $idx = make_str_index_entry($br_id, "<tt>$data_name</tt>"
593 . &get_indexsubitem);
594 $idx =~ s/ \(.*\)//;
596 "<dt><b>$idx</b><dd>" . $_;
599 sub do_env_excdesc{
600 local($_) = @_;
601 /$next_pair_rx/o;
602 my($br_id,$excname,$rest) = ($1, $2, $');
603 my $idx = make_str_index_entry($br_id, "<tt>$excname</tt>");
604 "<dl><dt><b>$idx</b>\n<dd>$rest</dl>"
607 sub do_env_fulllineitems{ do_env_itemize(@_); }
610 sub do_env_classdesc{
611 local($_) = @_;
612 my($class_name,$arg_list,$idx) = ('', '', '');
613 my $funcdesc_rx = "$next_pair_rx$any_next_pair_rx3";
614 if (/$funcdesc_rx/o) {
615 $class_name = "$2";
616 $arg_list = "$4";
617 $THIS_CLASS = $class_name;
618 $idx = make_str_index_entry($3,
619 "<tt>$class_name</tt> (class in $THIS_MODULE)" );
620 $idx =~ s/ \(.*\)//;
622 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'</dl>";
626 sub do_env_methoddesc{
627 local($_) = @_;
628 my($class_name,$arg_list,$idx,$extra);
629 # Predefined $opt_arg_rx & $optional_arg_rx don't work because they
630 # require the argument to be there.
631 my $opt_arg_rx = "^\\s*(\\[([^]]*)\\])?";
632 my $funcdesc_rx = "$opt_arg_rx$any_next_pair_rx3$any_next_pair_rx5";
633 if (/$funcdesc_rx/o) {
634 $class_name = $2;
635 $class_name = $THIS_CLASS
636 unless $class_name;
637 $method_name = $4;
638 $arg_list = $6;
639 if ($class_name) {
640 $extra = " ($class_name method)";
642 $idx = make_str_index_entry($3, "<tt>$method_name()</tt>$extra");
643 $idx =~ s/ \(.*\)//;
644 $idx =~ s/\(\)//;
646 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'</dl>";
650 sub do_env_methoddescni{
651 local($_) = @_;
652 # Predefined $opt_arg_rx & $optional_arg_rx don't work because they
653 # require the argument to be there.
654 my $opt_arg_rx = "^\\s*(\\[([^]]*)\\])?";
655 my $funcdesc_rx = "$opt_arg_rx$any_next_pair_rx3$any_next_pair_rx5";
656 /$funcdesc_rx/o;
657 my $method = $4;
658 my $arg_list = $6;
659 "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>$'</dl>";
663 sub do_env_memberdesc{
664 local($_) = @_;
665 # Predefined $opt_arg_rx & $optional_arg_rx don't work because they
666 # require the argument to be there.
667 my $opt_arg_rx = "^\\s*(\\[([^]]*)\\])?";
668 my $funcdesc_rx = "$opt_arg_rx$any_next_pair_rx3";
669 s/$funcdesc_rx//o;
670 my($class,$member) = ($2, $4);
671 $class = $THIS_CLASS
672 unless $class;
673 $extra = " ($class_name attribute)"
674 if (!($class eq ''));
675 my $idx = make_str_index_entry($3, "<tt>$member</tt>$extra");
676 $idx =~ s/ \(.*\)//;
677 $idx =~ s/\(\)//;
678 "<dl><dt><b>$idx</b>\n<dd>" . $_ . "</dl>";
682 sub do_env_memberdescni{
683 local($_) = @_;
684 # Predefined $opt_arg_rx & $optional_arg_rx don't work because they
685 # require the argument to be there.
686 my $opt_arg_rx = "^\\s*(\\[([^]]*)\\])?";
687 my $funcdesc_rx = "$opt_arg_rx$any_next_pair_rx3";
688 /$funcdesc_rx/o;
689 my $member = $4;
690 "<dl><dt><b>$member</b>\n<dd>$'</dl>";
694 @col_aligns = ("<td>", "<td>", "<td>");
696 sub setup_column_alignments{
697 local($_) = @_;
698 my($a1,$a2,$a3) = split(/[|]/,$_);
699 my($th1,$th2,$th3) = ('<th>', '<th>', '<th>');
700 $col_aligns[0] = (($a1 eq "c") ? "<td align=center>" : "<td>");
701 $col_aligns[1] = (($a2 eq "c") ? "<td align=center>" : "<td>");
702 $col_aligns[2] = (($a3 eq "c") ? "<td align=center>" : "<td>");
703 # return the aligned header start tags; only used for \begin{tableiii?}
704 $th1 = (($a1 eq "l") ? "<th align=left>"
705 : ($a1 eq "r" ? "<th align=right>" : "<th>"));
706 $th2 = (($a2 eq "l") ? "<th align=left>"
707 : ($a2 eq "r" ? "<th align=right>" : "<th>"));
708 $th3 = (($a3 eq "l") ? "<th align=left>"
709 : ($a3 eq "r" ? "<th align=right>" : "<th>"));
710 ($th1, $th2, $th3);
713 sub do_env_tableii{
714 local($_) = @_;
715 my($font,$h1,$h2) = ('', '', '');
716 my $tableiii_rx =
717 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7";
718 if (/$tableiii_rx/o) {
719 $font = $4;
720 $font = ''
721 if ($font eq 'textrm');
722 $h1 = $6;
723 $h2 = $8;
725 my($th1,$th2,$th3) = setup_column_alignments($2);
726 $globals{"lineifont"} = $font;
727 "<table border align=center>"
728 . "\n <tr>$th1<b>$h1</b></th>"
729 . "\n $th2<b>$h2</b></th>$'"
730 . "\n</table>";
733 sub do_cmd_lineii{
734 local($_) = @_;
735 s/$next_pair_pr_rx//o;
736 my $c1 = $2;
737 s/$next_pair_pr_rx//o;
738 my($c2,$font,$sfont,$efont) = ($2, $globals{"lineifont"}, '', '');
739 if ($font) {
740 $sfont = "<$font>";
741 $efont = "</$font>";
743 my($c1align,$c2align) = @col_aligns[0,1];
744 "<tr>$c1align$sfont$c1$efont</td>\n"
745 . " $c2align$c2</td>$'";
748 sub do_env_tableiii{
749 local($_) = @_;
750 my($font,$h1,$h2,$h3) = ('', '', '', '');
752 my $tableiii_rx =
753 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7"
754 . "$any_next_pair_rx9";
755 if (/$tableiii_rx/o) {
756 $font = $4;
757 $font = ''
758 if ($font eq 'textrm');
759 $h1 = $6;
760 $h2 = $8;
761 $h3 = $10;
763 my($th1,$th2,$th3) = setup_column_alignments($2);
764 $globals{"lineifont"} = $font;
765 "<table border align=center>"
766 . "\n <tr>$th1<b>$h1</b></th>"
767 . "\n $th2<b>$h2</b></th>"
768 . "\n $th3<b>$h3</b></th>$'"
769 . "\n</table>";
772 sub do_cmd_lineiii{
773 local($_) = @_;
774 s/$next_pair_pr_rx//o;
775 my $c1 = $2;
776 s/$next_pair_pr_rx//o;
777 my $c2 = $2;
778 s/$next_pair_pr_rx//o;
779 my($c3,$font,$sfont,$efont) = ($2, $globals{"lineifont"}, '', '');
780 if ($font) {
781 $sfont = "<$font>";
782 $efont = "</$font>";
784 my($c1align, $c2align, $c3align) = @col_aligns;
785 "<tr>$c1align$sfont$c1$efont</td>\n"
786 . " $c2align$c2</td>\n"
787 . " $c3align$c3</td>$'";
790 sub do_env_seealso{
791 "<p><b>See Also:</b></p>\n" . @_[0];
794 sub do_cmd_seemodule{
795 # Insert the right magic to jump to the module definition. This should
796 # work most of the time, at least for repeat builds....
797 local($_) = @_;
798 my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
799 my $any_next_pair_pr_rx5 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\5$CP";
800 # Predefined $opt_arg_rx & $optional_arg_rx don't work because they
801 # require the argument to be there.
802 my $opt_arg_rx = "^\\s*(\\[([^]]*)\\])?";
803 s/$opt_arg_rx$any_next_pair_pr_rx3$any_next_pair_pr_rx5//;
804 my($key,$module,$text) = ($2, $4, $6);
805 $key = $module unless $key;
806 "<p>Module <tt><b><a href=\"module-$key.html\">$module</a></b></tt>"
807 . "&nbsp;&nbsp;&nbsp;($text)</p>"
808 . $_;
811 sub do_cmd_seetext{
812 "<p>" . @_[0];
816 sub do_cmd_maketitle {
817 local($_) = @_;
818 my $the_title = '';
819 if ($t_title) {
820 $the_title .= "<h1 align=center>$t_title</h1>";
821 } else { &write_warnings("\nThis document has no title."); }
822 $the_title .= "\n<center>";
823 if ($t_author) {
824 if ($t_authorURL) {
825 my $href = &translate_commands($t_authorURL);
826 $href = &make_named_href('author', $href, "<strong>${t_author}</strong>");
827 $the_title .= "\n<p>$href</p>";
828 } else {
829 $the_title .= "\n<p><strong>$t_author</strong></p>";
831 } else { &write_warnings("\nThere is no author for this document."); }
832 if ($t_institute) {
833 $the_title .= "\n<p>$t_institute</p>";}
834 if ($AUTHOR_ADDRESS) {
835 $the_title .= "\n<p>$AUTHOR_ADDRESS</p>";}
836 if ($t_affil) {
837 $the_title .= "\n<p><i>$t_affil</i></p>";}
838 if ($t_date) {
839 $the_title .= "\n<p><strong>$t_date</strong>";
840 if ($PYTHON_VERSION) {
841 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";}
842 $the_title .= "</p>"
844 $the_title .= "\n</center>";
845 if ($t_address) {
846 $the_title .= "\n<p>$t_address</p>";
847 } else { $the_title .= "\n<p>"}
848 if ($t_email) {
849 $the_title .= "\n<p>$t_email</p>";
850 }# else { $the_title .= "</p>" }
851 $the_title . "<hr>\n" . $_ ;
855 # sub do_cmd_indexlabel{
856 # "genindex" . @_[0];
860 # These are located down here since they screw up fontlock. -- used to.
862 sub do_cmd_file{
863 # This uses a weird HTML construct to adjust the font to be
864 # reasonable match that used in the printed form as much as
865 # possible. The expected behavior is that a browser that doesn't
866 # understand "<font face=...>" markup will use courier (or whatever
867 # the font is for <tt>).
868 local($_) = @_;
869 s|$next_pair_pr_rx|\"<tt>\2</tt>\"|;
873 sub do_cmd_samp{
874 local($_) = @_;
875 s|$next_pair_pr_rx|\"<tt>\2</tt>\"|;
879 1; # This must be the last line