blob: 6dfa018896ee2fc0302e904732be1407fe1f1765 [file] [log] [blame]
Fred Drake6659c301998-03-03 22:02:19 +00001# python.perl by Fred L. Drake, Jr. <fdrake@acm.org> -*- perl -*-
2#
3# Heavily based on Guido van Rossum's myformat.perl (now obsolete).
4#
5# Extension to LaTeX2HTML for documents using myformat.sty.
6# Subroutines of the form do_cmd_<name> here define translations
7# for LaTeX commands \<name> defined in the corresponding .sty file.
8
9package main;
10
11
Fred Drake08932051998-04-17 02:15:42 +000012sub next_argument{
Fred Drakeccc62721999-01-05 22:16:29 +000013 my $param;
14 $param = missing_braces()
15 unless ((s/$next_pair_pr_rx/$param=$2;''/eo)
16 ||(s/$next_pair_rx/$param=$2;''/eo));
Fred Drake62e43691998-08-10 19:40:44 +000017 return $param;
Fred Drake08932051998-04-17 02:15:42 +000018}
19
20sub next_optional_argument{
21 my($param,$rx) = ('', "^\\s*(\\[([^]]*)\\])?");
Fred Drake5ccf3301998-04-17 20:04:09 +000022 s/$rx/$param=$2;''/eo;
Fred Drake62e43691998-08-10 19:40:44 +000023 return $param;
Fred Drake08932051998-04-17 02:15:42 +000024}
25
Fred Drakee16f6791998-05-15 04:28:37 +000026
27# This is a fairly simple hack; it supports \let when it is used to create
28# (or redefine) a macro to exactly be some other macro: \let\newname=\oldname.
Fred Drake5b73cdf1998-05-15 16:59:38 +000029# Many possible uses of \let aren't supported or aren't supported correctly.
Fred Drakee16f6791998-05-15 04:28:37 +000030#
31sub do_cmd_let{
32 local($_) = @_;
33 my $matched = 0;
Fred Drake7a4ad0f1998-05-15 13:45:54 +000034 s/[\\]([a-zA-Z]+)\s*(=\s*)?[\\]([a-zA-Z]*)/$matched=1; ''/e;
Fred Drakee16f6791998-05-15 04:28:37 +000035 if ($matched) {
36 my($new, $old) = ($1, $3);
37 eval "sub do_cmd_$new { do_cmd_$old" . '(@_); }';
38 print "\ndefining handler for \\$new using \\$old\n";
39 }
Fred Drake7a4ad0f1998-05-15 13:45:54 +000040 else {
41 s/[\\]([a-zA-Z]+)\s*(=\s*)?([^\\])/$matched=1; ''/es;
42 if ($matched) {
43 my($new, $char) = ($1, $3);
44 eval "sub do_cmd_$new { \"\\$char\" . \@_[0]; }";
45 print "\ndefining handler for \\$new to insert '$char'\n";
46 }
47 else {
48 write_warnings("Could not interpret \\let construct...");
49 }
50 }
Fred Drake62e43691998-08-10 19:40:44 +000051 return $_;
Fred Drakee16f6791998-05-15 04:28:37 +000052}
53
54
Fred Drake6659c301998-03-03 22:02:19 +000055# words typeset in a special way (not in HTML though)
56
57sub do_cmd_ABC{ 'ABC' . @_[0]; }
58sub do_cmd_UNIX{ 'Unix'. @_[0]; }
59sub do_cmd_ASCII{ 'ASCII' . @_[0]; }
60sub do_cmd_POSIX{ 'POSIX' . @_[0]; }
61sub do_cmd_C{ 'C' . @_[0]; }
62sub do_cmd_Cpp{ 'C++' . @_[0]; }
63sub do_cmd_EOF{ 'EOF' . @_[0]; }
Fred Drakee15956b2000-04-03 04:51:13 +000064sub do_cmd_NULL{ '<tt class="constant">NULL</tt>' . @_[0]; }
Fred Drake6659c301998-03-03 22:02:19 +000065
66sub do_cmd_e{ '&#92;' . @_[0]; }
67
Fred Draked07868a1998-05-14 21:00:28 +000068$DEVELOPER_ADDRESS = '';
Fred Drake6659c301998-03-03 22:02:19 +000069$PYTHON_VERSION = '';
70
71sub do_cmd_version{ $PYTHON_VERSION . @_[0]; }
72sub do_cmd_release{
73 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +000074 $PYTHON_VERSION = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000075 return $_;
Fred Drake6659c301998-03-03 22:02:19 +000076}
77
78sub do_cmd_authoraddress{
79 local($_) = @_;
Fred Draked07868a1998-05-14 21:00:28 +000080 $DEVELOPER_ADDRESS = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000081 return $_;
Fred Drake6659c301998-03-03 22:02:19 +000082}
83
Fred Drakee16f6791998-05-15 04:28:37 +000084#sub do_cmd_developer{ do_cmd_author(@_[0]); }
85#sub do_cmd_developers{ do_cmd_author(@_[0]); }
86#sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); }
Fred Draked07868a1998-05-14 21:00:28 +000087
Fred Drake6659c301998-03-03 22:02:19 +000088sub do_cmd_hackscore{
89 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +000090 next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000091 return '_' . $_;
Fred Drake6659c301998-03-03 22:02:19 +000092}
93
Fred Drake08932051998-04-17 02:15:42 +000094sub use_wrappers{
95 local($_,$before,$after) = @_;
96 my $stuff = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000097 return $before . $stuff . $after . $_;
Fred Drake08932051998-04-17 02:15:42 +000098}
99
Fred Drake62e43691998-08-10 19:40:44 +0000100sub use_sans_serif{
Fred Drakeccc62721999-01-05 22:16:29 +0000101 return use_wrappers(@_[0], '<font face="sans-serif">', '</font>');
Fred Drake62e43691998-08-10 19:40:44 +0000102}
103sub use_italics{
104 return use_wrappers(@_[0], '<i>', '</i>');
105}
Fred Drake08932051998-04-17 02:15:42 +0000106
Fred Drake6659c301998-03-03 22:02:19 +0000107sub do_cmd_optional{
Fred Drake62e43691998-08-10 19:40:44 +0000108 return use_wrappers(@_[0], "</var><big>\[</big><var>",
109 "</var><big>\]</big><var>");
Fred Drake6659c301998-03-03 22:02:19 +0000110}
111
Fred Drakec9a44381998-03-17 06:29:13 +0000112# Logical formatting (some based on texinfo), needs to be converted to
113# minimalist HTML. The "minimalist" is primarily to reduce the size of
114# output files for users that read them over the network rather than
115# from local repositories.
Fred Drake6659c301998-03-03 22:02:19 +0000116
Fred Drake2cafcbb1999-03-25 16:57:04 +0000117# \file and \samp are at the end of this file since they screw up fontlock.
118
Fred Drake2ff880e1999-02-05 18:31:29 +0000119sub do_cmd_pytype{ return @_[0]; }
120sub do_cmd_makevar{ return @_[0]; }
Fred Drake90fdda51999-02-16 20:27:42 +0000121sub do_cmd_code{
Fred Drakee15956b2000-04-03 04:51:13 +0000122 return use_wrappers(@_[0], '<code>', '</code>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000123sub do_cmd_module{
Fred Drakee15956b2000-04-03 04:51:13 +0000124 return use_wrappers(@_[0], '<tt class="module">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000125sub do_cmd_keyword{
Fred Drakee15956b2000-04-03 04:51:13 +0000126 return use_wrappers(@_[0], '<tt class="keyword">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000127sub do_cmd_exception{
Fred Drakee15956b2000-04-03 04:51:13 +0000128 return use_wrappers(@_[0], '<tt class="exception">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000129sub do_cmd_class{
Fred Drakee15956b2000-04-03 04:51:13 +0000130 return use_wrappers(@_[0], '<tt class="class">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000131sub do_cmd_function{
Fred Drakee15956b2000-04-03 04:51:13 +0000132 return use_wrappers(@_[0], '<tt class="function">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000133sub do_cmd_constant{
Fred Drakee15956b2000-04-03 04:51:13 +0000134 return use_wrappers(@_[0], '<tt class="constant">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000135sub do_cmd_member{
Fred Drakee15956b2000-04-03 04:51:13 +0000136 return use_wrappers(@_[0], '<tt class="member">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000137sub do_cmd_method{
Fred Drakee15956b2000-04-03 04:51:13 +0000138 return use_wrappers(@_[0], '<tt class="method">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000139sub do_cmd_cfunction{
Fred Drakee15956b2000-04-03 04:51:13 +0000140 return use_wrappers(@_[0], '<tt class="cfunction">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000141sub do_cmd_cdata{
Fred Drakee15956b2000-04-03 04:51:13 +0000142 return use_wrappers(@_[0], '<tt class="cdata">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000143sub do_cmd_ctype{
Fred Drakee15956b2000-04-03 04:51:13 +0000144 return use_wrappers(@_[0], '<tt class="ctype">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000145sub do_cmd_regexp{
Fred Drakee15956b2000-04-03 04:51:13 +0000146 return use_wrappers(@_[0], '<tt class="regexp">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000147sub do_cmd_character{
Fred Drakee15956b2000-04-03 04:51:13 +0000148 return use_wrappers(@_[0], '"<tt class="character">', '</tt>"'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000149sub do_cmd_program{
Fred Drakee15956b2000-04-03 04:51:13 +0000150 return use_wrappers(@_[0], '<b class="program">', '</b>'); }
Fred Drakec9f5fe01999-11-09 16:59:42 +0000151sub do_cmd_programopt{
152 return use_wrappers(@_[0], '<b class="programopt">', '</b>'); }
Fred Drake0cd60212000-04-11 18:46:59 +0000153sub do_cmd_longprogramopt{
154 # note that the --- will be later converted to -- by LaTeX2HTML
155 return use_wrappers(@_[0], '<b class="programopt">---', '</b>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000156sub do_cmd_email{
Fred Drakee15956b2000-04-03 04:51:13 +0000157 return use_wrappers(@_[0], '<span class="email">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000158sub do_cmd_mimetype{
Fred Drakee15956b2000-04-03 04:51:13 +0000159 return use_wrappers(@_[0], '<span class="mimetype">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000160sub do_cmd_var{
161 return use_wrappers(@_[0], "<var>", "</var>"); }
162sub do_cmd_dfn{
Fred Drakee15956b2000-04-03 04:51:13 +0000163 return use_wrappers(@_[0], '<i class="dfn">', '</i>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000164sub do_cmd_emph{
165 return use_italics(@_); }
166sub do_cmd_file{
Fred Drakee15956b2000-04-03 04:51:13 +0000167 return use_wrappers(@_[0],
168 '<font class="file" face="sans-serif">',
169 '</font>'); }
Fred Drakef74e5b71999-04-28 14:58:49 +0000170sub do_cmd_filenq{
Fred Drakee15956b2000-04-03 04:51:13 +0000171 return do_cmd_file(@_[0]); }
Fred Drake90fdda51999-02-16 20:27:42 +0000172sub do_cmd_samp{
Fred Drakee15956b2000-04-03 04:51:13 +0000173 return use_wrappers(@_[0], '"<tt class="samp">', '</tt>"'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000174sub do_cmd_kbd{
175 return use_wrappers(@_[0], '<kbd>', '</kbd>'); }
176sub do_cmd_strong{
177 return use_wrappers(@_[0], '<b>', '</b>'); }
Fred Drake2cafcbb1999-03-25 16:57:04 +0000178sub do_cmd_textbf{
179 return use_wrappers(@_[0], '<b>', '</b>'); }
180sub do_cmd_textit{
181 return use_wrappers(@_[0], '<i>', '</i>'); }
182
Fred Drakec9a44381998-03-17 06:29:13 +0000183
Fred Drake25817041999-01-13 17:06:34 +0000184sub do_cmd_refmodule{
185 # Insert the right magic to jump to the module definition.
186 local($_) = @_;
187 my $key = next_optional_argument();
188 my $module = next_argument();
189 $key = $module
190 unless $key;
Fred Drakee15956b2000-04-03 04:51:13 +0000191 return "<tt class='module'><a href='module-$key.html'>$module</a></tt>"
192 . $_;
Fred Drake25817041999-01-13 17:06:34 +0000193}
194
Fred Drake1a7af391998-04-01 22:44:56 +0000195sub do_cmd_newsgroup{
196 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000197 my $newsgroup = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000198 my $stuff = "<span class='newsgroup'><a href='news:$newsgroup'>"
199 . "$newsgroup</a></span>";
Fred Drake62e43691998-08-10 19:40:44 +0000200 return $stuff . $_;
Fred Drake1a7af391998-04-01 22:44:56 +0000201}
Fred Drakefc16e781998-03-12 21:03:26 +0000202
203sub do_cmd_envvar{
204 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000205 my $envvar = next_argument();
206 my($name,$aname,$ahref) = new_link_info();
Fred Drake166abba1998-04-08 23:10:54 +0000207 # The <tt> here is really to keep buildindex.py from making
208 # the variable name case-insensitive.
209 add_index_entry("environment variables!$envvar@<tt>\$$envvar</tt>",
210 $ahref);
Fred Drake42b31a51998-03-27 05:16:10 +0000211 add_index_entry("$envvar@\$$envvar", $ahref);
Fred Drakee15956b2000-04-03 04:51:13 +0000212 $aname =~ s/<a/<a class="envvar"/;
Fred Draked37cecf1999-09-23 16:45:08 +0000213 return "$aname\$$envvar</a>" . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000214}
215
Fred Drake6659c301998-03-03 22:02:19 +0000216sub do_cmd_url{
217 # use the URL as both text and hyperlink
218 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000219 my $url = next_argument();
Fred Drake6659c301998-03-03 22:02:19 +0000220 $url =~ s/~/&#126;/g;
Fred Drakee15956b2000-04-03 04:51:13 +0000221 return "<a class=\"url\" href=\"$url\">$url</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000222}
223
224sub do_cmd_manpage{
225 # two parameters: \manpage{name}{section}
226 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000227 my $page = next_argument();
228 my $section = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000229 return "<span class='manpage'><i>$page</i>($section)</span>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000230}
231
Fred Drake37cc0c02000-04-26 18:05:24 +0000232sub get_rfc_url{
233 my $rfcnum = sprintf("%04d", @_[0]);
234 return "http://www.ietf.org/rfc/rfc$rfcnum.txt";
235}
236
Fred Drake6659c301998-03-03 22:02:19 +0000237sub do_cmd_rfc{
238 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000239 my $rfcnumber = next_argument();
240 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drake37cc0c02000-04-26 18:05:24 +0000241 my $href = get_rfc_url($rfcnumber);
Fred Drake6659c301998-03-03 22:02:19 +0000242 # Save the reference
Fred Drake08932051998-04-17 02:15:42 +0000243 my $nstr = gen_index_id("RFC!RFC $rfcnumber", '');
Fred Drakeccc62721999-01-05 22:16:29 +0000244 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
Fred Drakee15956b2000-04-03 04:51:13 +0000245 return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">RFC $rfcnumber</a>"
Fred Draked52879c1999-09-22 19:58:51 +0000246 . $_);
Fred Drake6659c301998-03-03 22:02:19 +0000247}
248
Fred Drakec9f5fe01999-11-09 16:59:42 +0000249sub do_cmd_citetitle{
250 local($_) = @_;
251 my $url = next_optional_argument();
252 my $title = next_argument();
253 my $repl = '';
254 if ($url) {
255 $repl = ("<em class='citetitle'><a\n"
256 . " href='$url'\n"
257 . " title='$title'\n"
258 . " >$title</a></em>");
259 }
260 else {
261 $repl = "<em class='citetitle'\n >$title</em>";
262 }
263 return $repl . $_;
264}
265
Fred Drake6659c301998-03-03 22:02:19 +0000266sub do_cmd_deprecated{
267 # two parameters: \deprecated{version}{whattodo}
268 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000269 my $release = next_argument();
270 my $reason = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000271 return "<b>Deprecated since release $release.</b>\n$reason<p>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000272}
273
Fred Drake897d12b1998-07-27 20:33:17 +0000274sub do_cmd_versionadded{
275 # one parameter: \versionadded{version}
276 local($_) = @_;
277 my $release = next_argument();
Fred Drake2116d981999-02-02 18:02:48 +0000278 return "\nNew in version $release.\n" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000279}
280
281sub do_cmd_versionchanged{
282 # one parameter: \versionchanged{version}
283 local($_) = @_;
Fred Drake52e76842000-05-02 17:37:42 +0000284 my $explanation = next_optional_argument();
Fred Drake897d12b1998-07-27 20:33:17 +0000285 my $release = next_argument();
Fred Drake52e76842000-05-02 17:37:42 +0000286 my $text = "\nChanged in version $release.\n";
287 if ($release) {
288 $text = "\nChanged in version $release:\n$explanation.\n";
289 }
290 return $text . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000291}
292
Fred Drake557460c1999-03-02 16:05:35 +0000293#
Fred Drake2cafcbb1999-03-25 16:57:04 +0000294# These function handle platform dependency tracking.
Fred Drake557460c1999-03-02 16:05:35 +0000295#
296sub do_cmd_platform{
297 local($_) = @_;
298 my $platform = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000299 $ModulePlatforms{"<tt class='module'>$THIS_MODULE</tt>"} = $platform;
Fred Drake557460c1999-03-02 16:05:35 +0000300 $platform = "Macintosh"
Fred Drake085b8121999-04-21 14:00:29 +0000301 if $platform eq 'Mac';
Fred Drakee15956b2000-04-03 04:51:13 +0000302 return "\n<p class='availability'>Availability: <span"
303 . "\n class='platform'>$platform</span>.</p>\n" . $_;
Fred Drake557460c1999-03-02 16:05:35 +0000304}
305
Fred Drake557460c1999-03-02 16:05:35 +0000306$IGNORE_PLATFORM_ANNOTATION = '';
307sub do_cmd_ignorePlatformAnnotation{
308 local($_) = @_;
309 $IGNORE_PLATFORM_ANNOTATION = next_argument();
310 return $_;
311}
312
Fred Drake6659c301998-03-03 22:02:19 +0000313
314# index commands
315
316$INDEX_SUBITEM = "";
317
318sub get_indexsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000319 return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
Fred Drake6659c301998-03-03 22:02:19 +0000320}
321
322sub do_cmd_setindexsubitem{
323 local($_) = @_;
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000324 $INDEX_SUBITEM = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000325 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000326}
327
Fred Drakefc16e781998-03-12 21:03:26 +0000328sub do_cmd_withsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000329 # We can't really do the right thing, because LaTeX2HTML doesn't
Fred Drakefc16e781998-03-12 21:03:26 +0000330 # do things in the right order, but we need to at least strip this stuff
331 # out, and leave anything that the second argument expanded out to.
332 #
333 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000334 my $oldsubitem = $INDEX_SUBITEM;
335 $INDEX_SUBITEM = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000336 my $stuff = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000337 my $br_id = ++$globals{'max_id'};
338 my $marker = "$O$br_id$C";
Fred Drake7d45f6d1999-01-05 14:39:27 +0000339 return
340 $stuff
Fred Drakeccc62721999-01-05 22:16:29 +0000341 . "\\setindexsubitem$marker$oldsubitem$marker"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000342 . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000343}
344
Fred Drake08932051998-04-17 02:15:42 +0000345# This is the prologue macro which is required to start writing the
Fred Drakeab032151999-05-13 18:36:54 +0000346# mod\jobname.idx file; we can just ignore it. (Defining this suppresses
347# a warning that \makemodindex is unknown.)
Fred Drake08932051998-04-17 02:15:42 +0000348#
Fred Drake62e43691998-08-10 19:40:44 +0000349sub do_cmd_makemodindex{ return @_[0]; }
Fred Drakefc16e781998-03-12 21:03:26 +0000350
Fred Drake42b31a51998-03-27 05:16:10 +0000351# We're in the document subdirectory when this happens!
Fred Drake166abba1998-04-08 23:10:54 +0000352#
Fred Drake08932051998-04-17 02:15:42 +0000353open(IDXFILE, '>index.dat') || die "\n$!\n";
354open(INTLABELS, '>intlabels.pl') || die "\n$!\n";
Fred Drake166abba1998-04-08 23:10:54 +0000355print INTLABELS "%internal_labels = ();\n";
356print INTLABELS "1; # hack in case there are no entries\n\n";
357
358# Using \0 for this is bad because we can't use common tools to work with the
359# resulting files. Things like grep can be useful with this stuff!
360#
361$IDXFILE_FIELD_SEP = "\1";
362
Fred Drakeccc62721999-01-05 22:16:29 +0000363sub write_idxfile{
364 my ($ahref, $str) = @_;
365 print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n";
Fred Drake42b31a51998-03-27 05:16:10 +0000366}
367
Fred Drake42b31a51998-03-27 05:16:10 +0000368
369sub gen_link{
370 my($node,$target) = @_;
371 print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
Fred Drakee15956b2000-04-03 04:51:13 +0000372 return "<a href='$node#$target'>";
Fred Drake42b31a51998-03-27 05:16:10 +0000373}
374
Fred Drake42b31a51998-03-27 05:16:10 +0000375sub add_index_entry{
376 # add an entry to the index structures; ignore the return value
377 my($str,$ahref) = @_;
378 $str = gen_index_id($str, '');
379 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000380 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000381}
382
Fred Drakeccc62721999-01-05 22:16:29 +0000383sub new_link_info{
384 my $name = "l2h-" . ++$globals{'max_id'};
Fred Drakee15956b2000-04-03 04:51:13 +0000385 my $aname = "<a name='$name'>";
Fred Drake42b31a51998-03-27 05:16:10 +0000386 my $ahref = gen_link($CURRENT_FILE, $name);
387 return ($name, $aname, $ahref);
388}
389
Fred Drakeab032151999-05-13 18:36:54 +0000390$IndexMacroPattern = '';
391sub define_indexing_macro{
392 my $count = @_;
393 my $i = 0;
394 for (; $i < $count; ++$i) {
395 my $name = @_[$i];
396 my $cmd = "idx_cmd_$name";
397 die "\nNo function $cmd() defined!\n"
398 if (!defined &$cmd);
399 eval ("sub do_cmd_$name { return process_index_macros("
400 . "\@_[0], '$name'); }");
401 if (length($IndexMacroPattern) == 0) {
402 $IndexMacroPattern = "$name";
403 }
404 else {
405 $IndexMacroPattern .= "|$name";
406 }
407 }
408}
409
410$DEBUG_INDEXING = 0;
411sub process_index_macros{
Fred Drake42b31a51998-03-27 05:16:10 +0000412 local($_) = @_;
Fred Drakeab032151999-05-13 18:36:54 +0000413 my $cmdname = @_[1]; # This is what triggered us in the first place;
414 # we know it's real, so just process it.
Fred Drakeccc62721999-01-05 22:16:29 +0000415 my($name,$aname,$ahref) = new_link_info();
Fred Drakeab032151999-05-13 18:36:54 +0000416 my $cmd = "idx_cmd_$cmdname";
417 print "\nIndexing: \\$cmdname"
418 if $DEBUG_INDEXING;
419 &$cmd($ahref); # modifies $_ and adds index entries
420 while (/^[\s\n]*\\($IndexMacroPattern)</) {
421 $cmdname = "$1";
422 print " \\$cmdname"
423 if $DEBUG_INDEXING;
424 $cmd = "idx_cmd_$cmdname";
425 if (!defined &$cmd) {
426 last;
427 }
428 else {
429 s/^[\s\n]*\\$cmdname//;
430 &$cmd($ahref);
431 }
432 }
Fred Drake62e43691998-08-10 19:40:44 +0000433 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake42b31a51998-03-27 05:16:10 +0000434}
435
Fred Drakeab032151999-05-13 18:36:54 +0000436define_indexing_macro('index');
437sub idx_cmd_index{
Fred Drakeccc62721999-01-05 22:16:29 +0000438 my $str = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000439 add_index_entry("$str", @_[0]);
Fred Drake2e7edb81998-05-11 18:31:17 +0000440}
441
Fred Drakeab032151999-05-13 18:36:54 +0000442define_indexing_macro('kwindex');
443sub idx_cmd_kwindex{
444 my $str = next_argument();
445 add_index_entry("<tt>$str</tt>!keyword", @_[0]);
446 add_index_entry("keyword!<tt>$str</tt>", @_[0]);
447}
448
449define_indexing_macro('indexii');
450sub idx_cmd_indexii{
Fred Drakeccc62721999-01-05 22:16:29 +0000451 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000452 my $str2 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000453 add_index_entry("$str1!$str2", @_[0]);
454 add_index_entry("$str2!$str1", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000455}
456
Fred Drakeab032151999-05-13 18:36:54 +0000457define_indexing_macro('indexiii');
458sub idx_cmd_indexiii{
Fred Drakeccc62721999-01-05 22:16:29 +0000459 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000460 my $str2 = next_argument();
461 my $str3 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000462 add_index_entry("$str1!$str2 $str3", @_[0]);
463 add_index_entry("$str2!$str3, $str1", @_[0]);
464 add_index_entry("$str3!$str1 $str2", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000465}
466
Fred Drakeab032151999-05-13 18:36:54 +0000467define_indexing_macro('indexiv');
468sub idx_cmd_indexiv{
Fred Drakeccc62721999-01-05 22:16:29 +0000469 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000470 my $str2 = next_argument();
471 my $str3 = next_argument();
472 my $str4 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000473 add_index_entry("$str1!$str2 $str3 $str4", @_[0]);
474 add_index_entry("$str2!$str3 $str4, $str1", @_[0]);
475 add_index_entry("$str3!$str4, $str1 $str2", @_[0]);
476 add_index_entry("$str4!$$str1 $str2 $str3", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000477}
478
Fred Drakeab032151999-05-13 18:36:54 +0000479define_indexing_macro('ttindex');
480sub idx_cmd_ttindex{
Fred Drakeccc62721999-01-05 22:16:29 +0000481 my $str = next_argument();
482 my $entry = $str . get_indexsubitem();
Fred Drakeab032151999-05-13 18:36:54 +0000483 add_index_entry($entry, @_[0]);
Fred Drakec9a44381998-03-17 06:29:13 +0000484}
Fred Drake6659c301998-03-03 22:02:19 +0000485
486sub my_typed_index_helper{
Fred Drakeab032151999-05-13 18:36:54 +0000487 my($word,$ahref) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000488 my $str = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000489 add_index_entry("$str $word", $ahref);
490 add_index_entry("$word!$str", $ahref);
Fred Drake6659c301998-03-03 22:02:19 +0000491}
492
Fred Drakeab032151999-05-13 18:36:54 +0000493define_indexing_macro('stindex', 'opindex', 'exindex', 'obindex');
494sub idx_cmd_stindex{ my_typed_index_helper('statement', @_[0]); }
495sub idx_cmd_opindex{ my_typed_index_helper('operator', @_[0]); }
496sub idx_cmd_exindex{ my_typed_index_helper('exception', @_[0]); }
497sub idx_cmd_obindex{ my_typed_index_helper('object', @_[0]); }
Fred Drake6659c301998-03-03 22:02:19 +0000498
Fred Drakeab032151999-05-13 18:36:54 +0000499define_indexing_macro('bifuncindex');
500sub idx_cmd_bifuncindex{
Fred Drakeccc62721999-01-05 22:16:29 +0000501 my $str = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000502 add_index_entry("<tt class='function'>$str()</tt> (built-in function)",
503 @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000504}
505
506
Fred Drake6659c301998-03-03 22:02:19 +0000507sub make_mod_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000508 my($str,$define) = @_;
509 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000510 # equivalent of add_index_entry() using $define instead of ''
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000511 $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/
512 if ($define eq 'DEF');
Fred Drake42b31a51998-03-27 05:16:10 +0000513 $str = gen_index_id($str, $define);
514 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000515 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000516
Fred Drakec9a44381998-03-17 06:29:13 +0000517 if ($define eq 'DEF') {
Fred Drake42b31a51998-03-27 05:16:10 +0000518 # add to the module index
Fred Drakee15956b2000-04-03 04:51:13 +0000519 $str =~ /(<tt.*<\/tt>)/;
520 my $nstr = $1;
Fred Drake42b31a51998-03-27 05:16:10 +0000521 $Modules{$nstr} .= $ahref;
Fred Drake6659c301998-03-03 22:02:19 +0000522 }
Fred Drake62e43691998-08-10 19:40:44 +0000523 return "$aname$anchor_invisible_mark</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000524}
525
Fred Drake557460c1999-03-02 16:05:35 +0000526
Fred Drakec9a44381998-03-17 06:29:13 +0000527$THIS_MODULE = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000528$THIS_CLASS = '';
Fred Drakec9a44381998-03-17 06:29:13 +0000529
Fred Drakea0f4c941998-07-24 22:16:04 +0000530sub define_module{
531 my($word,$name) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000532 my $section_tag = join('', @curr_sec_id);
Fred Drake3e4c6141999-05-17 15:00:32 +0000533 if ($word ne "built-in" && $word ne "extension"
534 && $word ne "standard" && $word ne "") {
535 write_warnings("Bad module type '$word'"
536 . " for \\declaremodule (module $name)");
537 $word = "";
538 }
Fred Drake6659c301998-03-03 22:02:19 +0000539 $word = "$word " if $word;
Fred Drakea0f4c941998-07-24 22:16:04 +0000540 $THIS_MODULE = "$name";
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000541 $INDEX_SUBITEM = "(in $name)";
542 print "[$name]";
Fred Drakee15956b2000-04-03 04:51:13 +0000543 return make_mod_index_entry(
544 "<tt class='module'>$name</tt> (${word}module)", 'DEF');
Fred Drakea0f4c941998-07-24 22:16:04 +0000545}
546
547sub my_module_index_helper{
548 local($word, $_) = @_;
549 my $name = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000550 return define_module($word, $name) . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000551}
552
Fred Drake62e43691998-08-10 19:40:44 +0000553sub do_cmd_modindex{ return my_module_index_helper('', @_); }
554sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); }
555sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); }
556sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000557
Fred Drakeab032151999-05-13 18:36:54 +0000558sub ref_module_index_helper{
Fred Drake37cc0c02000-04-26 18:05:24 +0000559 my($word, $ahref) = @_;
Fred Drakeab032151999-05-13 18:36:54 +0000560 my $str = next_argument();
561 $word = "$word " if $word;
Fred Drakee15956b2000-04-03 04:51:13 +0000562 $str = "<tt class='module'>$str</tt> (${word}module)";
Fred Drakeab032151999-05-13 18:36:54 +0000563 # can't use add_index_entry() since the 2nd arg to gen_index_id() is used;
564 # just inline it all here
565 $str = gen_index_id($str, 'REF');
566 $index{$str} .= $ahref;
567 write_idxfile($ahref, $str);
568}
569
Fred Drake6659c301998-03-03 22:02:19 +0000570# these should be adjusted a bit....
Fred Drakeab032151999-05-13 18:36:54 +0000571define_indexing_macro('refmodindex', 'refbimodindex',
572 'refexmodindex', 'refstmodindex');
573sub idx_cmd_refmodindex{ return ref_module_index_helper('', @_); }
574sub idx_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); }
575sub idx_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); }
576sub idx_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000577
Fred Drake62e43691998-08-10 19:40:44 +0000578sub do_cmd_nodename{ return do_cmd_label(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000579
580sub init_myformat{
Fred Drake08932051998-04-17 02:15:42 +0000581# $anchor_invisible_mark = '';
Fred Drake6659c301998-03-03 22:02:19 +0000582 $anchor_mark = '';
583 $icons{'anchor_mark'} = '';
Fred Drake6659c301998-03-03 22:02:19 +0000584}
Fred Drake42b31a51998-03-27 05:16:10 +0000585init_myformat();
Fred Drake6659c301998-03-03 22:02:19 +0000586
Fred Drakeab032151999-05-13 18:36:54 +0000587# Create an index entry, but include the string in the target anchor
Fred Drake6659c301998-03-03 22:02:19 +0000588# instead of the dummy filler.
589#
590sub make_str_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000591 my($str) = @_;
592 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000593 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000594 return "$aname$str</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000595}
596
Fred Drakee15956b2000-04-03 04:51:13 +0000597$REFCOUNTS_LOADED = 0;
598
599sub load_refcounts{
600 $REFCOUNTS_LOADED = 1;
601
602 use File::Basename;
603 my $myname, $mydir, $myext;
604 ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*');
605 chop $mydir; # remove trailing '/'
606 ($myname, $mydir, $myext) = fileparse($mydir, '\..*');
607 chop $mydir; # remove trailing '/'
608 $mydir = getcwd() . "$dd$mydir"
609 unless $mydir =~ s|^/|/|;
610 local $_;
611 my $filename = "$mydir${dd}api${dd}refcounts.dat";
612 open(REFCOUNT_FILE, "<$filename") || die "\n$!\n";
613 print "[loading API refcount data]";
614 while (<REFCOUNT_FILE>) {
Fred Drakec2578c52000-04-10 18:26:45 +0000615 if (/([a-zA-Z0-9_]+):PyObject\*:([a-zA-Z0-9_]*):(0|[-+]1|null):(.*)$/) {
Fred Drakee15956b2000-04-03 04:51:13 +0000616 my($func, $param, $count, $comment) = ($1, $2, $3, $4);
617 #print "\n$func($param) --> $count";
618 $REFCOUNTS{"$func:$param"} = $count;
619 }
620 }
621}
622
623sub get_refcount{
624 my ($func, $param) = @_;
625 load_refcounts()
626 unless $REFCOUNTS_LOADED;
627 return $REFCOUNTS{"$func:$param"};
628}
629
Fred Drake6659c301998-03-03 22:02:19 +0000630sub do_env_cfuncdesc{
631 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000632 my $return_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000633 my $function_name = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000634 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000635 my $idx = make_str_index_entry(
636 "<tt class='cfunction'>$function_name()</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000637 $idx =~ s/ \(.*\)//;
638 $idx =~ s/\(\)//; # ????
Fred Drakee15956b2000-04-03 04:51:13 +0000639 my $result_rc = get_refcount($function_name, '');
640 my $rcinfo = '';
641 if ($result_rc eq '+1') {
642 $rcinfo = '<span class="label">Return value:</span>'
643 . "\n <span class=\"value\">New reference.</span>";
644 }
645 elsif ($result_rc eq '0') {
646 $rcinfo = '<span class="label">Return value:</span>'
647 . "\n <span class=\"value\">Borrowed reference.</span>";
648 }
Fred Drakec2578c52000-04-10 18:26:45 +0000649 elsif ($result_rc eq 'null') {
650 $rcinfo = '<span class="label">Return value:</span>'
651 . "\n <span class=\"value\">Always NULL.</span>";
652 }
Fred Drakee15956b2000-04-03 04:51:13 +0000653 if ($rcinfo ne '') {
654 $rcinfo = "\n<div class=\"refcount-info\">\n $rcinfo\n</div>";
655 }
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000656 return "<dl><dt>$return_type <b>$idx</b> (<var>$arg_list</var>)\n<dd>"
Fred Drakee15956b2000-04-03 04:51:13 +0000657 . $rcinfo
Fred Drake62e43691998-08-10 19:40:44 +0000658 . $_
659 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000660}
661
Fred Drakee15956b2000-04-03 04:51:13 +0000662sub do_env_csimplemacrodesc{
663 local($_) = @_;
664 my $name = next_argument();
665 my $idx = make_str_index_entry("<tt class='macro'>$name</tt>");
666 return "<dl><dt><b>$idx</b>\n<dd>"
667 . $_
668 . '</dl>'
669}
670
Fred Drake6659c301998-03-03 22:02:19 +0000671sub do_env_ctypedesc{
672 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +0000673 my $index_name = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000674 my $type_name = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000675 $index_name = $type_name
676 unless $index_name;
677 my($name,$aname,$ahref) = new_link_info();
678 add_index_entry("<tt class='ctype'>$index_name</tt> (C type)", $ahref);
679 return "<dl><dt><b><tt class='ctype'>$aname$type_name</a></tt></b>\n<dd>"
Fred Drake62e43691998-08-10 19:40:44 +0000680 . $_
681 . '</dl>'
Fred Drake6659c301998-03-03 22:02:19 +0000682}
683
684sub do_env_cvardesc{
685 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000686 my $var_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000687 my $var_name = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000688 my $idx = make_str_index_entry("<tt class='cdata'>$var_name</tt>"
Fred Drake90fdda51999-02-16 20:27:42 +0000689 . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000690 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000691 return "<dl><dt>$var_type <b>$idx</b>\n"
692 . '<dd>'
693 . $_
694 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000695}
696
697sub do_env_funcdesc{
698 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000699 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000700 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000701 my $idx = make_str_index_entry("<tt class='function'>$function_name()</tt>"
Fred Drake08932051998-04-17 02:15:42 +0000702 . get_indexsubitem());
703 $idx =~ s/ \(.*\)//;
Fred Drakeccc62721999-01-05 22:16:29 +0000704 $idx =~ s/\(\)<\/tt>/<\/tt>/;
Fred Drake62e43691998-08-10 19:40:44 +0000705 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000706}
707
708sub do_env_funcdescni{
709 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000710 my $function_name = next_argument();
711 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000712 return "<dl><dt><b><tt class='function'>$function_name</tt></b>"
Fred Drake90fdda51999-02-16 20:27:42 +0000713 . " (<var>$arg_list</var>)\n"
714 . '<dd>'
715 . $_
716 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000717}
718
719sub do_cmd_funcline{
720 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000721 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000722 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000723 my $prefix = "<tt class='function'>$function_name()</tt>";
Fred Drakeca675e41999-04-21 15:58:58 +0000724 my $idx = make_str_index_entry($prefix . get_indexsubitem());
725 $prefix =~ s/\(\)//;
726
727 return "<dt><b>$prefix</b> (<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000728}
729
Fred Drake6b3fb781999-07-12 16:50:09 +0000730sub do_cmd_funclineni{
731 local($_) = @_;
732 my $function_name = next_argument();
733 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000734 my $prefix = "<tt class='function'>$function_name</tt>";
Fred Drake6b3fb781999-07-12 16:50:09 +0000735
736 return "<dt><b>$prefix</b> (<var>$arg_list</var>)\n<dd>" . $_;
737}
738
Fred Drake6659c301998-03-03 22:02:19 +0000739# Change this flag to index the opcode entries. I don't think it's very
740# useful to index them, since they're only presented to describe the dis
741# module.
742#
743$INDEX_OPCODES = 0;
744
745sub do_env_opcodedesc{
746 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000747 my $opcode_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000748 my $arg_list = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000749 my $idx;
750 if ($INDEX_OPCODES) {
Fred Drakee15956b2000-04-03 04:51:13 +0000751 $idx = make_str_index_entry("<tt class='opcode'>$opcode_name</tt>"
752 . " (byte code instruction)");
Fred Drake08932051998-04-17 02:15:42 +0000753 $idx =~ s/ \(byte code instruction\)//;
754 }
755 else {
Fred Drakee15956b2000-04-03 04:51:13 +0000756 $idx = "<tt class='opcode'>$opcode_name</tt>";
Fred Drake08932051998-04-17 02:15:42 +0000757 }
758 my $stuff = "<dl><dt><b>$idx</b>";
Fred Drake6659c301998-03-03 22:02:19 +0000759 if ($arg_list) {
760 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
761 }
Fred Drake62e43691998-08-10 19:40:44 +0000762 return $stuff . "\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000763}
764
765sub do_env_datadesc{
766 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000767 my $dataname = next_argument();
768 my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000769 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000770 return "<dl><dt><b>$idx</b>\n<dd>"
771 . $_
772 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000773}
774
775sub do_env_datadescni{
776 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000777 my $idx = next_argument();
778 if (! $STRING_INDEX_TT) {
779 $idx = "<tt>$idx</tt>";
Fred Drake6659c301998-03-03 22:02:19 +0000780 }
Fred Drake62e43691998-08-10 19:40:44 +0000781 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000782}
783
784sub do_cmd_dataline{
785 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000786 my $data_name = next_argument();
787 my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem());
Fred Drake6659c301998-03-03 22:02:19 +0000788 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000789 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000790}
791
Fred Drakeadb272c2000-04-10 17:47:14 +0000792sub do_cmd_datalineni{
793 local($_) = @_;
794 my $data_name = next_argument();
795 return "<dt><b><tt>$data_name</tt></b><dd>" . $_;
796}
797
Fred Drake42b31a51998-03-27 05:16:10 +0000798sub do_env_excdesc{
799 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000800 my $excname = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000801 my $idx = make_str_index_entry("<tt class='exception'>$excname</tt>");
Fred Drake62e43691998-08-10 19:40:44 +0000802 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'
Fred Drake42b31a51998-03-27 05:16:10 +0000803}
804
Fred Drake62e43691998-08-10 19:40:44 +0000805sub do_env_fulllineitems{ return do_env_itemize(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000806
807
Fred Drakec9a44381998-03-17 06:29:13 +0000808sub do_env_classdesc{
809 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000810 $THIS_CLASS = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000811 my $arg_list = next_argument();
812 $idx = make_str_index_entry(
Fred Drakee15956b2000-04-03 04:51:13 +0000813 "<tt class='class'>$THIS_CLASS</tt> (class in $THIS_MODULE)" );
Fred Drake08932051998-04-17 02:15:42 +0000814 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000815 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drakec9a44381998-03-17 06:29:13 +0000816}
817
Fred Drake42b31a51998-03-27 05:16:10 +0000818
819sub do_env_methoddesc{
820 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000821 my $class_name = next_optional_argument();
822 $class_name = $THIS_CLASS
823 unless $class_name;
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000824 my $method = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000825 my $arg_list = next_argument();
826 my $extra = '';
827 if ($class_name) {
828 $extra = " ($class_name method)";
Fred Drake42b31a51998-03-27 05:16:10 +0000829 }
Fred Drakee15956b2000-04-03 04:51:13 +0000830 my $idx = make_str_index_entry("<tt class='method'>$method()</tt>$extra");
Fred Drake08932051998-04-17 02:15:42 +0000831 $idx =~ s/ \(.*\)//;
832 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000833 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000834}
835
836
Fred Drake7d45f6d1999-01-05 14:39:27 +0000837sub do_cmd_methodline{
838 local($_) = @_;
839 my $class_name = next_optional_argument();
840 $class_name = $THIS_CLASS
841 unless $class_name;
842 my $method = next_argument();
843 my $arg_list = next_argument();
844 my $extra = '';
845 if ($class_name) {
846 $extra = " ($class_name method)";
847 }
Fred Drakee15956b2000-04-03 04:51:13 +0000848 my $idx = make_str_index_entry("<tt class='method'>$method()</tt>$extra");
Fred Drake7d45f6d1999-01-05 14:39:27 +0000849 $idx =~ s/ \(.*\)//;
850 $idx =~ s/\(\)//;
851 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>"
852 . $_;
853}
854
855
Fred Draked64a40d1998-09-10 18:59:13 +0000856sub do_cmd_methodlineni{
857 local($_) = @_;
858 next_optional_argument();
859 my $method = next_argument();
860 my $arg_list = next_argument();
861 return "<dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
862 . $_;
863}
864
Fred Drake42b31a51998-03-27 05:16:10 +0000865sub do_env_methoddescni{
866 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000867 next_optional_argument();
868 my $method = next_argument();
869 my $arg_list = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000870 return "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
871 . $_
872 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000873}
874
875
876sub do_env_memberdesc{
877 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000878 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000879 my $member = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000880 $class = $THIS_CLASS
881 unless $class;
Fred Drake08932051998-04-17 02:15:42 +0000882 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +0000883 $extra = " ($class attribute)"
884 if ($class ne '');
Fred Drakee15956b2000-04-03 04:51:13 +0000885 my $idx = make_str_index_entry("<tt class='member'>$member</tt>$extra");
Fred Drake42b31a51998-03-27 05:16:10 +0000886 $idx =~ s/ \(.*\)//;
887 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000888 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000889}
890
891
Fred Drake5ccf3301998-04-17 20:04:09 +0000892sub do_cmd_memberline{
893 local($_) = @_;
894 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000895 my $member = next_argument();
Fred Drake5ccf3301998-04-17 20:04:09 +0000896 $class = $THIS_CLASS
897 unless $class;
898 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +0000899 $extra = " ($class attribute)"
900 if ($class ne '');
Fred Drakee15956b2000-04-03 04:51:13 +0000901 my $idx = make_str_index_entry("<tt class='member'>$member</tt>$extra");
Fred Drake5ccf3301998-04-17 20:04:09 +0000902 $idx =~ s/ \(.*\)//;
903 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000904 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000905}
906
Fred Drake42b31a51998-03-27 05:16:10 +0000907sub do_env_memberdescni{
908 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000909 next_optional_argument();
910 my $member = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000911 return "<dl><dt><b><tt class='member'>$member</tt></b>\n<dd>"
912 . $_
913 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000914}
915
916
Fred Drake5ccf3301998-04-17 20:04:09 +0000917sub do_cmd_memberlineni{
918 local($_) = @_;
919 next_optional_argument();
920 my $member = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000921 return "<dt><b><tt class='member'>$member</tt></b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000922}
923
Fred Drakee15956b2000-04-03 04:51:13 +0000924@col_aligns = ('<td>', '<td>', '<td>', '<td>');
Fred Drake6659c301998-03-03 22:02:19 +0000925
Fred Drake15799ed1999-02-12 19:23:17 +0000926$TABLE_HEADER_BGCOLOR = $NAV_BGCOLOR;
927
Fred Drakef74e5b71999-04-28 14:58:49 +0000928sub fix_font{
929 # do a little magic on a font name to get the right behavior in the first
930 # column of the output table
931 my $font = @_[0];
932 if ($font eq 'textrm') {
933 $font = '';
934 }
935 elsif ($font eq 'file' || $font eq 'filenq') {
Fred Drakee15956b2000-04-03 04:51:13 +0000936 $font = 'tt class="file"';
937 }
938 elsif ($font eq 'member') {
939 $font = 'tt class="member"';
Fred Drakef74e5b71999-04-28 14:58:49 +0000940 }
941 return $font;
942}
943
Fred Drakee15956b2000-04-03 04:51:13 +0000944sub figure_column_alignment{
945 my $a = @_[0];
946 my $mark = substr($a, 0, 1);
947 my $r = '';
948 if ($mark eq 'c')
949 { $r = ' align="center"'; }
950 elsif ($mark eq 'r')
951 { $r = ' align="right"'; }
952 elsif ($mark eq 'l')
953 { $r = ' align="left"'; }
954 elsif ($mark eq 'p')
955 { $r = ' align="left"'; }
956 return $r;
957}
958
Fred Drake6659c301998-03-03 22:02:19 +0000959sub setup_column_alignments{
960 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +0000961 my($s1,$s2,$s3,$s4) = split(/[|]/,$_);
962 my $a1 = figure_column_alignment($s1);
963 my $a2 = figure_column_alignment($s2);
964 my $a3 = figure_column_alignment($s3);
965 my $a4 = figure_column_alignment($s4);
966 $col_aligns[0] = "<td$a1 valign=\"baseline\">";
967 $col_aligns[1] = "<td$a2>";
968 $col_aligns[2] = "<td$a3>";
969 $col_aligns[3] = "<td$a4>";
Fred Drake79189b51999-04-28 13:54:30 +0000970 # return the aligned header start tags
Fred Drakee15956b2000-04-03 04:51:13 +0000971 return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>");
972}
973
974sub get_table_col1_fonts{
975 my $font = $globals{'lineifont'};
976 my ($sfont,$efont) = ('', '');
977 if ($font) {
978 $sfont = "<$font>";
979 $efont = "</$font>";
980 $efont =~ s/ .*>/>/;
981 }
982 return ($font, $sfont, $efont);
Fred Drake6659c301998-03-03 22:02:19 +0000983}
984
985sub do_env_tableii{
986 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000987 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +0000988 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000989 my $h1 = next_argument();
990 my $h2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +0000991 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +0000992 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +0000993 my $a1 = $col_aligns[0];
994 my $a2 = $col_aligns[1];
995 s/\\lineii</\\lineii[$a1|$a2]</g;
996 return '<table border align="center" style="border-collapse: collapse">'
Fred Drakef74e5b71999-04-28 14:58:49 +0000997 . "\n <thead>"
998 . "\n <tr$TABLE_HEADER_BGCOLOR>"
Fred Drakee15956b2000-04-03 04:51:13 +0000999 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1000 . "\n $th2<b>$h2</b>\&nbsp;</th>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001001 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001002 . "\n <tbody valign='baseline'>"
1003 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001004 . "\n </tbody>"
1005 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001006}
1007
1008sub do_cmd_lineii{
1009 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001010 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001011 my $c1 = next_argument();
1012 my $c2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001013 s/[\s\n]+//;
Fred Drakee15956b2000-04-03 04:51:13 +00001014 my($font,$sfont,$efont) = get_table_col1_fonts();
1015 $c2 = '&nbsp;' if ($c2 eq '');
1016 my($c1align,$c2align) = split('\|', $aligns);
1017 my $padding = '';
1018 if ($c1align =~ /align="right"/) {
1019 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001020 }
Fred Drakee15956b2000-04-03 04:51:13 +00001021 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
1022 . " $c2align$c2</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001023 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001024}
1025
1026sub do_env_tableiii{
1027 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001028 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001029 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001030 my $h1 = next_argument();
1031 my $h2 = next_argument();
1032 my $h3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001033 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001034 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001035 my $a1 = $col_aligns[0];
1036 my $a2 = $col_aligns[1];
1037 my $a3 = $col_aligns[2];
1038 s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g;
1039 return '<table border align="center" style="border-collapse: collapse">'
Fred Drakef74e5b71999-04-28 14:58:49 +00001040 . "\n <thead>"
1041 . "\n <tr$TABLE_HEADER_BGCOLOR>"
Fred Drakee15956b2000-04-03 04:51:13 +00001042 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1043 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1044 . "\n $th3<b>$h3</b>\&nbsp;</th>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001045 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001046 . "\n <tbody valign='baseline'>"
Fred Drake62e43691998-08-10 19:40:44 +00001047 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001048 . "\n </tbody>"
1049 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001050}
1051
1052sub do_cmd_lineiii{
1053 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001054 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001055 my $c1 = next_argument();
1056 my $c2 = next_argument();
1057 my $c3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001058 s/[\s\n]+//;
Fred Drakee15956b2000-04-03 04:51:13 +00001059 my($font,$sfont,$efont) = get_table_col1_fonts();
1060 $c3 = '&nbsp;' if ($c3 eq '');
1061 my($c1align,$c2align,$c3align) = split('\|', $aligns);
1062 my $padding = '';
1063 if ($c1align =~ /align="right"/) {
1064 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001065 }
Fred Drakee15956b2000-04-03 04:51:13 +00001066 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001067 . " $c2align$c2</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001068 . " $c3align$c3</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001069 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001070}
1071
Fred Drakea0f4c941998-07-24 22:16:04 +00001072sub do_env_tableiv{
1073 local($_) = @_;
1074 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001075 my $font = fix_font(next_argument());
Fred Drakea0f4c941998-07-24 22:16:04 +00001076 my $h1 = next_argument();
1077 my $h2 = next_argument();
1078 my $h3 = next_argument();
1079 my $h4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001080 s/[\s\n]+//;
Fred Drakea0f4c941998-07-24 22:16:04 +00001081 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001082 my $a1 = $col_aligns[0];
1083 my $a2 = $col_aligns[1];
1084 my $a3 = $col_aligns[2];
1085 my $a4 = $col_aligns[3];
1086 s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g;
1087 return '<table border align="center" style="border-collapse: collapse">'
Fred Drakef74e5b71999-04-28 14:58:49 +00001088 . "\n <thead>"
1089 . "\n <tr$TABLE_HEADER_BGCOLOR>"
Fred Drakee15956b2000-04-03 04:51:13 +00001090 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1091 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1092 . "\n $th3<b>$h3</b>\&nbsp;</th>"
1093 . "\n $th4<b>$h4</b>\&nbsp;</th>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001094 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001095 . "\n <tbody valign='baseline'>"
Fred Drake62e43691998-08-10 19:40:44 +00001096 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001097 . "\n </tbody>"
1098 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001099}
1100
Fred Drakea0f4c941998-07-24 22:16:04 +00001101sub do_cmd_lineiv{
Fred Drake6659c301998-03-03 22:02:19 +00001102 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001103 my $aligns = next_optional_argument();
Fred Drakea0f4c941998-07-24 22:16:04 +00001104 my $c1 = next_argument();
1105 my $c2 = next_argument();
1106 my $c3 = next_argument();
1107 my $c4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001108 s/[\s\n]+//;
Fred Drakee15956b2000-04-03 04:51:13 +00001109 my($font,$sfont,$efont) = get_table_col1_fonts();
1110 $c4 = '&nbsp;' if ($c4 eq '');
1111 my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns);
1112 my $padding = '';
1113 if ($c1align =~ /align="right"/) {
1114 $padding = '&nbsp;';
Fred Drakea0f4c941998-07-24 22:16:04 +00001115 }
Fred Drakee15956b2000-04-03 04:51:13 +00001116 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001117 . " $c2align$c2</td>\n"
1118 . " $c3align$c3</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001119 . " $c4align$c4</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001120 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001121}
1122
Fred Drake6659c301998-03-03 22:02:19 +00001123sub do_cmd_maketitle {
1124 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001125 my $the_title = "\n<div class='titlepage'><center>";
Fred Drake6659c301998-03-03 22:02:19 +00001126 if ($t_title) {
Fred Drake90fdda51999-02-16 20:27:42 +00001127 $the_title .= "\n<h1>$t_title</h1>";
Fred Drake08932051998-04-17 02:15:42 +00001128 } else { write_warnings("\nThis document has no title."); }
Fred Drake6659c301998-03-03 22:02:19 +00001129 if ($t_author) {
1130 if ($t_authorURL) {
Fred Drake08932051998-04-17 02:15:42 +00001131 my $href = translate_commands($t_authorURL);
Fred Drake2d1f81e1999-02-09 16:03:31 +00001132 $href = make_named_href('author', $href,
1133 "<b><font size='+2'>$t_author</font></b>");
Fred Drakec9a44381998-03-17 06:29:13 +00001134 $the_title .= "\n<p>$href</p>";
Fred Drake6659c301998-03-03 22:02:19 +00001135 } else {
Fred Drake2d1f81e1999-02-09 16:03:31 +00001136 $the_title .= ("\n<p><b><font size='+2'>$t_author</font></b></p>");
Fred Drake6659c301998-03-03 22:02:19 +00001137 }
Fred Drake08932051998-04-17 02:15:42 +00001138 } else { write_warnings("\nThere is no author for this document."); }
Fred Drake6659c301998-03-03 22:02:19 +00001139 if ($t_institute) {
Fred Drakec9a44381998-03-17 06:29:13 +00001140 $the_title .= "\n<p>$t_institute</p>";}
Fred Draked07868a1998-05-14 21:00:28 +00001141 if ($DEVELOPER_ADDRESS) {
1142 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";}
Fred Drake6659c301998-03-03 22:02:19 +00001143 if ($t_affil) {
Fred Drakec9a44381998-03-17 06:29:13 +00001144 $the_title .= "\n<p><i>$t_affil</i></p>";}
Fred Drake6659c301998-03-03 22:02:19 +00001145 if ($t_date) {
Fred Drakec9a44381998-03-17 06:29:13 +00001146 $the_title .= "\n<p><strong>$t_date</strong>";
Fred Drake6659c301998-03-03 22:02:19 +00001147 if ($PYTHON_VERSION) {
1148 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";}
1149 $the_title .= "</p>"
1150 }
1151 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +00001152 $the_title .= "\n<p>$t_address</p>";
1153 } else { $the_title .= "\n<p>"}
Fred Drake6659c301998-03-03 22:02:19 +00001154 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +00001155 $the_title .= "\n<p>$t_email</p>";
1156 }# else { $the_title .= "</p>" }
Fred Drake90fdda51999-02-16 20:27:42 +00001157 $the_title .= "\n</center></div>";
Fred Drake62e43691998-08-10 19:40:44 +00001158 return $the_title . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +00001159}
1160
1161
Fred Drake885215c1998-05-20 21:32:09 +00001162#
Fred Drakea0f4c941998-07-24 22:16:04 +00001163# Module synopsis support
1164#
1165
1166require SynopsisTable;
1167
Fred Drakef7685d71998-07-25 03:31:46 +00001168sub get_chapter_id(){
1169 my $id = do_cmd_thechapter('');
Fred Drake45f26011998-08-04 22:07:18 +00001170 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
1171 $id =~ s/\.//;
Fred Drakef7685d71998-07-25 03:31:46 +00001172 return $id;
Fred Drakea0f4c941998-07-24 22:16:04 +00001173}
1174
Fred Drakef7685d71998-07-25 03:31:46 +00001175%ModuleSynopses = ('chapter' => 'SynopsisTable instance');
1176
1177sub get_synopsis_table($){
1178 my($chap) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001179 my $st = $ModuleSynopses{$chap};
Fred Drakef7685d71998-07-25 03:31:46 +00001180 my $key;
1181 foreach $key (keys %ModuleSynopses) {
1182 if ($key eq $chap) {
1183 return $ModuleSynopses{$chap};
1184 }
Fred Drakea0f4c941998-07-24 22:16:04 +00001185 }
Fred Drakef7685d71998-07-25 03:31:46 +00001186 $st = SynopsisTable->new();
1187 $ModuleSynopses{$chap} = $st;
Fred Drakea0f4c941998-07-24 22:16:04 +00001188 return $st;
1189}
1190
Fred Drake62e43691998-08-10 19:40:44 +00001191sub do_cmd_moduleauthor{
1192 local($_) = @_;
1193 next_argument();
1194 next_argument();
1195 return $_;
1196}
1197
1198sub do_cmd_sectionauthor{
1199 local($_) = @_;
1200 next_argument();
1201 next_argument();
1202 return $_;
1203}
1204
Fred Drakea0f4c941998-07-24 22:16:04 +00001205sub do_cmd_declaremodule{
1206 local($_) = @_;
1207 my $key = next_optional_argument();
1208 my $type = next_argument();
1209 my $name = next_argument();
1210 my $st = get_synopsis_table(get_chapter_id());
1211 #
1212 $key = $name unless $key;
1213 $type = 'built-in' if $type eq 'builtin';
1214 $st->declare($name, $key, $type);
1215 define_module($type, $name);
Fred Drake62e43691998-08-10 19:40:44 +00001216 return anchor_label("module-$key",$CURRENT_FILE,$_)
Fred Drakea0f4c941998-07-24 22:16:04 +00001217}
1218
1219sub do_cmd_modulesynopsis{
1220 local($_) = @_;
1221 my $st = get_synopsis_table(get_chapter_id());
Fred Drake1cc58991999-04-13 22:08:59 +00001222 $st->set_synopsis($THIS_MODULE, translate_commands(next_argument()));
Fred Drake62e43691998-08-10 19:40:44 +00001223 return $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001224}
1225
1226sub do_cmd_localmoduletable{
1227 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001228 my $chap = get_chapter_id();
Fred Drake557460c1999-03-02 16:05:35 +00001229 return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001230}
1231
1232sub process_all_localmoduletables{
Fred Drake557460c1999-03-02 16:05:35 +00001233 while (/<tex2html-localmoduletable><(\d+)>/) {
Fred Drakef7685d71998-07-25 03:31:46 +00001234 my $match = $&;
Fred Drakea0f4c941998-07-24 22:16:04 +00001235 my $chap = $1;
1236 my $st = get_synopsis_table($chap);
1237 my $data = $st->tohtml();
Fred Drakef7685d71998-07-25 03:31:46 +00001238 s/$match/$data/;
Fred Drakea0f4c941998-07-24 22:16:04 +00001239 }
1240}
Fred Drake557460c1999-03-02 16:05:35 +00001241sub process_python_state{
1242 process_all_localmoduletables();
Fred Drake557460c1999-03-02 16:05:35 +00001243}
Fred Drakea0f4c941998-07-24 22:16:04 +00001244
1245
1246#
1247# "See also:" -- references placed at the end of a \section
1248#
1249
1250sub do_env_seealso{
Fred Drakee15956b2000-04-03 04:51:13 +00001251 return "<div class='seealso'>\n "
1252 . "<p class='heading'><b>See Also:</b></p>\n"
Fred Drake90fdda51999-02-16 20:27:42 +00001253 . @_[0]
1254 . '</div>';
Fred Drakea0f4c941998-07-24 22:16:04 +00001255}
1256
1257sub do_cmd_seemodule{
1258 # Insert the right magic to jump to the module definition. This should
1259 # work most of the time, at least for repeat builds....
1260 local($_) = @_;
1261 my $key = next_optional_argument();
1262 my $module = next_argument();
1263 my $text = next_argument();
Fred Drake84bd6f31999-05-11 15:42:51 +00001264 my $period = '.';
Fred Drakea0f4c941998-07-24 22:16:04 +00001265 $key = $module
1266 unless $key;
Fred Drake84bd6f31999-05-11 15:42:51 +00001267 if ($text =~ /\.$/) {
1268 $period = '';
1269 }
Fred Drakee15956b2000-04-03 04:51:13 +00001270 return '<dl compact class="seemodule">'
1271 . "\n <dt>Module <b><tt class='module'><a href='module-$key.html'>"
Fred Drake84bd6f31999-05-11 15:42:51 +00001272 . "$module</a></tt>:</b>"
1273 . "\n <dd>$text$period\n </dl>"
Fred Drake90fdda51999-02-16 20:27:42 +00001274 . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001275}
1276
Fred Drake37cc0c02000-04-26 18:05:24 +00001277sub do_cmd_seerfc{
1278 local($_) = @_;
1279 my $rfcnum = next_argument();
1280 my $title = next_argument();
1281 my $text = next_argument();
1282 my $url = get_rfc_url($rfcnum);
1283 return '<dl compact class="seerfc">'
1284 . "\n <dt><a href=\"$url\""
1285 . "\n title=\"$title\""
1286 . "\n >RFC $rfcnum, <em>$title</em></a>:"
1287 . "\n <dd>$text\n </dl>"
1288 . $_;
1289}
1290
Fred Drakeef4d1112000-05-09 16:17:51 +00001291sub do_cmd_seeurl{
1292 local($_) = @_;
1293 my $url = next_argument();
1294 my $text = next_argument();
1295 return '<dl compact class="seeurl">'
1296 . "\n <dt><a href=\"$url\""
1297 . "\n class=\"url\">$url</a>"
1298 . "\n <dd>$text\n </dl>"
1299 . $_;
1300}
1301
Fred Drakea0f4c941998-07-24 22:16:04 +00001302sub do_cmd_seetext{
Fred Drake79189b51999-04-28 13:54:30 +00001303 local($_) = @_;
1304 my $content = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +00001305 return '<div class="seetext"><p>' . $content . '</div>' . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001306}
1307
1308
1309#
Fred Drake885215c1998-05-20 21:32:09 +00001310# Definition list support.
1311#
1312
1313sub do_env_definitions{
Fred Drake37cc0c02000-04-26 18:05:24 +00001314 return "<dl class='definitions'>" . @_[0] . "</dl>\n";
Fred Drake885215c1998-05-20 21:32:09 +00001315}
1316
1317sub do_cmd_term{
1318 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001319 my $term = next_argument();
1320 my($name,$aname,$ahref) = new_link_info();
Fred Drake885215c1998-05-20 21:32:09 +00001321 # could easily add an index entry here...
Fred Drake62e43691998-08-10 19:40:44 +00001322 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
Fred Drake885215c1998-05-20 21:32:09 +00001323}
1324
1325
Fred Drake2ff880e1999-02-05 18:31:29 +00001326process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_);
1327code # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001328declaremodule # [] # {} # {}
1329memberline # [] # {}
1330methodline # [] # {} # {}
1331modulesynopsis # {}
Fred Drake557460c1999-03-02 16:05:35 +00001332platform # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001333samp # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001334setindexsubitem # {}
Fred Drakef32834c1999-02-12 22:06:32 +00001335withsubitem # {} # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001336_RAW_ARG_DEFERRED_CMDS_
1337
1338
Fred Drake6659c301998-03-03 22:02:19 +000013391; # This must be the last line