blob: 6caee3adfcaa07bb30433540139d4edeaa67d8ed [file] [log] [blame]
Fred Drake6659c301998-03-03 22:02:19 +00001# python.perl by Fred L. Drake, Jr. <fdrake@acm.org> -*- perl -*-
2#
3# Heavily based on Guido van Rossum's myformat.perl (now obsolete).
4#
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.
8
9package main;
10
11
Fred Drake08932051998-04-17 02:15:42 +000012sub next_argument{
Fred Drakeccc62721999-01-05 22:16:29 +000013 my $param;
14 $param = missing_braces()
15 unless ((s/$next_pair_pr_rx/$param=$2;''/eo)
16 ||(s/$next_pair_rx/$param=$2;''/eo));
Fred Drake62e43691998-08-10 19:40:44 +000017 return $param;
Fred Drake08932051998-04-17 02:15:42 +000018}
19
20sub next_optional_argument{
21 my($param,$rx) = ('', "^\\s*(\\[([^]]*)\\])?");
Fred Drake5ccf3301998-04-17 20:04:09 +000022 s/$rx/$param=$2;''/eo;
Fred Drake62e43691998-08-10 19:40:44 +000023 return $param;
Fred Drake08932051998-04-17 02:15:42 +000024}
25
26sub swallow_newline{
27 s/[\n]?//o;
28}
29
Fred Drakee16f6791998-05-15 04:28:37 +000030
31# This is a fairly simple hack; it supports \let when it is used to create
32# (or redefine) a macro to exactly be some other macro: \let\newname=\oldname.
Fred Drake5b73cdf1998-05-15 16:59:38 +000033# Many possible uses of \let aren't supported or aren't supported correctly.
Fred Drakee16f6791998-05-15 04:28:37 +000034#
35sub do_cmd_let{
36 local($_) = @_;
37 my $matched = 0;
Fred Drake7a4ad0f1998-05-15 13:45:54 +000038 s/[\\]([a-zA-Z]+)\s*(=\s*)?[\\]([a-zA-Z]*)/$matched=1; ''/e;
Fred Drakee16f6791998-05-15 04:28:37 +000039 if ($matched) {
40 my($new, $old) = ($1, $3);
41 eval "sub do_cmd_$new { do_cmd_$old" . '(@_); }';
42 print "\ndefining handler for \\$new using \\$old\n";
43 }
Fred Drake7a4ad0f1998-05-15 13:45:54 +000044 else {
45 s/[\\]([a-zA-Z]+)\s*(=\s*)?([^\\])/$matched=1; ''/es;
46 if ($matched) {
47 my($new, $char) = ($1, $3);
48 eval "sub do_cmd_$new { \"\\$char\" . \@_[0]; }";
49 print "\ndefining handler for \\$new to insert '$char'\n";
50 }
51 else {
52 write_warnings("Could not interpret \\let construct...");
53 }
54 }
Fred Drake62e43691998-08-10 19:40:44 +000055 return $_;
Fred Drakee16f6791998-05-15 04:28:37 +000056}
57
58
Fred Drake6659c301998-03-03 22:02:19 +000059# words typeset in a special way (not in HTML though)
60
61sub do_cmd_ABC{ 'ABC' . @_[0]; }
62sub do_cmd_UNIX{ 'Unix'. @_[0]; }
63sub do_cmd_ASCII{ 'ASCII' . @_[0]; }
64sub do_cmd_POSIX{ 'POSIX' . @_[0]; }
65sub do_cmd_C{ 'C' . @_[0]; }
66sub do_cmd_Cpp{ 'C++' . @_[0]; }
67sub do_cmd_EOF{ 'EOF' . @_[0]; }
68sub do_cmd_NULL{ '<tt>NULL</tt>' . @_[0]; }
69
70sub do_cmd_e{ '&#92;' . @_[0]; }
71
Fred Draked07868a1998-05-14 21:00:28 +000072$DEVELOPER_ADDRESS = '';
Fred Drake6659c301998-03-03 22:02:19 +000073$PYTHON_VERSION = '';
74
75sub do_cmd_version{ $PYTHON_VERSION . @_[0]; }
76sub do_cmd_release{
77 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +000078 $PYTHON_VERSION = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000079 return $_;
Fred Drake6659c301998-03-03 22:02:19 +000080}
81
82sub do_cmd_authoraddress{
83 local($_) = @_;
Fred Draked07868a1998-05-14 21:00:28 +000084 $DEVELOPER_ADDRESS = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000085 return $_;
Fred Drake6659c301998-03-03 22:02:19 +000086}
87
Fred Drakee16f6791998-05-15 04:28:37 +000088#sub do_cmd_developer{ do_cmd_author(@_[0]); }
89#sub do_cmd_developers{ do_cmd_author(@_[0]); }
90#sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); }
Fred Draked07868a1998-05-14 21:00:28 +000091
Fred Drake6659c301998-03-03 22:02:19 +000092sub do_cmd_hackscore{
93 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +000094 next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000095 return '_' . $_;
Fred Drake6659c301998-03-03 22:02:19 +000096}
97
Fred Drake08932051998-04-17 02:15:42 +000098sub use_wrappers{
99 local($_,$before,$after) = @_;
100 my $stuff = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000101 return $before . $stuff . $after . $_;
Fred Drake08932051998-04-17 02:15:42 +0000102}
103
Fred Drake62e43691998-08-10 19:40:44 +0000104sub use_sans_serif{
Fred Drakeccc62721999-01-05 22:16:29 +0000105 return use_wrappers(@_[0], '<font face="sans-serif">', '</font>');
Fred Drake62e43691998-08-10 19:40:44 +0000106}
107sub use_italics{
108 return use_wrappers(@_[0], '<i>', '</i>');
109}
Fred Drake08932051998-04-17 02:15:42 +0000110
Fred Drake6659c301998-03-03 22:02:19 +0000111sub do_cmd_optional{
Fred Drake62e43691998-08-10 19:40:44 +0000112 return use_wrappers(@_[0], "</var><big>\[</big><var>",
113 "</var><big>\]</big><var>");
Fred Drake6659c301998-03-03 22:02:19 +0000114}
115
Fred Drakec9a44381998-03-17 06:29:13 +0000116# Logical formatting (some based on texinfo), needs to be converted to
117# minimalist HTML. The "minimalist" is primarily to reduce the size of
118# output files for users that read them over the network rather than
119# from local repositories.
Fred Drake6659c301998-03-03 22:02:19 +0000120
Fred Drake2ff880e1999-02-05 18:31:29 +0000121sub do_cmd_pytype{ return @_[0]; }
122sub do_cmd_makevar{ return @_[0]; }
Fred Drake1a4c5391999-02-09 15:31:52 +0000123sub do_cmd_code{ return use_wrappers(@_[0], '<tt>', '</tt>'); }
Fred Drake62e43691998-08-10 19:40:44 +0000124sub do_cmd_module{ return do_cmd_code(@_); }
125sub do_cmd_keyword{ return do_cmd_code(@_); }
126sub do_cmd_exception{ return do_cmd_code(@_); }
127sub do_cmd_class{ return do_cmd_code(@_); }
128sub do_cmd_function{ return do_cmd_code(@_); }
129sub do_cmd_constant{ return do_cmd_code(@_); }
130sub do_cmd_member{ return do_cmd_code(@_); }
131sub do_cmd_method{ return do_cmd_code(@_); }
132sub do_cmd_cfunction{ return do_cmd_code(@_); }
133sub do_cmd_cdata{ return do_cmd_code(@_); }
134sub do_cmd_ctype{ return do_cmd_code(@_); }
135sub do_cmd_regexp{ return do_cmd_code(@_); }
136sub do_cmd_character{ return do_cmd_samp(@_); }
137sub do_cmd_program{ return do_cmd_strong(@_); }
138sub do_cmd_email{ return use_sans_serif(@_); }
139sub do_cmd_mimetype{ return use_sans_serif(@_); }
Fred Drake1a4c5391999-02-09 15:31:52 +0000140sub do_cmd_var{ return use_wrappers(@_[0], "<i>", "</i>"); }
Fred Drake62e43691998-08-10 19:40:44 +0000141sub do_cmd_dfn{ return use_italics(@_); } # make an index entry?
142sub do_cmd_emph{ return use_italics(@_); }
143sub do_cmd_file{ return use_wrappers(@_[0], '"<tt>', '</tt>"'); }
Fred Drake1a4c5391999-02-09 15:31:52 +0000144sub do_cmd_samp{ return use_wrappers(@_[0], '"<tt>', '</tt>"'); }
Fred Drake62e43691998-08-10 19:40:44 +0000145sub do_cmd_kbd{ return use_wrappers(@_[0], '<kbd>', '</kbd>'); }
146sub do_cmd_strong{ return use_wrappers(@_[0], '<b>', '</b>'); }
Fred Drakec9a44381998-03-17 06:29:13 +0000147
Fred Drake25817041999-01-13 17:06:34 +0000148sub do_cmd_refmodule{
149 # Insert the right magic to jump to the module definition.
150 local($_) = @_;
151 my $key = next_optional_argument();
152 my $module = next_argument();
153 $key = $module
154 unless $key;
155 return "<tt><a href=\"module-$key.html\">$module</a></tt>" . $_;
156}
157
Fred Drake1a7af391998-04-01 22:44:56 +0000158sub do_cmd_newsgroup{
159 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000160 my $newsgroup = next_argument();
Fred Drake1a7af391998-04-01 22:44:56 +0000161 my $stuff = "<a href=\"news:$newsgroup\"><font face=sans-serif>"
162 . "$newsgroup</font></a>";
Fred Drake62e43691998-08-10 19:40:44 +0000163 return $stuff . $_;
Fred Drake1a7af391998-04-01 22:44:56 +0000164}
Fred Drakefc16e781998-03-12 21:03:26 +0000165
166sub do_cmd_envvar{
167 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000168 my $envvar = next_argument();
169 my($name,$aname,$ahref) = new_link_info();
Fred Drake166abba1998-04-08 23:10:54 +0000170 # The <tt> here is really to keep buildindex.py from making
171 # the variable name case-insensitive.
172 add_index_entry("environment variables!$envvar@<tt>\$$envvar</tt>",
173 $ahref);
Fred Drake42b31a51998-03-27 05:16:10 +0000174 add_index_entry("$envvar@\$$envvar", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000175 return "$aname\$$envvar</a>" . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000176}
177
Fred Drake08932051998-04-17 02:15:42 +0000178
Fred Drake6659c301998-03-03 22:02:19 +0000179sub do_cmd_url{
180 # use the URL as both text and hyperlink
181 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000182 my $url = next_argument();
Fred Drake6659c301998-03-03 22:02:19 +0000183 $url =~ s/~/&#126;/g;
Fred Drake62e43691998-08-10 19:40:44 +0000184 return "<a href=\"$url\"><font face=sans-serif>$url</font></a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000185}
186
187sub do_cmd_manpage{
188 # two parameters: \manpage{name}{section}
189 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000190 my $page = next_argument();
191 my $section = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000192 return "<i>$page</i>($section)" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000193}
194
195sub do_cmd_rfc{
196 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000197 my $rfcnumber = next_argument();
198 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drake2eff3c51998-12-22 18:02:25 +0000199 my $href =
200 "http://info.internet.isi.edu/in-notes/rfc/files/rfc$rfcnumber.txt";
Fred Drake6659c301998-03-03 22:02:19 +0000201 # Save the reference
Fred Drake08932051998-04-17 02:15:42 +0000202 my $nstr = gen_index_id("RFC!RFC $rfcnumber", '');
Fred Drakeccc62721999-01-05 22:16:29 +0000203 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
204 return "<a name=\"$id\"\nhref=\"$href\">RFC $rfcnumber</a>" .$_;
Fred Drake6659c301998-03-03 22:02:19 +0000205}
206
Fred Drake6659c301998-03-03 22:02:19 +0000207sub do_cmd_deprecated{
208 # two parameters: \deprecated{version}{whattodo}
209 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000210 my $release = next_argument();
211 my $reason = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000212 return "<b>Deprecated since release $release.</b>\n$reason<p>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000213}
214
Fred Drake897d12b1998-07-27 20:33:17 +0000215sub do_cmd_versionadded{
216 # one parameter: \versionadded{version}
217 local($_) = @_;
218 my $release = next_argument();
Fred Drake2116d981999-02-02 18:02:48 +0000219 return "\nNew in version $release.\n" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000220}
221
222sub do_cmd_versionchanged{
223 # one parameter: \versionchanged{version}
224 local($_) = @_;
225 my $release = next_argument();
Fred Drake2116d981999-02-02 18:02:48 +0000226 return "\nChanged in version $release.\n" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000227}
228
Fred Drake6659c301998-03-03 22:02:19 +0000229# file and samp are at the end of this file since they screw up fontlock.
230
231# index commands
232
233$INDEX_SUBITEM = "";
234
235sub get_indexsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000236 return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
Fred Drake6659c301998-03-03 22:02:19 +0000237}
238
239sub do_cmd_setindexsubitem{
240 local($_) = @_;
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000241 $INDEX_SUBITEM = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000242 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000243}
244
Fred Drakefc16e781998-03-12 21:03:26 +0000245sub do_cmd_withsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000246 # We can't really do the right thing, because LaTeX2HTML doesn't
Fred Drakefc16e781998-03-12 21:03:26 +0000247 # do things in the right order, but we need to at least strip this stuff
248 # out, and leave anything that the second argument expanded out to.
249 #
250 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000251 my $oldsubitem = $INDEX_SUBITEM;
252 $INDEX_SUBITEM = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000253 my $stuff = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000254 my $br_id = ++$globals{'max_id'};
255 my $marker = "$O$br_id$C";
Fred Drake7d45f6d1999-01-05 14:39:27 +0000256 return
257 $stuff
Fred Drakeccc62721999-01-05 22:16:29 +0000258 . "\\setindexsubitem$marker$oldsubitem$marker"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000259 . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000260}
261
Fred Drake08932051998-04-17 02:15:42 +0000262# This is the prologue macro which is required to start writing the
263# mod\jobname.idx file; we can just ignore it.
264#
Fred Drake62e43691998-08-10 19:40:44 +0000265sub do_cmd_makemodindex{ return @_[0]; }
Fred Drakefc16e781998-03-12 21:03:26 +0000266
Fred Drake42b31a51998-03-27 05:16:10 +0000267# We're in the document subdirectory when this happens!
Fred Drake166abba1998-04-08 23:10:54 +0000268#
Fred Drake08932051998-04-17 02:15:42 +0000269open(IDXFILE, '>index.dat') || die "\n$!\n";
270open(INTLABELS, '>intlabels.pl') || die "\n$!\n";
Fred Drake166abba1998-04-08 23:10:54 +0000271print INTLABELS "%internal_labels = ();\n";
272print INTLABELS "1; # hack in case there are no entries\n\n";
273
274# Using \0 for this is bad because we can't use common tools to work with the
275# resulting files. Things like grep can be useful with this stuff!
276#
277$IDXFILE_FIELD_SEP = "\1";
278
Fred Drakeccc62721999-01-05 22:16:29 +0000279sub write_idxfile{
280 my ($ahref, $str) = @_;
281 print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n";
Fred Drake42b31a51998-03-27 05:16:10 +0000282}
283
Fred Drake42b31a51998-03-27 05:16:10 +0000284
285sub gen_link{
286 my($node,$target) = @_;
287 print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
Fred Drake62e43691998-08-10 19:40:44 +0000288 return "<a href=\"$node#$target\">";
Fred Drake42b31a51998-03-27 05:16:10 +0000289}
290
291sub make_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000292 my($str) = @_;
293 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000294 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000295 return "$aname$anchor_invisible_mark</a>";
Fred Drake42b31a51998-03-27 05:16:10 +0000296}
297
298sub add_index_entry{
299 # add an entry to the index structures; ignore the return value
300 my($str,$ahref) = @_;
301 $str = gen_index_id($str, '');
302 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000303 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000304}
305
Fred Drakeccc62721999-01-05 22:16:29 +0000306sub new_link_info{
307 my $name = "l2h-" . ++$globals{'max_id'};
308 my $aname = '<a name="' . $name . '">';
Fred Drake42b31a51998-03-27 05:16:10 +0000309 my $ahref = gen_link($CURRENT_FILE, $name);
310 return ($name, $aname, $ahref);
311}
312
313sub do_cmd_index{
314 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000315 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000316 swallow_newline();
Fred Drake42b31a51998-03-27 05:16:10 +0000317 #
Fred Drakeccc62721999-01-05 22:16:29 +0000318 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000319 add_index_entry("$str", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000320 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake42b31a51998-03-27 05:16:10 +0000321}
322
Fred Drake2e7edb81998-05-11 18:31:17 +0000323sub do_cmd_kwindex{
324 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000325 my $str = next_argument();
Fred Drake2e7edb81998-05-11 18:31:17 +0000326 #
Fred Drakeccc62721999-01-05 22:16:29 +0000327 my($name,$aname,$ahref) = new_link_info();
Fred Drake2e7edb81998-05-11 18:31:17 +0000328 add_index_entry("<tt>$str</tt>!keyword", $ahref);
329 add_index_entry("keyword!<tt>$str</tt>", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000330 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake2e7edb81998-05-11 18:31:17 +0000331}
332
Fred Drake6659c301998-03-03 22:02:19 +0000333sub do_cmd_indexii{
334 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000335 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000336 my $str2 = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000337 #
Fred Drakeccc62721999-01-05 22:16:29 +0000338 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000339 add_index_entry("$str1!$str2", $ahref);
340 add_index_entry("$str2!$str1", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000341 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000342}
343
344sub do_cmd_indexiii{
345 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000346 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000347 my $str2 = next_argument();
348 my $str3 = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000349 #
Fred Drakeccc62721999-01-05 22:16:29 +0000350 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000351 add_index_entry("$str1!$str2 $str3", $ahref);
352 add_index_entry("$str2!$str3, $str1", $ahref);
353 add_index_entry("$str3!$str1 $str2", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000354 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000355}
356
357sub do_cmd_indexiv{
358 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000359 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000360 my $str2 = next_argument();
361 my $str3 = next_argument();
362 my $str4 = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000363 #
Fred Drakeccc62721999-01-05 22:16:29 +0000364 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000365 add_index_entry("$str1!$str2 $str3 $str4", $ahref);
366 add_index_entry("$str2!$str3 $str4, $str1", $ahref);
367 add_index_entry("$str3!$str4, $str1 $str2", $ahref);
368 add_index_entry("$str4!$$str1 $str2 $str3", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000369 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000370}
371
Fred Drakec9a44381998-03-17 06:29:13 +0000372sub do_cmd_ttindex{
373 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000374 my $str = next_argument();
375 my $entry = $str . get_indexsubitem();
Fred Drake08932051998-04-17 02:15:42 +0000376 swallow_newline();
Fred Drakeccc62721999-01-05 22:16:29 +0000377 return make_index_entry($entry) . $_;
Fred Drakec9a44381998-03-17 06:29:13 +0000378}
Fred Drake6659c301998-03-03 22:02:19 +0000379
380sub my_typed_index_helper{
Fred Drakec9a44381998-03-17 06:29:13 +0000381 local($word,$_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000382 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000383 swallow_newline();
Fred Drake42b31a51998-03-27 05:16:10 +0000384 #
Fred Drakeccc62721999-01-05 22:16:29 +0000385 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000386 add_index_entry("$str $word", $ahref);
387 add_index_entry("$word!$str", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000388 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000389}
390
Fred Drake62e43691998-08-10 19:40:44 +0000391sub do_cmd_stindex{ return my_typed_index_helper('statement', @_); }
392sub do_cmd_opindex{ return my_typed_index_helper('operator', @_); }
393sub do_cmd_exindex{ return my_typed_index_helper('exception', @_); }
394sub do_cmd_obindex{ return my_typed_index_helper('object', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000395
396sub my_parword_index_helper{
Fred Drakec9a44381998-03-17 06:29:13 +0000397 local($word,$_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000398 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000399 swallow_newline();
Fred Drakeccc62721999-01-05 22:16:29 +0000400 return make_index_entry("$str ($word)") . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000401}
402
403
Fred Drake6659c301998-03-03 22:02:19 +0000404sub make_mod_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000405 my($str,$define) = @_;
406 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000407 # equivalent of add_index_entry() using $define instead of ''
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000408 $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/
409 if ($define eq 'DEF');
Fred Drake42b31a51998-03-27 05:16:10 +0000410 $str = gen_index_id($str, $define);
411 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000412 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000413
Fred Drakec9a44381998-03-17 06:29:13 +0000414 if ($define eq 'DEF') {
Fred Drake42b31a51998-03-27 05:16:10 +0000415 # add to the module index
Fred Drakec9a44381998-03-17 06:29:13 +0000416 my($nstr,$garbage) = split / /, $str, 2;
Fred Drake42b31a51998-03-27 05:16:10 +0000417 $Modules{$nstr} .= $ahref;
Fred Drake6659c301998-03-03 22:02:19 +0000418 }
Fred Drake62e43691998-08-10 19:40:44 +0000419 return "$aname$anchor_invisible_mark</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000420}
421
Fred Drakec9a44381998-03-17 06:29:13 +0000422$THIS_MODULE = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000423$THIS_CLASS = '';
Fred Drakec9a44381998-03-17 06:29:13 +0000424
Fred Drakea0f4c941998-07-24 22:16:04 +0000425sub define_module{
426 my($word,$name) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000427 my $section_tag = join('', @curr_sec_id);
Fred Drake6659c301998-03-03 22:02:19 +0000428 $word = "$word " if $word;
Fred Drakea0f4c941998-07-24 22:16:04 +0000429 $THIS_MODULE = "$name";
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000430 $INDEX_SUBITEM = "(in $name)";
431 print "[$name]";
Fred Drakeccc62721999-01-05 22:16:29 +0000432 return make_mod_index_entry("<tt>$name</tt> (${word}module)", 'DEF');
Fred Drakea0f4c941998-07-24 22:16:04 +0000433}
434
435sub my_module_index_helper{
436 local($word, $_) = @_;
437 my $name = next_argument();
438 swallow_newline();
Fred Drake62e43691998-08-10 19:40:44 +0000439 return define_module($word, $name) . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000440}
441
442sub ref_module_index_helper{
443 local($word, $_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000444 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000445 swallow_newline();
Fred Drake6659c301998-03-03 22:02:19 +0000446 $word = "$word " if $word;
Fred Drakeccc62721999-01-05 22:16:29 +0000447 return make_mod_index_entry("<tt>$str</tt> (${word}module)", 'REF') . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000448}
449
Fred Drakec9a44381998-03-17 06:29:13 +0000450sub do_cmd_bifuncindex{
451 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000452 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000453 my $fname = "<tt>$str()</tt>";
Fred Drakeccc62721999-01-05 22:16:29 +0000454 swallow_newline();
455 return make_index_entry("$fname (built-in function)") . $_;
Fred Drakec9a44381998-03-17 06:29:13 +0000456}
457
Fred Drake62e43691998-08-10 19:40:44 +0000458sub do_cmd_modindex{ return my_module_index_helper('', @_); }
459sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); }
460sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); }
461sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000462
463# these should be adjusted a bit....
Fred Drake62e43691998-08-10 19:40:44 +0000464sub do_cmd_refmodindex{ return ref_module_index_helper('', @_); }
465sub do_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); }
466sub do_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); }
467sub do_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000468
Fred Drake62e43691998-08-10 19:40:44 +0000469sub do_cmd_nodename{ return do_cmd_label(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000470
471sub init_myformat{
Fred Drake08932051998-04-17 02:15:42 +0000472# $anchor_invisible_mark = '';
Fred Drake6659c301998-03-03 22:02:19 +0000473 $anchor_mark = '';
474 $icons{'anchor_mark'} = '';
Fred Drake6659c301998-03-03 22:02:19 +0000475}
Fred Drake42b31a51998-03-27 05:16:10 +0000476init_myformat();
Fred Drake6659c301998-03-03 22:02:19 +0000477
478# similar to make_index_entry(), but includes the string in the result
479# instead of the dummy filler.
480#
481sub make_str_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000482 my($str) = @_;
483 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000484 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000485 return "$aname$str</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000486}
487
Fred Drake6659c301998-03-03 22:02:19 +0000488sub do_env_cfuncdesc{
489 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000490 my $return_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000491 my $function_name = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000492 my $arg_list = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000493 my $idx = make_str_index_entry("<tt>$function_name()</tt>"
494 . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000495 $idx =~ s/ \(.*\)//;
496 $idx =~ s/\(\)//; # ????
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000497 return "<dl><dt>$return_type <b>$idx</b> (<var>$arg_list</var>)\n<dd>"
Fred Drake62e43691998-08-10 19:40:44 +0000498 . $_
499 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000500}
501
502sub do_env_ctypedesc{
503 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000504 my $type_name = next_argument();
505 my $idx = make_str_index_entry("<tt>$type_name</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000506 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000507 return "<dl><dt><b>$idx</b>\n<dd>"
508 . $_
509 . '</dl>'
Fred Drake6659c301998-03-03 22:02:19 +0000510}
511
512sub do_env_cvardesc{
513 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000514 my $var_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000515 my $var_name = next_argument();
516 my $idx = make_str_index_entry("<tt>$var_name</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000517 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000518 return "<dl><dt>$var_type <b>$idx</b>\n"
519 . '<dd>'
520 . $_
521 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000522}
523
524sub do_env_funcdesc{
525 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000526 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000527 my $arg_list = next_argument();
528 my $idx = make_str_index_entry("<tt>$function_name()</tt>"
Fred Drake08932051998-04-17 02:15:42 +0000529 . get_indexsubitem());
530 $idx =~ s/ \(.*\)//;
Fred Drakeccc62721999-01-05 22:16:29 +0000531 $idx =~ s/\(\)<\/tt>/<\/tt>/;
Fred Drake62e43691998-08-10 19:40:44 +0000532 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000533}
534
535sub do_env_funcdescni{
536 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000537 my $function_name = next_argument();
538 my $arg_list = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000539 return "<dl><dt><b><tt>$function_name</tt></b> (<var>$arg_list</var>)\n"
540 . "<dd>"
541 . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000542}
543
544sub do_cmd_funcline{
545 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000546 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000547 my $arg_list = next_argument();
548 my $idx = make_str_index_entry("<tt>$function_name()</tt>"
Fred Drake08932051998-04-17 02:15:42 +0000549 . get_indexsubitem());
Fred Drakec9a44381998-03-17 06:29:13 +0000550 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000551 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000552}
553
554# Change this flag to index the opcode entries. I don't think it's very
555# useful to index them, since they're only presented to describe the dis
556# module.
557#
558$INDEX_OPCODES = 0;
559
560sub do_env_opcodedesc{
561 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000562 my $opcode_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000563 my $arg_list = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000564 my $idx;
565 if ($INDEX_OPCODES) {
Fred Drakeccc62721999-01-05 22:16:29 +0000566 $idx = make_str_index_entry(
Fred Drake6659c301998-03-03 22:02:19 +0000567 "<tt>$opcode_name</tt> (byte code instruction)");
Fred Drake08932051998-04-17 02:15:42 +0000568 $idx =~ s/ \(byte code instruction\)//;
569 }
570 else {
571 $idx = "<tt>$opcode_name</tt>";
572 }
573 my $stuff = "<dl><dt><b>$idx</b>";
Fred Drake6659c301998-03-03 22:02:19 +0000574 if ($arg_list) {
575 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
576 }
Fred Drake62e43691998-08-10 19:40:44 +0000577 return $stuff . "\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000578}
579
580sub do_env_datadesc{
581 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000582 my $dataname = next_argument();
583 my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000584 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000585 return "<dl><dt><b>$idx</b>\n<dd>"
586 . $_
587 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000588}
589
590sub do_env_datadescni{
591 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000592 my $idx = next_argument();
593 if (! $STRING_INDEX_TT) {
594 $idx = "<tt>$idx</tt>";
Fred Drake6659c301998-03-03 22:02:19 +0000595 }
Fred Drake62e43691998-08-10 19:40:44 +0000596 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000597}
598
599sub do_cmd_dataline{
600 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000601 my $data_name = next_argument();
602 my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem());
Fred Drake6659c301998-03-03 22:02:19 +0000603 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000604 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000605}
606
Fred Drake42b31a51998-03-27 05:16:10 +0000607sub do_env_excdesc{
608 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000609 my $excname = next_argument();
610 my $idx = make_str_index_entry("<tt>$excname</tt>");
Fred Drake62e43691998-08-10 19:40:44 +0000611 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'
Fred Drake42b31a51998-03-27 05:16:10 +0000612}
613
Fred Drake62e43691998-08-10 19:40:44 +0000614sub do_env_fulllineitems{ return do_env_itemize(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000615
616
Fred Drakec9a44381998-03-17 06:29:13 +0000617sub do_env_classdesc{
618 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000619 $THIS_CLASS = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000620 my $arg_list = next_argument();
621 $idx = make_str_index_entry(
Fred Drake08932051998-04-17 02:15:42 +0000622 "<tt>$THIS_CLASS</tt> (class in $THIS_MODULE)" );
623 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000624 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drakec9a44381998-03-17 06:29:13 +0000625}
626
Fred Drake42b31a51998-03-27 05:16:10 +0000627
628sub do_env_methoddesc{
629 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000630 my $class_name = next_optional_argument();
631 $class_name = $THIS_CLASS
632 unless $class_name;
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000633 my $method = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000634 my $arg_list = next_argument();
635 my $extra = '';
636 if ($class_name) {
637 $extra = " ($class_name method)";
Fred Drake42b31a51998-03-27 05:16:10 +0000638 }
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000639 my $idx = make_str_index_entry("<tt>$method()</tt>$extra");
Fred Drake08932051998-04-17 02:15:42 +0000640 $idx =~ s/ \(.*\)//;
641 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000642 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000643}
644
645
Fred Drake7d45f6d1999-01-05 14:39:27 +0000646sub do_cmd_methodline{
647 local($_) = @_;
648 my $class_name = next_optional_argument();
649 $class_name = $THIS_CLASS
650 unless $class_name;
651 my $method = next_argument();
652 my $arg_list = next_argument();
653 my $extra = '';
654 if ($class_name) {
655 $extra = " ($class_name method)";
656 }
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000657 my $idx = make_str_index_entry("<tt>$method()</tt>$extra");
Fred Drake7d45f6d1999-01-05 14:39:27 +0000658 $idx =~ s/ \(.*\)//;
659 $idx =~ s/\(\)//;
660 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>"
661 . $_;
662}
663
664
Fred Draked64a40d1998-09-10 18:59:13 +0000665sub do_cmd_methodlineni{
666 local($_) = @_;
667 next_optional_argument();
668 my $method = next_argument();
669 my $arg_list = next_argument();
670 return "<dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
671 . $_;
672}
673
Fred Drake42b31a51998-03-27 05:16:10 +0000674sub do_env_methoddescni{
675 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000676 next_optional_argument();
677 my $method = next_argument();
678 my $arg_list = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000679 return "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
680 . $_
681 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000682}
683
684
685sub do_env_memberdesc{
686 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000687 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000688 my $member = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000689 $class = $THIS_CLASS
690 unless $class;
Fred Drake08932051998-04-17 02:15:42 +0000691 my $extra = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000692 $extra = " ($class_name attribute)"
Fred Drakea608feb1998-04-12 03:58:13 +0000693 if (!($class eq ''));
Fred Drakeccc62721999-01-05 22:16:29 +0000694 my $idx = make_str_index_entry("<tt>$member</tt>$extra");
Fred Drake42b31a51998-03-27 05:16:10 +0000695 $idx =~ s/ \(.*\)//;
696 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000697 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000698}
699
700
Fred Drake5ccf3301998-04-17 20:04:09 +0000701sub do_cmd_memberline{
702 local($_) = @_;
703 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000704 my $member = next_argument();
Fred Drake5ccf3301998-04-17 20:04:09 +0000705 $class = $THIS_CLASS
706 unless $class;
707 my $extra = '';
708 $extra = " ($class_name attribute)"
709 if (!($class eq ''));
Fred Drakeccc62721999-01-05 22:16:29 +0000710 my $idx = make_str_index_entry("<tt>$member</tt>$extra");
Fred Drake5ccf3301998-04-17 20:04:09 +0000711 $idx =~ s/ \(.*\)//;
712 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000713 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000714}
715
Fred Drake42b31a51998-03-27 05:16:10 +0000716sub do_env_memberdescni{
717 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000718 next_optional_argument();
719 my $member = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000720 return "<dl><dt><b>$member</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000721}
722
723
Fred Drake5ccf3301998-04-17 20:04:09 +0000724sub do_cmd_memberlineni{
725 local($_) = @_;
726 next_optional_argument();
727 my $member = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000728 return "<dt><b>$member</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000729}
730
Fred Drakea0f4c941998-07-24 22:16:04 +0000731@col_aligns = ("<td>", "<td>", "<td>", "<td>");
Fred Drake6659c301998-03-03 22:02:19 +0000732
Fred Drake15799ed1999-02-12 19:23:17 +0000733$TABLE_HEADER_BGCOLOR = $NAV_BGCOLOR;
734
Fred Drake6659c301998-03-03 22:02:19 +0000735sub setup_column_alignments{
736 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000737 my($a1,$a2,$a3,$a4) = split(/[|]/,$_);
738 my($th1,$th2,$th3,$th4) = ('<th>', '<th>', '<th>', '<th>');
Fred Drake08932051998-04-17 02:15:42 +0000739 $col_aligns[0] = (($a1 eq 'c') ? '<td align=center>' : '<td>');
740 $col_aligns[1] = (($a2 eq 'c') ? '<td align=center>' : '<td>');
741 $col_aligns[2] = (($a3 eq 'c') ? '<td align=center>' : '<td>');
Fred Drakea0f4c941998-07-24 22:16:04 +0000742 $col_aligns[3] = (($a4 eq 'c') ? '<td align=center>' : '<td>');
Fred Drake6659c301998-03-03 22:02:19 +0000743 # return the aligned header start tags; only used for \begin{tableiii?}
Fred Drake08932051998-04-17 02:15:42 +0000744 $th1 = (($a1 eq 'l') ? '<th align=left>'
745 : ($a1 eq 'r' ? '<th align=right>' : '<th>'));
746 $th2 = (($a2 eq 'l') ? '<th align=left>'
747 : ($a2 eq 'r' ? '<th align=right>' : '<th>'));
748 $th3 = (($a3 eq 'l') ? '<th align=left>'
749 : ($a3 eq 'r' ? '<th align=right>' : '<th>'));
Fred Drakea0f4c941998-07-24 22:16:04 +0000750 $th4 = (($a4 eq 'l') ? '<th align=left>'
751 : ($a4 eq 'r' ? '<th align=right>' : '<th>'));
Fred Drake62e43691998-08-10 19:40:44 +0000752 return ($th1, $th2, $th3, $th4);
Fred Drake6659c301998-03-03 22:02:19 +0000753}
754
755sub do_env_tableii{
756 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000757 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000758 my $font = next_argument();
759 my $h1 = next_argument();
760 my $h2 = next_argument();
761 $font = ''
762 if ($font eq 'textrm');
763 $globals{'lineifont'} = $font;
Fred Drake62e43691998-08-10 19:40:44 +0000764 return '<table border align=center>'
Fred Drake15799ed1999-02-12 19:23:17 +0000765 . "\n <tr$TABLE_HEADER_BGCOLOR>"
766 . "\n $th1<b>$h1</b></th>"
767 . "\n $th2<b>$h2</b></th>"
Fred Drake62e43691998-08-10 19:40:44 +0000768 . $_
769 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000770}
771
772sub do_cmd_lineii{
773 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000774 my $c1 = next_argument();
775 my $c2 = next_argument();
776 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
Fred Drake58b2bfd1998-04-02 20:14:04 +0000777 if ($font) {
Fred Drake5cca42e1998-04-09 17:59:11 +0000778 $sfont = "<$font>";
Fred Drake58b2bfd1998-04-02 20:14:04 +0000779 $efont = "</$font>";
780 }
Fred Drakec9a44381998-03-17 06:29:13 +0000781 my($c1align,$c2align) = @col_aligns[0,1];
Fred Drake62e43691998-08-10 19:40:44 +0000782 return "<tr>$c1align$sfont$c1$efont</td>\n"
Fred Drake15799ed1999-02-12 19:23:17 +0000783 . " $c2align$c2\&nbsp;</td>"
Fred Drake62e43691998-08-10 19:40:44 +0000784 . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000785}
786
787sub do_env_tableiii{
788 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000789 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000790 my $font = next_argument();
791 my $h1 = next_argument();
792 my $h2 = next_argument();
793 my $h3 = next_argument();
794 $font = ''
795 if ($font eq 'textrm');
796 $globals{'lineifont'} = $font;
Fred Drake62e43691998-08-10 19:40:44 +0000797 return '<table border align=center>'
Fred Drake15799ed1999-02-12 19:23:17 +0000798 . "\n <tr$TABLE_HEADER_BGCOLOR>"
799 . "\n $th1<b>$h1</b></th>"
800 . "\n $th2<b>$h2</b></th>"
801 . "\n $th3<b>$h3</b></th>"
Fred Drake62e43691998-08-10 19:40:44 +0000802 . $_
803 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000804}
805
806sub do_cmd_lineiii{
807 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000808 my $c1 = next_argument();
809 my $c2 = next_argument();
810 my $c3 = next_argument();
811 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
Fred Drake58b2bfd1998-04-02 20:14:04 +0000812 if ($font) {
Fred Drake5cca42e1998-04-09 17:59:11 +0000813 $sfont = "<$font>";
Fred Drake58b2bfd1998-04-02 20:14:04 +0000814 $efont = "</$font>";
815 }
Fred Drakea0f4c941998-07-24 22:16:04 +0000816 my($c1align,$c2align,$c3align) = @col_aligns[0,1,2];
Fred Drake62e43691998-08-10 19:40:44 +0000817 return "<tr>$c1align$sfont$c1$efont</td>\n"
818 . " $c2align$c2</td>\n"
Fred Drake15799ed1999-02-12 19:23:17 +0000819 . " $c3align$c3\&nbsp;</td>"
Fred Drake62e43691998-08-10 19:40:44 +0000820 . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000821}
822
Fred Drakea0f4c941998-07-24 22:16:04 +0000823sub do_env_tableiv{
824 local($_) = @_;
825 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
826 my $font = next_argument();
827 my $h1 = next_argument();
828 my $h2 = next_argument();
829 my $h3 = next_argument();
830 my $h4 = next_argument();
831 $font = ''
832 if ($font eq 'textrm');
833 $globals{'lineifont'} = $font;
Fred Drake62e43691998-08-10 19:40:44 +0000834 return '<table border align=center>'
Fred Drake15799ed1999-02-12 19:23:17 +0000835 . "\n <tr$TABLE_HEADER_BGCOLOR>"
836 . "\n $th1<b>$h1</b></th>"
837 . "\n $th2<b>$h2</b></th>"
838 . "\n $th3<b>$h3</b></th>"
839 . "\n $th4<b>$h4</b></th>"
Fred Drake62e43691998-08-10 19:40:44 +0000840 . $_
841 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000842}
843
Fred Drakea0f4c941998-07-24 22:16:04 +0000844sub do_cmd_lineiv{
Fred Drake6659c301998-03-03 22:02:19 +0000845 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000846 my $c1 = next_argument();
847 my $c2 = next_argument();
848 my $c3 = next_argument();
849 my $c4 = next_argument();
850 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
851 if ($font) {
852 $sfont = "<$font>";
853 $efont = "</$font>";
854 }
855 my($c1align,$c2align,$c3align,$c4align) = @col_aligns;
Fred Drake62e43691998-08-10 19:40:44 +0000856 return "<tr>$c1align$sfont$c1$efont</td>\n"
857 . " $c2align$c2</td>\n"
858 . " $c3align$c3</td>\n"
Fred Drake15799ed1999-02-12 19:23:17 +0000859 . " $c4align$c4\&nbsp;</td>"
Fred Drake62e43691998-08-10 19:40:44 +0000860 . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000861}
862
Fred Drake6659c301998-03-03 22:02:19 +0000863sub do_cmd_maketitle {
864 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000865 my $the_title = '';
Fred Drake6659c301998-03-03 22:02:19 +0000866 if ($t_title) {
Fred Drakec9a44381998-03-17 06:29:13 +0000867 $the_title .= "<h1 align=center>$t_title</h1>";
Fred Drake08932051998-04-17 02:15:42 +0000868 } else { write_warnings("\nThis document has no title."); }
Fred Drakec9a44381998-03-17 06:29:13 +0000869 $the_title .= "\n<center>";
Fred Drake6659c301998-03-03 22:02:19 +0000870 if ($t_author) {
871 if ($t_authorURL) {
Fred Drake08932051998-04-17 02:15:42 +0000872 my $href = translate_commands($t_authorURL);
Fred Drake2d1f81e1999-02-09 16:03:31 +0000873 $href = make_named_href('author', $href,
874 "<b><font size='+2'>$t_author</font></b>");
Fred Drakec9a44381998-03-17 06:29:13 +0000875 $the_title .= "\n<p>$href</p>";
Fred Drake6659c301998-03-03 22:02:19 +0000876 } else {
Fred Drake2d1f81e1999-02-09 16:03:31 +0000877 $the_title .= ("\n<p><b><font size='+2'>$t_author</font></b></p>");
Fred Drake6659c301998-03-03 22:02:19 +0000878 }
Fred Drake08932051998-04-17 02:15:42 +0000879 } else { write_warnings("\nThere is no author for this document."); }
Fred Drake6659c301998-03-03 22:02:19 +0000880 if ($t_institute) {
Fred Drakec9a44381998-03-17 06:29:13 +0000881 $the_title .= "\n<p>$t_institute</p>";}
Fred Draked07868a1998-05-14 21:00:28 +0000882 if ($DEVELOPER_ADDRESS) {
883 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";}
Fred Drake6659c301998-03-03 22:02:19 +0000884 if ($t_affil) {
Fred Drakec9a44381998-03-17 06:29:13 +0000885 $the_title .= "\n<p><i>$t_affil</i></p>";}
Fred Drake6659c301998-03-03 22:02:19 +0000886 if ($t_date) {
Fred Drakec9a44381998-03-17 06:29:13 +0000887 $the_title .= "\n<p><strong>$t_date</strong>";
Fred Drake6659c301998-03-03 22:02:19 +0000888 if ($PYTHON_VERSION) {
889 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";}
890 $the_title .= "</p>"
891 }
Fred Drakec9a44381998-03-17 06:29:13 +0000892 $the_title .= "\n</center>";
Fred Drake6659c301998-03-03 22:02:19 +0000893 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +0000894 $the_title .= "\n<p>$t_address</p>";
895 } else { $the_title .= "\n<p>"}
Fred Drake6659c301998-03-03 22:02:19 +0000896 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +0000897 $the_title .= "\n<p>$t_email</p>";
898 }# else { $the_title .= "</p>" }
Fred Drake62e43691998-08-10 19:40:44 +0000899 return $the_title . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +0000900}
901
902
Fred Drake885215c1998-05-20 21:32:09 +0000903#
Fred Drakea0f4c941998-07-24 22:16:04 +0000904# Module synopsis support
905#
906
907require SynopsisTable;
908
Fred Drakef7685d71998-07-25 03:31:46 +0000909sub get_chapter_id(){
910 my $id = do_cmd_thechapter('');
Fred Drake45f26011998-08-04 22:07:18 +0000911 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
912 $id =~ s/\.//;
Fred Drakef7685d71998-07-25 03:31:46 +0000913 return $id;
Fred Drakea0f4c941998-07-24 22:16:04 +0000914}
915
Fred Drakef7685d71998-07-25 03:31:46 +0000916%ModuleSynopses = ('chapter' => 'SynopsisTable instance');
917
918sub get_synopsis_table($){
919 my($chap) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000920 my $st = $ModuleSynopses{$chap};
Fred Drakef7685d71998-07-25 03:31:46 +0000921 my $key;
922 foreach $key (keys %ModuleSynopses) {
923 if ($key eq $chap) {
924 return $ModuleSynopses{$chap};
925 }
Fred Drakea0f4c941998-07-24 22:16:04 +0000926 }
Fred Drakef7685d71998-07-25 03:31:46 +0000927 $st = SynopsisTable->new();
928 $ModuleSynopses{$chap} = $st;
Fred Drakea0f4c941998-07-24 22:16:04 +0000929 return $st;
930}
931
Fred Drake62e43691998-08-10 19:40:44 +0000932sub do_cmd_moduleauthor{
933 local($_) = @_;
934 next_argument();
935 next_argument();
936 return $_;
937}
938
939sub do_cmd_sectionauthor{
940 local($_) = @_;
941 next_argument();
942 next_argument();
943 return $_;
944}
945
Fred Drakea0f4c941998-07-24 22:16:04 +0000946sub do_cmd_declaremodule{
947 local($_) = @_;
948 my $key = next_optional_argument();
949 my $type = next_argument();
950 my $name = next_argument();
951 my $st = get_synopsis_table(get_chapter_id());
952 #
953 $key = $name unless $key;
954 $type = 'built-in' if $type eq 'builtin';
955 $st->declare($name, $key, $type);
956 define_module($type, $name);
Fred Drake62e43691998-08-10 19:40:44 +0000957 return anchor_label("module-$key",$CURRENT_FILE,$_)
Fred Drakea0f4c941998-07-24 22:16:04 +0000958}
959
960sub do_cmd_modulesynopsis{
961 local($_) = @_;
962 my $st = get_synopsis_table(get_chapter_id());
963 $st->set_synopsis($THIS_MODULE, next_argument());
964 swallow_newline();
Fred Drake62e43691998-08-10 19:40:44 +0000965 return $_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000966}
967
968sub do_cmd_localmoduletable{
969 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000970 my $chap = get_chapter_id();
Fred Drake62e43691998-08-10 19:40:44 +0000971 return "<tex2htmllocalmoduletable><$chap>\\tableofchildlinks[off]" . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000972}
973
974sub process_all_localmoduletables{
975 while (/<tex2htmllocalmoduletable><(\d+)>/) {
Fred Drakef7685d71998-07-25 03:31:46 +0000976 my $match = $&;
Fred Drakea0f4c941998-07-24 22:16:04 +0000977 my $chap = $1;
978 my $st = get_synopsis_table($chap);
979 my $data = $st->tohtml();
Fred Drakef7685d71998-07-25 03:31:46 +0000980 s/$match/$data/;
Fred Drakea0f4c941998-07-24 22:16:04 +0000981 }
982}
983
984
985#
986# "See also:" -- references placed at the end of a \section
987#
988
989sub do_env_seealso{
Fred Drake62e43691998-08-10 19:40:44 +0000990 return "<p><b>See Also:</b></p>\n" . @_[0];
Fred Drakea0f4c941998-07-24 22:16:04 +0000991}
992
993sub do_cmd_seemodule{
994 # Insert the right magic to jump to the module definition. This should
995 # work most of the time, at least for repeat builds....
996 local($_) = @_;
997 my $key = next_optional_argument();
998 my $module = next_argument();
999 my $text = next_argument();
1000 $key = $module
1001 unless $key;
Fred Drake62e43691998-08-10 19:40:44 +00001002 return "<p>Module <tt><b><a href=\"module-$key.html\">$module</a></b></tt>"
1003 . "&nbsp;&nbsp;&nbsp;($text)</p>"
1004 . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001005}
1006
1007sub do_cmd_seetext{
Fred Drake62e43691998-08-10 19:40:44 +00001008 return '<p>' . @_[0];
Fred Drakea0f4c941998-07-24 22:16:04 +00001009}
1010
1011
1012#
Fred Drake885215c1998-05-20 21:32:09 +00001013# Definition list support.
1014#
1015
1016sub do_env_definitions{
1017 local($_) = @_;
1018 swallow_newline();
Fred Drake62e43691998-08-10 19:40:44 +00001019 return "<dl>$_</dl>\n";
Fred Drake885215c1998-05-20 21:32:09 +00001020}
1021
1022sub do_cmd_term{
1023 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001024 my $term = next_argument();
1025 my($name,$aname,$ahref) = new_link_info();
Fred Drake885215c1998-05-20 21:32:09 +00001026 swallow_newline();
1027 # could easily add an index entry here...
Fred Drake62e43691998-08-10 19:40:44 +00001028 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
Fred Drake885215c1998-05-20 21:32:09 +00001029}
1030
1031
Fred Drake2ff880e1999-02-05 18:31:29 +00001032process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_);
1033code # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001034declaremodule # [] # {} # {}
1035memberline # [] # {}
1036methodline # [] # {} # {}
1037modulesynopsis # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001038samp # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001039setindexsubitem # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001040_RAW_ARG_DEFERRED_CMDS_
1041
1042
Fred Drake6659c301998-03-03 22:02:19 +000010431; # This must be the last line