blob: 26fc3ce1d5eb8dc051c7a36f133070a2bede8ead [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
Fred Drakee16f6791998-05-15 04:28:37 +000026
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.
Fred Drake5b73cdf1998-05-15 16:59:38 +000029# Many possible uses of \let aren't supported or aren't supported correctly.
Fred Drakee16f6791998-05-15 04:28:37 +000030#
31sub do_cmd_let{
32 local($_) = @_;
33 my $matched = 0;
Fred Drake7a4ad0f1998-05-15 13:45:54 +000034 s/[\\]([a-zA-Z]+)\s*(=\s*)?[\\]([a-zA-Z]*)/$matched=1; ''/e;
Fred Drakee16f6791998-05-15 04:28:37 +000035 if ($matched) {
36 my($new, $old) = ($1, $3);
37 eval "sub do_cmd_$new { do_cmd_$old" . '(@_); }';
38 print "\ndefining handler for \\$new using \\$old\n";
39 }
Fred Drake7a4ad0f1998-05-15 13:45:54 +000040 else {
41 s/[\\]([a-zA-Z]+)\s*(=\s*)?([^\\])/$matched=1; ''/es;
42 if ($matched) {
43 my($new, $char) = ($1, $3);
44 eval "sub do_cmd_$new { \"\\$char\" . \@_[0]; }";
45 print "\ndefining handler for \\$new to insert '$char'\n";
46 }
47 else {
48 write_warnings("Could not interpret \\let construct...");
49 }
50 }
Fred Drake62e43691998-08-10 19:40:44 +000051 return $_;
Fred Drakee16f6791998-05-15 04:28:37 +000052}
53
54
Fred Drake6659c301998-03-03 22:02:19 +000055# words typeset in a special way (not in HTML though)
56
57sub do_cmd_ABC{ 'ABC' . @_[0]; }
58sub do_cmd_UNIX{ 'Unix'. @_[0]; }
59sub do_cmd_ASCII{ 'ASCII' . @_[0]; }
60sub do_cmd_POSIX{ 'POSIX' . @_[0]; }
61sub do_cmd_C{ 'C' . @_[0]; }
62sub do_cmd_Cpp{ 'C++' . @_[0]; }
63sub do_cmd_EOF{ 'EOF' . @_[0]; }
64sub do_cmd_NULL{ '<tt>NULL</tt>' . @_[0]; }
65
66sub do_cmd_e{ '&#92;' . @_[0]; }
67
Fred Draked07868a1998-05-14 21:00:28 +000068$DEVELOPER_ADDRESS = '';
Fred Drake6659c301998-03-03 22:02:19 +000069$PYTHON_VERSION = '';
70
71sub do_cmd_version{ $PYTHON_VERSION . @_[0]; }
72sub do_cmd_release{
73 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +000074 $PYTHON_VERSION = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000075 return $_;
Fred Drake6659c301998-03-03 22:02:19 +000076}
77
78sub do_cmd_authoraddress{
79 local($_) = @_;
Fred Draked07868a1998-05-14 21:00:28 +000080 $DEVELOPER_ADDRESS = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000081 return $_;
Fred Drake6659c301998-03-03 22:02:19 +000082}
83
Fred Drakee16f6791998-05-15 04:28:37 +000084#sub do_cmd_developer{ do_cmd_author(@_[0]); }
85#sub do_cmd_developers{ do_cmd_author(@_[0]); }
86#sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); }
Fred Draked07868a1998-05-14 21:00:28 +000087
Fred Drake6659c301998-03-03 22:02:19 +000088sub do_cmd_hackscore{
89 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +000090 next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000091 return '_' . $_;
Fred Drake6659c301998-03-03 22:02:19 +000092}
93
Fred Drake08932051998-04-17 02:15:42 +000094sub use_wrappers{
95 local($_,$before,$after) = @_;
96 my $stuff = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000097 return $before . $stuff . $after . $_;
Fred Drake08932051998-04-17 02:15:42 +000098}
99
Fred Drake62e43691998-08-10 19:40:44 +0000100sub use_sans_serif{
Fred Drakeccc62721999-01-05 22:16:29 +0000101 return use_wrappers(@_[0], '<font face="sans-serif">', '</font>');
Fred Drake62e43691998-08-10 19:40:44 +0000102}
103sub use_italics{
104 return use_wrappers(@_[0], '<i>', '</i>');
105}
Fred Drake08932051998-04-17 02:15:42 +0000106
Fred Drake6659c301998-03-03 22:02:19 +0000107sub do_cmd_optional{
Fred Drake62e43691998-08-10 19:40:44 +0000108 return use_wrappers(@_[0], "</var><big>\[</big><var>",
109 "</var><big>\]</big><var>");
Fred Drake6659c301998-03-03 22:02:19 +0000110}
111
Fred Drakec9a44381998-03-17 06:29:13 +0000112# Logical formatting (some based on texinfo), needs to be converted to
113# minimalist HTML. The "minimalist" is primarily to reduce the size of
114# output files for users that read them over the network rather than
115# from local repositories.
Fred Drake6659c301998-03-03 22:02:19 +0000116
Fred Drake2ff880e1999-02-05 18:31:29 +0000117sub do_cmd_pytype{ return @_[0]; }
118sub do_cmd_makevar{ return @_[0]; }
Fred Drake90fdda51999-02-16 20:27:42 +0000119sub do_cmd_code{
120 return use_wrappers(@_[0], '<tt>', '</tt>'); }
121sub do_cmd_module{
122 return use_wrappers(@_[0], '<tt class=module>', '</tt>'); }
123sub do_cmd_keyword{
124 return use_wrappers(@_[0], '<tt class=keyword>', '</tt>'); }
125sub do_cmd_exception{
126 return use_wrappers(@_[0], '<tt class=exception>', '</tt>'); }
127sub do_cmd_class{
128 return use_wrappers(@_[0], '<tt class=class>', '</tt>'); }
129sub do_cmd_function{
130 return use_wrappers(@_[0], '<tt class=function>', '</tt>'); }
131sub do_cmd_constant{
132 return use_wrappers(@_[0], '<tt class=constant>', '</tt>'); }
133sub do_cmd_member{
134 return use_wrappers(@_[0], '<tt class=member>', '</tt>'); }
135sub do_cmd_method{
136 return use_wrappers(@_[0], '<tt class=method>', '</tt>'); }
137sub do_cmd_cfunction{
138 return use_wrappers(@_[0], '<tt class=cfunction>', '</tt>'); }
139sub do_cmd_cdata{
140 return use_wrappers(@_[0], '<tt class=cdata>', '</tt>'); }
141sub do_cmd_ctype{
142 return use_wrappers(@_[0], '<tt class=ctype>', '</tt>'); }
143sub do_cmd_regexp{
144 return use_wrappers(@_[0], '<tt class=regexp>', '</tt>'); }
145sub do_cmd_character{
146 return use_wrappers(@_[0], '"<tt class=character>', '</tt>"'); }
147sub do_cmd_program{
148 return use_wrappers(@_[0], '<b class=program>', '</b>'); }
149sub do_cmd_email{
150 return use_wrappers(@_[0], '<span class=email>', '</span>'); }
151sub do_cmd_mimetype{
152 return use_wrappers(@_[0], '<span class=mimetype>', '</span>'); }
153sub do_cmd_var{
154 return use_wrappers(@_[0], "<var>", "</var>"); }
155sub do_cmd_dfn{
156 return use_wrappers(@_[0], '<i class=dfn>', '</i>'); }
157sub do_cmd_emph{
158 return use_italics(@_); }
159sub do_cmd_file{
160 return use_wrappers(@_[0], '"<tt class=file>', '</tt>"'); }
161sub do_cmd_samp{
162 return use_wrappers(@_[0], '"<tt class=samp>', '</tt>"'); }
163sub do_cmd_kbd{
164 return use_wrappers(@_[0], '<kbd>', '</kbd>'); }
165sub do_cmd_strong{
166 return use_wrappers(@_[0], '<b>', '</b>'); }
Fred Drakec9a44381998-03-17 06:29:13 +0000167
Fred Drake25817041999-01-13 17:06:34 +0000168sub do_cmd_refmodule{
169 # Insert the right magic to jump to the module definition.
170 local($_) = @_;
171 my $key = next_optional_argument();
172 my $module = next_argument();
173 $key = $module
174 unless $key;
Fred Drake90fdda51999-02-16 20:27:42 +0000175 return "<tt class=module><a href=\"module-$key.html\">$module</a></tt>" . $_;
Fred Drake25817041999-01-13 17:06:34 +0000176}
177
Fred Drake1a7af391998-04-01 22:44:56 +0000178sub do_cmd_newsgroup{
179 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000180 my $newsgroup = next_argument();
Fred Drake90fdda51999-02-16 20:27:42 +0000181 my $stuff = "<span class=newsgroup><a href=\"news:$newsgroup\">"
182 . "$newsgroup</a></span>";
Fred Drake62e43691998-08-10 19:40:44 +0000183 return $stuff . $_;
Fred Drake1a7af391998-04-01 22:44:56 +0000184}
Fred Drakefc16e781998-03-12 21:03:26 +0000185
186sub do_cmd_envvar{
187 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000188 my $envvar = next_argument();
189 my($name,$aname,$ahref) = new_link_info();
Fred Drake166abba1998-04-08 23:10:54 +0000190 # The <tt> here is really to keep buildindex.py from making
191 # the variable name case-insensitive.
192 add_index_entry("environment variables!$envvar@<tt>\$$envvar</tt>",
193 $ahref);
Fred Drake42b31a51998-03-27 05:16:10 +0000194 add_index_entry("$envvar@\$$envvar", $ahref);
Fred Drake90fdda51999-02-16 20:27:42 +0000195 return "<span class=envvar>$aname\$$envvar</a></span>" . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000196}
197
Fred Drake08932051998-04-17 02:15:42 +0000198
Fred Drake6659c301998-03-03 22:02:19 +0000199sub do_cmd_url{
200 # use the URL as both text and hyperlink
201 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000202 my $url = next_argument();
Fred Drake6659c301998-03-03 22:02:19 +0000203 $url =~ s/~/&#126;/g;
Fred Drake90fdda51999-02-16 20:27:42 +0000204 return "<span class=url><a href=\"$url\">$url</a></span>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000205}
206
207sub do_cmd_manpage{
208 # two parameters: \manpage{name}{section}
209 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000210 my $page = next_argument();
211 my $section = next_argument();
Fred Drake90fdda51999-02-16 20:27:42 +0000212 return "<span class=manpage><i>$page</i>($section)</span>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000213}
214
215sub do_cmd_rfc{
216 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000217 my $rfcnumber = next_argument();
218 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drake2eff3c51998-12-22 18:02:25 +0000219 my $href =
220 "http://info.internet.isi.edu/in-notes/rfc/files/rfc$rfcnumber.txt";
Fred Drake6659c301998-03-03 22:02:19 +0000221 # Save the reference
Fred Drake08932051998-04-17 02:15:42 +0000222 my $nstr = gen_index_id("RFC!RFC $rfcnumber", '');
Fred Drakeccc62721999-01-05 22:16:29 +0000223 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
Fred Drake90fdda51999-02-16 20:27:42 +0000224 return ("<span class=rfc><a name=\"$id\"\nhref=\"$href\">"
225 . "RFC $rfcnumber</a></span>" .$_);
Fred Drake6659c301998-03-03 22:02:19 +0000226}
227
Fred Drake6659c301998-03-03 22:02:19 +0000228sub do_cmd_deprecated{
229 # two parameters: \deprecated{version}{whattodo}
230 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000231 my $release = next_argument();
232 my $reason = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000233 return "<b>Deprecated since release $release.</b>\n$reason<p>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000234}
235
Fred Drake897d12b1998-07-27 20:33:17 +0000236sub do_cmd_versionadded{
237 # one parameter: \versionadded{version}
238 local($_) = @_;
239 my $release = next_argument();
Fred Drake2116d981999-02-02 18:02:48 +0000240 return "\nNew in version $release.\n" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000241}
242
243sub do_cmd_versionchanged{
244 # one parameter: \versionchanged{version}
245 local($_) = @_;
246 my $release = next_argument();
Fred Drake2116d981999-02-02 18:02:48 +0000247 return "\nChanged in version $release.\n" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000248}
249
Fred Drake557460c1999-03-02 16:05:35 +0000250#
251# These function handle platform dependency tracking. The first two implement
252# the \platform and \platformof macros, and the third is called at the end of
253# processing to fill in references to the platform of a module.
254#
255sub do_cmd_platform{
256 local($_) = @_;
257 my $platform = next_argument();
258 $ModulePlatforms{$THIS_MODULE} = $platform;
259 $platform = "Macintosh"
260 if $platform eq "Mac";
261 return "\n<p class=availability>Availability: <span"
262 . "\n class=platform>$platform</span>.</p>\n" . $_;
263}
264
265sub do_cmd_platformof{
266 local($_) = @_;
267 next_optional_argument();
268 my $module = next_argument();
269 return "<tex2html-platformof><$module>" . $_;
270}
271
272$IGNORE_PLATFORM_ANNOTATION = '';
273sub do_cmd_ignorePlatformAnnotation{
274 local($_) = @_;
275 $IGNORE_PLATFORM_ANNOTATION = next_argument();
276 return $_;
277}
278
279sub process_all_platformofs{
280 while (/<tex2html-platformof><([^>]+)>/) {
281 my $match = $&;
282 my $module = $1;
283 s/$match/<span\n class=platform>$ModulePlatforms{$module}<\/span>/;
284 }
285}
286
287
Fred Drake6659c301998-03-03 22:02:19 +0000288# file and samp are at the end of this file since they screw up fontlock.
289
290# index commands
291
292$INDEX_SUBITEM = "";
293
294sub get_indexsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000295 return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
Fred Drake6659c301998-03-03 22:02:19 +0000296}
297
298sub do_cmd_setindexsubitem{
299 local($_) = @_;
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000300 $INDEX_SUBITEM = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000301 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000302}
303
Fred Drakefc16e781998-03-12 21:03:26 +0000304sub do_cmd_withsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000305 # We can't really do the right thing, because LaTeX2HTML doesn't
Fred Drakefc16e781998-03-12 21:03:26 +0000306 # do things in the right order, but we need to at least strip this stuff
307 # out, and leave anything that the second argument expanded out to.
308 #
309 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000310 my $oldsubitem = $INDEX_SUBITEM;
311 $INDEX_SUBITEM = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000312 my $stuff = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000313 my $br_id = ++$globals{'max_id'};
314 my $marker = "$O$br_id$C";
Fred Drake7d45f6d1999-01-05 14:39:27 +0000315 return
316 $stuff
Fred Drakeccc62721999-01-05 22:16:29 +0000317 . "\\setindexsubitem$marker$oldsubitem$marker"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000318 . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000319}
320
Fred Drake08932051998-04-17 02:15:42 +0000321# This is the prologue macro which is required to start writing the
322# mod\jobname.idx file; we can just ignore it.
323#
Fred Drake62e43691998-08-10 19:40:44 +0000324sub do_cmd_makemodindex{ return @_[0]; }
Fred Drakefc16e781998-03-12 21:03:26 +0000325
Fred Drake42b31a51998-03-27 05:16:10 +0000326# We're in the document subdirectory when this happens!
Fred Drake166abba1998-04-08 23:10:54 +0000327#
Fred Drake08932051998-04-17 02:15:42 +0000328open(IDXFILE, '>index.dat') || die "\n$!\n";
329open(INTLABELS, '>intlabels.pl') || die "\n$!\n";
Fred Drake166abba1998-04-08 23:10:54 +0000330print INTLABELS "%internal_labels = ();\n";
331print INTLABELS "1; # hack in case there are no entries\n\n";
332
333# Using \0 for this is bad because we can't use common tools to work with the
334# resulting files. Things like grep can be useful with this stuff!
335#
336$IDXFILE_FIELD_SEP = "\1";
337
Fred Drakeccc62721999-01-05 22:16:29 +0000338sub write_idxfile{
339 my ($ahref, $str) = @_;
340 print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n";
Fred Drake42b31a51998-03-27 05:16:10 +0000341}
342
Fred Drake42b31a51998-03-27 05:16:10 +0000343
344sub gen_link{
345 my($node,$target) = @_;
346 print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
Fred Drake62e43691998-08-10 19:40:44 +0000347 return "<a href=\"$node#$target\">";
Fred Drake42b31a51998-03-27 05:16:10 +0000348}
349
350sub make_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000351 my($str) = @_;
352 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000353 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000354 return "$aname$anchor_invisible_mark</a>";
Fred Drake42b31a51998-03-27 05:16:10 +0000355}
356
357sub add_index_entry{
358 # add an entry to the index structures; ignore the return value
359 my($str,$ahref) = @_;
360 $str = gen_index_id($str, '');
361 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000362 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000363}
364
Fred Drakeccc62721999-01-05 22:16:29 +0000365sub new_link_info{
366 my $name = "l2h-" . ++$globals{'max_id'};
367 my $aname = '<a name="' . $name . '">';
Fred Drake42b31a51998-03-27 05:16:10 +0000368 my $ahref = gen_link($CURRENT_FILE, $name);
369 return ($name, $aname, $ahref);
370}
371
372sub do_cmd_index{
373 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000374 my $str = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000375 #
Fred Drakeccc62721999-01-05 22:16:29 +0000376 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000377 add_index_entry("$str", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000378 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake42b31a51998-03-27 05:16:10 +0000379}
380
Fred Drake2e7edb81998-05-11 18:31:17 +0000381sub do_cmd_kwindex{
382 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000383 my $str = next_argument();
Fred Drake2e7edb81998-05-11 18:31:17 +0000384 #
Fred Drakeccc62721999-01-05 22:16:29 +0000385 my($name,$aname,$ahref) = new_link_info();
Fred Drake2e7edb81998-05-11 18:31:17 +0000386 add_index_entry("<tt>$str</tt>!keyword", $ahref);
387 add_index_entry("keyword!<tt>$str</tt>", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000388 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake2e7edb81998-05-11 18:31:17 +0000389}
390
Fred Drake6659c301998-03-03 22:02:19 +0000391sub do_cmd_indexii{
392 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000393 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000394 my $str2 = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000395 #
Fred Drakeccc62721999-01-05 22:16:29 +0000396 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000397 add_index_entry("$str1!$str2", $ahref);
398 add_index_entry("$str2!$str1", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000399 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000400}
401
402sub do_cmd_indexiii{
403 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000404 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000405 my $str2 = next_argument();
406 my $str3 = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000407 #
Fred Drakeccc62721999-01-05 22:16:29 +0000408 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000409 add_index_entry("$str1!$str2 $str3", $ahref);
410 add_index_entry("$str2!$str3, $str1", $ahref);
411 add_index_entry("$str3!$str1 $str2", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000412 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000413}
414
415sub do_cmd_indexiv{
416 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000417 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000418 my $str2 = next_argument();
419 my $str3 = next_argument();
420 my $str4 = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000421 #
Fred Drakeccc62721999-01-05 22:16:29 +0000422 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000423 add_index_entry("$str1!$str2 $str3 $str4", $ahref);
424 add_index_entry("$str2!$str3 $str4, $str1", $ahref);
425 add_index_entry("$str3!$str4, $str1 $str2", $ahref);
426 add_index_entry("$str4!$$str1 $str2 $str3", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000427 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000428}
429
Fred Drakec9a44381998-03-17 06:29:13 +0000430sub do_cmd_ttindex{
431 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000432 my $str = next_argument();
433 my $entry = $str . get_indexsubitem();
Fred Drakeccc62721999-01-05 22:16:29 +0000434 return make_index_entry($entry) . $_;
Fred Drakec9a44381998-03-17 06:29:13 +0000435}
Fred Drake6659c301998-03-03 22:02:19 +0000436
437sub my_typed_index_helper{
Fred Drakec9a44381998-03-17 06:29:13 +0000438 local($word,$_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000439 my $str = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000440 #
Fred Drakeccc62721999-01-05 22:16:29 +0000441 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000442 add_index_entry("$str $word", $ahref);
443 add_index_entry("$word!$str", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000444 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000445}
446
Fred Drake62e43691998-08-10 19:40:44 +0000447sub do_cmd_stindex{ return my_typed_index_helper('statement', @_); }
448sub do_cmd_opindex{ return my_typed_index_helper('operator', @_); }
449sub do_cmd_exindex{ return my_typed_index_helper('exception', @_); }
450sub do_cmd_obindex{ return my_typed_index_helper('object', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000451
452sub my_parword_index_helper{
Fred Drakec9a44381998-03-17 06:29:13 +0000453 local($word,$_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000454 my $str = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000455 return make_index_entry("$str ($word)") . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000456}
457
458
Fred Drake6659c301998-03-03 22:02:19 +0000459sub make_mod_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000460 my($str,$define) = @_;
461 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000462 # equivalent of add_index_entry() using $define instead of ''
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000463 $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/
464 if ($define eq 'DEF');
Fred Drake42b31a51998-03-27 05:16:10 +0000465 $str = gen_index_id($str, $define);
466 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000467 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000468
Fred Drakec9a44381998-03-17 06:29:13 +0000469 if ($define eq 'DEF') {
Fred Drake42b31a51998-03-27 05:16:10 +0000470 # add to the module index
Fred Drakec9a44381998-03-17 06:29:13 +0000471 my($nstr,$garbage) = split / /, $str, 2;
Fred Drake42b31a51998-03-27 05:16:10 +0000472 $Modules{$nstr} .= $ahref;
Fred Drake6659c301998-03-03 22:02:19 +0000473 }
Fred Drake62e43691998-08-10 19:40:44 +0000474 return "$aname$anchor_invisible_mark</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000475}
476
Fred Drake557460c1999-03-02 16:05:35 +0000477
Fred Drakec9a44381998-03-17 06:29:13 +0000478$THIS_MODULE = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000479$THIS_CLASS = '';
Fred Drakec9a44381998-03-17 06:29:13 +0000480
Fred Drakea0f4c941998-07-24 22:16:04 +0000481sub define_module{
482 my($word,$name) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000483 my $section_tag = join('', @curr_sec_id);
Fred Drake6659c301998-03-03 22:02:19 +0000484 $word = "$word " if $word;
Fred Drakea0f4c941998-07-24 22:16:04 +0000485 $THIS_MODULE = "$name";
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000486 $INDEX_SUBITEM = "(in $name)";
487 print "[$name]";
Fred Drakeccc62721999-01-05 22:16:29 +0000488 return make_mod_index_entry("<tt>$name</tt> (${word}module)", 'DEF');
Fred Drakea0f4c941998-07-24 22:16:04 +0000489}
490
491sub my_module_index_helper{
492 local($word, $_) = @_;
493 my $name = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000494 return define_module($word, $name) . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000495}
496
497sub ref_module_index_helper{
498 local($word, $_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000499 my $str = next_argument();
Fred Drake6659c301998-03-03 22:02:19 +0000500 $word = "$word " if $word;
Fred Drakeccc62721999-01-05 22:16:29 +0000501 return make_mod_index_entry("<tt>$str</tt> (${word}module)", 'REF') . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000502}
503
Fred Drakec9a44381998-03-17 06:29:13 +0000504sub do_cmd_bifuncindex{
505 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000506 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000507 my $fname = "<tt>$str()</tt>";
Fred Drakeccc62721999-01-05 22:16:29 +0000508 return make_index_entry("$fname (built-in function)") . $_;
Fred Drakec9a44381998-03-17 06:29:13 +0000509}
510
Fred Drake62e43691998-08-10 19:40:44 +0000511sub do_cmd_modindex{ return my_module_index_helper('', @_); }
512sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); }
513sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); }
514sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000515
516# these should be adjusted a bit....
Fred Drake62e43691998-08-10 19:40:44 +0000517sub do_cmd_refmodindex{ return ref_module_index_helper('', @_); }
518sub do_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); }
519sub do_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); }
520sub do_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000521
Fred Drake62e43691998-08-10 19:40:44 +0000522sub do_cmd_nodename{ return do_cmd_label(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000523
524sub init_myformat{
Fred Drake08932051998-04-17 02:15:42 +0000525# $anchor_invisible_mark = '';
Fred Drake6659c301998-03-03 22:02:19 +0000526 $anchor_mark = '';
527 $icons{'anchor_mark'} = '';
Fred Drake6659c301998-03-03 22:02:19 +0000528}
Fred Drake42b31a51998-03-27 05:16:10 +0000529init_myformat();
Fred Drake6659c301998-03-03 22:02:19 +0000530
531# similar to make_index_entry(), but includes the string in the result
532# instead of the dummy filler.
533#
534sub make_str_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000535 my($str) = @_;
536 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000537 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000538 return "$aname$str</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000539}
540
Fred Drake6659c301998-03-03 22:02:19 +0000541sub do_env_cfuncdesc{
542 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000543 my $return_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000544 my $function_name = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000545 my $arg_list = next_argument();
Fred Drake90fdda51999-02-16 20:27:42 +0000546 my $idx = make_str_index_entry("<tt class=cfunction>$function_name()</tt>"
Fred Drakeccc62721999-01-05 22:16:29 +0000547 . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000548 $idx =~ s/ \(.*\)//;
549 $idx =~ s/\(\)//; # ????
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000550 return "<dl><dt>$return_type <b>$idx</b> (<var>$arg_list</var>)\n<dd>"
Fred Drake62e43691998-08-10 19:40:44 +0000551 . $_
552 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000553}
554
555sub do_env_ctypedesc{
556 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000557 my $type_name = next_argument();
Fred Drake90fdda51999-02-16 20:27:42 +0000558 my $idx = make_str_index_entry("<tt class=ctype>$type_name</tt>"
559 . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000560 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000561 return "<dl><dt><b>$idx</b>\n<dd>"
562 . $_
563 . '</dl>'
Fred Drake6659c301998-03-03 22:02:19 +0000564}
565
566sub do_env_cvardesc{
567 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000568 my $var_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000569 my $var_name = next_argument();
Fred Drake90fdda51999-02-16 20:27:42 +0000570 my $idx = make_str_index_entry("<tt class=cdata>$var_name</tt>"
571 . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000572 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000573 return "<dl><dt>$var_type <b>$idx</b>\n"
574 . '<dd>'
575 . $_
576 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000577}
578
579sub do_env_funcdesc{
580 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000581 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000582 my $arg_list = next_argument();
Fred Drake90fdda51999-02-16 20:27:42 +0000583 my $idx = make_str_index_entry("<tt class=function>$function_name()</tt>"
Fred Drake08932051998-04-17 02:15:42 +0000584 . get_indexsubitem());
585 $idx =~ s/ \(.*\)//;
Fred Drakeccc62721999-01-05 22:16:29 +0000586 $idx =~ s/\(\)<\/tt>/<\/tt>/;
Fred Drake62e43691998-08-10 19:40:44 +0000587 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000588}
589
590sub do_env_funcdescni{
591 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000592 my $function_name = next_argument();
593 my $arg_list = next_argument();
Fred Drake90fdda51999-02-16 20:27:42 +0000594 return "<dl><dt><b><tt class=function>$function_name</tt></b>"
595 . " (<var>$arg_list</var>)\n"
596 . '<dd>'
597 . $_
598 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000599}
600
601sub do_cmd_funcline{
602 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000603 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000604 my $arg_list = next_argument();
Fred Drake90fdda51999-02-16 20:27:42 +0000605 my $idx = make_str_index_entry("<tt class=function>$function_name()</tt>"
Fred Drake08932051998-04-17 02:15:42 +0000606 . get_indexsubitem());
Fred Drakec9a44381998-03-17 06:29:13 +0000607 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000608 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000609}
610
611# Change this flag to index the opcode entries. I don't think it's very
612# useful to index them, since they're only presented to describe the dis
613# module.
614#
615$INDEX_OPCODES = 0;
616
617sub do_env_opcodedesc{
618 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000619 my $opcode_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000620 my $arg_list = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000621 my $idx;
622 if ($INDEX_OPCODES) {
Fred Drakeccc62721999-01-05 22:16:29 +0000623 $idx = make_str_index_entry(
Fred Drake90fdda51999-02-16 20:27:42 +0000624 "<tt class=opcode>$opcode_name</tt> (byte code instruction)");
Fred Drake08932051998-04-17 02:15:42 +0000625 $idx =~ s/ \(byte code instruction\)//;
626 }
627 else {
Fred Drake90fdda51999-02-16 20:27:42 +0000628 $idx = "<tt class=opcode>$opcode_name</tt>";
Fred Drake08932051998-04-17 02:15:42 +0000629 }
630 my $stuff = "<dl><dt><b>$idx</b>";
Fred Drake6659c301998-03-03 22:02:19 +0000631 if ($arg_list) {
632 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
633 }
Fred Drake62e43691998-08-10 19:40:44 +0000634 return $stuff . "\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000635}
636
637sub do_env_datadesc{
638 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000639 my $dataname = next_argument();
640 my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000641 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000642 return "<dl><dt><b>$idx</b>\n<dd>"
643 . $_
644 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000645}
646
647sub do_env_datadescni{
648 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000649 my $idx = next_argument();
650 if (! $STRING_INDEX_TT) {
651 $idx = "<tt>$idx</tt>";
Fred Drake6659c301998-03-03 22:02:19 +0000652 }
Fred Drake62e43691998-08-10 19:40:44 +0000653 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000654}
655
656sub do_cmd_dataline{
657 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000658 my $data_name = next_argument();
659 my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem());
Fred Drake6659c301998-03-03 22:02:19 +0000660 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000661 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000662}
663
Fred Drake42b31a51998-03-27 05:16:10 +0000664sub do_env_excdesc{
665 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000666 my $excname = next_argument();
Fred Drake90fdda51999-02-16 20:27:42 +0000667 my $idx = make_str_index_entry("<tt class=exception>$excname</tt>");
Fred Drake62e43691998-08-10 19:40:44 +0000668 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'
Fred Drake42b31a51998-03-27 05:16:10 +0000669}
670
Fred Drake62e43691998-08-10 19:40:44 +0000671sub do_env_fulllineitems{ return do_env_itemize(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000672
673
Fred Drakec9a44381998-03-17 06:29:13 +0000674sub do_env_classdesc{
675 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000676 $THIS_CLASS = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000677 my $arg_list = next_argument();
678 $idx = make_str_index_entry(
Fred Drake90fdda51999-02-16 20:27:42 +0000679 "<tt class=class>$THIS_CLASS</tt> (class in $THIS_MODULE)" );
Fred Drake08932051998-04-17 02:15:42 +0000680 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000681 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drakec9a44381998-03-17 06:29:13 +0000682}
683
Fred Drake42b31a51998-03-27 05:16:10 +0000684
685sub do_env_methoddesc{
686 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000687 my $class_name = next_optional_argument();
688 $class_name = $THIS_CLASS
689 unless $class_name;
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000690 my $method = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000691 my $arg_list = next_argument();
692 my $extra = '';
693 if ($class_name) {
694 $extra = " ($class_name method)";
Fred Drake42b31a51998-03-27 05:16:10 +0000695 }
Fred Drake90fdda51999-02-16 20:27:42 +0000696 my $idx = make_str_index_entry("<tt class=method>$method()</tt>$extra");
Fred Drake08932051998-04-17 02:15:42 +0000697 $idx =~ s/ \(.*\)//;
698 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000699 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000700}
701
702
Fred Drake7d45f6d1999-01-05 14:39:27 +0000703sub do_cmd_methodline{
704 local($_) = @_;
705 my $class_name = next_optional_argument();
706 $class_name = $THIS_CLASS
707 unless $class_name;
708 my $method = next_argument();
709 my $arg_list = next_argument();
710 my $extra = '';
711 if ($class_name) {
712 $extra = " ($class_name method)";
713 }
Fred Drake90fdda51999-02-16 20:27:42 +0000714 my $idx = make_str_index_entry("<tt class=method>$method()</tt>$extra");
Fred Drake7d45f6d1999-01-05 14:39:27 +0000715 $idx =~ s/ \(.*\)//;
716 $idx =~ s/\(\)//;
717 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>"
718 . $_;
719}
720
721
Fred Draked64a40d1998-09-10 18:59:13 +0000722sub do_cmd_methodlineni{
723 local($_) = @_;
724 next_optional_argument();
725 my $method = next_argument();
726 my $arg_list = next_argument();
727 return "<dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
728 . $_;
729}
730
Fred Drake42b31a51998-03-27 05:16:10 +0000731sub do_env_methoddescni{
732 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000733 next_optional_argument();
734 my $method = next_argument();
735 my $arg_list = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000736 return "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
737 . $_
738 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000739}
740
741
742sub do_env_memberdesc{
743 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000744 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000745 my $member = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000746 $class = $THIS_CLASS
747 unless $class;
Fred Drake08932051998-04-17 02:15:42 +0000748 my $extra = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000749 $extra = " ($class_name attribute)"
Fred Drakea608feb1998-04-12 03:58:13 +0000750 if (!($class eq ''));
Fred Drakeccc62721999-01-05 22:16:29 +0000751 my $idx = make_str_index_entry("<tt>$member</tt>$extra");
Fred Drake42b31a51998-03-27 05:16:10 +0000752 $idx =~ s/ \(.*\)//;
753 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000754 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000755}
756
757
Fred Drake5ccf3301998-04-17 20:04:09 +0000758sub do_cmd_memberline{
759 local($_) = @_;
760 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000761 my $member = next_argument();
Fred Drake5ccf3301998-04-17 20:04:09 +0000762 $class = $THIS_CLASS
763 unless $class;
764 my $extra = '';
765 $extra = " ($class_name attribute)"
766 if (!($class eq ''));
Fred Drake90fdda51999-02-16 20:27:42 +0000767 my $idx = make_str_index_entry("<tt class=member>$member</tt>$extra");
Fred Drake5ccf3301998-04-17 20:04:09 +0000768 $idx =~ s/ \(.*\)//;
769 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000770 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000771}
772
Fred Drake42b31a51998-03-27 05:16:10 +0000773sub do_env_memberdescni{
774 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000775 next_optional_argument();
776 my $member = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000777 return "<dl><dt><b>$member</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000778}
779
780
Fred Drake5ccf3301998-04-17 20:04:09 +0000781sub do_cmd_memberlineni{
782 local($_) = @_;
783 next_optional_argument();
784 my $member = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000785 return "<dt><b>$member</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000786}
787
Fred Drakea0f4c941998-07-24 22:16:04 +0000788@col_aligns = ("<td>", "<td>", "<td>", "<td>");
Fred Drake6659c301998-03-03 22:02:19 +0000789
Fred Drake15799ed1999-02-12 19:23:17 +0000790$TABLE_HEADER_BGCOLOR = $NAV_BGCOLOR;
791
Fred Drake6659c301998-03-03 22:02:19 +0000792sub setup_column_alignments{
793 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000794 my($a1,$a2,$a3,$a4) = split(/[|]/,$_);
795 my($th1,$th2,$th3,$th4) = ('<th>', '<th>', '<th>', '<th>');
Fred Drake08932051998-04-17 02:15:42 +0000796 $col_aligns[0] = (($a1 eq 'c') ? '<td align=center>' : '<td>');
797 $col_aligns[1] = (($a2 eq 'c') ? '<td align=center>' : '<td>');
798 $col_aligns[2] = (($a3 eq 'c') ? '<td align=center>' : '<td>');
Fred Drakea0f4c941998-07-24 22:16:04 +0000799 $col_aligns[3] = (($a4 eq 'c') ? '<td align=center>' : '<td>');
Fred Drake6659c301998-03-03 22:02:19 +0000800 # return the aligned header start tags; only used for \begin{tableiii?}
Fred Drake08932051998-04-17 02:15:42 +0000801 $th1 = (($a1 eq 'l') ? '<th align=left>'
802 : ($a1 eq 'r' ? '<th align=right>' : '<th>'));
803 $th2 = (($a2 eq 'l') ? '<th align=left>'
804 : ($a2 eq 'r' ? '<th align=right>' : '<th>'));
805 $th3 = (($a3 eq 'l') ? '<th align=left>'
806 : ($a3 eq 'r' ? '<th align=right>' : '<th>'));
Fred Drakea0f4c941998-07-24 22:16:04 +0000807 $th4 = (($a4 eq 'l') ? '<th align=left>'
808 : ($a4 eq 'r' ? '<th align=right>' : '<th>'));
Fred Drake62e43691998-08-10 19:40:44 +0000809 return ($th1, $th2, $th3, $th4);
Fred Drake6659c301998-03-03 22:02:19 +0000810}
811
812sub do_env_tableii{
813 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000814 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000815 my $font = next_argument();
816 my $h1 = next_argument();
817 my $h2 = next_argument();
818 $font = ''
819 if ($font eq 'textrm');
820 $globals{'lineifont'} = $font;
Fred Drake62e43691998-08-10 19:40:44 +0000821 return '<table border align=center>'
Fred Drake15799ed1999-02-12 19:23:17 +0000822 . "\n <tr$TABLE_HEADER_BGCOLOR>"
823 . "\n $th1<b>$h1</b></th>"
824 . "\n $th2<b>$h2</b></th>"
Fred Drake62e43691998-08-10 19:40:44 +0000825 . $_
826 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000827}
828
829sub do_cmd_lineii{
830 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000831 my $c1 = next_argument();
832 my $c2 = next_argument();
833 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
Fred Drake58b2bfd1998-04-02 20:14:04 +0000834 if ($font) {
Fred Drake5cca42e1998-04-09 17:59:11 +0000835 $sfont = "<$font>";
Fred Drake58b2bfd1998-04-02 20:14:04 +0000836 $efont = "</$font>";
837 }
Fred Drakec9a44381998-03-17 06:29:13 +0000838 my($c1align,$c2align) = @col_aligns[0,1];
Fred Drake62e43691998-08-10 19:40:44 +0000839 return "<tr>$c1align$sfont$c1$efont</td>\n"
Fred Drake15799ed1999-02-12 19:23:17 +0000840 . " $c2align$c2\&nbsp;</td>"
Fred Drake62e43691998-08-10 19:40:44 +0000841 . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000842}
843
844sub do_env_tableiii{
845 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000846 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000847 my $font = next_argument();
848 my $h1 = next_argument();
849 my $h2 = next_argument();
850 my $h3 = next_argument();
851 $font = ''
852 if ($font eq 'textrm');
853 $globals{'lineifont'} = $font;
Fred Drake62e43691998-08-10 19:40:44 +0000854 return '<table border align=center>'
Fred Drake15799ed1999-02-12 19:23:17 +0000855 . "\n <tr$TABLE_HEADER_BGCOLOR>"
856 . "\n $th1<b>$h1</b></th>"
857 . "\n $th2<b>$h2</b></th>"
858 . "\n $th3<b>$h3</b></th>"
Fred Drake62e43691998-08-10 19:40:44 +0000859 . $_
860 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000861}
862
863sub do_cmd_lineiii{
864 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000865 my $c1 = next_argument();
866 my $c2 = next_argument();
867 my $c3 = next_argument();
868 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
Fred Drake58b2bfd1998-04-02 20:14:04 +0000869 if ($font) {
Fred Drake5cca42e1998-04-09 17:59:11 +0000870 $sfont = "<$font>";
Fred Drake58b2bfd1998-04-02 20:14:04 +0000871 $efont = "</$font>";
872 }
Fred Drakea0f4c941998-07-24 22:16:04 +0000873 my($c1align,$c2align,$c3align) = @col_aligns[0,1,2];
Fred Drake62e43691998-08-10 19:40:44 +0000874 return "<tr>$c1align$sfont$c1$efont</td>\n"
875 . " $c2align$c2</td>\n"
Fred Drake15799ed1999-02-12 19:23:17 +0000876 . " $c3align$c3\&nbsp;</td>"
Fred Drake62e43691998-08-10 19:40:44 +0000877 . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000878}
879
Fred Drakea0f4c941998-07-24 22:16:04 +0000880sub do_env_tableiv{
881 local($_) = @_;
882 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
883 my $font = next_argument();
884 my $h1 = next_argument();
885 my $h2 = next_argument();
886 my $h3 = next_argument();
887 my $h4 = next_argument();
888 $font = ''
889 if ($font eq 'textrm');
890 $globals{'lineifont'} = $font;
Fred Drake62e43691998-08-10 19:40:44 +0000891 return '<table border align=center>'
Fred Drake15799ed1999-02-12 19:23:17 +0000892 . "\n <tr$TABLE_HEADER_BGCOLOR>"
893 . "\n $th1<b>$h1</b></th>"
894 . "\n $th2<b>$h2</b></th>"
895 . "\n $th3<b>$h3</b></th>"
896 . "\n $th4<b>$h4</b></th>"
Fred Drake62e43691998-08-10 19:40:44 +0000897 . $_
898 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000899}
900
Fred Drakea0f4c941998-07-24 22:16:04 +0000901sub do_cmd_lineiv{
Fred Drake6659c301998-03-03 22:02:19 +0000902 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000903 my $c1 = next_argument();
904 my $c2 = next_argument();
905 my $c3 = next_argument();
906 my $c4 = next_argument();
907 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
908 if ($font) {
909 $sfont = "<$font>";
910 $efont = "</$font>";
911 }
912 my($c1align,$c2align,$c3align,$c4align) = @col_aligns;
Fred Drake62e43691998-08-10 19:40:44 +0000913 return "<tr>$c1align$sfont$c1$efont</td>\n"
914 . " $c2align$c2</td>\n"
915 . " $c3align$c3</td>\n"
Fred Drake15799ed1999-02-12 19:23:17 +0000916 . " $c4align$c4\&nbsp;</td>"
Fred Drake62e43691998-08-10 19:40:44 +0000917 . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000918}
919
Fred Drake6659c301998-03-03 22:02:19 +0000920sub do_cmd_maketitle {
921 local($_) = @_;
Fred Drake90fdda51999-02-16 20:27:42 +0000922 my $the_title = "\n<div class=titlepage><center>";
Fred Drake6659c301998-03-03 22:02:19 +0000923 if ($t_title) {
Fred Drake90fdda51999-02-16 20:27:42 +0000924 $the_title .= "\n<h1>$t_title</h1>";
Fred Drake08932051998-04-17 02:15:42 +0000925 } else { write_warnings("\nThis document has no title."); }
Fred Drake6659c301998-03-03 22:02:19 +0000926 if ($t_author) {
927 if ($t_authorURL) {
Fred Drake08932051998-04-17 02:15:42 +0000928 my $href = translate_commands($t_authorURL);
Fred Drake2d1f81e1999-02-09 16:03:31 +0000929 $href = make_named_href('author', $href,
930 "<b><font size='+2'>$t_author</font></b>");
Fred Drakec9a44381998-03-17 06:29:13 +0000931 $the_title .= "\n<p>$href</p>";
Fred Drake6659c301998-03-03 22:02:19 +0000932 } else {
Fred Drake2d1f81e1999-02-09 16:03:31 +0000933 $the_title .= ("\n<p><b><font size='+2'>$t_author</font></b></p>");
Fred Drake6659c301998-03-03 22:02:19 +0000934 }
Fred Drake08932051998-04-17 02:15:42 +0000935 } else { write_warnings("\nThere is no author for this document."); }
Fred Drake6659c301998-03-03 22:02:19 +0000936 if ($t_institute) {
Fred Drakec9a44381998-03-17 06:29:13 +0000937 $the_title .= "\n<p>$t_institute</p>";}
Fred Draked07868a1998-05-14 21:00:28 +0000938 if ($DEVELOPER_ADDRESS) {
939 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";}
Fred Drake6659c301998-03-03 22:02:19 +0000940 if ($t_affil) {
Fred Drakec9a44381998-03-17 06:29:13 +0000941 $the_title .= "\n<p><i>$t_affil</i></p>";}
Fred Drake6659c301998-03-03 22:02:19 +0000942 if ($t_date) {
Fred Drakec9a44381998-03-17 06:29:13 +0000943 $the_title .= "\n<p><strong>$t_date</strong>";
Fred Drake6659c301998-03-03 22:02:19 +0000944 if ($PYTHON_VERSION) {
945 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";}
946 $the_title .= "</p>"
947 }
948 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +0000949 $the_title .= "\n<p>$t_address</p>";
950 } else { $the_title .= "\n<p>"}
Fred Drake6659c301998-03-03 22:02:19 +0000951 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +0000952 $the_title .= "\n<p>$t_email</p>";
953 }# else { $the_title .= "</p>" }
Fred Drake90fdda51999-02-16 20:27:42 +0000954 $the_title .= "\n</center></div>";
Fred Drake62e43691998-08-10 19:40:44 +0000955 return $the_title . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +0000956}
957
958
Fred Drake885215c1998-05-20 21:32:09 +0000959#
Fred Drakea0f4c941998-07-24 22:16:04 +0000960# Module synopsis support
961#
962
963require SynopsisTable;
964
Fred Drakef7685d71998-07-25 03:31:46 +0000965sub get_chapter_id(){
966 my $id = do_cmd_thechapter('');
Fred Drake45f26011998-08-04 22:07:18 +0000967 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
968 $id =~ s/\.//;
Fred Drakef7685d71998-07-25 03:31:46 +0000969 return $id;
Fred Drakea0f4c941998-07-24 22:16:04 +0000970}
971
Fred Drakef7685d71998-07-25 03:31:46 +0000972%ModuleSynopses = ('chapter' => 'SynopsisTable instance');
973
974sub get_synopsis_table($){
975 my($chap) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000976 my $st = $ModuleSynopses{$chap};
Fred Drakef7685d71998-07-25 03:31:46 +0000977 my $key;
978 foreach $key (keys %ModuleSynopses) {
979 if ($key eq $chap) {
980 return $ModuleSynopses{$chap};
981 }
Fred Drakea0f4c941998-07-24 22:16:04 +0000982 }
Fred Drakef7685d71998-07-25 03:31:46 +0000983 $st = SynopsisTable->new();
984 $ModuleSynopses{$chap} = $st;
Fred Drakea0f4c941998-07-24 22:16:04 +0000985 return $st;
986}
987
Fred Drake62e43691998-08-10 19:40:44 +0000988sub do_cmd_moduleauthor{
989 local($_) = @_;
990 next_argument();
991 next_argument();
992 return $_;
993}
994
995sub do_cmd_sectionauthor{
996 local($_) = @_;
997 next_argument();
998 next_argument();
999 return $_;
1000}
1001
Fred Drakea0f4c941998-07-24 22:16:04 +00001002sub do_cmd_declaremodule{
1003 local($_) = @_;
1004 my $key = next_optional_argument();
1005 my $type = next_argument();
1006 my $name = next_argument();
1007 my $st = get_synopsis_table(get_chapter_id());
1008 #
1009 $key = $name unless $key;
1010 $type = 'built-in' if $type eq 'builtin';
1011 $st->declare($name, $key, $type);
1012 define_module($type, $name);
Fred Drake62e43691998-08-10 19:40:44 +00001013 return anchor_label("module-$key",$CURRENT_FILE,$_)
Fred Drakea0f4c941998-07-24 22:16:04 +00001014}
1015
1016sub do_cmd_modulesynopsis{
1017 local($_) = @_;
1018 my $st = get_synopsis_table(get_chapter_id());
1019 $st->set_synopsis($THIS_MODULE, next_argument());
Fred Drake62e43691998-08-10 19:40:44 +00001020 return $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001021}
1022
1023sub do_cmd_localmoduletable{
1024 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001025 my $chap = get_chapter_id();
Fred Drake557460c1999-03-02 16:05:35 +00001026 return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001027}
1028
1029sub process_all_localmoduletables{
Fred Drake557460c1999-03-02 16:05:35 +00001030 while (/<tex2html-localmoduletable><(\d+)>/) {
Fred Drakef7685d71998-07-25 03:31:46 +00001031 my $match = $&;
Fred Drakea0f4c941998-07-24 22:16:04 +00001032 my $chap = $1;
1033 my $st = get_synopsis_table($chap);
1034 my $data = $st->tohtml();
Fred Drakef7685d71998-07-25 03:31:46 +00001035 s/$match/$data/;
Fred Drakea0f4c941998-07-24 22:16:04 +00001036 }
1037}
Fred Drake557460c1999-03-02 16:05:35 +00001038sub process_python_state{
1039 process_all_localmoduletables();
1040 process_all_platformofs();
1041}
Fred Drakea0f4c941998-07-24 22:16:04 +00001042
1043
1044#
1045# "See also:" -- references placed at the end of a \section
1046#
1047
1048sub do_env_seealso{
Fred Drake90fdda51999-02-16 20:27:42 +00001049 return "<div class=seealso>\n "
1050 . "<p><b>See Also:</b></p>\n"
1051 . @_[0]
1052 . '</div>';
Fred Drakea0f4c941998-07-24 22:16:04 +00001053}
1054
1055sub do_cmd_seemodule{
1056 # Insert the right magic to jump to the module definition. This should
1057 # work most of the time, at least for repeat builds....
1058 local($_) = @_;
1059 my $key = next_optional_argument();
1060 my $module = next_argument();
1061 my $text = next_argument();
1062 $key = $module
1063 unless $key;
Fred Drake90fdda51999-02-16 20:27:42 +00001064 return '<div class=seemodule>'
1065 . "\n<p>Module <b><tt class=module><a href=\"module-$key.html\">"
1066 . "$module</a></tt></b>"
1067 . "&nbsp;&nbsp;&nbsp;($text)</p>\n</div>"
1068 . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001069}
1070
1071sub do_cmd_seetext{
Fred Drake90fdda51999-02-16 20:27:42 +00001072 return '<div class=seetext><p>' . @_[0] . '</div>';
Fred Drakea0f4c941998-07-24 22:16:04 +00001073}
1074
1075
1076#
Fred Drake885215c1998-05-20 21:32:09 +00001077# Definition list support.
1078#
1079
1080sub do_env_definitions{
1081 local($_) = @_;
Fred Drake90fdda51999-02-16 20:27:42 +00001082 return "<dl class=definitions>$_</dl>\n";
Fred Drake885215c1998-05-20 21:32:09 +00001083}
1084
1085sub do_cmd_term{
1086 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001087 my $term = next_argument();
1088 my($name,$aname,$ahref) = new_link_info();
Fred Drake885215c1998-05-20 21:32:09 +00001089 # could easily add an index entry here...
Fred Drake62e43691998-08-10 19:40:44 +00001090 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
Fred Drake885215c1998-05-20 21:32:09 +00001091}
1092
1093
Fred Drake2ff880e1999-02-05 18:31:29 +00001094process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_);
1095code # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001096declaremodule # [] # {} # {}
1097memberline # [] # {}
1098methodline # [] # {} # {}
1099modulesynopsis # {}
Fred Drake557460c1999-03-02 16:05:35 +00001100platform # {}
1101platformof # [] # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001102samp # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001103setindexsubitem # {}
Fred Drakef32834c1999-02-12 22:06:32 +00001104withsubitem # {} # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001105_RAW_ARG_DEFERRED_CMDS_
1106
1107
Fred Drake6659c301998-03-03 22:02:19 +000011081; # This must be the last line