blob: 5c31e804f3d39bfb67837357e9c4a151f41e357e [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 Drakef74e5b71999-04-28 14:58:49 +0000935sub fix_font{
936 # do a little magic on a font name to get the right behavior in the first
937 # column of the output table
938 my $font = @_[0];
939 if ($font eq 'textrm') {
940 $font = '';
941 }
942 elsif ($font eq 'file' || $font eq 'filenq') {
Fred Drakee15956b2000-04-03 04:51:13 +0000943 $font = 'tt class="file"';
944 }
945 elsif ($font eq 'member') {
946 $font = 'tt class="member"';
Fred Drakef74e5b71999-04-28 14:58:49 +0000947 }
Fred Drake7388f732000-06-28 21:06:08 +0000948 elsif ($font eq 'constant') {
949 $font = 'tt class="constant"';
950 }
Fred Drakecb0fc9c2000-08-09 13:45:04 +0000951 elsif ($font eq 'kbd') {
952 $font = 'kbd';
953 }
Fred Drakef74e5b71999-04-28 14:58:49 +0000954 return $font;
955}
956
Fred Drakee15956b2000-04-03 04:51:13 +0000957sub figure_column_alignment{
958 my $a = @_[0];
959 my $mark = substr($a, 0, 1);
960 my $r = '';
961 if ($mark eq 'c')
962 { $r = ' align="center"'; }
963 elsif ($mark eq 'r')
964 { $r = ' align="right"'; }
965 elsif ($mark eq 'l')
966 { $r = ' align="left"'; }
967 elsif ($mark eq 'p')
968 { $r = ' align="left"'; }
969 return $r;
970}
971
Fred Drake6659c301998-03-03 22:02:19 +0000972sub setup_column_alignments{
973 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +0000974 my($s1,$s2,$s3,$s4) = split(/[|]/,$_);
975 my $a1 = figure_column_alignment($s1);
976 my $a2 = figure_column_alignment($s2);
977 my $a3 = figure_column_alignment($s3);
978 my $a4 = figure_column_alignment($s4);
979 $col_aligns[0] = "<td$a1 valign=\"baseline\">";
980 $col_aligns[1] = "<td$a2>";
981 $col_aligns[2] = "<td$a3>";
982 $col_aligns[3] = "<td$a4>";
Fred Drake79189b51999-04-28 13:54:30 +0000983 # return the aligned header start tags
Fred Drakee15956b2000-04-03 04:51:13 +0000984 return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>");
985}
986
987sub get_table_col1_fonts{
988 my $font = $globals{'lineifont'};
989 my ($sfont,$efont) = ('', '');
990 if ($font) {
991 $sfont = "<$font>";
992 $efont = "</$font>";
993 $efont =~ s/ .*>/>/;
994 }
995 return ($font, $sfont, $efont);
Fred Drake6659c301998-03-03 22:02:19 +0000996}
997
998sub do_env_tableii{
999 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001000 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001001 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001002 my $h1 = next_argument();
1003 my $h2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001004 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001005 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001006 my $a1 = $col_aligns[0];
1007 my $a2 = $col_aligns[1];
1008 s/\\lineii</\\lineii[$a1|$a2]</g;
1009 return '<table border align="center" style="border-collapse: collapse">'
Fred Drakef74e5b71999-04-28 14:58:49 +00001010 . "\n <thead>"
Fred Drake3be20742000-08-31 06:22:54 +00001011 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001012 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1013 . "\n $th2<b>$h2</b>\&nbsp;</th>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001014 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001015 . "\n <tbody valign='baseline'>"
1016 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001017 . "\n </tbody>"
1018 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001019}
1020
1021sub do_cmd_lineii{
1022 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001023 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001024 my $c1 = next_argument();
1025 my $c2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001026 s/[\s\n]+//;
Fred Drakee15956b2000-04-03 04:51:13 +00001027 my($font,$sfont,$efont) = get_table_col1_fonts();
1028 $c2 = '&nbsp;' if ($c2 eq '');
1029 my($c1align,$c2align) = split('\|', $aligns);
1030 my $padding = '';
1031 if ($c1align =~ /align="right"/) {
1032 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001033 }
Fred Drakee15956b2000-04-03 04:51:13 +00001034 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
1035 . " $c2align$c2</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001036 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001037}
1038
1039sub do_env_tableiii{
1040 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001041 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001042 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001043 my $h1 = next_argument();
1044 my $h2 = next_argument();
1045 my $h3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001046 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001047 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001048 my $a1 = $col_aligns[0];
1049 my $a2 = $col_aligns[1];
1050 my $a3 = $col_aligns[2];
1051 s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g;
1052 return '<table border align="center" style="border-collapse: collapse">'
Fred Drakef74e5b71999-04-28 14:58:49 +00001053 . "\n <thead>"
1054 . "\n <tr$TABLE_HEADER_BGCOLOR>"
Fred Drakee15956b2000-04-03 04:51:13 +00001055 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1056 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1057 . "\n $th3<b>$h3</b>\&nbsp;</th>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001058 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001059 . "\n <tbody valign='baseline'>"
Fred Drake62e43691998-08-10 19:40:44 +00001060 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001061 . "\n </tbody>"
1062 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001063}
1064
1065sub do_cmd_lineiii{
1066 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001067 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001068 my $c1 = next_argument();
1069 my $c2 = next_argument();
1070 my $c3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001071 s/[\s\n]+//;
Fred Drakee15956b2000-04-03 04:51:13 +00001072 my($font,$sfont,$efont) = get_table_col1_fonts();
1073 $c3 = '&nbsp;' if ($c3 eq '');
1074 my($c1align,$c2align,$c3align) = split('\|', $aligns);
1075 my $padding = '';
1076 if ($c1align =~ /align="right"/) {
1077 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001078 }
Fred Drakee15956b2000-04-03 04:51:13 +00001079 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001080 . " $c2align$c2</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001081 . " $c3align$c3</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001082 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001083}
1084
Fred Drakea0f4c941998-07-24 22:16:04 +00001085sub do_env_tableiv{
1086 local($_) = @_;
1087 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001088 my $font = fix_font(next_argument());
Fred Drakea0f4c941998-07-24 22:16:04 +00001089 my $h1 = next_argument();
1090 my $h2 = next_argument();
1091 my $h3 = next_argument();
1092 my $h4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001093 s/[\s\n]+//;
Fred Drakea0f4c941998-07-24 22:16:04 +00001094 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001095 my $a1 = $col_aligns[0];
1096 my $a2 = $col_aligns[1];
1097 my $a3 = $col_aligns[2];
1098 my $a4 = $col_aligns[3];
1099 s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g;
1100 return '<table border align="center" style="border-collapse: collapse">'
Fred Drakef74e5b71999-04-28 14:58:49 +00001101 . "\n <thead>"
1102 . "\n <tr$TABLE_HEADER_BGCOLOR>"
Fred Drakee15956b2000-04-03 04:51:13 +00001103 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1104 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1105 . "\n $th3<b>$h3</b>\&nbsp;</th>"
1106 . "\n $th4<b>$h4</b>\&nbsp;</th>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001107 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001108 . "\n <tbody valign='baseline'>"
Fred Drake62e43691998-08-10 19:40:44 +00001109 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001110 . "\n </tbody>"
1111 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001112}
1113
Fred Drakea0f4c941998-07-24 22:16:04 +00001114sub do_cmd_lineiv{
Fred Drake6659c301998-03-03 22:02:19 +00001115 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001116 my $aligns = next_optional_argument();
Fred Drakea0f4c941998-07-24 22:16:04 +00001117 my $c1 = next_argument();
1118 my $c2 = next_argument();
1119 my $c3 = next_argument();
1120 my $c4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001121 s/[\s\n]+//;
Fred Drakee15956b2000-04-03 04:51:13 +00001122 my($font,$sfont,$efont) = get_table_col1_fonts();
1123 $c4 = '&nbsp;' if ($c4 eq '');
1124 my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns);
1125 my $padding = '';
1126 if ($c1align =~ /align="right"/) {
1127 $padding = '&nbsp;';
Fred Drakea0f4c941998-07-24 22:16:04 +00001128 }
Fred Drakee15956b2000-04-03 04:51:13 +00001129 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001130 . " $c2align$c2</td>\n"
1131 . " $c3align$c3</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001132 . " $c4align$c4</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001133 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001134}
1135
Fred Drake3be20742000-08-31 06:22:54 +00001136
1137# These can be used to control the title page appearance;
1138# they need a little bit of documentation.
1139#
1140# If $TITLE_PAGE_GRAPHIC is set, it should be the name of a file in the
1141# $ICONSERVER directory, or include path information (other than "./"). The
1142# default image type will be assumed if an extension is not provided.
1143#
1144# If specified, the "title page" will contain two colums: one containing the
1145# title/author/etc., and the other containing the graphic. Use the other
1146# four variables listed here to control specific details of the layout; all
1147# are optional.
1148#
1149# $TITLE_PAGE_GRAPHIC = "my-company-logo";
1150# $TITLE_PAGE_GRAPHIC_COLWIDTH = "30%";
1151# $TITLE_PAGE_GRAPHIC_WIDTH = 150;
1152# $TITLE_PAGE_GRAPHIC_HEIGHT = 150;
1153# $TITLE_PAGE_GRAPHIC_ON_RIGHT = 0;
1154
1155sub make_my_titlepage() {
1156 my $the_title = "";
Fred Drake6659c301998-03-03 22:02:19 +00001157 if ($t_title) {
Fred Drake90fdda51999-02-16 20:27:42 +00001158 $the_title .= "\n<h1>$t_title</h1>";
Fred Drake3be20742000-08-31 06:22:54 +00001159 }
1160 else {
1161 write_warnings("\nThis document has no title.");
1162 }
Fred Drake6659c301998-03-03 22:02:19 +00001163 if ($t_author) {
1164 if ($t_authorURL) {
Fred Drake08932051998-04-17 02:15:42 +00001165 my $href = translate_commands($t_authorURL);
Fred Drake2d1f81e1999-02-09 16:03:31 +00001166 $href = make_named_href('author', $href,
1167 "<b><font size='+2'>$t_author</font></b>");
Fred Drakec9a44381998-03-17 06:29:13 +00001168 $the_title .= "\n<p>$href</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001169 }
1170 else {
Fred Drake2d1f81e1999-02-09 16:03:31 +00001171 $the_title .= ("\n<p><b><font size='+2'>$t_author</font></b></p>");
Fred Drake6659c301998-03-03 22:02:19 +00001172 }
Fred Drake3be20742000-08-31 06:22:54 +00001173 }
1174 else {
1175 write_warnings("\nThere is no author for this document.");
1176 }
Fred Drake6659c301998-03-03 22:02:19 +00001177 if ($t_institute) {
Fred Drake3be20742000-08-31 06:22:54 +00001178 $the_title .= "\n<p>$t_institute</p>";
1179 }
Fred Draked07868a1998-05-14 21:00:28 +00001180 if ($DEVELOPER_ADDRESS) {
Fred Drake3be20742000-08-31 06:22:54 +00001181 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";
1182 }
Fred Drake6659c301998-03-03 22:02:19 +00001183 if ($t_affil) {
Fred Drake3be20742000-08-31 06:22:54 +00001184 $the_title .= "\n<p><i>$t_affil</i></p>";
1185 }
Fred Drake6659c301998-03-03 22:02:19 +00001186 if ($t_date) {
Fred Drakec9a44381998-03-17 06:29:13 +00001187 $the_title .= "\n<p><strong>$t_date</strong>";
Fred Drake6659c301998-03-03 22:02:19 +00001188 if ($PYTHON_VERSION) {
Fred Drake3be20742000-08-31 06:22:54 +00001189 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";
1190 }
Fred Drake6659c301998-03-03 22:02:19 +00001191 $the_title .= "</p>"
1192 }
1193 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +00001194 $the_title .= "\n<p>$t_address</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001195 }
1196 else {
1197 $the_title .= "\n<p>";
1198 }
Fred Drake6659c301998-03-03 22:02:19 +00001199 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +00001200 $the_title .= "\n<p>$t_email</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001201 }
1202 return $the_title;
1203}
1204
1205use File::Basename;
1206
1207sub make_my_titlegraphic() {
1208 my($myname, $mydir, $myext) = fileparse($TITLE_PAGE_GRAPHIC, '\..*');
1209 chop $mydir;
1210 if ($mydir eq '.') {
1211 $mydir = $ICONSERVER;
1212 }
1213 $myext = ".$IMAGE_TYPE"
1214 unless $myext;
1215 my $graphic = "<td class=\"titlegraphic\"";
1216 $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_COLWIDTH\""
1217 if ($TITLE_PAGE_GRAPHIC_COLWIDTH);
1218 $graphic .= "><img";
1219 $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_WIDTH\""
1220 if ($TITLE_PAGE_GRAPHIC_WIDTH);
1221 $graphic .= " height=\"$TITLE_PAGE_GRAPHIC_HEIGHT\""
1222 if ($TITLE_PAGE_GRAPHIC_HEIGHT);
1223 $graphic .= "\n src=\"$mydir/$myname$myext\"></td>\n";
1224 return $graphic;
1225}
1226
1227sub do_cmd_maketitle {
1228 local($_) = @_;
1229 my $the_title = "\n<div class=\"titlepage\">";
1230 if ($TITLE_PAGE_GRAPHIC) {
1231 if ($TITLE_PAGE_GRAPHIC_ON_RIGHT) {
1232 $the_title .= ("\n<table border=\"0\" width=\"100%\">"
1233 . "<tr align=\"right\">\n<td>"
1234 . make_my_titlepage()
1235 . "</td>\n"
1236 . make_my_titlegraphic()
1237 . "</tr>\n</table>");
1238 }
1239 else {
1240 $the_title .= ("\n<table border=\"0\" width=\"100%\"><tr>\n"
1241 . make_my_titlegraphic()
1242 . "<td>"
1243 . make_my_titlepage()
1244 . "</td></tr>\n</table>");
1245 }
1246 }
1247 else {
1248 $the_title .= ("\n<center>"
1249 . make_my_titlepage()
1250 . "\n</center>");
1251 }
1252 $the_title .= "\n</div>";
1253 return $the_title . $_;
Fred Drake90fdda51999-02-16 20:27:42 +00001254 $the_title .= "\n</center></div>";
Fred Drake62e43691998-08-10 19:40:44 +00001255 return $the_title . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +00001256}
1257
1258
Fred Drake885215c1998-05-20 21:32:09 +00001259#
Fred Drakea0f4c941998-07-24 22:16:04 +00001260# Module synopsis support
1261#
1262
1263require SynopsisTable;
1264
Fred Drakef7685d71998-07-25 03:31:46 +00001265sub get_chapter_id(){
1266 my $id = do_cmd_thechapter('');
Fred Drake45f26011998-08-04 22:07:18 +00001267 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
1268 $id =~ s/\.//;
Fred Drakef7685d71998-07-25 03:31:46 +00001269 return $id;
Fred Drakea0f4c941998-07-24 22:16:04 +00001270}
1271
Fred Drakef7685d71998-07-25 03:31:46 +00001272%ModuleSynopses = ('chapter' => 'SynopsisTable instance');
1273
1274sub get_synopsis_table($){
1275 my($chap) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001276 my $st = $ModuleSynopses{$chap};
Fred Drakef7685d71998-07-25 03:31:46 +00001277 my $key;
1278 foreach $key (keys %ModuleSynopses) {
1279 if ($key eq $chap) {
1280 return $ModuleSynopses{$chap};
1281 }
Fred Drakea0f4c941998-07-24 22:16:04 +00001282 }
Fred Drakef7685d71998-07-25 03:31:46 +00001283 $st = SynopsisTable->new();
1284 $ModuleSynopses{$chap} = $st;
Fred Drakea0f4c941998-07-24 22:16:04 +00001285 return $st;
1286}
1287
Fred Drake62e43691998-08-10 19:40:44 +00001288sub do_cmd_moduleauthor{
1289 local($_) = @_;
1290 next_argument();
1291 next_argument();
1292 return $_;
1293}
1294
1295sub do_cmd_sectionauthor{
1296 local($_) = @_;
1297 next_argument();
1298 next_argument();
1299 return $_;
1300}
1301
Fred Drakea0f4c941998-07-24 22:16:04 +00001302sub do_cmd_declaremodule{
1303 local($_) = @_;
1304 my $key = next_optional_argument();
1305 my $type = next_argument();
1306 my $name = next_argument();
1307 my $st = get_synopsis_table(get_chapter_id());
1308 #
1309 $key = $name unless $key;
1310 $type = 'built-in' if $type eq 'builtin';
1311 $st->declare($name, $key, $type);
1312 define_module($type, $name);
Fred Drake62e43691998-08-10 19:40:44 +00001313 return anchor_label("module-$key",$CURRENT_FILE,$_)
Fred Drakea0f4c941998-07-24 22:16:04 +00001314}
1315
1316sub do_cmd_modulesynopsis{
1317 local($_) = @_;
1318 my $st = get_synopsis_table(get_chapter_id());
Fred Drake1cc58991999-04-13 22:08:59 +00001319 $st->set_synopsis($THIS_MODULE, translate_commands(next_argument()));
Fred Drake62e43691998-08-10 19:40:44 +00001320 return $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001321}
1322
1323sub do_cmd_localmoduletable{
1324 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001325 my $chap = get_chapter_id();
Fred Drake557460c1999-03-02 16:05:35 +00001326 return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001327}
1328
1329sub process_all_localmoduletables{
Fred Drake557460c1999-03-02 16:05:35 +00001330 while (/<tex2html-localmoduletable><(\d+)>/) {
Fred Drakef7685d71998-07-25 03:31:46 +00001331 my $match = $&;
Fred Drakea0f4c941998-07-24 22:16:04 +00001332 my $chap = $1;
1333 my $st = get_synopsis_table($chap);
1334 my $data = $st->tohtml();
Fred Drakef7685d71998-07-25 03:31:46 +00001335 s/$match/$data/;
Fred Drakea0f4c941998-07-24 22:16:04 +00001336 }
1337}
Fred Drake557460c1999-03-02 16:05:35 +00001338sub process_python_state{
1339 process_all_localmoduletables();
Fred Drake557460c1999-03-02 16:05:35 +00001340}
Fred Drakea0f4c941998-07-24 22:16:04 +00001341
1342
1343#
1344# "See also:" -- references placed at the end of a \section
1345#
1346
1347sub do_env_seealso{
Fred Drakee15956b2000-04-03 04:51:13 +00001348 return "<div class='seealso'>\n "
1349 . "<p class='heading'><b>See Also:</b></p>\n"
Fred Drake90fdda51999-02-16 20:27:42 +00001350 . @_[0]
1351 . '</div>';
Fred Drakea0f4c941998-07-24 22:16:04 +00001352}
1353
1354sub do_cmd_seemodule{
1355 # Insert the right magic to jump to the module definition. This should
1356 # work most of the time, at least for repeat builds....
1357 local($_) = @_;
1358 my $key = next_optional_argument();
1359 my $module = next_argument();
1360 my $text = next_argument();
Fred Drake84bd6f31999-05-11 15:42:51 +00001361 my $period = '.';
Fred Drakea0f4c941998-07-24 22:16:04 +00001362 $key = $module
1363 unless $key;
Fred Drake84bd6f31999-05-11 15:42:51 +00001364 if ($text =~ /\.$/) {
1365 $period = '';
1366 }
Fred Drakee15956b2000-04-03 04:51:13 +00001367 return '<dl compact class="seemodule">'
1368 . "\n <dt>Module <b><tt class='module'><a href='module-$key.html'>"
Fred Drake84bd6f31999-05-11 15:42:51 +00001369 . "$module</a></tt>:</b>"
1370 . "\n <dd>$text$period\n </dl>"
Fred Drake90fdda51999-02-16 20:27:42 +00001371 . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001372}
1373
Fred Drake37cc0c02000-04-26 18:05:24 +00001374sub do_cmd_seerfc{
1375 local($_) = @_;
1376 my $rfcnum = next_argument();
1377 my $title = next_argument();
1378 my $text = next_argument();
1379 my $url = get_rfc_url($rfcnum);
1380 return '<dl compact class="seerfc">'
1381 . "\n <dt><a href=\"$url\""
1382 . "\n title=\"$title\""
1383 . "\n >RFC $rfcnum, <em>$title</em></a>:"
1384 . "\n <dd>$text\n </dl>"
1385 . $_;
1386}
1387
Fred Drakeef4d1112000-05-09 16:17:51 +00001388sub do_cmd_seeurl{
1389 local($_) = @_;
1390 my $url = next_argument();
1391 my $text = next_argument();
1392 return '<dl compact class="seeurl">'
1393 . "\n <dt><a href=\"$url\""
1394 . "\n class=\"url\">$url</a>"
1395 . "\n <dd>$text\n </dl>"
1396 . $_;
1397}
1398
Fred Drakea0f4c941998-07-24 22:16:04 +00001399sub do_cmd_seetext{
Fred Drake79189b51999-04-28 13:54:30 +00001400 local($_) = @_;
1401 my $content = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +00001402 return '<div class="seetext"><p>' . $content . '</div>' . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001403}
1404
1405
1406#
Fred Drake885215c1998-05-20 21:32:09 +00001407# Definition list support.
1408#
1409
1410sub do_env_definitions{
Fred Drake37cc0c02000-04-26 18:05:24 +00001411 return "<dl class='definitions'>" . @_[0] . "</dl>\n";
Fred Drake885215c1998-05-20 21:32:09 +00001412}
1413
1414sub do_cmd_term{
1415 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001416 my $term = next_argument();
1417 my($name,$aname,$ahref) = new_link_info();
Fred Drake885215c1998-05-20 21:32:09 +00001418 # could easily add an index entry here...
Fred Drake62e43691998-08-10 19:40:44 +00001419 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
Fred Drake885215c1998-05-20 21:32:09 +00001420}
1421
1422
Fred Drake2ff880e1999-02-05 18:31:29 +00001423process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_);
1424code # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001425declaremodule # [] # {} # {}
1426memberline # [] # {}
1427methodline # [] # {} # {}
1428modulesynopsis # {}
Fred Drake557460c1999-03-02 16:05:35 +00001429platform # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001430samp # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001431setindexsubitem # {}
Fred Drakef32834c1999-02-12 22:06:32 +00001432withsubitem # {} # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001433_RAW_ARG_DEFERRED_CMDS_
1434
1435
Fred Drake6659c301998-03-03 22:02:19 +000014361; # This must be the last line