blob: bacc8cc708ab1cfe72eabba1b0ba834dbff03d78 [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 Drakec3fd45f2000-06-15 22:41:48 +000055# the older version of LaTeX2HTML we use doesn't support this, but we use it:
56
57sub do_cmd_textasciitilde{ '~' . @_[0]; }
58
59
Fred Drake6659c301998-03-03 22:02:19 +000060# words typeset in a special way (not in HTML though)
61
62sub do_cmd_ABC{ 'ABC' . @_[0]; }
63sub do_cmd_UNIX{ 'Unix'. @_[0]; }
64sub do_cmd_ASCII{ 'ASCII' . @_[0]; }
65sub do_cmd_POSIX{ 'POSIX' . @_[0]; }
66sub do_cmd_C{ 'C' . @_[0]; }
67sub do_cmd_Cpp{ 'C++' . @_[0]; }
68sub do_cmd_EOF{ 'EOF' . @_[0]; }
Fred Drakee15956b2000-04-03 04:51:13 +000069sub do_cmd_NULL{ '<tt class="constant">NULL</tt>' . @_[0]; }
Fred Drake6659c301998-03-03 22:02:19 +000070
71sub do_cmd_e{ '&#92;' . @_[0]; }
72
Fred Draked07868a1998-05-14 21:00:28 +000073$DEVELOPER_ADDRESS = '';
Fred Drake6659c301998-03-03 22:02:19 +000074$PYTHON_VERSION = '';
75
76sub do_cmd_version{ $PYTHON_VERSION . @_[0]; }
77sub do_cmd_release{
78 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +000079 $PYTHON_VERSION = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000080 return $_;
Fred Drake6659c301998-03-03 22:02:19 +000081}
82
83sub do_cmd_authoraddress{
84 local($_) = @_;
Fred Draked07868a1998-05-14 21:00:28 +000085 $DEVELOPER_ADDRESS = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000086 return $_;
Fred Drake6659c301998-03-03 22:02:19 +000087}
88
Fred Drakee16f6791998-05-15 04:28:37 +000089#sub do_cmd_developer{ do_cmd_author(@_[0]); }
90#sub do_cmd_developers{ do_cmd_author(@_[0]); }
91#sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); }
Fred Draked07868a1998-05-14 21:00:28 +000092
Fred Drake6659c301998-03-03 22:02:19 +000093sub do_cmd_hackscore{
94 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +000095 next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000096 return '_' . $_;
Fred Drake6659c301998-03-03 22:02:19 +000097}
98
Fred Drake08932051998-04-17 02:15:42 +000099sub use_wrappers{
100 local($_,$before,$after) = @_;
101 my $stuff = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000102 return $before . $stuff . $after . $_;
Fred Drake08932051998-04-17 02:15:42 +0000103}
104
Fred Drake62e43691998-08-10 19:40:44 +0000105sub use_sans_serif{
Fred Drakeccc62721999-01-05 22:16:29 +0000106 return use_wrappers(@_[0], '<font face="sans-serif">', '</font>');
Fred Drake62e43691998-08-10 19:40:44 +0000107}
108sub use_italics{
109 return use_wrappers(@_[0], '<i>', '</i>');
110}
Fred Drake08932051998-04-17 02:15:42 +0000111
Fred Drake6659c301998-03-03 22:02:19 +0000112sub do_cmd_optional{
Fred Drake62e43691998-08-10 19:40:44 +0000113 return use_wrappers(@_[0], "</var><big>\[</big><var>",
114 "</var><big>\]</big><var>");
Fred Drake6659c301998-03-03 22:02:19 +0000115}
116
Fred Drakec9a44381998-03-17 06:29:13 +0000117# Logical formatting (some based on texinfo), needs to be converted to
118# minimalist HTML. The "minimalist" is primarily to reduce the size of
119# output files for users that read them over the network rather than
120# from local repositories.
Fred Drake6659c301998-03-03 22:02:19 +0000121
Fred Drake2cafcbb1999-03-25 16:57:04 +0000122# \file and \samp are at the end of this file since they screw up fontlock.
123
Fred Drake2ff880e1999-02-05 18:31:29 +0000124sub do_cmd_pytype{ return @_[0]; }
Fred Drake3d5a04a2000-08-03 17:25:44 +0000125sub do_cmd_makevar{
126 return use_wrappers(@_[0], '<span class="makevar">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000127sub do_cmd_code{
Fred Drakee15956b2000-04-03 04:51:13 +0000128 return use_wrappers(@_[0], '<code>', '</code>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000129sub do_cmd_module{
Fred Drakee15956b2000-04-03 04:51:13 +0000130 return use_wrappers(@_[0], '<tt class="module">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000131sub do_cmd_keyword{
Fred Drakee15956b2000-04-03 04:51:13 +0000132 return use_wrappers(@_[0], '<tt class="keyword">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000133sub do_cmd_exception{
Fred Drakee15956b2000-04-03 04:51:13 +0000134 return use_wrappers(@_[0], '<tt class="exception">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000135sub do_cmd_class{
Fred Drakee15956b2000-04-03 04:51:13 +0000136 return use_wrappers(@_[0], '<tt class="class">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000137sub do_cmd_function{
Fred Drakee15956b2000-04-03 04:51:13 +0000138 return use_wrappers(@_[0], '<tt class="function">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000139sub do_cmd_constant{
Fred Drakee15956b2000-04-03 04:51:13 +0000140 return use_wrappers(@_[0], '<tt class="constant">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000141sub do_cmd_member{
Fred Drakee15956b2000-04-03 04:51:13 +0000142 return use_wrappers(@_[0], '<tt class="member">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000143sub do_cmd_method{
Fred Drakee15956b2000-04-03 04:51:13 +0000144 return use_wrappers(@_[0], '<tt class="method">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000145sub do_cmd_cfunction{
Fred Drakee15956b2000-04-03 04:51:13 +0000146 return use_wrappers(@_[0], '<tt class="cfunction">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000147sub do_cmd_cdata{
Fred Drakee15956b2000-04-03 04:51:13 +0000148 return use_wrappers(@_[0], '<tt class="cdata">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000149sub do_cmd_ctype{
Fred Drakee15956b2000-04-03 04:51:13 +0000150 return use_wrappers(@_[0], '<tt class="ctype">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000151sub do_cmd_regexp{
Fred Drakee15956b2000-04-03 04:51:13 +0000152 return use_wrappers(@_[0], '<tt class="regexp">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000153sub do_cmd_character{
Fred Drakee15956b2000-04-03 04:51:13 +0000154 return use_wrappers(@_[0], '"<tt class="character">', '</tt>"'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000155sub do_cmd_program{
Fred Drakee15956b2000-04-03 04:51:13 +0000156 return use_wrappers(@_[0], '<b class="program">', '</b>'); }
Fred Drakec9f5fe01999-11-09 16:59:42 +0000157sub do_cmd_programopt{
158 return use_wrappers(@_[0], '<b class="programopt">', '</b>'); }
Fred Drake0cd60212000-04-11 18:46:59 +0000159sub do_cmd_longprogramopt{
160 # note that the --- will be later converted to -- by LaTeX2HTML
161 return use_wrappers(@_[0], '<b class="programopt">---', '</b>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000162sub do_cmd_email{
Fred Drakee15956b2000-04-03 04:51:13 +0000163 return use_wrappers(@_[0], '<span class="email">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000164sub do_cmd_mimetype{
Fred Drakee15956b2000-04-03 04:51:13 +0000165 return use_wrappers(@_[0], '<span class="mimetype">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000166sub do_cmd_var{
167 return use_wrappers(@_[0], "<var>", "</var>"); }
168sub do_cmd_dfn{
Fred Drakee15956b2000-04-03 04:51:13 +0000169 return use_wrappers(@_[0], '<i class="dfn">', '</i>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000170sub do_cmd_emph{
171 return use_italics(@_); }
172sub do_cmd_file{
Fred Drake3d5a04a2000-08-03 17:25:44 +0000173 return use_wrappers(@_[0], '<span class="file">', '</span>'); }
Fred Drakef74e5b71999-04-28 14:58:49 +0000174sub do_cmd_filenq{
Fred Drakee15956b2000-04-03 04:51:13 +0000175 return do_cmd_file(@_[0]); }
Fred Drake90fdda51999-02-16 20:27:42 +0000176sub do_cmd_samp{
Fred Drakee15956b2000-04-03 04:51:13 +0000177 return use_wrappers(@_[0], '"<tt class="samp">', '</tt>"'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000178sub do_cmd_kbd{
179 return use_wrappers(@_[0], '<kbd>', '</kbd>'); }
180sub do_cmd_strong{
181 return use_wrappers(@_[0], '<b>', '</b>'); }
Fred Drake2cafcbb1999-03-25 16:57:04 +0000182sub do_cmd_textbf{
183 return use_wrappers(@_[0], '<b>', '</b>'); }
184sub do_cmd_textit{
185 return use_wrappers(@_[0], '<i>', '</i>'); }
186
Fred Drake3d5a04a2000-08-03 17:25:44 +0000187sub do_cmd_moreargs{
188 return '...' . @_[0]; }
189sub do_cmd_unspecified{
190 return '...' . @_[0]; }
191
Fred Drakec9a44381998-03-17 06:29:13 +0000192
Fred Drake25817041999-01-13 17:06:34 +0000193sub do_cmd_refmodule{
194 # Insert the right magic to jump to the module definition.
195 local($_) = @_;
196 my $key = next_optional_argument();
197 my $module = next_argument();
198 $key = $module
199 unless $key;
Fred Drakee15956b2000-04-03 04:51:13 +0000200 return "<tt class='module'><a href='module-$key.html'>$module</a></tt>"
201 . $_;
Fred Drake25817041999-01-13 17:06:34 +0000202}
203
Fred Drake1a7af391998-04-01 22:44:56 +0000204sub do_cmd_newsgroup{
205 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000206 my $newsgroup = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000207 my $stuff = "<span class='newsgroup'><a href='news:$newsgroup'>"
208 . "$newsgroup</a></span>";
Fred Drake62e43691998-08-10 19:40:44 +0000209 return $stuff . $_;
Fred Drake1a7af391998-04-01 22:44:56 +0000210}
Fred Drakefc16e781998-03-12 21:03:26 +0000211
212sub do_cmd_envvar{
213 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000214 my $envvar = next_argument();
215 my($name,$aname,$ahref) = new_link_info();
Fred Drake166abba1998-04-08 23:10:54 +0000216 # The <tt> here is really to keep buildindex.py from making
217 # the variable name case-insensitive.
218 add_index_entry("environment variables!$envvar@<tt>\$$envvar</tt>",
219 $ahref);
Fred Drake42b31a51998-03-27 05:16:10 +0000220 add_index_entry("$envvar@\$$envvar", $ahref);
Fred Drakee15956b2000-04-03 04:51:13 +0000221 $aname =~ s/<a/<a class="envvar"/;
Fred Draked37cecf1999-09-23 16:45:08 +0000222 return "$aname\$$envvar</a>" . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000223}
224
Fred Drake6659c301998-03-03 22:02:19 +0000225sub do_cmd_url{
226 # use the URL as both text and hyperlink
227 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000228 my $url = next_argument();
Fred Drake6659c301998-03-03 22:02:19 +0000229 $url =~ s/~/&#126;/g;
Fred Drakee15956b2000-04-03 04:51:13 +0000230 return "<a class=\"url\" href=\"$url\">$url</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000231}
232
233sub do_cmd_manpage{
234 # two parameters: \manpage{name}{section}
235 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000236 my $page = next_argument();
237 my $section = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000238 return "<span class='manpage'><i>$page</i>($section)</span>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000239}
240
Fred Drake37cc0c02000-04-26 18:05:24 +0000241sub get_rfc_url{
242 my $rfcnum = sprintf("%04d", @_[0]);
243 return "http://www.ietf.org/rfc/rfc$rfcnum.txt";
244}
245
Fred Drake6659c301998-03-03 22:02:19 +0000246sub do_cmd_rfc{
247 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000248 my $rfcnumber = next_argument();
249 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drake37cc0c02000-04-26 18:05:24 +0000250 my $href = get_rfc_url($rfcnumber);
Fred Drake6659c301998-03-03 22:02:19 +0000251 # Save the reference
Fred Drake08932051998-04-17 02:15:42 +0000252 my $nstr = gen_index_id("RFC!RFC $rfcnumber", '');
Fred Drakeccc62721999-01-05 22:16:29 +0000253 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
Fred Drakee15956b2000-04-03 04:51:13 +0000254 return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">RFC $rfcnumber</a>"
Fred Draked52879c1999-09-22 19:58:51 +0000255 . $_);
Fred Drake6659c301998-03-03 22:02:19 +0000256}
257
Fred Drakec9f5fe01999-11-09 16:59:42 +0000258sub do_cmd_citetitle{
259 local($_) = @_;
260 my $url = next_optional_argument();
261 my $title = next_argument();
262 my $repl = '';
263 if ($url) {
264 $repl = ("<em class='citetitle'><a\n"
265 . " href='$url'\n"
266 . " title='$title'\n"
267 . " >$title</a></em>");
268 }
269 else {
270 $repl = "<em class='citetitle'\n >$title</em>";
271 }
272 return $repl . $_;
273}
274
Fred Drake6659c301998-03-03 22:02:19 +0000275sub do_cmd_deprecated{
276 # two parameters: \deprecated{version}{whattodo}
277 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000278 my $release = next_argument();
279 my $reason = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000280 return "<b>Deprecated since release $release.</b>\n$reason<p>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000281}
282
Fred Drake897d12b1998-07-27 20:33:17 +0000283sub do_cmd_versionadded{
284 # one parameter: \versionadded{version}
285 local($_) = @_;
286 my $release = next_argument();
Fred Drake2116d981999-02-02 18:02:48 +0000287 return "\nNew in version $release.\n" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000288}
289
290sub do_cmd_versionchanged{
291 # one parameter: \versionchanged{version}
292 local($_) = @_;
Fred Drake52e76842000-05-02 17:37:42 +0000293 my $explanation = next_optional_argument();
Fred Drake897d12b1998-07-27 20:33:17 +0000294 my $release = next_argument();
Fred Drake52e76842000-05-02 17:37:42 +0000295 my $text = "\nChanged in version $release.\n";
296 if ($release) {
297 $text = "\nChanged in version $release:\n$explanation.\n";
298 }
299 return $text . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000300}
301
Fred Drake557460c1999-03-02 16:05:35 +0000302#
Fred Drake2cafcbb1999-03-25 16:57:04 +0000303# These function handle platform dependency tracking.
Fred Drake557460c1999-03-02 16:05:35 +0000304#
305sub do_cmd_platform{
306 local($_) = @_;
307 my $platform = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000308 $ModulePlatforms{"<tt class='module'>$THIS_MODULE</tt>"} = $platform;
Fred Drake557460c1999-03-02 16:05:35 +0000309 $platform = "Macintosh"
Fred Drake085b8121999-04-21 14:00:29 +0000310 if $platform eq 'Mac';
Fred Drakee15956b2000-04-03 04:51:13 +0000311 return "\n<p class='availability'>Availability: <span"
312 . "\n class='platform'>$platform</span>.</p>\n" . $_;
Fred Drake557460c1999-03-02 16:05:35 +0000313}
314
Fred Drake557460c1999-03-02 16:05:35 +0000315$IGNORE_PLATFORM_ANNOTATION = '';
316sub do_cmd_ignorePlatformAnnotation{
317 local($_) = @_;
318 $IGNORE_PLATFORM_ANNOTATION = next_argument();
319 return $_;
320}
321
Fred Drake6659c301998-03-03 22:02:19 +0000322
323# index commands
324
325$INDEX_SUBITEM = "";
326
327sub get_indexsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000328 return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
Fred Drake6659c301998-03-03 22:02:19 +0000329}
330
331sub do_cmd_setindexsubitem{
332 local($_) = @_;
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000333 $INDEX_SUBITEM = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000334 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000335}
336
Fred Drakefc16e781998-03-12 21:03:26 +0000337sub do_cmd_withsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000338 # We can't really do the right thing, because LaTeX2HTML doesn't
Fred Drakefc16e781998-03-12 21:03:26 +0000339 # do things in the right order, but we need to at least strip this stuff
340 # out, and leave anything that the second argument expanded out to.
341 #
342 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000343 my $oldsubitem = $INDEX_SUBITEM;
344 $INDEX_SUBITEM = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000345 my $stuff = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000346 my $br_id = ++$globals{'max_id'};
347 my $marker = "$O$br_id$C";
Fred Drake7d45f6d1999-01-05 14:39:27 +0000348 return
349 $stuff
Fred Drakeccc62721999-01-05 22:16:29 +0000350 . "\\setindexsubitem$marker$oldsubitem$marker"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000351 . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000352}
353
Fred Drake08932051998-04-17 02:15:42 +0000354# This is the prologue macro which is required to start writing the
Fred Drakeab032151999-05-13 18:36:54 +0000355# mod\jobname.idx file; we can just ignore it. (Defining this suppresses
356# a warning that \makemodindex is unknown.)
Fred Drake08932051998-04-17 02:15:42 +0000357#
Fred Drake62e43691998-08-10 19:40:44 +0000358sub do_cmd_makemodindex{ return @_[0]; }
Fred Drakefc16e781998-03-12 21:03:26 +0000359
Fred Drake42b31a51998-03-27 05:16:10 +0000360# We're in the document subdirectory when this happens!
Fred Drake166abba1998-04-08 23:10:54 +0000361#
Fred Drake08932051998-04-17 02:15:42 +0000362open(IDXFILE, '>index.dat') || die "\n$!\n";
363open(INTLABELS, '>intlabels.pl') || die "\n$!\n";
Fred Drake166abba1998-04-08 23:10:54 +0000364print INTLABELS "%internal_labels = ();\n";
365print INTLABELS "1; # hack in case there are no entries\n\n";
366
367# Using \0 for this is bad because we can't use common tools to work with the
368# resulting files. Things like grep can be useful with this stuff!
369#
370$IDXFILE_FIELD_SEP = "\1";
371
Fred Drakeccc62721999-01-05 22:16:29 +0000372sub write_idxfile{
373 my ($ahref, $str) = @_;
374 print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n";
Fred Drake42b31a51998-03-27 05:16:10 +0000375}
376
Fred Drake42b31a51998-03-27 05:16:10 +0000377
378sub gen_link{
379 my($node,$target) = @_;
380 print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
Fred Drakee15956b2000-04-03 04:51:13 +0000381 return "<a href='$node#$target'>";
Fred Drake42b31a51998-03-27 05:16:10 +0000382}
383
Fred Drake42b31a51998-03-27 05:16:10 +0000384sub add_index_entry{
385 # add an entry to the index structures; ignore the return value
386 my($str,$ahref) = @_;
387 $str = gen_index_id($str, '');
388 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000389 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000390}
391
Fred Drakeccc62721999-01-05 22:16:29 +0000392sub new_link_info{
393 my $name = "l2h-" . ++$globals{'max_id'};
Fred Drakee15956b2000-04-03 04:51:13 +0000394 my $aname = "<a name='$name'>";
Fred Drake42b31a51998-03-27 05:16:10 +0000395 my $ahref = gen_link($CURRENT_FILE, $name);
396 return ($name, $aname, $ahref);
397}
398
Fred Drakeab032151999-05-13 18:36:54 +0000399$IndexMacroPattern = '';
400sub define_indexing_macro{
401 my $count = @_;
402 my $i = 0;
403 for (; $i < $count; ++$i) {
404 my $name = @_[$i];
405 my $cmd = "idx_cmd_$name";
406 die "\nNo function $cmd() defined!\n"
407 if (!defined &$cmd);
408 eval ("sub do_cmd_$name { return process_index_macros("
409 . "\@_[0], '$name'); }");
410 if (length($IndexMacroPattern) == 0) {
411 $IndexMacroPattern = "$name";
412 }
413 else {
414 $IndexMacroPattern .= "|$name";
415 }
416 }
417}
418
419$DEBUG_INDEXING = 0;
420sub process_index_macros{
Fred Drake42b31a51998-03-27 05:16:10 +0000421 local($_) = @_;
Fred Drakeab032151999-05-13 18:36:54 +0000422 my $cmdname = @_[1]; # This is what triggered us in the first place;
423 # we know it's real, so just process it.
Fred Drakeccc62721999-01-05 22:16:29 +0000424 my($name,$aname,$ahref) = new_link_info();
Fred Drakeab032151999-05-13 18:36:54 +0000425 my $cmd = "idx_cmd_$cmdname";
426 print "\nIndexing: \\$cmdname"
427 if $DEBUG_INDEXING;
428 &$cmd($ahref); # modifies $_ and adds index entries
429 while (/^[\s\n]*\\($IndexMacroPattern)</) {
430 $cmdname = "$1";
431 print " \\$cmdname"
432 if $DEBUG_INDEXING;
433 $cmd = "idx_cmd_$cmdname";
434 if (!defined &$cmd) {
435 last;
436 }
437 else {
438 s/^[\s\n]*\\$cmdname//;
439 &$cmd($ahref);
440 }
441 }
Fred Drake62e43691998-08-10 19:40:44 +0000442 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake42b31a51998-03-27 05:16:10 +0000443}
444
Fred Drakeab032151999-05-13 18:36:54 +0000445define_indexing_macro('index');
446sub idx_cmd_index{
Fred Drakeccc62721999-01-05 22:16:29 +0000447 my $str = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000448 add_index_entry("$str", @_[0]);
Fred Drake2e7edb81998-05-11 18:31:17 +0000449}
450
Fred Drakeab032151999-05-13 18:36:54 +0000451define_indexing_macro('kwindex');
452sub idx_cmd_kwindex{
453 my $str = next_argument();
454 add_index_entry("<tt>$str</tt>!keyword", @_[0]);
455 add_index_entry("keyword!<tt>$str</tt>", @_[0]);
456}
457
458define_indexing_macro('indexii');
459sub idx_cmd_indexii{
Fred Drakeccc62721999-01-05 22:16:29 +0000460 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000461 my $str2 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000462 add_index_entry("$str1!$str2", @_[0]);
463 add_index_entry("$str2!$str1", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000464}
465
Fred Drakeab032151999-05-13 18:36:54 +0000466define_indexing_macro('indexiii');
467sub idx_cmd_indexiii{
Fred Drakeccc62721999-01-05 22:16:29 +0000468 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000469 my $str2 = next_argument();
470 my $str3 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000471 add_index_entry("$str1!$str2 $str3", @_[0]);
472 add_index_entry("$str2!$str3, $str1", @_[0]);
473 add_index_entry("$str3!$str1 $str2", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000474}
475
Fred Drakeab032151999-05-13 18:36:54 +0000476define_indexing_macro('indexiv');
477sub idx_cmd_indexiv{
Fred Drakeccc62721999-01-05 22:16:29 +0000478 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000479 my $str2 = next_argument();
480 my $str3 = next_argument();
481 my $str4 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000482 add_index_entry("$str1!$str2 $str3 $str4", @_[0]);
483 add_index_entry("$str2!$str3 $str4, $str1", @_[0]);
484 add_index_entry("$str3!$str4, $str1 $str2", @_[0]);
485 add_index_entry("$str4!$$str1 $str2 $str3", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000486}
487
Fred Drakeab032151999-05-13 18:36:54 +0000488define_indexing_macro('ttindex');
489sub idx_cmd_ttindex{
Fred Drakeccc62721999-01-05 22:16:29 +0000490 my $str = next_argument();
491 my $entry = $str . get_indexsubitem();
Fred Drakeab032151999-05-13 18:36:54 +0000492 add_index_entry($entry, @_[0]);
Fred Drakec9a44381998-03-17 06:29:13 +0000493}
Fred Drake6659c301998-03-03 22:02:19 +0000494
495sub my_typed_index_helper{
Fred Drakeab032151999-05-13 18:36:54 +0000496 my($word,$ahref) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000497 my $str = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000498 add_index_entry("$str $word", $ahref);
499 add_index_entry("$word!$str", $ahref);
Fred Drake6659c301998-03-03 22:02:19 +0000500}
501
Fred Drakeab032151999-05-13 18:36:54 +0000502define_indexing_macro('stindex', 'opindex', 'exindex', 'obindex');
503sub idx_cmd_stindex{ my_typed_index_helper('statement', @_[0]); }
504sub idx_cmd_opindex{ my_typed_index_helper('operator', @_[0]); }
505sub idx_cmd_exindex{ my_typed_index_helper('exception', @_[0]); }
506sub idx_cmd_obindex{ my_typed_index_helper('object', @_[0]); }
Fred Drake6659c301998-03-03 22:02:19 +0000507
Fred Drakeab032151999-05-13 18:36:54 +0000508define_indexing_macro('bifuncindex');
509sub idx_cmd_bifuncindex{
Fred Drakeccc62721999-01-05 22:16:29 +0000510 my $str = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000511 add_index_entry("<tt class='function'>$str()</tt> (built-in function)",
512 @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000513}
514
515
Fred Drake6659c301998-03-03 22:02:19 +0000516sub make_mod_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000517 my($str,$define) = @_;
518 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000519 # equivalent of add_index_entry() using $define instead of ''
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000520 $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/
521 if ($define eq 'DEF');
Fred Drake42b31a51998-03-27 05:16:10 +0000522 $str = gen_index_id($str, $define);
523 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000524 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000525
Fred Drakec9a44381998-03-17 06:29:13 +0000526 if ($define eq 'DEF') {
Fred Drake42b31a51998-03-27 05:16:10 +0000527 # add to the module index
Fred Drakee15956b2000-04-03 04:51:13 +0000528 $str =~ /(<tt.*<\/tt>)/;
529 my $nstr = $1;
Fred Drake42b31a51998-03-27 05:16:10 +0000530 $Modules{$nstr} .= $ahref;
Fred Drake6659c301998-03-03 22:02:19 +0000531 }
Fred Drake62e43691998-08-10 19:40:44 +0000532 return "$aname$anchor_invisible_mark</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000533}
534
Fred Drake557460c1999-03-02 16:05:35 +0000535
Fred Drakec9a44381998-03-17 06:29:13 +0000536$THIS_MODULE = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000537$THIS_CLASS = '';
Fred Drakec9a44381998-03-17 06:29:13 +0000538
Fred Drakea0f4c941998-07-24 22:16:04 +0000539sub define_module{
540 my($word,$name) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000541 my $section_tag = join('', @curr_sec_id);
Fred Drake3e4c6141999-05-17 15:00:32 +0000542 if ($word ne "built-in" && $word ne "extension"
543 && $word ne "standard" && $word ne "") {
544 write_warnings("Bad module type '$word'"
545 . " for \\declaremodule (module $name)");
546 $word = "";
547 }
Fred Drake6659c301998-03-03 22:02:19 +0000548 $word = "$word " if $word;
Fred Drakea0f4c941998-07-24 22:16:04 +0000549 $THIS_MODULE = "$name";
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000550 $INDEX_SUBITEM = "(in $name)";
551 print "[$name]";
Fred Drakee15956b2000-04-03 04:51:13 +0000552 return make_mod_index_entry(
553 "<tt class='module'>$name</tt> (${word}module)", 'DEF');
Fred Drakea0f4c941998-07-24 22:16:04 +0000554}
555
556sub my_module_index_helper{
557 local($word, $_) = @_;
558 my $name = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000559 return define_module($word, $name) . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000560}
561
Fred Drake62e43691998-08-10 19:40:44 +0000562sub do_cmd_modindex{ return my_module_index_helper('', @_); }
563sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); }
564sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); }
565sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000566
Fred Drakeab032151999-05-13 18:36:54 +0000567sub ref_module_index_helper{
Fred Drake37cc0c02000-04-26 18:05:24 +0000568 my($word, $ahref) = @_;
Fred Drakeab032151999-05-13 18:36:54 +0000569 my $str = next_argument();
570 $word = "$word " if $word;
Fred Drakee15956b2000-04-03 04:51:13 +0000571 $str = "<tt class='module'>$str</tt> (${word}module)";
Fred Drakeab032151999-05-13 18:36:54 +0000572 # can't use add_index_entry() since the 2nd arg to gen_index_id() is used;
573 # just inline it all here
574 $str = gen_index_id($str, 'REF');
575 $index{$str} .= $ahref;
576 write_idxfile($ahref, $str);
577}
578
Fred Drake6659c301998-03-03 22:02:19 +0000579# these should be adjusted a bit....
Fred Drakeab032151999-05-13 18:36:54 +0000580define_indexing_macro('refmodindex', 'refbimodindex',
581 'refexmodindex', 'refstmodindex');
582sub idx_cmd_refmodindex{ return ref_module_index_helper('', @_); }
583sub idx_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); }
584sub idx_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); }
585sub idx_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000586
Fred Drake62e43691998-08-10 19:40:44 +0000587sub do_cmd_nodename{ return do_cmd_label(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000588
589sub init_myformat{
Fred Drake08932051998-04-17 02:15:42 +0000590# $anchor_invisible_mark = '';
Fred Drake6659c301998-03-03 22:02:19 +0000591 $anchor_mark = '';
592 $icons{'anchor_mark'} = '';
Fred Drake6659c301998-03-03 22:02:19 +0000593}
Fred Drake42b31a51998-03-27 05:16:10 +0000594init_myformat();
Fred Drake6659c301998-03-03 22:02:19 +0000595
Fred Drakeab032151999-05-13 18:36:54 +0000596# Create an index entry, but include the string in the target anchor
Fred Drake6659c301998-03-03 22:02:19 +0000597# instead of the dummy filler.
598#
599sub make_str_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000600 my($str) = @_;
601 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000602 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000603 return "$aname$str</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000604}
605
Fred Drakee15956b2000-04-03 04:51:13 +0000606$REFCOUNTS_LOADED = 0;
607
608sub load_refcounts{
609 $REFCOUNTS_LOADED = 1;
610
611 use File::Basename;
612 my $myname, $mydir, $myext;
613 ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*');
614 chop $mydir; # remove trailing '/'
615 ($myname, $mydir, $myext) = fileparse($mydir, '\..*');
616 chop $mydir; # remove trailing '/'
617 $mydir = getcwd() . "$dd$mydir"
618 unless $mydir =~ s|^/|/|;
619 local $_;
620 my $filename = "$mydir${dd}api${dd}refcounts.dat";
621 open(REFCOUNT_FILE, "<$filename") || die "\n$!\n";
622 print "[loading API refcount data]";
623 while (<REFCOUNT_FILE>) {
Fred Drakec2578c52000-04-10 18:26:45 +0000624 if (/([a-zA-Z0-9_]+):PyObject\*:([a-zA-Z0-9_]*):(0|[-+]1|null):(.*)$/) {
Fred Drakee15956b2000-04-03 04:51:13 +0000625 my($func, $param, $count, $comment) = ($1, $2, $3, $4);
626 #print "\n$func($param) --> $count";
627 $REFCOUNTS{"$func:$param"} = $count;
628 }
629 }
630}
631
632sub get_refcount{
633 my ($func, $param) = @_;
634 load_refcounts()
635 unless $REFCOUNTS_LOADED;
636 return $REFCOUNTS{"$func:$param"};
637}
638
Fred Drake6659c301998-03-03 22:02:19 +0000639sub do_env_cfuncdesc{
640 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000641 my $return_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000642 my $function_name = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000643 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000644 my $idx = make_str_index_entry(
645 "<tt class='cfunction'>$function_name()</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000646 $idx =~ s/ \(.*\)//;
Fred Drake241551c2000-08-11 20:04:19 +0000647 $idx =~ s/\(\)//; # ???? - why both of these?
Fred Drakee15956b2000-04-03 04:51:13 +0000648 my $result_rc = get_refcount($function_name, '');
649 my $rcinfo = '';
650 if ($result_rc eq '+1') {
Fred Drake241551c2000-08-11 20:04:19 +0000651 $rcinfo = 'New reference';
Fred Drakee15956b2000-04-03 04:51:13 +0000652 }
653 elsif ($result_rc eq '0') {
Fred Drake241551c2000-08-11 20:04:19 +0000654 $rcinfo = 'Borrowed reference';
Fred Drakee15956b2000-04-03 04:51:13 +0000655 }
Fred Drakec2578c52000-04-10 18:26:45 +0000656 elsif ($result_rc eq 'null') {
Fred Drake241551c2000-08-11 20:04:19 +0000657 $rcinfo = 'Always <tt class="constant">NULL</tt>';
Fred Drakec2578c52000-04-10 18:26:45 +0000658 }
Fred Drakee15956b2000-04-03 04:51:13 +0000659 if ($rcinfo ne '') {
Fred Drake241551c2000-08-11 20:04:19 +0000660 $rcinfo = ( "\n<div class=\"refcount-info\">"
661 . "\n <span class=\"label\">Return value:</span>"
662 . "\n <span class=\"value\">$rcinfo.</span>"
663 . "\n</div>");
Fred Drakee15956b2000-04-03 04:51:13 +0000664 }
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000665 return "<dl><dt>$return_type <b>$idx</b> (<var>$arg_list</var>)\n<dd>"
Fred Drakee15956b2000-04-03 04:51:13 +0000666 . $rcinfo
Fred Drake62e43691998-08-10 19:40:44 +0000667 . $_
668 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000669}
670
Fred Drakee15956b2000-04-03 04:51:13 +0000671sub do_env_csimplemacrodesc{
672 local($_) = @_;
673 my $name = next_argument();
674 my $idx = make_str_index_entry("<tt class='macro'>$name</tt>");
675 return "<dl><dt><b>$idx</b>\n<dd>"
676 . $_
677 . '</dl>'
678}
679
Fred Drake6659c301998-03-03 22:02:19 +0000680sub do_env_ctypedesc{
681 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +0000682 my $index_name = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000683 my $type_name = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000684 $index_name = $type_name
685 unless $index_name;
686 my($name,$aname,$ahref) = new_link_info();
687 add_index_entry("<tt class='ctype'>$index_name</tt> (C type)", $ahref);
688 return "<dl><dt><b><tt class='ctype'>$aname$type_name</a></tt></b>\n<dd>"
Fred Drake62e43691998-08-10 19:40:44 +0000689 . $_
690 . '</dl>'
Fred Drake6659c301998-03-03 22:02:19 +0000691}
692
693sub do_env_cvardesc{
694 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000695 my $var_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000696 my $var_name = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000697 my $idx = make_str_index_entry("<tt class='cdata'>$var_name</tt>"
Fred Drake90fdda51999-02-16 20:27:42 +0000698 . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000699 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000700 return "<dl><dt>$var_type <b>$idx</b>\n"
701 . '<dd>'
702 . $_
703 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000704}
705
706sub do_env_funcdesc{
707 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000708 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000709 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000710 my $idx = make_str_index_entry("<tt class='function'>$function_name()</tt>"
Fred Drake08932051998-04-17 02:15:42 +0000711 . get_indexsubitem());
712 $idx =~ s/ \(.*\)//;
Fred Drakeccc62721999-01-05 22:16:29 +0000713 $idx =~ s/\(\)<\/tt>/<\/tt>/;
Fred Drake62e43691998-08-10 19:40:44 +0000714 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000715}
716
717sub do_env_funcdescni{
718 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000719 my $function_name = next_argument();
720 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000721 return "<dl><dt><b><tt class='function'>$function_name</tt></b>"
Fred Drake90fdda51999-02-16 20:27:42 +0000722 . " (<var>$arg_list</var>)\n"
723 . '<dd>'
724 . $_
725 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000726}
727
728sub do_cmd_funcline{
729 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000730 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000731 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000732 my $prefix = "<tt class='function'>$function_name()</tt>";
Fred Drakeca675e41999-04-21 15:58:58 +0000733 my $idx = make_str_index_entry($prefix . get_indexsubitem());
734 $prefix =~ s/\(\)//;
735
736 return "<dt><b>$prefix</b> (<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000737}
738
Fred Drake6b3fb781999-07-12 16:50:09 +0000739sub do_cmd_funclineni{
740 local($_) = @_;
741 my $function_name = next_argument();
742 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000743 my $prefix = "<tt class='function'>$function_name</tt>";
Fred Drake6b3fb781999-07-12 16:50:09 +0000744
745 return "<dt><b>$prefix</b> (<var>$arg_list</var>)\n<dd>" . $_;
746}
747
Fred Drake6659c301998-03-03 22:02:19 +0000748# Change this flag to index the opcode entries. I don't think it's very
749# useful to index them, since they're only presented to describe the dis
750# module.
751#
752$INDEX_OPCODES = 0;
753
754sub do_env_opcodedesc{
755 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000756 my $opcode_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000757 my $arg_list = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000758 my $idx;
759 if ($INDEX_OPCODES) {
Fred Drakee15956b2000-04-03 04:51:13 +0000760 $idx = make_str_index_entry("<tt class='opcode'>$opcode_name</tt>"
761 . " (byte code instruction)");
Fred Drake08932051998-04-17 02:15:42 +0000762 $idx =~ s/ \(byte code instruction\)//;
763 }
764 else {
Fred Drakee15956b2000-04-03 04:51:13 +0000765 $idx = "<tt class='opcode'>$opcode_name</tt>";
Fred Drake08932051998-04-17 02:15:42 +0000766 }
767 my $stuff = "<dl><dt><b>$idx</b>";
Fred Drake6659c301998-03-03 22:02:19 +0000768 if ($arg_list) {
769 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
770 }
Fred Drake62e43691998-08-10 19:40:44 +0000771 return $stuff . "\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000772}
773
774sub do_env_datadesc{
775 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000776 my $dataname = next_argument();
777 my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000778 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000779 return "<dl><dt><b>$idx</b>\n<dd>"
780 . $_
781 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000782}
783
784sub do_env_datadescni{
785 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000786 my $idx = next_argument();
787 if (! $STRING_INDEX_TT) {
788 $idx = "<tt>$idx</tt>";
Fred Drake6659c301998-03-03 22:02:19 +0000789 }
Fred Drake62e43691998-08-10 19:40:44 +0000790 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000791}
792
793sub do_cmd_dataline{
794 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000795 my $data_name = next_argument();
796 my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem());
Fred Drake6659c301998-03-03 22:02:19 +0000797 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000798 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000799}
800
Fred Drakeadb272c2000-04-10 17:47:14 +0000801sub do_cmd_datalineni{
802 local($_) = @_;
803 my $data_name = next_argument();
804 return "<dt><b><tt>$data_name</tt></b><dd>" . $_;
805}
806
Fred Drake42b31a51998-03-27 05:16:10 +0000807sub do_env_excdesc{
808 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000809 my $excname = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000810 my $idx = make_str_index_entry("<tt class='exception'>$excname</tt>");
Fred Drake62e43691998-08-10 19:40:44 +0000811 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'
Fred Drake42b31a51998-03-27 05:16:10 +0000812}
813
Fred Drake62e43691998-08-10 19:40:44 +0000814sub do_env_fulllineitems{ return do_env_itemize(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000815
816
Fred Drakec9a44381998-03-17 06:29:13 +0000817sub do_env_classdesc{
818 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000819 $THIS_CLASS = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000820 my $arg_list = next_argument();
821 $idx = make_str_index_entry(
Fred Drakee15956b2000-04-03 04:51:13 +0000822 "<tt class='class'>$THIS_CLASS</tt> (class in $THIS_MODULE)" );
Fred Drake08932051998-04-17 02:15:42 +0000823 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000824 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drakec9a44381998-03-17 06:29:13 +0000825}
826
Fred Drake42b31a51998-03-27 05:16:10 +0000827
828sub do_env_methoddesc{
829 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000830 my $class_name = next_optional_argument();
831 $class_name = $THIS_CLASS
832 unless $class_name;
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000833 my $method = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000834 my $arg_list = next_argument();
835 my $extra = '';
836 if ($class_name) {
837 $extra = " ($class_name method)";
Fred Drake42b31a51998-03-27 05:16:10 +0000838 }
Fred Drakee15956b2000-04-03 04:51:13 +0000839 my $idx = make_str_index_entry("<tt class='method'>$method()</tt>$extra");
Fred Drake08932051998-04-17 02:15:42 +0000840 $idx =~ s/ \(.*\)//;
841 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000842 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000843}
844
845
Fred Drake7d45f6d1999-01-05 14:39:27 +0000846sub do_cmd_methodline{
847 local($_) = @_;
848 my $class_name = next_optional_argument();
849 $class_name = $THIS_CLASS
850 unless $class_name;
851 my $method = next_argument();
852 my $arg_list = next_argument();
853 my $extra = '';
854 if ($class_name) {
855 $extra = " ($class_name method)";
856 }
Fred Drakee15956b2000-04-03 04:51:13 +0000857 my $idx = make_str_index_entry("<tt class='method'>$method()</tt>$extra");
Fred Drake7d45f6d1999-01-05 14:39:27 +0000858 $idx =~ s/ \(.*\)//;
859 $idx =~ s/\(\)//;
860 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>"
861 . $_;
862}
863
864
Fred Draked64a40d1998-09-10 18:59:13 +0000865sub do_cmd_methodlineni{
866 local($_) = @_;
867 next_optional_argument();
868 my $method = next_argument();
869 my $arg_list = next_argument();
870 return "<dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
871 . $_;
872}
873
Fred Drake42b31a51998-03-27 05:16:10 +0000874sub do_env_methoddescni{
875 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000876 next_optional_argument();
877 my $method = next_argument();
878 my $arg_list = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000879 return "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
880 . $_
881 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000882}
883
884
885sub do_env_memberdesc{
886 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000887 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000888 my $member = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000889 $class = $THIS_CLASS
890 unless $class;
Fred Drake08932051998-04-17 02:15:42 +0000891 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +0000892 $extra = " ($class attribute)"
893 if ($class ne '');
Fred Drakee15956b2000-04-03 04:51:13 +0000894 my $idx = make_str_index_entry("<tt class='member'>$member</tt>$extra");
Fred Drake42b31a51998-03-27 05:16:10 +0000895 $idx =~ s/ \(.*\)//;
896 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000897 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000898}
899
900
Fred Drake5ccf3301998-04-17 20:04:09 +0000901sub do_cmd_memberline{
902 local($_) = @_;
903 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000904 my $member = next_argument();
Fred Drake5ccf3301998-04-17 20:04:09 +0000905 $class = $THIS_CLASS
906 unless $class;
907 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +0000908 $extra = " ($class attribute)"
909 if ($class ne '');
Fred Drakee15956b2000-04-03 04:51:13 +0000910 my $idx = make_str_index_entry("<tt class='member'>$member</tt>$extra");
Fred Drake5ccf3301998-04-17 20:04:09 +0000911 $idx =~ s/ \(.*\)//;
912 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000913 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000914}
915
Fred Drake42b31a51998-03-27 05:16:10 +0000916sub do_env_memberdescni{
917 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000918 next_optional_argument();
919 my $member = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000920 return "<dl><dt><b><tt class='member'>$member</tt></b>\n<dd>"
921 . $_
922 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000923}
924
925
Fred Drake5ccf3301998-04-17 20:04:09 +0000926sub do_cmd_memberlineni{
927 local($_) = @_;
928 next_optional_argument();
929 my $member = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000930 return "<dt><b><tt class='member'>$member</tt></b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000931}
932
Fred Drakee15956b2000-04-03 04:51:13 +0000933@col_aligns = ('<td>', '<td>', '<td>', '<td>');
Fred Drake6659c301998-03-03 22:02:19 +0000934
Fred Drake15799ed1999-02-12 19:23:17 +0000935$TABLE_HEADER_BGCOLOR = $NAV_BGCOLOR;
936
Fred Drakef74e5b71999-04-28 14:58:49 +0000937sub fix_font{
938 # do a little magic on a font name to get the right behavior in the first
939 # column of the output table
940 my $font = @_[0];
941 if ($font eq 'textrm') {
942 $font = '';
943 }
944 elsif ($font eq 'file' || $font eq 'filenq') {
Fred Drakee15956b2000-04-03 04:51:13 +0000945 $font = 'tt class="file"';
946 }
947 elsif ($font eq 'member') {
948 $font = 'tt class="member"';
Fred Drakef74e5b71999-04-28 14:58:49 +0000949 }
Fred Drake7388f732000-06-28 21:06:08 +0000950 elsif ($font eq 'constant') {
951 $font = 'tt class="constant"';
952 }
Fred Drakecb0fc9c2000-08-09 13:45:04 +0000953 elsif ($font eq 'kbd') {
954 $font = 'kbd';
955 }
Fred Drakef74e5b71999-04-28 14:58:49 +0000956 return $font;
957}
958
Fred Drakee15956b2000-04-03 04:51:13 +0000959sub figure_column_alignment{
960 my $a = @_[0];
961 my $mark = substr($a, 0, 1);
962 my $r = '';
963 if ($mark eq 'c')
964 { $r = ' align="center"'; }
965 elsif ($mark eq 'r')
966 { $r = ' align="right"'; }
967 elsif ($mark eq 'l')
968 { $r = ' align="left"'; }
969 elsif ($mark eq 'p')
970 { $r = ' align="left"'; }
971 return $r;
972}
973
Fred Drake6659c301998-03-03 22:02:19 +0000974sub setup_column_alignments{
975 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +0000976 my($s1,$s2,$s3,$s4) = split(/[|]/,$_);
977 my $a1 = figure_column_alignment($s1);
978 my $a2 = figure_column_alignment($s2);
979 my $a3 = figure_column_alignment($s3);
980 my $a4 = figure_column_alignment($s4);
981 $col_aligns[0] = "<td$a1 valign=\"baseline\">";
982 $col_aligns[1] = "<td$a2>";
983 $col_aligns[2] = "<td$a3>";
984 $col_aligns[3] = "<td$a4>";
Fred Drake79189b51999-04-28 13:54:30 +0000985 # return the aligned header start tags
Fred Drakee15956b2000-04-03 04:51:13 +0000986 return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>");
987}
988
989sub get_table_col1_fonts{
990 my $font = $globals{'lineifont'};
991 my ($sfont,$efont) = ('', '');
992 if ($font) {
993 $sfont = "<$font>";
994 $efont = "</$font>";
995 $efont =~ s/ .*>/>/;
996 }
997 return ($font, $sfont, $efont);
Fred Drake6659c301998-03-03 22:02:19 +0000998}
999
1000sub do_env_tableii{
1001 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001002 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001003 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001004 my $h1 = next_argument();
1005 my $h2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001006 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001007 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001008 my $a1 = $col_aligns[0];
1009 my $a2 = $col_aligns[1];
1010 s/\\lineii</\\lineii[$a1|$a2]</g;
1011 return '<table border align="center" style="border-collapse: collapse">'
Fred Drakef74e5b71999-04-28 14:58:49 +00001012 . "\n <thead>"
1013 . "\n <tr$TABLE_HEADER_BGCOLOR>"
Fred Drakee15956b2000-04-03 04:51:13 +00001014 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1015 . "\n $th2<b>$h2</b>\&nbsp;</th>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001016 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001017 . "\n <tbody valign='baseline'>"
1018 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001019 . "\n </tbody>"
1020 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001021}
1022
1023sub do_cmd_lineii{
1024 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001025 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001026 my $c1 = next_argument();
1027 my $c2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001028 s/[\s\n]+//;
Fred Drakee15956b2000-04-03 04:51:13 +00001029 my($font,$sfont,$efont) = get_table_col1_fonts();
1030 $c2 = '&nbsp;' if ($c2 eq '');
1031 my($c1align,$c2align) = split('\|', $aligns);
1032 my $padding = '';
1033 if ($c1align =~ /align="right"/) {
1034 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001035 }
Fred Drakee15956b2000-04-03 04:51:13 +00001036 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
1037 . " $c2align$c2</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001038 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001039}
1040
1041sub do_env_tableiii{
1042 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001043 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001044 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001045 my $h1 = next_argument();
1046 my $h2 = next_argument();
1047 my $h3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001048 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001049 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001050 my $a1 = $col_aligns[0];
1051 my $a2 = $col_aligns[1];
1052 my $a3 = $col_aligns[2];
1053 s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g;
1054 return '<table border align="center" style="border-collapse: collapse">'
Fred Drakef74e5b71999-04-28 14:58:49 +00001055 . "\n <thead>"
1056 . "\n <tr$TABLE_HEADER_BGCOLOR>"
Fred Drakee15956b2000-04-03 04:51:13 +00001057 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1058 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1059 . "\n $th3<b>$h3</b>\&nbsp;</th>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001060 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001061 . "\n <tbody valign='baseline'>"
Fred Drake62e43691998-08-10 19:40:44 +00001062 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001063 . "\n </tbody>"
1064 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001065}
1066
1067sub do_cmd_lineiii{
1068 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001069 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001070 my $c1 = next_argument();
1071 my $c2 = next_argument();
1072 my $c3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001073 s/[\s\n]+//;
Fred Drakee15956b2000-04-03 04:51:13 +00001074 my($font,$sfont,$efont) = get_table_col1_fonts();
1075 $c3 = '&nbsp;' if ($c3 eq '');
1076 my($c1align,$c2align,$c3align) = split('\|', $aligns);
1077 my $padding = '';
1078 if ($c1align =~ /align="right"/) {
1079 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001080 }
Fred Drakee15956b2000-04-03 04:51:13 +00001081 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001082 . " $c2align$c2</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001083 . " $c3align$c3</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001084 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001085}
1086
Fred Drakea0f4c941998-07-24 22:16:04 +00001087sub do_env_tableiv{
1088 local($_) = @_;
1089 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001090 my $font = fix_font(next_argument());
Fred Drakea0f4c941998-07-24 22:16:04 +00001091 my $h1 = next_argument();
1092 my $h2 = next_argument();
1093 my $h3 = next_argument();
1094 my $h4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001095 s/[\s\n]+//;
Fred Drakea0f4c941998-07-24 22:16:04 +00001096 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001097 my $a1 = $col_aligns[0];
1098 my $a2 = $col_aligns[1];
1099 my $a3 = $col_aligns[2];
1100 my $a4 = $col_aligns[3];
1101 s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g;
1102 return '<table border align="center" style="border-collapse: collapse">'
Fred Drakef74e5b71999-04-28 14:58:49 +00001103 . "\n <thead>"
1104 . "\n <tr$TABLE_HEADER_BGCOLOR>"
Fred Drakee15956b2000-04-03 04:51:13 +00001105 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1106 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1107 . "\n $th3<b>$h3</b>\&nbsp;</th>"
1108 . "\n $th4<b>$h4</b>\&nbsp;</th>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001109 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001110 . "\n <tbody valign='baseline'>"
Fred Drake62e43691998-08-10 19:40:44 +00001111 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001112 . "\n </tbody>"
1113 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001114}
1115
Fred Drakea0f4c941998-07-24 22:16:04 +00001116sub do_cmd_lineiv{
Fred Drake6659c301998-03-03 22:02:19 +00001117 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001118 my $aligns = next_optional_argument();
Fred Drakea0f4c941998-07-24 22:16:04 +00001119 my $c1 = next_argument();
1120 my $c2 = next_argument();
1121 my $c3 = next_argument();
1122 my $c4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001123 s/[\s\n]+//;
Fred Drakee15956b2000-04-03 04:51:13 +00001124 my($font,$sfont,$efont) = get_table_col1_fonts();
1125 $c4 = '&nbsp;' if ($c4 eq '');
1126 my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns);
1127 my $padding = '';
1128 if ($c1align =~ /align="right"/) {
1129 $padding = '&nbsp;';
Fred Drakea0f4c941998-07-24 22:16:04 +00001130 }
Fred Drakee15956b2000-04-03 04:51:13 +00001131 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001132 . " $c2align$c2</td>\n"
1133 . " $c3align$c3</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001134 . " $c4align$c4</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001135 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001136}
1137
Fred Drake6659c301998-03-03 22:02:19 +00001138sub do_cmd_maketitle {
1139 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001140 my $the_title = "\n<div class='titlepage'><center>";
Fred Drake6659c301998-03-03 22:02:19 +00001141 if ($t_title) {
Fred Drake90fdda51999-02-16 20:27:42 +00001142 $the_title .= "\n<h1>$t_title</h1>";
Fred Drake08932051998-04-17 02:15:42 +00001143 } else { write_warnings("\nThis document has no title."); }
Fred Drake6659c301998-03-03 22:02:19 +00001144 if ($t_author) {
1145 if ($t_authorURL) {
Fred Drake08932051998-04-17 02:15:42 +00001146 my $href = translate_commands($t_authorURL);
Fred Drake2d1f81e1999-02-09 16:03:31 +00001147 $href = make_named_href('author', $href,
1148 "<b><font size='+2'>$t_author</font></b>");
Fred Drakec9a44381998-03-17 06:29:13 +00001149 $the_title .= "\n<p>$href</p>";
Fred Drake6659c301998-03-03 22:02:19 +00001150 } else {
Fred Drake2d1f81e1999-02-09 16:03:31 +00001151 $the_title .= ("\n<p><b><font size='+2'>$t_author</font></b></p>");
Fred Drake6659c301998-03-03 22:02:19 +00001152 }
Fred Drake08932051998-04-17 02:15:42 +00001153 } else { write_warnings("\nThere is no author for this document."); }
Fred Drake6659c301998-03-03 22:02:19 +00001154 if ($t_institute) {
Fred Drakec9a44381998-03-17 06:29:13 +00001155 $the_title .= "\n<p>$t_institute</p>";}
Fred Draked07868a1998-05-14 21:00:28 +00001156 if ($DEVELOPER_ADDRESS) {
1157 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";}
Fred Drake6659c301998-03-03 22:02:19 +00001158 if ($t_affil) {
Fred Drakec9a44381998-03-17 06:29:13 +00001159 $the_title .= "\n<p><i>$t_affil</i></p>";}
Fred Drake6659c301998-03-03 22:02:19 +00001160 if ($t_date) {
Fred Drakec9a44381998-03-17 06:29:13 +00001161 $the_title .= "\n<p><strong>$t_date</strong>";
Fred Drake6659c301998-03-03 22:02:19 +00001162 if ($PYTHON_VERSION) {
1163 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";}
1164 $the_title .= "</p>"
1165 }
1166 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +00001167 $the_title .= "\n<p>$t_address</p>";
1168 } else { $the_title .= "\n<p>"}
Fred Drake6659c301998-03-03 22:02:19 +00001169 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +00001170 $the_title .= "\n<p>$t_email</p>";
1171 }# else { $the_title .= "</p>" }
Fred Drake90fdda51999-02-16 20:27:42 +00001172 $the_title .= "\n</center></div>";
Fred Drake62e43691998-08-10 19:40:44 +00001173 return $the_title . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +00001174}
1175
1176
Fred Drake885215c1998-05-20 21:32:09 +00001177#
Fred Drakea0f4c941998-07-24 22:16:04 +00001178# Module synopsis support
1179#
1180
1181require SynopsisTable;
1182
Fred Drakef7685d71998-07-25 03:31:46 +00001183sub get_chapter_id(){
1184 my $id = do_cmd_thechapter('');
Fred Drake45f26011998-08-04 22:07:18 +00001185 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
1186 $id =~ s/\.//;
Fred Drakef7685d71998-07-25 03:31:46 +00001187 return $id;
Fred Drakea0f4c941998-07-24 22:16:04 +00001188}
1189
Fred Drakef7685d71998-07-25 03:31:46 +00001190%ModuleSynopses = ('chapter' => 'SynopsisTable instance');
1191
1192sub get_synopsis_table($){
1193 my($chap) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001194 my $st = $ModuleSynopses{$chap};
Fred Drakef7685d71998-07-25 03:31:46 +00001195 my $key;
1196 foreach $key (keys %ModuleSynopses) {
1197 if ($key eq $chap) {
1198 return $ModuleSynopses{$chap};
1199 }
Fred Drakea0f4c941998-07-24 22:16:04 +00001200 }
Fred Drakef7685d71998-07-25 03:31:46 +00001201 $st = SynopsisTable->new();
1202 $ModuleSynopses{$chap} = $st;
Fred Drakea0f4c941998-07-24 22:16:04 +00001203 return $st;
1204}
1205
Fred Drake62e43691998-08-10 19:40:44 +00001206sub do_cmd_moduleauthor{
1207 local($_) = @_;
1208 next_argument();
1209 next_argument();
1210 return $_;
1211}
1212
1213sub do_cmd_sectionauthor{
1214 local($_) = @_;
1215 next_argument();
1216 next_argument();
1217 return $_;
1218}
1219
Fred Drakea0f4c941998-07-24 22:16:04 +00001220sub do_cmd_declaremodule{
1221 local($_) = @_;
1222 my $key = next_optional_argument();
1223 my $type = next_argument();
1224 my $name = next_argument();
1225 my $st = get_synopsis_table(get_chapter_id());
1226 #
1227 $key = $name unless $key;
1228 $type = 'built-in' if $type eq 'builtin';
1229 $st->declare($name, $key, $type);
1230 define_module($type, $name);
Fred Drake62e43691998-08-10 19:40:44 +00001231 return anchor_label("module-$key",$CURRENT_FILE,$_)
Fred Drakea0f4c941998-07-24 22:16:04 +00001232}
1233
1234sub do_cmd_modulesynopsis{
1235 local($_) = @_;
1236 my $st = get_synopsis_table(get_chapter_id());
Fred Drake1cc58991999-04-13 22:08:59 +00001237 $st->set_synopsis($THIS_MODULE, translate_commands(next_argument()));
Fred Drake62e43691998-08-10 19:40:44 +00001238 return $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001239}
1240
1241sub do_cmd_localmoduletable{
1242 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001243 my $chap = get_chapter_id();
Fred Drake557460c1999-03-02 16:05:35 +00001244 return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001245}
1246
1247sub process_all_localmoduletables{
Fred Drake557460c1999-03-02 16:05:35 +00001248 while (/<tex2html-localmoduletable><(\d+)>/) {
Fred Drakef7685d71998-07-25 03:31:46 +00001249 my $match = $&;
Fred Drakea0f4c941998-07-24 22:16:04 +00001250 my $chap = $1;
1251 my $st = get_synopsis_table($chap);
1252 my $data = $st->tohtml();
Fred Drakef7685d71998-07-25 03:31:46 +00001253 s/$match/$data/;
Fred Drakea0f4c941998-07-24 22:16:04 +00001254 }
1255}
Fred Drake557460c1999-03-02 16:05:35 +00001256sub process_python_state{
1257 process_all_localmoduletables();
Fred Drake557460c1999-03-02 16:05:35 +00001258}
Fred Drakea0f4c941998-07-24 22:16:04 +00001259
1260
1261#
1262# "See also:" -- references placed at the end of a \section
1263#
1264
1265sub do_env_seealso{
Fred Drakee15956b2000-04-03 04:51:13 +00001266 return "<div class='seealso'>\n "
1267 . "<p class='heading'><b>See Also:</b></p>\n"
Fred Drake90fdda51999-02-16 20:27:42 +00001268 . @_[0]
1269 . '</div>';
Fred Drakea0f4c941998-07-24 22:16:04 +00001270}
1271
1272sub do_cmd_seemodule{
1273 # Insert the right magic to jump to the module definition. This should
1274 # work most of the time, at least for repeat builds....
1275 local($_) = @_;
1276 my $key = next_optional_argument();
1277 my $module = next_argument();
1278 my $text = next_argument();
Fred Drake84bd6f31999-05-11 15:42:51 +00001279 my $period = '.';
Fred Drakea0f4c941998-07-24 22:16:04 +00001280 $key = $module
1281 unless $key;
Fred Drake84bd6f31999-05-11 15:42:51 +00001282 if ($text =~ /\.$/) {
1283 $period = '';
1284 }
Fred Drakee15956b2000-04-03 04:51:13 +00001285 return '<dl compact class="seemodule">'
1286 . "\n <dt>Module <b><tt class='module'><a href='module-$key.html'>"
Fred Drake84bd6f31999-05-11 15:42:51 +00001287 . "$module</a></tt>:</b>"
1288 . "\n <dd>$text$period\n </dl>"
Fred Drake90fdda51999-02-16 20:27:42 +00001289 . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001290}
1291
Fred Drake37cc0c02000-04-26 18:05:24 +00001292sub do_cmd_seerfc{
1293 local($_) = @_;
1294 my $rfcnum = next_argument();
1295 my $title = next_argument();
1296 my $text = next_argument();
1297 my $url = get_rfc_url($rfcnum);
1298 return '<dl compact class="seerfc">'
1299 . "\n <dt><a href=\"$url\""
1300 . "\n title=\"$title\""
1301 . "\n >RFC $rfcnum, <em>$title</em></a>:"
1302 . "\n <dd>$text\n </dl>"
1303 . $_;
1304}
1305
Fred Drakeef4d1112000-05-09 16:17:51 +00001306sub do_cmd_seeurl{
1307 local($_) = @_;
1308 my $url = next_argument();
1309 my $text = next_argument();
1310 return '<dl compact class="seeurl">'
1311 . "\n <dt><a href=\"$url\""
1312 . "\n class=\"url\">$url</a>"
1313 . "\n <dd>$text\n </dl>"
1314 . $_;
1315}
1316
Fred Drakea0f4c941998-07-24 22:16:04 +00001317sub do_cmd_seetext{
Fred Drake79189b51999-04-28 13:54:30 +00001318 local($_) = @_;
1319 my $content = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +00001320 return '<div class="seetext"><p>' . $content . '</div>' . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001321}
1322
1323
1324#
Fred Drake885215c1998-05-20 21:32:09 +00001325# Definition list support.
1326#
1327
1328sub do_env_definitions{
Fred Drake37cc0c02000-04-26 18:05:24 +00001329 return "<dl class='definitions'>" . @_[0] . "</dl>\n";
Fred Drake885215c1998-05-20 21:32:09 +00001330}
1331
1332sub do_cmd_term{
1333 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001334 my $term = next_argument();
1335 my($name,$aname,$ahref) = new_link_info();
Fred Drake885215c1998-05-20 21:32:09 +00001336 # could easily add an index entry here...
Fred Drake62e43691998-08-10 19:40:44 +00001337 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
Fred Drake885215c1998-05-20 21:32:09 +00001338}
1339
1340
Fred Drake2ff880e1999-02-05 18:31:29 +00001341process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_);
1342code # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001343declaremodule # [] # {} # {}
1344memberline # [] # {}
1345methodline # [] # {} # {}
1346modulesynopsis # {}
Fred Drake557460c1999-03-02 16:05:35 +00001347platform # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001348samp # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001349setindexsubitem # {}
Fred Drakef32834c1999-02-12 22:06:32 +00001350withsubitem # {} # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001351_RAW_ARG_DEFERRED_CMDS_
1352
1353
Fred Drake6659c301998-03-03 22:02:19 +000013541; # This must be the last line