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.
14 $param = missing_braces
()
15 unless ((s/$next_pair_pr_rx/$param=$2;''/eo)
16 ||(s/$next_pair_rx/$param=$2;''/eo));
20 sub next_optional_argument
{
21 my($param,$rx) = ('', "^\\s*(\\[([^]]*)\\])?");
22 s/$rx/$param=$2;''/eo;
27 # This is a fairly simple hack; it supports \let when it is used to create
28 # (or redefine) a macro to exactly be some other macro: \let\newname=\oldname.
29 # Many possible uses of \let aren't supported or aren't supported correctly.
34 s/[\\]([a-zA-Z]+)\s*(=\s*)?[\\]([a-zA-Z]*)/$matched=1; ''/e;
36 my($new, $old) = ($1, $3);
37 eval "sub do_cmd_$new { do_cmd_$old" . '(@_); }';
38 print "\ndefining handler for \\$new using \\$old\n";
41 s/[\\]([a-zA-Z]+)\s*(=\s*)?([^\\])/$matched=1; ''/es;
43 my($new, $char) = ($1, $3);
44 eval "sub do_cmd_$new { \"\\$char\" . \@_[0]; }";
45 print "\ndefining handler for \\$new to insert '$char'\n";
48 write_warnings
("Could not interpret \\let construct...");
55 # the older version of LaTeX2HTML we use doesn't support this, but we use it:
57 sub do_cmd_textasciitilde
{ '~' . @_[0]; }
60 # words typeset in a special way (not in HTML though)
62 sub do_cmd_ABC
{ 'ABC' . @_[0]; }
63 sub do_cmd_UNIX
{ 'Unix'. @_[0]; }
64 sub do_cmd_ASCII
{ 'ASCII' . @_[0]; }
65 sub do_cmd_POSIX
{ 'POSIX' . @_[0]; }
66 sub do_cmd_C
{ 'C' . @_[0]; }
67 sub do_cmd_Cpp
{ 'C++' . @_[0]; }
68 sub do_cmd_EOF
{ 'EOF' . @_[0]; }
69 sub do_cmd_NULL
{ '<tt class="constant">NULL</tt>' . @_[0]; }
71 sub do_cmd_e
{ '\' . @_[0]; }
73 $DEVELOPER_ADDRESS = '';
76 sub do_cmd_version
{ $PYTHON_VERSION . @_[0]; }
79 $PYTHON_VERSION = next_argument
();
83 sub do_cmd_authoraddress
{
85 $DEVELOPER_ADDRESS = next_argument
();
89 #sub do_cmd_developer{ do_cmd_author(@_[0]); }
90 #sub do_cmd_developers{ do_cmd_author(@_[0]); }
91 #sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); }
100 local($_,$before,$after) = @_;
101 my $stuff = next_argument
();
102 return $before . $stuff . $after . $_;
106 return use_wrappers
(@_[0], '<font face="sans-serif">', '</font>');
109 return use_wrappers
(@_[0], '<i>', '</i>');
113 return use_wrappers
(@_[0], "</var><big>\[</big><var>",
114 "</var><big>\]</big><var>");
117 # Logical formatting (some based on texinfo), needs to be converted to
118 # minimalist HTML. The "minimalist" is primarily to reduce the size of
119 # output files for users that read them over the network rather than
120 # from local repositories.
122 # \file and \samp are at the end of this file since they screw up fontlock.
124 sub do_cmd_pytype
{ return @_[0]; }
126 return use_wrappers
(@_[0], '<span class="makevar">', '</span>'); }
128 return use_wrappers
(@_[0], '<code>', '</code>'); }
130 return use_wrappers
(@_[0], '<tt class="module">', '</tt>'); }
132 return use_wrappers
(@_[0], '<tt class="keyword">', '</tt>'); }
133 sub do_cmd_exception
{
134 return use_wrappers
(@_[0], '<tt class="exception">', '</tt>'); }
136 return use_wrappers
(@_[0], '<tt class="class">', '</tt>'); }
138 return use_wrappers
(@_[0], '<tt class="function">', '</tt>'); }
140 return use_wrappers
(@_[0], '<tt class="constant">', '</tt>'); }
142 return use_wrappers
(@_[0], '<tt class="member">', '</tt>'); }
144 return use_wrappers
(@_[0], '<tt class="method">', '</tt>'); }
145 sub do_cmd_cfunction
{
146 return use_wrappers
(@_[0], '<tt class="cfunction">', '</tt>'); }
148 return use_wrappers
(@_[0], '<tt class="cdata">', '</tt>'); }
150 return use_wrappers
(@_[0], '<tt class="ctype">', '</tt>'); }
152 return use_wrappers
(@_[0], '<tt class="regexp">', '</tt>'); }
153 sub do_cmd_character
{
154 return use_wrappers
(@_[0], '"<tt class="character">', '</tt>"'); }
156 return use_wrappers
(@_[0], '<b class="program">', '</b>'); }
157 sub do_cmd_programopt
{
158 return use_wrappers
(@_[0], '<b class="programopt">', '</b>'); }
159 sub do_cmd_longprogramopt
{
160 # note that the --- will be later converted to -- by LaTeX2HTML
161 return use_wrappers
(@_[0], '<b class="programopt">---', '</b>'); }
163 return use_wrappers
(@_[0], '<span class="email">', '</span>'); }
165 return use_wrappers
(@_[0], '<span class="mimetype">', '</span>'); }
167 return use_wrappers
(@_[0], "<var>", "</var>"); }
169 return use_wrappers
(@_[0], '<i class="dfn">', '</i>'); }
171 return use_italics
(@_); }
173 return use_wrappers
(@_[0], '<span class="file">', '</span>'); }
175 return do_cmd_file
(@_[0]); }
177 return use_wrappers
(@_[0], '"<tt class="samp">', '</tt>"'); }
179 return use_wrappers
(@_[0], '<kbd>', '</kbd>'); }
181 return use_wrappers
(@_[0], '<b>', '</b>'); }
183 return use_wrappers
(@_[0], '<b>', '</b>'); }
185 return use_wrappers
(@_[0], '<i>', '</i>'); }
188 return '...' . @_[0]; }
189 sub do_cmd_unspecified
{
190 return '...' . @_[0]; }
193 sub do_cmd_refmodule
{
194 # Insert the right magic to jump to the module definition.
196 my $key = next_optional_argument
();
197 my $module = next_argument
();
200 return "<tt class='module'><a href='module-$key.html'>$module</a></tt>"
204 sub do_cmd_newsgroup
{
206 my $newsgroup = next_argument
();
207 my $stuff = "<span class='newsgroup'><a href='news:$newsgroup'>"
208 . "$newsgroup</a></span>";
214 my $envvar = next_argument
();
215 my($name,$aname,$ahref) = new_link_info
();
216 # The <tt> here is really to keep buildindex.py from making
217 # the variable name case-insensitive.
218 add_index_entry
("environment variables!$envvar@<tt>\$$envvar</tt>",
220 add_index_entry
("$envvar@\$$envvar", $ahref);
221 $aname =~ s/<a/<a class="envvar"/;
222 return "$aname\$$envvar</a>" . $_;
226 # use the URL as both text and hyperlink
228 my $url = next_argument
();
229 $url =~ s/~/~/g;
230 return "<a class=\"url\" href=\"$url\">$url</a>" . $_;
234 # two parameters: \manpage{name}{section}
236 my $page = next_argument
();
237 my $section = next_argument
();
238 return "<span class='manpage'><i>$page</i>($section)</span>" . $_;
242 my $rfcnum = sprintf("%04d", @_[0]);
243 return "http://www.ietf.org/rfc/rfc$rfcnum.txt";
248 my $rfcnumber = next_argument
();
249 my $id = "rfcref-" . ++$global{'max_id'};
250 my $href = get_rfc_url
($rfcnumber);
252 my $nstr = gen_index_id
("RFC!RFC $rfcnumber", '');
253 $index{$nstr} .= make_half_href
("$CURRENT_FILE#$id");
254 return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">RFC $rfcnumber</a>"
258 sub do_cmd_citetitle
{
260 my $url = next_optional_argument
();
261 my $title = next_argument
();
264 $repl = ("<em class='citetitle'><a\n"
266 . " title='$title'\n"
267 . " >$title</a></em>");
270 $repl = "<em class='citetitle'\n >$title</em>";
275 sub do_cmd_deprecated
{
276 # two parameters: \deprecated{version}{whattodo}
278 my $release = next_argument
();
279 my $reason = next_argument
();
280 return "<b>Deprecated since release $release.</b>\n$reason<p>" . $_;
283 sub do_cmd_versionadded
{
284 # one parameter: \versionadded{version}
286 my $release = next_argument
();
287 return "\nNew in version $release.\n" . $_;
290 sub do_cmd_versionchanged
{
291 # one parameter: \versionchanged{version}
293 my $explanation = next_optional_argument
();
294 my $release = next_argument
();
295 my $text = "\nChanged in version $release.\n";
297 $text = "\nChanged in version $release:\n$explanation.\n";
303 # These function handle platform dependency tracking.
307 my $platform = next_argument
();
308 $ModulePlatforms{"<tt class='module'>$THIS_MODULE</tt>"} = $platform;
309 $platform = "Macintosh"
310 if $platform eq 'Mac';
311 return "\n<p class='availability'>Availability: <span"
312 . "\n class='platform'>$platform</span>.</p>\n" . $_;
315 $IGNORE_PLATFORM_ANNOTATION = '';
316 sub do_cmd_ignorePlatformAnnotation
{
318 $IGNORE_PLATFORM_ANNOTATION = next_argument
();
327 sub get_indexsubitem
{
328 return $INDEX_SUBITEM ?
" $INDEX_SUBITEM" : '';
331 sub do_cmd_setindexsubitem
{
333 $INDEX_SUBITEM = next_argument
();
337 sub do_cmd_withsubitem
{
338 # We can't really do the right thing, because LaTeX2HTML doesn't
339 # do things in the right order, but we need to at least strip this stuff
340 # out, and leave anything that the second argument expanded out to.
343 my $oldsubitem = $INDEX_SUBITEM;
344 $INDEX_SUBITEM = next_argument
();
345 my $stuff = next_argument
();
346 my $br_id = ++$globals{'max_id'};
347 my $marker = "$O$br_id$C";
350 . "\\setindexsubitem$marker$oldsubitem$marker"
354 # This is the prologue macro which is required to start writing the
355 # mod\jobname.idx file; we can just ignore it. (Defining this suppresses
356 # a warning that \makemodindex is unknown.)
358 sub do_cmd_makemodindex
{ return @_[0]; }
360 # We're in the document subdirectory when this happens!
362 open(IDXFILE
, '>index.dat') || die "\n$!\n";
363 open(INTLABELS
, '>intlabels.pl') || die "\n$!\n";
364 print INTLABELS
"%internal_labels = ();\n";
365 print INTLABELS
"1; # hack in case there are no entries\n\n";
367 # Using \0 for this is bad because we can't use common tools to work with the
368 # resulting files. Things like grep can be useful with this stuff!
370 $IDXFILE_FIELD_SEP = "\1";
373 my ($ahref, $str) = @_;
374 print IDXFILE
$ahref, $IDXFILE_FIELD_SEP, $str, "\n";
379 my($node,$target) = @_;
380 print INTLABELS
"\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
381 return "<a href='$node#$target'>";
385 # add an entry to the index structures; ignore the return value
386 my($str,$ahref) = @_;
387 $str = gen_index_id
($str, '');
388 $index{$str} .= $ahref;
389 write_idxfile
($ahref, $str);
393 my $name = "l2h-" . ++$globals{'max_id'};
394 my $aname = "<a name='$name'>";
395 my $ahref = gen_link
($CURRENT_FILE, $name);
396 return ($name, $aname, $ahref);
399 $IndexMacroPattern = '';
400 sub define_indexing_macro
{
403 for (; $i < $count; ++$i) {
405 my $cmd = "idx_cmd_$name";
406 die "\nNo function $cmd() defined!\n"
408 eval ("sub do_cmd_$name { return process_index_macros("
409 . "\@_[0], '$name'); }");
410 if (length($IndexMacroPattern) == 0) {
411 $IndexMacroPattern = "$name";
414 $IndexMacroPattern .= "|$name";
420 sub process_index_macros
{
422 my $cmdname = @_[1]; # This is what triggered us in the first place;
423 # we know it's real, so just process it.
424 my($name,$aname,$ahref) = new_link_info
();
425 my $cmd = "idx_cmd_$cmdname";
426 print "\nIndexing: \\$cmdname"
428 &$cmd($ahref); # modifies $_ and adds index entries
429 while (/^[\s\n]*\\($IndexMacroPattern)</) {
433 $cmd = "idx_cmd_$cmdname";
434 if (!defined &$cmd) {
438 s/^[\s\n]*\\$cmdname//;
442 return "$aname$anchor_invisible_mark</a>" . $_;
445 define_indexing_macro
('index');
447 my $str = next_argument
();
448 add_index_entry
("$str", @_[0]);
451 define_indexing_macro
('kwindex');
453 my $str = next_argument
();
454 add_index_entry
("<tt>$str</tt>!keyword", @_[0]);
455 add_index_entry
("keyword!<tt>$str</tt>", @_[0]);
458 define_indexing_macro
('indexii');
460 my $str1 = next_argument
();
461 my $str2 = next_argument
();
462 add_index_entry
("$str1!$str2", @_[0]);
463 add_index_entry
("$str2!$str1", @_[0]);
466 define_indexing_macro
('indexiii');
467 sub idx_cmd_indexiii
{
468 my $str1 = next_argument
();
469 my $str2 = next_argument
();
470 my $str3 = next_argument
();
471 add_index_entry
("$str1!$str2 $str3", @_[0]);
472 add_index_entry
("$str2!$str3, $str1", @_[0]);
473 add_index_entry
("$str3!$str1 $str2", @_[0]);
476 define_indexing_macro
('indexiv');
478 my $str1 = next_argument
();
479 my $str2 = next_argument
();
480 my $str3 = next_argument
();
481 my $str4 = next_argument
();
482 add_index_entry
("$str1!$str2 $str3 $str4", @_[0]);
483 add_index_entry
("$str2!$str3 $str4, $str1", @_[0]);
484 add_index_entry
("$str3!$str4, $str1 $str2", @_[0]);
485 add_index_entry
("$str4!$$str1 $str2 $str3", @_[0]);
488 define_indexing_macro
('ttindex');
490 my $str = next_argument
();
491 my $entry = $str . get_indexsubitem
();
492 add_index_entry
($entry, @_[0]);
495 sub my_typed_index_helper
{
496 my($word,$ahref) = @_;
497 my $str = next_argument
();
498 add_index_entry
("$str $word", $ahref);
499 add_index_entry
("$word!$str", $ahref);
502 define_indexing_macro
('stindex', 'opindex', 'exindex', 'obindex');
503 sub idx_cmd_stindex
{ my_typed_index_helper
('statement', @_[0]); }
504 sub idx_cmd_opindex
{ my_typed_index_helper
('operator', @_[0]); }
505 sub idx_cmd_exindex
{ my_typed_index_helper
('exception', @_[0]); }
506 sub idx_cmd_obindex
{ my_typed_index_helper
('object', @_[0]); }
508 define_indexing_macro
('bifuncindex');
509 sub idx_cmd_bifuncindex
{
510 my $str = next_argument
();
511 add_index_entry
("<tt class='function'>$str()</tt> (built-in function)",
516 sub make_mod_index_entry
{
517 my($str,$define) = @_;
518 my($name,$aname,$ahref) = new_link_info
();
519 # equivalent of add_index_entry() using $define instead of ''
520 $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/
521 if ($define eq 'DEF');
522 $str = gen_index_id
($str, $define);
523 $index{$str} .= $ahref;
524 write_idxfile
($ahref, $str);
526 if ($define eq 'DEF') {
527 # add to the module index
528 $str =~ /(<tt.*<\/tt
>)/;
530 $Modules{$nstr} .= $ahref;
532 return "$aname$anchor_invisible_mark</a>";
540 my($word,$name) = @_;
541 my $section_tag = join('', @curr_sec_id);
542 if ($word ne "built-in" && $word ne "extension"
543 && $word ne "standard" && $word ne "") {
544 write_warnings
("Bad module type '$word'"
545 . " for \\declaremodule (module $name)");
548 $word = "$word " if $word;
549 $THIS_MODULE = "$name";
550 $INDEX_SUBITEM = "(in $name)";
552 return make_mod_index_entry
(
553 "<tt class='module'>$name</tt> (${word}module)", 'DEF');
556 sub my_module_index_helper
{
557 local($word, $_) = @_;
558 my $name = next_argument
();
559 return define_module
($word, $name) . $_;
562 sub do_cmd_modindex
{ return my_module_index_helper
('', @_); }
563 sub do_cmd_bimodindex
{ return my_module_index_helper
('built-in', @_); }
564 sub do_cmd_exmodindex
{ return my_module_index_helper
('extension', @_); }
565 sub do_cmd_stmodindex
{ return my_module_index_helper
('standard', @_); }
567 sub ref_module_index_helper
{
568 my($word, $ahref) = @_;
569 my $str = next_argument
();
570 $word = "$word " if $word;
571 $str = "<tt class='module'>$str</tt> (${word}module)";
572 # can't use add_index_entry() since the 2nd arg to gen_index_id() is used;
573 # just inline it all here
574 $str = gen_index_id
($str, 'REF');
575 $index{$str} .= $ahref;
576 write_idxfile
($ahref, $str);
579 # these should be adjusted a bit....
580 define_indexing_macro
('refmodindex', 'refbimodindex',
581 'refexmodindex', 'refstmodindex');
582 sub idx_cmd_refmodindex
{ return ref_module_index_helper
('', @_); }
583 sub idx_cmd_refbimodindex
{ return ref_module_index_helper
('built-in', @_); }
584 sub idx_cmd_refexmodindex
{ return ref_module_index_helper
('extension', @_); }
585 sub idx_cmd_refstmodindex
{ return ref_module_index_helper
('standard', @_); }
587 sub do_cmd_nodename
{ return do_cmd_label
(@_); }
590 # $anchor_invisible_mark = '';
592 $icons{'anchor_mark'} = '';
596 # Create an index entry, but include the string in the target anchor
597 # instead of the dummy filler.
599 sub make_str_index_entry
{
601 my($name,$aname,$ahref) = new_link_info
();
602 add_index_entry
($str, $ahref);
603 return "$aname$str</a>";
606 $REFCOUNTS_LOADED = 0;
609 $REFCOUNTS_LOADED = 1;
612 my $myname, $mydir, $myext;
613 ($myname, $mydir, $myext) = fileparse
(__FILE__
, '\..*');
614 chop $mydir; # remove trailing '/'
615 ($myname, $mydir, $myext) = fileparse
($mydir, '\..*');
616 chop $mydir; # remove trailing '/'
617 $mydir = getcwd
() . "$dd$mydir"
618 unless $mydir =~ s
|^/|/|;
620 my $filename = "$mydir${dd}api${dd}refcounts.dat";
621 open(REFCOUNT_FILE
, "<$filename") || die "\n$!\n";
622 print "[loading API refcount data]";
623 while (<REFCOUNT_FILE
>) {
624 if (/([a-zA-Z0-9_]+):PyObject\*:([a-zA-Z0-9_]*):(0|[-+]1|null):(.*)$/) {
625 my($func, $param, $count, $comment) = ($1, $2, $3, $4);
626 #print "\n$func($param) --> $count";
627 $REFCOUNTS{"$func:$param"} = $count;
633 my ($func, $param) = @_;
635 unless $REFCOUNTS_LOADED;
636 return $REFCOUNTS{"$func:$param"};
639 sub do_env_cfuncdesc
{
641 my $return_type = next_argument
();
642 my $function_name = next_argument
();
643 my $arg_list = next_argument
();
644 my $idx = make_str_index_entry
(
645 "<tt class='cfunction'>$function_name()</tt>" . get_indexsubitem
());
647 $idx =~ s/\(\)//; # ???? - why both of these?
648 my $result_rc = get_refcount
($function_name, '');
650 if ($result_rc eq '+1') {
651 $rcinfo = 'New reference';
653 elsif ($result_rc eq '0') {
654 $rcinfo = 'Borrowed reference';
656 elsif ($result_rc eq 'null') {
657 $rcinfo = 'Always <tt class="constant">NULL</tt>';
660 $rcinfo = ( "\n<div class=\"refcount-info\">"
661 . "\n <span class=\"label\">Return value:</span>"
662 . "\n <span class=\"value\">$rcinfo.</span>"
665 return "<dl><dt>$return_type <b>$idx</b> (<var>$arg_list</var>)\n<dd>"
671 sub do_env_csimplemacrodesc
{
673 my $name = next_argument
();
674 my $idx = make_str_index_entry
("<tt class='macro'>$name</tt>");
675 return "<dl><dt><b>$idx</b>\n<dd>"
680 sub do_env_ctypedesc
{
682 my $index_name = next_optional_argument
();
683 my $type_name = next_argument
();
684 $index_name = $type_name
686 my($name,$aname,$ahref) = new_link_info
();
687 add_index_entry
("<tt class='ctype'>$index_name</tt> (C type)", $ahref);
688 return "<dl><dt><b><tt class='ctype'>$aname$type_name</a></tt></b>\n<dd>"
695 my $var_type = next_argument
();
696 my $var_name = next_argument
();
697 my $idx = make_str_index_entry
("<tt class='cdata'>$var_name</tt>"
698 . get_indexsubitem
());
700 return "<dl><dt>$var_type <b>$idx</b>\n"
708 my $function_name = next_argument
();
709 my $arg_list = next_argument
();
710 my $idx = make_str_index_entry
("<tt class='function'>$function_name()</tt>"
711 . get_indexsubitem
());
713 $idx =~ s/\(\)<\/tt>/<\
/tt>/;
714 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
717 sub do_env_funcdescni
{
719 my $function_name = next_argument
();
720 my $arg_list = next_argument
();
721 return "<dl><dt><b><tt class='function'>$function_name</tt></b>"
722 . " (<var>$arg_list</var>)\n"
730 my $function_name = next_argument
();
731 my $arg_list = next_argument
();
732 my $prefix = "<tt class='function'>$function_name()</tt>";
733 my $idx = make_str_index_entry
($prefix . get_indexsubitem
());
736 return "<dt><b>$prefix</b> (<var>$arg_list</var>)\n<dd>" . $_;
739 sub do_cmd_funclineni
{
741 my $function_name = next_argument
();
742 my $arg_list = next_argument
();
743 my $prefix = "<tt class='function'>$function_name</tt>";
745 return "<dt><b>$prefix</b> (<var>$arg_list</var>)\n<dd>" . $_;
748 # Change this flag to index the opcode entries. I don't think it's very
749 # useful to index them, since they're only presented to describe the dis
754 sub do_env_opcodedesc
{
756 my $opcode_name = next_argument
();
757 my $arg_list = next_argument
();
759 if ($INDEX_OPCODES) {
760 $idx = make_str_index_entry
("<tt class='opcode'>$opcode_name</tt>"
761 . " (byte code instruction)");
762 $idx =~ s/ \(byte code instruction\)//;
765 $idx = "<tt class='opcode'>$opcode_name</tt>";
767 my $stuff = "<dl><dt><b>$idx</b>";
769 $stuff .= " <var>$arg_list</var>";
771 return $stuff . "\n<dd>" . $_ . '</dl>';
776 my $dataname = next_argument
();
777 my $idx = make_str_index_entry
("<tt>$dataname</tt>" . get_indexsubitem
());
779 return "<dl><dt><b>$idx</b>\n<dd>"
784 sub do_env_datadescni
{
786 my $idx = next_argument
();
787 if (! $STRING_INDEX_TT) {
788 $idx = "<tt>$idx</tt>";
790 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
795 my $data_name = next_argument
();
796 my $idx = make_str_index_entry
("<tt>$data_name</tt>" . get_indexsubitem
());
798 return "<dt><b>$idx</b><dd>" . $_;
801 sub do_cmd_datalineni
{
803 my $data_name = next_argument
();
804 return "<dt><b><tt>$data_name</tt></b><dd>" . $_;
809 my $excname = next_argument
();
810 my $idx = make_str_index_entry
("<tt class='exception'>$excname</tt>");
811 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'
814 sub do_env_fulllineitems
{ return do_env_itemize
(@_); }
817 sub do_env_classdesc
{
819 $THIS_CLASS = next_argument
();
820 my $arg_list = next_argument
();
821 $idx = make_str_index_entry
(
822 "<tt class='class'>$THIS_CLASS</tt> (class in $THIS_MODULE)" );
824 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
828 sub do_env_methoddesc
{
830 my $class_name = next_optional_argument
();
831 $class_name = $THIS_CLASS
833 my $method = next_argument
();
834 my $arg_list = next_argument
();
837 $extra = " ($class_name method)";
839 my $idx = make_str_index_entry
("<tt class='method'>$method()</tt>$extra");
842 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
846 sub do_cmd_methodline
{
848 my $class_name = next_optional_argument
();
849 $class_name = $THIS_CLASS
851 my $method = next_argument
();
852 my $arg_list = next_argument
();
855 $extra = " ($class_name method)";
857 my $idx = make_str_index_entry
("<tt class='method'>$method()</tt>$extra");
860 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>"
865 sub do_cmd_methodlineni
{
867 next_optional_argument
();
868 my $method = next_argument
();
869 my $arg_list = next_argument
();
870 return "<dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
874 sub do_env_methoddescni
{
876 next_optional_argument
();
877 my $method = next_argument
();
878 my $arg_list = next_argument
();
879 return "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
885 sub do_env_memberdesc
{
887 my $class = next_optional_argument
();
888 my $member = next_argument
();
892 $extra = " ($class attribute)"
894 my $idx = make_str_index_entry
("<tt class='member'>$member</tt>$extra");
897 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
901 sub do_cmd_memberline
{
903 my $class = next_optional_argument
();
904 my $member = next_argument
();
908 $extra = " ($class attribute)"
910 my $idx = make_str_index_entry
("<tt class='member'>$member</tt>$extra");
913 return "<dt><b>$idx</b><dd>" . $_;
916 sub do_env_memberdescni
{
918 next_optional_argument
();
919 my $member = next_argument
();
920 return "<dl><dt><b><tt class='member'>$member</tt></b>\n<dd>"
926 sub do_cmd_memberlineni
{
928 next_optional_argument
();
929 my $member = next_argument
();
930 return "<dt><b><tt class='member'>$member</tt></b><dd>" . $_;
933 @col_aligns = ('<td>', '<td>', '<td>', '<td>');
935 $TABLE_HEADER_BGCOLOR = $NAV_BGCOLOR;
938 # do a little magic on a font name to get the right behavior in the first
939 # column of the output table
941 if ($font eq 'textrm') {
944 elsif ($font eq 'file' || $font eq 'filenq') {
945 $font = 'tt class="file"';
947 elsif ($font eq 'member') {
948 $font = 'tt class="member"';
950 elsif ($font eq 'constant') {
951 $font = 'tt class="constant"';
953 elsif ($font eq 'kbd') {
959 sub figure_column_alignment
{
961 my $mark = substr($a, 0, 1);
964 { $r = ' align="center"'; }
966 { $r = ' align="right"'; }
968 { $r = ' align="left"'; }
970 { $r = ' align="left"'; }
974 sub setup_column_alignments
{
976 my($s1,$s2,$s3,$s4) = split(/[|]/,$_);
977 my $a1 = figure_column_alignment
($s1);
978 my $a2 = figure_column_alignment
($s2);
979 my $a3 = figure_column_alignment
($s3);
980 my $a4 = figure_column_alignment
($s4);
981 $col_aligns[0] = "<td$a1 valign=\"baseline\">";
982 $col_aligns[1] = "<td$a2>";
983 $col_aligns[2] = "<td$a3>";
984 $col_aligns[3] = "<td$a4>";
985 # return the aligned header start tags
986 return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>");
989 sub get_table_col1_fonts
{
990 my $font = $globals{'lineifont'};
991 my ($sfont,$efont) = ('', '');
997 return ($font, $sfont, $efont);
1002 my($th1,$th2,$th3,$th4) = setup_column_alignments
(next_argument
());
1003 my $font = fix_font
(next_argument
());
1004 my $h1 = next_argument
();
1005 my $h2 = next_argument
();
1007 $globals{'lineifont'} = $font;
1008 my $a1 = $col_aligns[0];
1009 my $a2 = $col_aligns[1];
1010 s/\\lineii</\\lineii[$a1|$a2]</g;
1011 return '<table border align="center" style="border-collapse: collapse">'
1013 . "\n <tr$TABLE_HEADER_BGCOLOR>"
1014 . "\n $th1<b>$h1</b>\ </th>"
1015 . "\n $th2<b>$h2</b>\ </th>"
1017 . "\n <tbody valign='baseline'>"
1025 my $aligns = next_optional_argument
();
1026 my $c1 = next_argument
();
1027 my $c2 = next_argument
();
1029 my($font,$sfont,$efont) = get_table_col1_fonts
();
1030 $c2 = ' ' if ($c2 eq '');
1031 my($c1align,$c2align) = split('\|', $aligns);
1033 if ($c1align =~ /align="right"/) {
1034 $padding = ' ';
1036 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
1037 . " $c2align$c2</td>"
1041 sub do_env_tableiii
{
1043 my($th1,$th2,$th3,$th4) = setup_column_alignments
(next_argument
());
1044 my $font = fix_font
(next_argument
());
1045 my $h1 = next_argument
();
1046 my $h2 = next_argument
();
1047 my $h3 = next_argument
();
1049 $globals{'lineifont'} = $font;
1050 my $a1 = $col_aligns[0];
1051 my $a2 = $col_aligns[1];
1052 my $a3 = $col_aligns[2];
1053 s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g;
1054 return '<table border align="center" style="border-collapse: collapse">'
1056 . "\n <tr$TABLE_HEADER_BGCOLOR>"
1057 . "\n $th1<b>$h1</b>\ </th>"
1058 . "\n $th2<b>$h2</b>\ </th>"
1059 . "\n $th3<b>$h3</b>\ </th>"
1061 . "\n <tbody valign='baseline'>"
1069 my $aligns = next_optional_argument
();
1070 my $c1 = next_argument
();
1071 my $c2 = next_argument
();
1072 my $c3 = next_argument
();
1074 my($font,$sfont,$efont) = get_table_col1_fonts
();
1075 $c3 = ' ' if ($c3 eq '');
1076 my($c1align,$c2align,$c3align) = split('\|', $aligns);
1078 if ($c1align =~ /align="right"/) {
1079 $padding = ' ';
1081 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
1082 . " $c2align$c2</td>\n"
1083 . " $c3align$c3</td>"
1089 my($th1,$th2,$th3,$th4) = setup_column_alignments
(next_argument
());
1090 my $font = fix_font
(next_argument
());
1091 my $h1 = next_argument
();
1092 my $h2 = next_argument
();
1093 my $h3 = next_argument
();
1094 my $h4 = next_argument
();
1096 $globals{'lineifont'} = $font;
1097 my $a1 = $col_aligns[0];
1098 my $a2 = $col_aligns[1];
1099 my $a3 = $col_aligns[2];
1100 my $a4 = $col_aligns[3];
1101 s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g;
1102 return '<table border align="center" style="border-collapse: collapse">'
1104 . "\n <tr$TABLE_HEADER_BGCOLOR>"
1105 . "\n $th1<b>$h1</b>\ </th>"
1106 . "\n $th2<b>$h2</b>\ </th>"
1107 . "\n $th3<b>$h3</b>\ </th>"
1108 . "\n $th4<b>$h4</b>\ </th>"
1110 . "\n <tbody valign='baseline'>"
1118 my $aligns = next_optional_argument
();
1119 my $c1 = next_argument
();
1120 my $c2 = next_argument
();
1121 my $c3 = next_argument
();
1122 my $c4 = next_argument
();
1124 my($font,$sfont,$efont) = get_table_col1_fonts
();
1125 $c4 = ' ' if ($c4 eq '');
1126 my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns);
1128 if ($c1align =~ /align="right"/) {
1129 $padding = ' ';
1131 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
1132 . " $c2align$c2</td>\n"
1133 . " $c3align$c3</td>\n"
1134 . " $c4align$c4</td>"
1138 sub do_cmd_maketitle
{
1140 my $the_title = "\n<div class='titlepage'><center>";
1142 $the_title .= "\n<h1>$t_title</h1>";
1143 } else { write_warnings
("\nThis document has no title."); }
1146 my $href = translate_commands
($t_authorURL);
1147 $href = make_named_href
('author', $href,
1148 "<b><font size='+2'>$t_author</font></b>");
1149 $the_title .= "\n<p>$href</p>";
1151 $the_title .= ("\n<p><b><font size='+2'>$t_author</font></b></p>");
1153 } else { write_warnings
("\nThere is no author for this document."); }
1155 $the_title .= "\n<p>$t_institute</p>";}
1156 if ($DEVELOPER_ADDRESS) {
1157 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";}
1159 $the_title .= "\n<p><i>$t_affil</i></p>";}
1161 $the_title .= "\n<p><strong>$t_date</strong>";
1162 if ($PYTHON_VERSION) {
1163 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";}
1164 $the_title .= "</p>"
1167 $the_title .= "\n<p>$t_address</p>";
1168 } else { $the_title .= "\n<p>"}
1170 $the_title .= "\n<p>$t_email</p>";
1171 }# else { $the_title .= "</p>" }
1172 $the_title .= "\n</center></div>";
1173 return $the_title . $_ ;
1178 # Module synopsis support
1181 require SynopsisTable
;
1183 sub get_chapter_id
(){
1184 my $id = do_cmd_thechapter
('');
1185 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\
1/;
1190 %ModuleSynopses = ('chapter' => 'SynopsisTable instance');
1192 sub get_synopsis_table
($){
1194 my $st = $ModuleSynopses{$chap};
1196 foreach $key (keys %ModuleSynopses) {
1197 if ($key eq $chap) {
1198 return $ModuleSynopses{$chap};
1201 $st = SynopsisTable
->new();
1202 $ModuleSynopses{$chap} = $st;
1206 sub do_cmd_moduleauthor
{
1213 sub do_cmd_sectionauthor
{
1220 sub do_cmd_declaremodule
{
1222 my $key = next_optional_argument
();
1223 my $type = next_argument
();
1224 my $name = next_argument
();
1225 my $st = get_synopsis_table
(get_chapter_id
());
1227 $key = $name unless $key;
1228 $type = 'built-in' if $type eq 'builtin';
1229 $st->declare($name, $key, $type);
1230 define_module
($type, $name);
1231 return anchor_label
("module-$key",$CURRENT_FILE,$_)
1234 sub do_cmd_modulesynopsis
{
1236 my $st = get_synopsis_table
(get_chapter_id
());
1237 $st->set_synopsis($THIS_MODULE, translate_commands
(next_argument
()));
1241 sub do_cmd_localmoduletable
{
1243 my $chap = get_chapter_id
();
1244 return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_;
1247 sub process_all_localmoduletables
{
1248 while (/<tex2html-localmoduletable><(\d+)>/) {
1251 my $st = get_synopsis_table
($chap);
1252 my $data = $st->tohtml();
1256 sub process_python_state
{
1257 process_all_localmoduletables
();
1262 # "See also:" -- references placed at the end of a \section
1266 return "<div class='seealso'>\n "
1267 . "<p class='heading'><b>See Also:</b></p>\n"
1272 sub do_cmd_seemodule
{
1273 # Insert the right magic to jump to the module definition. This should
1274 # work most of the time, at least for repeat builds....
1276 my $key = next_optional_argument
();
1277 my $module = next_argument
();
1278 my $text = next_argument
();
1282 if ($text =~ /\.$/) {
1285 return '<dl compact class="seemodule">'
1286 . "\n <dt>Module <b><tt class='module'><a href='module-$key.html'>"
1287 . "$module</a></tt>:</b>"
1288 . "\n <dd>$text$period\n </dl>"
1294 my $rfcnum = next_argument
();
1295 my $title = next_argument
();
1296 my $text = next_argument
();
1297 my $url = get_rfc_url
($rfcnum);
1298 return '<dl compact class="seerfc">'
1299 . "\n <dt><a href=\"$url\""
1300 . "\n title=\"$title\""
1301 . "\n >RFC $rfcnum, <em>$title</em></a>:"
1302 . "\n <dd>$text\n </dl>"
1308 my $url = next_argument
();
1309 my $text = next_argument
();
1310 return '<dl compact class="seeurl">'
1311 . "\n <dt><a href=\"$url\""
1312 . "\n class=\"url\">$url</a>"
1313 . "\n <dd>$text\n </dl>"
1319 my $content = next_argument
();
1320 return '<div class="seetext"><p>' . $content . '</div>' . $_;
1325 # Definition list support.
1328 sub do_env_definitions
{
1329 return "<dl class='definitions'>" . @_[0] . "</dl>\n";
1334 my $term = next_argument
();
1335 my($name,$aname,$ahref) = new_link_info
();
1336 # could easily add an index entry here...
1337 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
1341 process_commands_wrap_deferred
(<<_RAW_ARG_DEFERRED_CMDS_
);
1343 declaremodule
# [] # {} # {}
1344 memberline
# [] # {}
1345 methodline
# [] # {} # {}
1349 setindexsubitem
# {}
1350 withsubitem
# {} # {}
1351 _RAW_ARG_DEFERRED_CMDS_
1354 1; # This must be the last line