blob: d4e8ea82a67024e937c81589dcea267c060e635a [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
232sub do_cmd_rfc{
233 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000234 my $rfcnumber = next_argument();
235 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drake2eff3c51998-12-22 18:02:25 +0000236 my $href =
237 "http://info.internet.isi.edu/in-notes/rfc/files/rfc$rfcnumber.txt";
Fred Drake6659c301998-03-03 22:02:19 +0000238 # Save the reference
Fred Drake08932051998-04-17 02:15:42 +0000239 my $nstr = gen_index_id("RFC!RFC $rfcnumber", '');
Fred Drakeccc62721999-01-05 22:16:29 +0000240 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
Fred Drakee15956b2000-04-03 04:51:13 +0000241 return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">RFC $rfcnumber</a>"
Fred Draked52879c1999-09-22 19:58:51 +0000242 . $_);
Fred Drake6659c301998-03-03 22:02:19 +0000243}
244
Fred Drakec9f5fe01999-11-09 16:59:42 +0000245sub do_cmd_citetitle{
246 local($_) = @_;
247 my $url = next_optional_argument();
248 my $title = next_argument();
249 my $repl = '';
250 if ($url) {
251 $repl = ("<em class='citetitle'><a\n"
252 . " href='$url'\n"
253 . " title='$title'\n"
254 . " >$title</a></em>");
255 }
256 else {
257 $repl = "<em class='citetitle'\n >$title</em>";
258 }
259 return $repl . $_;
260}
261
Fred Drake6659c301998-03-03 22:02:19 +0000262sub do_cmd_deprecated{
263 # two parameters: \deprecated{version}{whattodo}
264 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000265 my $release = next_argument();
266 my $reason = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000267 return "<b>Deprecated since release $release.</b>\n$reason<p>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000268}
269
Fred Drake897d12b1998-07-27 20:33:17 +0000270sub do_cmd_versionadded{
271 # one parameter: \versionadded{version}
272 local($_) = @_;
273 my $release = next_argument();
Fred Drake2116d981999-02-02 18:02:48 +0000274 return "\nNew in version $release.\n" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000275}
276
277sub do_cmd_versionchanged{
278 # one parameter: \versionchanged{version}
279 local($_) = @_;
280 my $release = next_argument();
Fred Drake2116d981999-02-02 18:02:48 +0000281 return "\nChanged in version $release.\n" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000282}
283
Fred Drake557460c1999-03-02 16:05:35 +0000284#
Fred Drake2cafcbb1999-03-25 16:57:04 +0000285# These function handle platform dependency tracking.
Fred Drake557460c1999-03-02 16:05:35 +0000286#
287sub do_cmd_platform{
288 local($_) = @_;
289 my $platform = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000290 $ModulePlatforms{"<tt class='module'>$THIS_MODULE</tt>"} = $platform;
Fred Drake557460c1999-03-02 16:05:35 +0000291 $platform = "Macintosh"
Fred Drake085b8121999-04-21 14:00:29 +0000292 if $platform eq 'Mac';
Fred Drakee15956b2000-04-03 04:51:13 +0000293 return "\n<p class='availability'>Availability: <span"
294 . "\n class='platform'>$platform</span>.</p>\n" . $_;
Fred Drake557460c1999-03-02 16:05:35 +0000295}
296
Fred Drake557460c1999-03-02 16:05:35 +0000297$IGNORE_PLATFORM_ANNOTATION = '';
298sub do_cmd_ignorePlatformAnnotation{
299 local($_) = @_;
300 $IGNORE_PLATFORM_ANNOTATION = next_argument();
301 return $_;
302}
303
Fred Drake6659c301998-03-03 22:02:19 +0000304
305# index commands
306
307$INDEX_SUBITEM = "";
308
309sub get_indexsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000310 return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
Fred Drake6659c301998-03-03 22:02:19 +0000311}
312
313sub do_cmd_setindexsubitem{
314 local($_) = @_;
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000315 $INDEX_SUBITEM = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000316 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000317}
318
Fred Drakefc16e781998-03-12 21:03:26 +0000319sub do_cmd_withsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000320 # We can't really do the right thing, because LaTeX2HTML doesn't
Fred Drakefc16e781998-03-12 21:03:26 +0000321 # do things in the right order, but we need to at least strip this stuff
322 # out, and leave anything that the second argument expanded out to.
323 #
324 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000325 my $oldsubitem = $INDEX_SUBITEM;
326 $INDEX_SUBITEM = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000327 my $stuff = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000328 my $br_id = ++$globals{'max_id'};
329 my $marker = "$O$br_id$C";
Fred Drake7d45f6d1999-01-05 14:39:27 +0000330 return
331 $stuff
Fred Drakeccc62721999-01-05 22:16:29 +0000332 . "\\setindexsubitem$marker$oldsubitem$marker"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000333 . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000334}
335
Fred Drake08932051998-04-17 02:15:42 +0000336# This is the prologue macro which is required to start writing the
Fred Drakeab032151999-05-13 18:36:54 +0000337# mod\jobname.idx file; we can just ignore it. (Defining this suppresses
338# a warning that \makemodindex is unknown.)
Fred Drake08932051998-04-17 02:15:42 +0000339#
Fred Drake62e43691998-08-10 19:40:44 +0000340sub do_cmd_makemodindex{ return @_[0]; }
Fred Drakefc16e781998-03-12 21:03:26 +0000341
Fred Drake42b31a51998-03-27 05:16:10 +0000342# We're in the document subdirectory when this happens!
Fred Drake166abba1998-04-08 23:10:54 +0000343#
Fred Drake08932051998-04-17 02:15:42 +0000344open(IDXFILE, '>index.dat') || die "\n$!\n";
345open(INTLABELS, '>intlabels.pl') || die "\n$!\n";
Fred Drake166abba1998-04-08 23:10:54 +0000346print INTLABELS "%internal_labels = ();\n";
347print INTLABELS "1; # hack in case there are no entries\n\n";
348
349# Using \0 for this is bad because we can't use common tools to work with the
350# resulting files. Things like grep can be useful with this stuff!
351#
352$IDXFILE_FIELD_SEP = "\1";
353
Fred Drakeccc62721999-01-05 22:16:29 +0000354sub write_idxfile{
355 my ($ahref, $str) = @_;
356 print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n";
Fred Drake42b31a51998-03-27 05:16:10 +0000357}
358
Fred Drake42b31a51998-03-27 05:16:10 +0000359
360sub gen_link{
361 my($node,$target) = @_;
362 print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
Fred Drakee15956b2000-04-03 04:51:13 +0000363 return "<a href='$node#$target'>";
Fred Drake42b31a51998-03-27 05:16:10 +0000364}
365
Fred Drake42b31a51998-03-27 05:16:10 +0000366sub add_index_entry{
367 # add an entry to the index structures; ignore the return value
368 my($str,$ahref) = @_;
369 $str = gen_index_id($str, '');
370 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000371 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000372}
373
Fred Drakeccc62721999-01-05 22:16:29 +0000374sub new_link_info{
375 my $name = "l2h-" . ++$globals{'max_id'};
Fred Drakee15956b2000-04-03 04:51:13 +0000376 my $aname = "<a name='$name'>";
Fred Drake42b31a51998-03-27 05:16:10 +0000377 my $ahref = gen_link($CURRENT_FILE, $name);
378 return ($name, $aname, $ahref);
379}
380
Fred Drakeab032151999-05-13 18:36:54 +0000381$IndexMacroPattern = '';
382sub define_indexing_macro{
383 my $count = @_;
384 my $i = 0;
385 for (; $i < $count; ++$i) {
386 my $name = @_[$i];
387 my $cmd = "idx_cmd_$name";
388 die "\nNo function $cmd() defined!\n"
389 if (!defined &$cmd);
390 eval ("sub do_cmd_$name { return process_index_macros("
391 . "\@_[0], '$name'); }");
392 if (length($IndexMacroPattern) == 0) {
393 $IndexMacroPattern = "$name";
394 }
395 else {
396 $IndexMacroPattern .= "|$name";
397 }
398 }
399}
400
401$DEBUG_INDEXING = 0;
402sub process_index_macros{
Fred Drake42b31a51998-03-27 05:16:10 +0000403 local($_) = @_;
Fred Drakeab032151999-05-13 18:36:54 +0000404 my $cmdname = @_[1]; # This is what triggered us in the first place;
405 # we know it's real, so just process it.
Fred Drakeccc62721999-01-05 22:16:29 +0000406 my($name,$aname,$ahref) = new_link_info();
Fred Drakeab032151999-05-13 18:36:54 +0000407 my $cmd = "idx_cmd_$cmdname";
408 print "\nIndexing: \\$cmdname"
409 if $DEBUG_INDEXING;
410 &$cmd($ahref); # modifies $_ and adds index entries
411 while (/^[\s\n]*\\($IndexMacroPattern)</) {
412 $cmdname = "$1";
413 print " \\$cmdname"
414 if $DEBUG_INDEXING;
415 $cmd = "idx_cmd_$cmdname";
416 if (!defined &$cmd) {
417 last;
418 }
419 else {
420 s/^[\s\n]*\\$cmdname//;
421 &$cmd($ahref);
422 }
423 }
Fred Drake62e43691998-08-10 19:40:44 +0000424 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake42b31a51998-03-27 05:16:10 +0000425}
426
Fred Drakeab032151999-05-13 18:36:54 +0000427define_indexing_macro('index');
428sub idx_cmd_index{
Fred Drakeccc62721999-01-05 22:16:29 +0000429 my $str = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000430 add_index_entry("$str", @_[0]);
Fred Drake2e7edb81998-05-11 18:31:17 +0000431}
432
Fred Drakeab032151999-05-13 18:36:54 +0000433define_indexing_macro('kwindex');
434sub idx_cmd_kwindex{
435 my $str = next_argument();
436 add_index_entry("<tt>$str</tt>!keyword", @_[0]);
437 add_index_entry("keyword!<tt>$str</tt>", @_[0]);
438}
439
440define_indexing_macro('indexii');
441sub idx_cmd_indexii{
Fred Drakeccc62721999-01-05 22:16:29 +0000442 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000443 my $str2 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000444 add_index_entry("$str1!$str2", @_[0]);
445 add_index_entry("$str2!$str1", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000446}
447
Fred Drakeab032151999-05-13 18:36:54 +0000448define_indexing_macro('indexiii');
449sub idx_cmd_indexiii{
Fred Drakeccc62721999-01-05 22:16:29 +0000450 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000451 my $str2 = next_argument();
452 my $str3 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000453 add_index_entry("$str1!$str2 $str3", @_[0]);
454 add_index_entry("$str2!$str3, $str1", @_[0]);
455 add_index_entry("$str3!$str1 $str2", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000456}
457
Fred Drakeab032151999-05-13 18:36:54 +0000458define_indexing_macro('indexiv');
459sub idx_cmd_indexiv{
Fred Drakeccc62721999-01-05 22:16:29 +0000460 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000461 my $str2 = next_argument();
462 my $str3 = next_argument();
463 my $str4 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000464 add_index_entry("$str1!$str2 $str3 $str4", @_[0]);
465 add_index_entry("$str2!$str3 $str4, $str1", @_[0]);
466 add_index_entry("$str3!$str4, $str1 $str2", @_[0]);
467 add_index_entry("$str4!$$str1 $str2 $str3", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000468}
469
Fred Drakeab032151999-05-13 18:36:54 +0000470define_indexing_macro('ttindex');
471sub idx_cmd_ttindex{
Fred Drakeccc62721999-01-05 22:16:29 +0000472 my $str = next_argument();
473 my $entry = $str . get_indexsubitem();
Fred Drakeab032151999-05-13 18:36:54 +0000474 add_index_entry($entry, @_[0]);
Fred Drakec9a44381998-03-17 06:29:13 +0000475}
Fred Drake6659c301998-03-03 22:02:19 +0000476
477sub my_typed_index_helper{
Fred Drakeab032151999-05-13 18:36:54 +0000478 my($word,$ahref) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000479 my $str = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000480 add_index_entry("$str $word", $ahref);
481 add_index_entry("$word!$str", $ahref);
Fred Drake6659c301998-03-03 22:02:19 +0000482}
483
Fred Drakeab032151999-05-13 18:36:54 +0000484define_indexing_macro('stindex', 'opindex', 'exindex', 'obindex');
485sub idx_cmd_stindex{ my_typed_index_helper('statement', @_[0]); }
486sub idx_cmd_opindex{ my_typed_index_helper('operator', @_[0]); }
487sub idx_cmd_exindex{ my_typed_index_helper('exception', @_[0]); }
488sub idx_cmd_obindex{ my_typed_index_helper('object', @_[0]); }
Fred Drake6659c301998-03-03 22:02:19 +0000489
Fred Drakeab032151999-05-13 18:36:54 +0000490define_indexing_macro('bifuncindex');
491sub idx_cmd_bifuncindex{
Fred Drakeccc62721999-01-05 22:16:29 +0000492 my $str = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000493 add_index_entry("<tt class='function'>$str()</tt> (built-in function)",
494 @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000495}
496
497
Fred Drake6659c301998-03-03 22:02:19 +0000498sub make_mod_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000499 my($str,$define) = @_;
500 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000501 # equivalent of add_index_entry() using $define instead of ''
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000502 $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/
503 if ($define eq 'DEF');
Fred Drake42b31a51998-03-27 05:16:10 +0000504 $str = gen_index_id($str, $define);
505 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000506 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000507
Fred Drakec9a44381998-03-17 06:29:13 +0000508 if ($define eq 'DEF') {
Fred Drake42b31a51998-03-27 05:16:10 +0000509 # add to the module index
Fred Drakee15956b2000-04-03 04:51:13 +0000510 $str =~ /(<tt.*<\/tt>)/;
511 my $nstr = $1;
Fred Drake42b31a51998-03-27 05:16:10 +0000512 $Modules{$nstr} .= $ahref;
Fred Drake6659c301998-03-03 22:02:19 +0000513 }
Fred Drake62e43691998-08-10 19:40:44 +0000514 return "$aname$anchor_invisible_mark</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000515}
516
Fred Drake557460c1999-03-02 16:05:35 +0000517
Fred Drakec9a44381998-03-17 06:29:13 +0000518$THIS_MODULE = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000519$THIS_CLASS = '';
Fred Drakec9a44381998-03-17 06:29:13 +0000520
Fred Drakea0f4c941998-07-24 22:16:04 +0000521sub define_module{
522 my($word,$name) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000523 my $section_tag = join('', @curr_sec_id);
Fred Drake3e4c6141999-05-17 15:00:32 +0000524 if ($word ne "built-in" && $word ne "extension"
525 && $word ne "standard" && $word ne "") {
526 write_warnings("Bad module type '$word'"
527 . " for \\declaremodule (module $name)");
528 $word = "";
529 }
Fred Drake6659c301998-03-03 22:02:19 +0000530 $word = "$word " if $word;
Fred Drakea0f4c941998-07-24 22:16:04 +0000531 $THIS_MODULE = "$name";
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000532 $INDEX_SUBITEM = "(in $name)";
533 print "[$name]";
Fred Drakee15956b2000-04-03 04:51:13 +0000534 return make_mod_index_entry(
535 "<tt class='module'>$name</tt> (${word}module)", 'DEF');
Fred Drakea0f4c941998-07-24 22:16:04 +0000536}
537
538sub my_module_index_helper{
539 local($word, $_) = @_;
540 my $name = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000541 return define_module($word, $name) . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000542}
543
Fred Drake62e43691998-08-10 19:40:44 +0000544sub do_cmd_modindex{ return my_module_index_helper('', @_); }
545sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); }
546sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); }
547sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000548
Fred Drakeab032151999-05-13 18:36:54 +0000549sub ref_module_index_helper{
550 local($word, $ahref) = @_;
551 my $str = next_argument();
552 $word = "$word " if $word;
Fred Drakee15956b2000-04-03 04:51:13 +0000553 $str = "<tt class='module'>$str</tt> (${word}module)";
Fred Drakeab032151999-05-13 18:36:54 +0000554 # can't use add_index_entry() since the 2nd arg to gen_index_id() is used;
555 # just inline it all here
556 $str = gen_index_id($str, 'REF');
557 $index{$str} .= $ahref;
558 write_idxfile($ahref, $str);
559}
560
Fred Drake6659c301998-03-03 22:02:19 +0000561# these should be adjusted a bit....
Fred Drakeab032151999-05-13 18:36:54 +0000562define_indexing_macro('refmodindex', 'refbimodindex',
563 'refexmodindex', 'refstmodindex');
564sub idx_cmd_refmodindex{ return ref_module_index_helper('', @_); }
565sub idx_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); }
566sub idx_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); }
567sub idx_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000568
Fred Drake62e43691998-08-10 19:40:44 +0000569sub do_cmd_nodename{ return do_cmd_label(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000570
571sub init_myformat{
Fred Drake08932051998-04-17 02:15:42 +0000572# $anchor_invisible_mark = '';
Fred Drake6659c301998-03-03 22:02:19 +0000573 $anchor_mark = '';
574 $icons{'anchor_mark'} = '';
Fred Drake6659c301998-03-03 22:02:19 +0000575}
Fred Drake42b31a51998-03-27 05:16:10 +0000576init_myformat();
Fred Drake6659c301998-03-03 22:02:19 +0000577
Fred Drakeab032151999-05-13 18:36:54 +0000578# Create an index entry, but include the string in the target anchor
Fred Drake6659c301998-03-03 22:02:19 +0000579# instead of the dummy filler.
580#
581sub make_str_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000582 my($str) = @_;
583 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000584 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000585 return "$aname$str</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000586}
587
Fred Drakee15956b2000-04-03 04:51:13 +0000588$REFCOUNTS_LOADED = 0;
589
590sub load_refcounts{
591 $REFCOUNTS_LOADED = 1;
592
593 use File::Basename;
594 my $myname, $mydir, $myext;
595 ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*');
596 chop $mydir; # remove trailing '/'
597 ($myname, $mydir, $myext) = fileparse($mydir, '\..*');
598 chop $mydir; # remove trailing '/'
599 $mydir = getcwd() . "$dd$mydir"
600 unless $mydir =~ s|^/|/|;
601 local $_;
602 my $filename = "$mydir${dd}api${dd}refcounts.dat";
603 open(REFCOUNT_FILE, "<$filename") || die "\n$!\n";
604 print "[loading API refcount data]";
605 while (<REFCOUNT_FILE>) {
Fred Drakec2578c52000-04-10 18:26:45 +0000606 if (/([a-zA-Z0-9_]+):PyObject\*:([a-zA-Z0-9_]*):(0|[-+]1|null):(.*)$/) {
Fred Drakee15956b2000-04-03 04:51:13 +0000607 my($func, $param, $count, $comment) = ($1, $2, $3, $4);
608 #print "\n$func($param) --> $count";
609 $REFCOUNTS{"$func:$param"} = $count;
610 }
611 }
612}
613
614sub get_refcount{
615 my ($func, $param) = @_;
616 load_refcounts()
617 unless $REFCOUNTS_LOADED;
618 return $REFCOUNTS{"$func:$param"};
619}
620
Fred Drake6659c301998-03-03 22:02:19 +0000621sub do_env_cfuncdesc{
622 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000623 my $return_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000624 my $function_name = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000625 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000626 my $idx = make_str_index_entry(
627 "<tt class='cfunction'>$function_name()</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000628 $idx =~ s/ \(.*\)//;
629 $idx =~ s/\(\)//; # ????
Fred Drakee15956b2000-04-03 04:51:13 +0000630 my $result_rc = get_refcount($function_name, '');
631 my $rcinfo = '';
632 if ($result_rc eq '+1') {
633 $rcinfo = '<span class="label">Return value:</span>'
634 . "\n <span class=\"value\">New reference.</span>";
635 }
636 elsif ($result_rc eq '0') {
637 $rcinfo = '<span class="label">Return value:</span>'
638 . "\n <span class=\"value\">Borrowed reference.</span>";
639 }
Fred Drakec2578c52000-04-10 18:26:45 +0000640 elsif ($result_rc eq 'null') {
641 $rcinfo = '<span class="label">Return value:</span>'
642 . "\n <span class=\"value\">Always NULL.</span>";
643 }
Fred Drakee15956b2000-04-03 04:51:13 +0000644 if ($rcinfo ne '') {
645 $rcinfo = "\n<div class=\"refcount-info\">\n $rcinfo\n</div>";
646 }
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000647 return "<dl><dt>$return_type <b>$idx</b> (<var>$arg_list</var>)\n<dd>"
Fred Drakee15956b2000-04-03 04:51:13 +0000648 . $rcinfo
Fred Drake62e43691998-08-10 19:40:44 +0000649 . $_
650 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000651}
652
Fred Drakee15956b2000-04-03 04:51:13 +0000653sub do_env_csimplemacrodesc{
654 local($_) = @_;
655 my $name = next_argument();
656 my $idx = make_str_index_entry("<tt class='macro'>$name</tt>");
657 return "<dl><dt><b>$idx</b>\n<dd>"
658 . $_
659 . '</dl>'
660}
661
Fred Drake6659c301998-03-03 22:02:19 +0000662sub do_env_ctypedesc{
663 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +0000664 my $index_name = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000665 my $type_name = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000666 $index_name = $type_name
667 unless $index_name;
668 my($name,$aname,$ahref) = new_link_info();
669 add_index_entry("<tt class='ctype'>$index_name</tt> (C type)", $ahref);
670 return "<dl><dt><b><tt class='ctype'>$aname$type_name</a></tt></b>\n<dd>"
Fred Drake62e43691998-08-10 19:40:44 +0000671 . $_
672 . '</dl>'
Fred Drake6659c301998-03-03 22:02:19 +0000673}
674
675sub do_env_cvardesc{
676 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000677 my $var_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000678 my $var_name = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000679 my $idx = make_str_index_entry("<tt class='cdata'>$var_name</tt>"
Fred Drake90fdda51999-02-16 20:27:42 +0000680 . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000681 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000682 return "<dl><dt>$var_type <b>$idx</b>\n"
683 . '<dd>'
684 . $_
685 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000686}
687
688sub do_env_funcdesc{
689 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000690 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000691 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000692 my $idx = make_str_index_entry("<tt class='function'>$function_name()</tt>"
Fred Drake08932051998-04-17 02:15:42 +0000693 . get_indexsubitem());
694 $idx =~ s/ \(.*\)//;
Fred Drakeccc62721999-01-05 22:16:29 +0000695 $idx =~ s/\(\)<\/tt>/<\/tt>/;
Fred Drake62e43691998-08-10 19:40:44 +0000696 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000697}
698
699sub do_env_funcdescni{
700 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000701 my $function_name = next_argument();
702 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000703 return "<dl><dt><b><tt class='function'>$function_name</tt></b>"
Fred Drake90fdda51999-02-16 20:27:42 +0000704 . " (<var>$arg_list</var>)\n"
705 . '<dd>'
706 . $_
707 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000708}
709
710sub do_cmd_funcline{
711 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000712 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000713 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000714 my $prefix = "<tt class='function'>$function_name()</tt>";
Fred Drakeca675e41999-04-21 15:58:58 +0000715 my $idx = make_str_index_entry($prefix . get_indexsubitem());
716 $prefix =~ s/\(\)//;
717
718 return "<dt><b>$prefix</b> (<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000719}
720
Fred Drake6b3fb781999-07-12 16:50:09 +0000721sub do_cmd_funclineni{
722 local($_) = @_;
723 my $function_name = next_argument();
724 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000725 my $prefix = "<tt class='function'>$function_name</tt>";
Fred Drake6b3fb781999-07-12 16:50:09 +0000726
727 return "<dt><b>$prefix</b> (<var>$arg_list</var>)\n<dd>" . $_;
728}
729
Fred Drake6659c301998-03-03 22:02:19 +0000730# Change this flag to index the opcode entries. I don't think it's very
731# useful to index them, since they're only presented to describe the dis
732# module.
733#
734$INDEX_OPCODES = 0;
735
736sub do_env_opcodedesc{
737 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000738 my $opcode_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000739 my $arg_list = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000740 my $idx;
741 if ($INDEX_OPCODES) {
Fred Drakee15956b2000-04-03 04:51:13 +0000742 $idx = make_str_index_entry("<tt class='opcode'>$opcode_name</tt>"
743 . " (byte code instruction)");
Fred Drake08932051998-04-17 02:15:42 +0000744 $idx =~ s/ \(byte code instruction\)//;
745 }
746 else {
Fred Drakee15956b2000-04-03 04:51:13 +0000747 $idx = "<tt class='opcode'>$opcode_name</tt>";
Fred Drake08932051998-04-17 02:15:42 +0000748 }
749 my $stuff = "<dl><dt><b>$idx</b>";
Fred Drake6659c301998-03-03 22:02:19 +0000750 if ($arg_list) {
751 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
752 }
Fred Drake62e43691998-08-10 19:40:44 +0000753 return $stuff . "\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000754}
755
756sub do_env_datadesc{
757 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000758 my $dataname = next_argument();
759 my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000760 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000761 return "<dl><dt><b>$idx</b>\n<dd>"
762 . $_
763 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000764}
765
766sub do_env_datadescni{
767 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000768 my $idx = next_argument();
769 if (! $STRING_INDEX_TT) {
770 $idx = "<tt>$idx</tt>";
Fred Drake6659c301998-03-03 22:02:19 +0000771 }
Fred Drake62e43691998-08-10 19:40:44 +0000772 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000773}
774
775sub do_cmd_dataline{
776 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000777 my $data_name = next_argument();
778 my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem());
Fred Drake6659c301998-03-03 22:02:19 +0000779 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000780 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000781}
782
Fred Drakeadb272c2000-04-10 17:47:14 +0000783sub do_cmd_datalineni{
784 local($_) = @_;
785 my $data_name = next_argument();
786 return "<dt><b><tt>$data_name</tt></b><dd>" . $_;
787}
788
Fred Drake42b31a51998-03-27 05:16:10 +0000789sub do_env_excdesc{
790 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000791 my $excname = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000792 my $idx = make_str_index_entry("<tt class='exception'>$excname</tt>");
Fred Drake62e43691998-08-10 19:40:44 +0000793 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'
Fred Drake42b31a51998-03-27 05:16:10 +0000794}
795
Fred Drake62e43691998-08-10 19:40:44 +0000796sub do_env_fulllineitems{ return do_env_itemize(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000797
798
Fred Drakec9a44381998-03-17 06:29:13 +0000799sub do_env_classdesc{
800 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000801 $THIS_CLASS = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000802 my $arg_list = next_argument();
803 $idx = make_str_index_entry(
Fred Drakee15956b2000-04-03 04:51:13 +0000804 "<tt class='class'>$THIS_CLASS</tt> (class in $THIS_MODULE)" );
Fred Drake08932051998-04-17 02:15:42 +0000805 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000806 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drakec9a44381998-03-17 06:29:13 +0000807}
808
Fred Drake42b31a51998-03-27 05:16:10 +0000809
810sub do_env_methoddesc{
811 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000812 my $class_name = next_optional_argument();
813 $class_name = $THIS_CLASS
814 unless $class_name;
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000815 my $method = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000816 my $arg_list = next_argument();
817 my $extra = '';
818 if ($class_name) {
819 $extra = " ($class_name method)";
Fred Drake42b31a51998-03-27 05:16:10 +0000820 }
Fred Drakee15956b2000-04-03 04:51:13 +0000821 my $idx = make_str_index_entry("<tt class='method'>$method()</tt>$extra");
Fred Drake08932051998-04-17 02:15:42 +0000822 $idx =~ s/ \(.*\)//;
823 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000824 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000825}
826
827
Fred Drake7d45f6d1999-01-05 14:39:27 +0000828sub do_cmd_methodline{
829 local($_) = @_;
830 my $class_name = next_optional_argument();
831 $class_name = $THIS_CLASS
832 unless $class_name;
833 my $method = next_argument();
834 my $arg_list = next_argument();
835 my $extra = '';
836 if ($class_name) {
837 $extra = " ($class_name method)";
838 }
Fred Drakee15956b2000-04-03 04:51:13 +0000839 my $idx = make_str_index_entry("<tt class='method'>$method()</tt>$extra");
Fred Drake7d45f6d1999-01-05 14:39:27 +0000840 $idx =~ s/ \(.*\)//;
841 $idx =~ s/\(\)//;
842 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>"
843 . $_;
844}
845
846
Fred Draked64a40d1998-09-10 18:59:13 +0000847sub do_cmd_methodlineni{
848 local($_) = @_;
849 next_optional_argument();
850 my $method = next_argument();
851 my $arg_list = next_argument();
852 return "<dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
853 . $_;
854}
855
Fred Drake42b31a51998-03-27 05:16:10 +0000856sub do_env_methoddescni{
857 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000858 next_optional_argument();
859 my $method = next_argument();
860 my $arg_list = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000861 return "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
862 . $_
863 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000864}
865
866
867sub do_env_memberdesc{
868 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000869 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000870 my $member = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000871 $class = $THIS_CLASS
872 unless $class;
Fred Drake08932051998-04-17 02:15:42 +0000873 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +0000874 $extra = " ($class attribute)"
875 if ($class ne '');
Fred Drakee15956b2000-04-03 04:51:13 +0000876 my $idx = make_str_index_entry("<tt class='member'>$member</tt>$extra");
Fred Drake42b31a51998-03-27 05:16:10 +0000877 $idx =~ s/ \(.*\)//;
878 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000879 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000880}
881
882
Fred Drake5ccf3301998-04-17 20:04:09 +0000883sub do_cmd_memberline{
884 local($_) = @_;
885 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000886 my $member = next_argument();
Fred Drake5ccf3301998-04-17 20:04:09 +0000887 $class = $THIS_CLASS
888 unless $class;
889 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +0000890 $extra = " ($class attribute)"
891 if ($class ne '');
Fred Drakee15956b2000-04-03 04:51:13 +0000892 my $idx = make_str_index_entry("<tt class='member'>$member</tt>$extra");
Fred Drake5ccf3301998-04-17 20:04:09 +0000893 $idx =~ s/ \(.*\)//;
894 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000895 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000896}
897
Fred Drake42b31a51998-03-27 05:16:10 +0000898sub do_env_memberdescni{
899 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000900 next_optional_argument();
901 my $member = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000902 return "<dl><dt><b><tt class='member'>$member</tt></b>\n<dd>"
903 . $_
904 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000905}
906
907
Fred Drake5ccf3301998-04-17 20:04:09 +0000908sub do_cmd_memberlineni{
909 local($_) = @_;
910 next_optional_argument();
911 my $member = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000912 return "<dt><b><tt class='member'>$member</tt></b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000913}
914
Fred Drakee15956b2000-04-03 04:51:13 +0000915@col_aligns = ('<td>', '<td>', '<td>', '<td>');
Fred Drake6659c301998-03-03 22:02:19 +0000916
Fred Drake15799ed1999-02-12 19:23:17 +0000917$TABLE_HEADER_BGCOLOR = $NAV_BGCOLOR;
918
Fred Drakef74e5b71999-04-28 14:58:49 +0000919sub fix_font{
920 # do a little magic on a font name to get the right behavior in the first
921 # column of the output table
922 my $font = @_[0];
923 if ($font eq 'textrm') {
924 $font = '';
925 }
926 elsif ($font eq 'file' || $font eq 'filenq') {
Fred Drakee15956b2000-04-03 04:51:13 +0000927 $font = 'tt class="file"';
928 }
929 elsif ($font eq 'member') {
930 $font = 'tt class="member"';
Fred Drakef74e5b71999-04-28 14:58:49 +0000931 }
932 return $font;
933}
934
Fred Drakee15956b2000-04-03 04:51:13 +0000935sub figure_column_alignment{
936 my $a = @_[0];
937 my $mark = substr($a, 0, 1);
938 my $r = '';
939 if ($mark eq 'c')
940 { $r = ' align="center"'; }
941 elsif ($mark eq 'r')
942 { $r = ' align="right"'; }
943 elsif ($mark eq 'l')
944 { $r = ' align="left"'; }
945 elsif ($mark eq 'p')
946 { $r = ' align="left"'; }
947 return $r;
948}
949
Fred Drake6659c301998-03-03 22:02:19 +0000950sub setup_column_alignments{
951 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +0000952 my($s1,$s2,$s3,$s4) = split(/[|]/,$_);
953 my $a1 = figure_column_alignment($s1);
954 my $a2 = figure_column_alignment($s2);
955 my $a3 = figure_column_alignment($s3);
956 my $a4 = figure_column_alignment($s4);
957 $col_aligns[0] = "<td$a1 valign=\"baseline\">";
958 $col_aligns[1] = "<td$a2>";
959 $col_aligns[2] = "<td$a3>";
960 $col_aligns[3] = "<td$a4>";
Fred Drake79189b51999-04-28 13:54:30 +0000961 # return the aligned header start tags
Fred Drakee15956b2000-04-03 04:51:13 +0000962 return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>");
963}
964
965sub get_table_col1_fonts{
966 my $font = $globals{'lineifont'};
967 my ($sfont,$efont) = ('', '');
968 if ($font) {
969 $sfont = "<$font>";
970 $efont = "</$font>";
971 $efont =~ s/ .*>/>/;
972 }
973 return ($font, $sfont, $efont);
Fred Drake6659c301998-03-03 22:02:19 +0000974}
975
976sub do_env_tableii{
977 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000978 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +0000979 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000980 my $h1 = next_argument();
981 my $h2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +0000982 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +0000983 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +0000984 my $a1 = $col_aligns[0];
985 my $a2 = $col_aligns[1];
986 s/\\lineii</\\lineii[$a1|$a2]</g;
987 return '<table border align="center" style="border-collapse: collapse">'
Fred Drakef74e5b71999-04-28 14:58:49 +0000988 . "\n <thead>"
989 . "\n <tr$TABLE_HEADER_BGCOLOR>"
Fred Drakee15956b2000-04-03 04:51:13 +0000990 . "\n $th1<b>$h1</b>\&nbsp;</th>"
991 . "\n $th2<b>$h2</b>\&nbsp;</th>"
Fred Drakef74e5b71999-04-28 14:58:49 +0000992 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +0000993 . "\n <tbody valign='baseline'>"
994 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +0000995 . "\n </tbody>"
996 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000997}
998
999sub do_cmd_lineii{
1000 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001001 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001002 my $c1 = next_argument();
1003 my $c2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001004 s/[\s\n]+//;
Fred Drakee15956b2000-04-03 04:51:13 +00001005 my($font,$sfont,$efont) = get_table_col1_fonts();
1006 $c2 = '&nbsp;' if ($c2 eq '');
1007 my($c1align,$c2align) = split('\|', $aligns);
1008 my $padding = '';
1009 if ($c1align =~ /align="right"/) {
1010 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001011 }
Fred Drakee15956b2000-04-03 04:51:13 +00001012 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
1013 . " $c2align$c2</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001014 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001015}
1016
1017sub do_env_tableiii{
1018 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001019 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001020 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001021 my $h1 = next_argument();
1022 my $h2 = next_argument();
1023 my $h3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001024 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001025 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001026 my $a1 = $col_aligns[0];
1027 my $a2 = $col_aligns[1];
1028 my $a3 = $col_aligns[2];
1029 s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g;
1030 return '<table border align="center" style="border-collapse: collapse">'
Fred Drakef74e5b71999-04-28 14:58:49 +00001031 . "\n <thead>"
1032 . "\n <tr$TABLE_HEADER_BGCOLOR>"
Fred Drakee15956b2000-04-03 04:51:13 +00001033 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1034 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1035 . "\n $th3<b>$h3</b>\&nbsp;</th>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001036 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001037 . "\n <tbody valign='baseline'>"
Fred Drake62e43691998-08-10 19:40:44 +00001038 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001039 . "\n </tbody>"
1040 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001041}
1042
1043sub do_cmd_lineiii{
1044 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001045 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001046 my $c1 = next_argument();
1047 my $c2 = next_argument();
1048 my $c3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001049 s/[\s\n]+//;
Fred Drakee15956b2000-04-03 04:51:13 +00001050 my($font,$sfont,$efont) = get_table_col1_fonts();
1051 $c3 = '&nbsp;' if ($c3 eq '');
1052 my($c1align,$c2align,$c3align) = split('\|', $aligns);
1053 my $padding = '';
1054 if ($c1align =~ /align="right"/) {
1055 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001056 }
Fred Drakee15956b2000-04-03 04:51:13 +00001057 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001058 . " $c2align$c2</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001059 . " $c3align$c3</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001060 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001061}
1062
Fred Drakea0f4c941998-07-24 22:16:04 +00001063sub do_env_tableiv{
1064 local($_) = @_;
1065 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001066 my $font = fix_font(next_argument());
Fred Drakea0f4c941998-07-24 22:16:04 +00001067 my $h1 = next_argument();
1068 my $h2 = next_argument();
1069 my $h3 = next_argument();
1070 my $h4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001071 s/[\s\n]+//;
Fred Drakea0f4c941998-07-24 22:16:04 +00001072 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001073 my $a1 = $col_aligns[0];
1074 my $a2 = $col_aligns[1];
1075 my $a3 = $col_aligns[2];
1076 my $a4 = $col_aligns[3];
1077 s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g;
1078 return '<table border align="center" style="border-collapse: collapse">'
Fred Drakef74e5b71999-04-28 14:58:49 +00001079 . "\n <thead>"
1080 . "\n <tr$TABLE_HEADER_BGCOLOR>"
Fred Drakee15956b2000-04-03 04:51:13 +00001081 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1082 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1083 . "\n $th3<b>$h3</b>\&nbsp;</th>"
1084 . "\n $th4<b>$h4</b>\&nbsp;</th>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001085 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001086 . "\n <tbody valign='baseline'>"
Fred Drake62e43691998-08-10 19:40:44 +00001087 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001088 . "\n </tbody>"
1089 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001090}
1091
Fred Drakea0f4c941998-07-24 22:16:04 +00001092sub do_cmd_lineiv{
Fred Drake6659c301998-03-03 22:02:19 +00001093 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001094 my $aligns = next_optional_argument();
Fred Drakea0f4c941998-07-24 22:16:04 +00001095 my $c1 = next_argument();
1096 my $c2 = next_argument();
1097 my $c3 = next_argument();
1098 my $c4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001099 s/[\s\n]+//;
Fred Drakee15956b2000-04-03 04:51:13 +00001100 my($font,$sfont,$efont) = get_table_col1_fonts();
1101 $c4 = '&nbsp;' if ($c4 eq '');
1102 my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns);
1103 my $padding = '';
1104 if ($c1align =~ /align="right"/) {
1105 $padding = '&nbsp;';
Fred Drakea0f4c941998-07-24 22:16:04 +00001106 }
Fred Drakee15956b2000-04-03 04:51:13 +00001107 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001108 . " $c2align$c2</td>\n"
1109 . " $c3align$c3</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001110 . " $c4align$c4</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001111 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001112}
1113
Fred Drake6659c301998-03-03 22:02:19 +00001114sub do_cmd_maketitle {
1115 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001116 my $the_title = "\n<div class='titlepage'><center>";
Fred Drake6659c301998-03-03 22:02:19 +00001117 if ($t_title) {
Fred Drake90fdda51999-02-16 20:27:42 +00001118 $the_title .= "\n<h1>$t_title</h1>";
Fred Drake08932051998-04-17 02:15:42 +00001119 } else { write_warnings("\nThis document has no title."); }
Fred Drake6659c301998-03-03 22:02:19 +00001120 if ($t_author) {
1121 if ($t_authorURL) {
Fred Drake08932051998-04-17 02:15:42 +00001122 my $href = translate_commands($t_authorURL);
Fred Drake2d1f81e1999-02-09 16:03:31 +00001123 $href = make_named_href('author', $href,
1124 "<b><font size='+2'>$t_author</font></b>");
Fred Drakec9a44381998-03-17 06:29:13 +00001125 $the_title .= "\n<p>$href</p>";
Fred Drake6659c301998-03-03 22:02:19 +00001126 } else {
Fred Drake2d1f81e1999-02-09 16:03:31 +00001127 $the_title .= ("\n<p><b><font size='+2'>$t_author</font></b></p>");
Fred Drake6659c301998-03-03 22:02:19 +00001128 }
Fred Drake08932051998-04-17 02:15:42 +00001129 } else { write_warnings("\nThere is no author for this document."); }
Fred Drake6659c301998-03-03 22:02:19 +00001130 if ($t_institute) {
Fred Drakec9a44381998-03-17 06:29:13 +00001131 $the_title .= "\n<p>$t_institute</p>";}
Fred Draked07868a1998-05-14 21:00:28 +00001132 if ($DEVELOPER_ADDRESS) {
1133 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";}
Fred Drake6659c301998-03-03 22:02:19 +00001134 if ($t_affil) {
Fred Drakec9a44381998-03-17 06:29:13 +00001135 $the_title .= "\n<p><i>$t_affil</i></p>";}
Fred Drake6659c301998-03-03 22:02:19 +00001136 if ($t_date) {
Fred Drakec9a44381998-03-17 06:29:13 +00001137 $the_title .= "\n<p><strong>$t_date</strong>";
Fred Drake6659c301998-03-03 22:02:19 +00001138 if ($PYTHON_VERSION) {
1139 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";}
1140 $the_title .= "</p>"
1141 }
1142 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +00001143 $the_title .= "\n<p>$t_address</p>";
1144 } else { $the_title .= "\n<p>"}
Fred Drake6659c301998-03-03 22:02:19 +00001145 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +00001146 $the_title .= "\n<p>$t_email</p>";
1147 }# else { $the_title .= "</p>" }
Fred Drake90fdda51999-02-16 20:27:42 +00001148 $the_title .= "\n</center></div>";
Fred Drake62e43691998-08-10 19:40:44 +00001149 return $the_title . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +00001150}
1151
1152
Fred Drake885215c1998-05-20 21:32:09 +00001153#
Fred Drakea0f4c941998-07-24 22:16:04 +00001154# Module synopsis support
1155#
1156
1157require SynopsisTable;
1158
Fred Drakef7685d71998-07-25 03:31:46 +00001159sub get_chapter_id(){
1160 my $id = do_cmd_thechapter('');
Fred Drake45f26011998-08-04 22:07:18 +00001161 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
1162 $id =~ s/\.//;
Fred Drakef7685d71998-07-25 03:31:46 +00001163 return $id;
Fred Drakea0f4c941998-07-24 22:16:04 +00001164}
1165
Fred Drakef7685d71998-07-25 03:31:46 +00001166%ModuleSynopses = ('chapter' => 'SynopsisTable instance');
1167
1168sub get_synopsis_table($){
1169 my($chap) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001170 my $st = $ModuleSynopses{$chap};
Fred Drakef7685d71998-07-25 03:31:46 +00001171 my $key;
1172 foreach $key (keys %ModuleSynopses) {
1173 if ($key eq $chap) {
1174 return $ModuleSynopses{$chap};
1175 }
Fred Drakea0f4c941998-07-24 22:16:04 +00001176 }
Fred Drakef7685d71998-07-25 03:31:46 +00001177 $st = SynopsisTable->new();
1178 $ModuleSynopses{$chap} = $st;
Fred Drakea0f4c941998-07-24 22:16:04 +00001179 return $st;
1180}
1181
Fred Drake62e43691998-08-10 19:40:44 +00001182sub do_cmd_moduleauthor{
1183 local($_) = @_;
1184 next_argument();
1185 next_argument();
1186 return $_;
1187}
1188
1189sub do_cmd_sectionauthor{
1190 local($_) = @_;
1191 next_argument();
1192 next_argument();
1193 return $_;
1194}
1195
Fred Drakea0f4c941998-07-24 22:16:04 +00001196sub do_cmd_declaremodule{
1197 local($_) = @_;
1198 my $key = next_optional_argument();
1199 my $type = next_argument();
1200 my $name = next_argument();
1201 my $st = get_synopsis_table(get_chapter_id());
1202 #
1203 $key = $name unless $key;
1204 $type = 'built-in' if $type eq 'builtin';
1205 $st->declare($name, $key, $type);
1206 define_module($type, $name);
Fred Drake62e43691998-08-10 19:40:44 +00001207 return anchor_label("module-$key",$CURRENT_FILE,$_)
Fred Drakea0f4c941998-07-24 22:16:04 +00001208}
1209
1210sub do_cmd_modulesynopsis{
1211 local($_) = @_;
1212 my $st = get_synopsis_table(get_chapter_id());
Fred Drake1cc58991999-04-13 22:08:59 +00001213 $st->set_synopsis($THIS_MODULE, translate_commands(next_argument()));
Fred Drake62e43691998-08-10 19:40:44 +00001214 return $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001215}
1216
1217sub do_cmd_localmoduletable{
1218 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001219 my $chap = get_chapter_id();
Fred Drake557460c1999-03-02 16:05:35 +00001220 return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001221}
1222
1223sub process_all_localmoduletables{
Fred Drake557460c1999-03-02 16:05:35 +00001224 while (/<tex2html-localmoduletable><(\d+)>/) {
Fred Drakef7685d71998-07-25 03:31:46 +00001225 my $match = $&;
Fred Drakea0f4c941998-07-24 22:16:04 +00001226 my $chap = $1;
1227 my $st = get_synopsis_table($chap);
1228 my $data = $st->tohtml();
Fred Drakef7685d71998-07-25 03:31:46 +00001229 s/$match/$data/;
Fred Drakea0f4c941998-07-24 22:16:04 +00001230 }
1231}
Fred Drake557460c1999-03-02 16:05:35 +00001232sub process_python_state{
1233 process_all_localmoduletables();
Fred Drake557460c1999-03-02 16:05:35 +00001234}
Fred Drakea0f4c941998-07-24 22:16:04 +00001235
1236
1237#
1238# "See also:" -- references placed at the end of a \section
1239#
1240
1241sub do_env_seealso{
Fred Drakee15956b2000-04-03 04:51:13 +00001242 return "<div class='seealso'>\n "
1243 . "<p class='heading'><b>See Also:</b></p>\n"
Fred Drake90fdda51999-02-16 20:27:42 +00001244 . @_[0]
1245 . '</div>';
Fred Drakea0f4c941998-07-24 22:16:04 +00001246}
1247
1248sub do_cmd_seemodule{
1249 # Insert the right magic to jump to the module definition. This should
1250 # work most of the time, at least for repeat builds....
1251 local($_) = @_;
1252 my $key = next_optional_argument();
1253 my $module = next_argument();
1254 my $text = next_argument();
Fred Drake84bd6f31999-05-11 15:42:51 +00001255 my $period = '.';
Fred Drakea0f4c941998-07-24 22:16:04 +00001256 $key = $module
1257 unless $key;
Fred Drake84bd6f31999-05-11 15:42:51 +00001258 if ($text =~ /\.$/) {
1259 $period = '';
1260 }
Fred Drakee15956b2000-04-03 04:51:13 +00001261 return '<dl compact class="seemodule">'
1262 . "\n <dt>Module <b><tt class='module'><a href='module-$key.html'>"
Fred Drake84bd6f31999-05-11 15:42:51 +00001263 . "$module</a></tt>:</b>"
1264 . "\n <dd>$text$period\n </dl>"
Fred Drake90fdda51999-02-16 20:27:42 +00001265 . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001266}
1267
1268sub do_cmd_seetext{
Fred Drake79189b51999-04-28 13:54:30 +00001269 local($_) = @_;
1270 my $content = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +00001271 return '<div class="seetext"><p>' . $content . '</div>' . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001272}
1273
1274
1275#
Fred Drake885215c1998-05-20 21:32:09 +00001276# Definition list support.
1277#
1278
1279sub do_env_definitions{
1280 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001281 return "<dl class='definitions'>$_</dl>\n";
Fred Drake885215c1998-05-20 21:32:09 +00001282}
1283
1284sub do_cmd_term{
1285 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001286 my $term = next_argument();
1287 my($name,$aname,$ahref) = new_link_info();
Fred Drake885215c1998-05-20 21:32:09 +00001288 # could easily add an index entry here...
Fred Drake62e43691998-08-10 19:40:44 +00001289 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
Fred Drake885215c1998-05-20 21:32:09 +00001290}
1291
1292
Fred Drake2ff880e1999-02-05 18:31:29 +00001293process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_);
1294code # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001295declaremodule # [] # {} # {}
1296memberline # [] # {}
1297methodline # [] # {} # {}
1298modulesynopsis # {}
Fred Drake557460c1999-03-02 16:05:35 +00001299platform # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001300samp # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001301setindexsubitem # {}
Fred Drakef32834c1999-02-12 22:06:32 +00001302withsubitem # {} # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001303_RAW_ARG_DEFERRED_CMDS_
1304
1305
Fred Drake6659c301998-03-03 22:02:19 +000013061; # This must be the last line