blob: 8606ece970c960152036f11a802bc46a75471e92 [file] [log] [blame]
Fred Drake6659c301998-03-03 22:02:19 +00001# python.perl by Fred L. Drake, Jr. <fdrake@acm.org> -*- perl -*-
2#
3# Heavily based on Guido van Rossum's myformat.perl (now obsolete).
4#
5# Extension to LaTeX2HTML for documents using myformat.sty.
6# Subroutines of the form do_cmd_<name> here define translations
7# for LaTeX commands \<name> defined in the corresponding .sty file.
8
9package main;
10
11
Fred Drake08932051998-04-17 02:15:42 +000012sub next_argument{
Fred Drakeccc62721999-01-05 22:16:29 +000013 my $param;
14 $param = missing_braces()
15 unless ((s/$next_pair_pr_rx/$param=$2;''/eo)
16 ||(s/$next_pair_rx/$param=$2;''/eo));
Fred Drake62e43691998-08-10 19:40:44 +000017 return $param;
Fred Drake08932051998-04-17 02:15:42 +000018}
19
20sub next_optional_argument{
21 my($param,$rx) = ('', "^\\s*(\\[([^]]*)\\])?");
Fred Drake5ccf3301998-04-17 20:04:09 +000022 s/$rx/$param=$2;''/eo;
Fred Drake62e43691998-08-10 19:40:44 +000023 return $param;
Fred Drake08932051998-04-17 02:15:42 +000024}
25
Fred Drakee16f6791998-05-15 04:28:37 +000026
27# This is a fairly simple hack; it supports \let when it is used to create
28# (or redefine) a macro to exactly be some other macro: \let\newname=\oldname.
Fred Drake5b73cdf1998-05-15 16:59:38 +000029# Many possible uses of \let aren't supported or aren't supported correctly.
Fred Drakee16f6791998-05-15 04:28:37 +000030#
31sub do_cmd_let{
32 local($_) = @_;
33 my $matched = 0;
Fred Drake7a4ad0f1998-05-15 13:45:54 +000034 s/[\\]([a-zA-Z]+)\s*(=\s*)?[\\]([a-zA-Z]*)/$matched=1; ''/e;
Fred Drakee16f6791998-05-15 04:28:37 +000035 if ($matched) {
36 my($new, $old) = ($1, $3);
37 eval "sub do_cmd_$new { do_cmd_$old" . '(@_); }';
38 print "\ndefining handler for \\$new using \\$old\n";
39 }
Fred Drake7a4ad0f1998-05-15 13:45:54 +000040 else {
41 s/[\\]([a-zA-Z]+)\s*(=\s*)?([^\\])/$matched=1; ''/es;
42 if ($matched) {
43 my($new, $char) = ($1, $3);
44 eval "sub do_cmd_$new { \"\\$char\" . \@_[0]; }";
45 print "\ndefining handler for \\$new to insert '$char'\n";
46 }
47 else {
48 write_warnings("Could not interpret \\let construct...");
49 }
50 }
Fred Drake62e43691998-08-10 19:40:44 +000051 return $_;
Fred Drakee16f6791998-05-15 04:28:37 +000052}
53
54
Fred Drakec3fd45f2000-06-15 22:41:48 +000055# the older version of LaTeX2HTML we use doesn't support this, but we use it:
56
57sub do_cmd_textasciitilde{ '~' . @_[0]; }
58
59
Fred Drake6659c301998-03-03 22:02:19 +000060# words typeset in a special way (not in HTML though)
61
62sub do_cmd_ABC{ 'ABC' . @_[0]; }
63sub do_cmd_UNIX{ 'Unix'. @_[0]; }
64sub do_cmd_ASCII{ 'ASCII' . @_[0]; }
65sub do_cmd_POSIX{ 'POSIX' . @_[0]; }
66sub do_cmd_C{ 'C' . @_[0]; }
67sub do_cmd_Cpp{ 'C++' . @_[0]; }
68sub do_cmd_EOF{ 'EOF' . @_[0]; }
Fred Drakee15956b2000-04-03 04:51:13 +000069sub do_cmd_NULL{ '<tt class="constant">NULL</tt>' . @_[0]; }
Fred Drake6659c301998-03-03 22:02:19 +000070
71sub do_cmd_e{ '&#92;' . @_[0]; }
72
Fred Draked07868a1998-05-14 21:00:28 +000073$DEVELOPER_ADDRESS = '';
Fred Drake6659c301998-03-03 22:02:19 +000074$PYTHON_VERSION = '';
75
76sub do_cmd_version{ $PYTHON_VERSION . @_[0]; }
77sub do_cmd_release{
78 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +000079 $PYTHON_VERSION = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000080 return $_;
Fred Drake6659c301998-03-03 22:02:19 +000081}
82
83sub do_cmd_authoraddress{
84 local($_) = @_;
Fred Draked07868a1998-05-14 21:00:28 +000085 $DEVELOPER_ADDRESS = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000086 return $_;
Fred Drake6659c301998-03-03 22:02:19 +000087}
88
Fred Drakee16f6791998-05-15 04:28:37 +000089#sub do_cmd_developer{ do_cmd_author(@_[0]); }
90#sub do_cmd_developers{ do_cmd_author(@_[0]); }
91#sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); }
Fred Draked07868a1998-05-14 21:00:28 +000092
Fred Drake6659c301998-03-03 22:02:19 +000093sub do_cmd_hackscore{
94 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +000095 next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000096 return '_' . $_;
Fred Drake6659c301998-03-03 22:02:19 +000097}
98
Fred Drake08932051998-04-17 02:15:42 +000099sub use_wrappers{
100 local($_,$before,$after) = @_;
101 my $stuff = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000102 return $before . $stuff . $after . $_;
Fred Drake08932051998-04-17 02:15:42 +0000103}
104
Fred Drake62e43691998-08-10 19:40:44 +0000105sub use_sans_serif{
Fred Drakeccc62721999-01-05 22:16:29 +0000106 return use_wrappers(@_[0], '<font face="sans-serif">', '</font>');
Fred Drake62e43691998-08-10 19:40:44 +0000107}
108sub use_italics{
109 return use_wrappers(@_[0], '<i>', '</i>');
110}
Fred Drake08932051998-04-17 02:15:42 +0000111
Fred Drake6659c301998-03-03 22:02:19 +0000112sub do_cmd_optional{
Fred Drake62e43691998-08-10 19:40:44 +0000113 return use_wrappers(@_[0], "</var><big>\[</big><var>",
114 "</var><big>\]</big><var>");
Fred Drake6659c301998-03-03 22:02:19 +0000115}
116
Fred Drakec9a44381998-03-17 06:29:13 +0000117# Logical formatting (some based on texinfo), needs to be converted to
118# minimalist HTML. The "minimalist" is primarily to reduce the size of
119# output files for users that read them over the network rather than
120# from local repositories.
Fred Drake6659c301998-03-03 22:02:19 +0000121
Fred Drake2cafcbb1999-03-25 16:57:04 +0000122# \file and \samp are at the end of this file since they screw up fontlock.
123
Fred Drake2ff880e1999-02-05 18:31:29 +0000124sub do_cmd_pytype{ return @_[0]; }
125sub do_cmd_makevar{ return @_[0]; }
Fred Drake90fdda51999-02-16 20:27:42 +0000126sub do_cmd_code{
Fred Drakee15956b2000-04-03 04:51:13 +0000127 return use_wrappers(@_[0], '<code>', '</code>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000128sub do_cmd_module{
Fred Drakee15956b2000-04-03 04:51:13 +0000129 return use_wrappers(@_[0], '<tt class="module">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000130sub do_cmd_keyword{
Fred Drakee15956b2000-04-03 04:51:13 +0000131 return use_wrappers(@_[0], '<tt class="keyword">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000132sub do_cmd_exception{
Fred Drakee15956b2000-04-03 04:51:13 +0000133 return use_wrappers(@_[0], '<tt class="exception">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000134sub do_cmd_class{
Fred Drakee15956b2000-04-03 04:51:13 +0000135 return use_wrappers(@_[0], '<tt class="class">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000136sub do_cmd_function{
Fred Drakee15956b2000-04-03 04:51:13 +0000137 return use_wrappers(@_[0], '<tt class="function">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000138sub do_cmd_constant{
Fred Drakee15956b2000-04-03 04:51:13 +0000139 return use_wrappers(@_[0], '<tt class="constant">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000140sub do_cmd_member{
Fred Drakee15956b2000-04-03 04:51:13 +0000141 return use_wrappers(@_[0], '<tt class="member">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000142sub do_cmd_method{
Fred Drakee15956b2000-04-03 04:51:13 +0000143 return use_wrappers(@_[0], '<tt class="method">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000144sub do_cmd_cfunction{
Fred Drakee15956b2000-04-03 04:51:13 +0000145 return use_wrappers(@_[0], '<tt class="cfunction">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000146sub do_cmd_cdata{
Fred Drakee15956b2000-04-03 04:51:13 +0000147 return use_wrappers(@_[0], '<tt class="cdata">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000148sub do_cmd_ctype{
Fred Drakee15956b2000-04-03 04:51:13 +0000149 return use_wrappers(@_[0], '<tt class="ctype">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000150sub do_cmd_regexp{
Fred Drakee15956b2000-04-03 04:51:13 +0000151 return use_wrappers(@_[0], '<tt class="regexp">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000152sub do_cmd_character{
Fred Drakee15956b2000-04-03 04:51:13 +0000153 return use_wrappers(@_[0], '"<tt class="character">', '</tt>"'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000154sub do_cmd_program{
Fred Drakee15956b2000-04-03 04:51:13 +0000155 return use_wrappers(@_[0], '<b class="program">', '</b>'); }
Fred Drakec9f5fe01999-11-09 16:59:42 +0000156sub do_cmd_programopt{
157 return use_wrappers(@_[0], '<b class="programopt">', '</b>'); }
Fred Drake0cd60212000-04-11 18:46:59 +0000158sub do_cmd_longprogramopt{
159 # note that the --- will be later converted to -- by LaTeX2HTML
160 return use_wrappers(@_[0], '<b class="programopt">---', '</b>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000161sub do_cmd_email{
Fred Drakee15956b2000-04-03 04:51:13 +0000162 return use_wrappers(@_[0], '<span class="email">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000163sub do_cmd_mimetype{
Fred Drakee15956b2000-04-03 04:51:13 +0000164 return use_wrappers(@_[0], '<span class="mimetype">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000165sub do_cmd_var{
166 return use_wrappers(@_[0], "<var>", "</var>"); }
167sub do_cmd_dfn{
Fred Drakee15956b2000-04-03 04:51:13 +0000168 return use_wrappers(@_[0], '<i class="dfn">', '</i>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000169sub do_cmd_emph{
170 return use_italics(@_); }
171sub do_cmd_file{
Fred Drakee15956b2000-04-03 04:51:13 +0000172 return use_wrappers(@_[0],
173 '<font class="file" face="sans-serif">',
174 '</font>'); }
Fred Drakef74e5b71999-04-28 14:58:49 +0000175sub do_cmd_filenq{
Fred Drakee15956b2000-04-03 04:51:13 +0000176 return do_cmd_file(@_[0]); }
Fred Drake90fdda51999-02-16 20:27:42 +0000177sub do_cmd_samp{
Fred Drakee15956b2000-04-03 04:51:13 +0000178 return use_wrappers(@_[0], '"<tt class="samp">', '</tt>"'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000179sub do_cmd_kbd{
180 return use_wrappers(@_[0], '<kbd>', '</kbd>'); }
181sub do_cmd_strong{
182 return use_wrappers(@_[0], '<b>', '</b>'); }
Fred Drake2cafcbb1999-03-25 16:57:04 +0000183sub do_cmd_textbf{
184 return use_wrappers(@_[0], '<b>', '</b>'); }
185sub do_cmd_textit{
186 return use_wrappers(@_[0], '<i>', '</i>'); }
187
Fred Drakec9a44381998-03-17 06:29:13 +0000188
Fred Drake25817041999-01-13 17:06:34 +0000189sub do_cmd_refmodule{
190 # Insert the right magic to jump to the module definition.
191 local($_) = @_;
192 my $key = next_optional_argument();
193 my $module = next_argument();
194 $key = $module
195 unless $key;
Fred Drakee15956b2000-04-03 04:51:13 +0000196 return "<tt class='module'><a href='module-$key.html'>$module</a></tt>"
197 . $_;
Fred Drake25817041999-01-13 17:06:34 +0000198}
199
Fred Drake1a7af391998-04-01 22:44:56 +0000200sub do_cmd_newsgroup{
201 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000202 my $newsgroup = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000203 my $stuff = "<span class='newsgroup'><a href='news:$newsgroup'>"
204 . "$newsgroup</a></span>";
Fred Drake62e43691998-08-10 19:40:44 +0000205 return $stuff . $_;
Fred Drake1a7af391998-04-01 22:44:56 +0000206}
Fred Drakefc16e781998-03-12 21:03:26 +0000207
208sub do_cmd_envvar{
209 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000210 my $envvar = next_argument();
211 my($name,$aname,$ahref) = new_link_info();
Fred Drake166abba1998-04-08 23:10:54 +0000212 # The <tt> here is really to keep buildindex.py from making
213 # the variable name case-insensitive.
214 add_index_entry("environment variables!$envvar@<tt>\$$envvar</tt>",
215 $ahref);
Fred Drake42b31a51998-03-27 05:16:10 +0000216 add_index_entry("$envvar@\$$envvar", $ahref);
Fred Drakee15956b2000-04-03 04:51:13 +0000217 $aname =~ s/<a/<a class="envvar"/;
Fred Draked37cecf1999-09-23 16:45:08 +0000218 return "$aname\$$envvar</a>" . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000219}
220
Fred Drake6659c301998-03-03 22:02:19 +0000221sub do_cmd_url{
222 # use the URL as both text and hyperlink
223 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000224 my $url = next_argument();
Fred Drake6659c301998-03-03 22:02:19 +0000225 $url =~ s/~/&#126;/g;
Fred Drakee15956b2000-04-03 04:51:13 +0000226 return "<a class=\"url\" href=\"$url\">$url</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000227}
228
229sub do_cmd_manpage{
230 # two parameters: \manpage{name}{section}
231 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000232 my $page = next_argument();
233 my $section = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000234 return "<span class='manpage'><i>$page</i>($section)</span>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000235}
236
Fred Drake37cc0c02000-04-26 18:05:24 +0000237sub get_rfc_url{
238 my $rfcnum = sprintf("%04d", @_[0]);
239 return "http://www.ietf.org/rfc/rfc$rfcnum.txt";
240}
241
Fred Drake6659c301998-03-03 22:02:19 +0000242sub do_cmd_rfc{
243 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000244 my $rfcnumber = next_argument();
245 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drake37cc0c02000-04-26 18:05:24 +0000246 my $href = get_rfc_url($rfcnumber);
Fred Drake6659c301998-03-03 22:02:19 +0000247 # Save the reference
Fred Drake08932051998-04-17 02:15:42 +0000248 my $nstr = gen_index_id("RFC!RFC $rfcnumber", '');
Fred Drakeccc62721999-01-05 22:16:29 +0000249 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
Fred Drakee15956b2000-04-03 04:51:13 +0000250 return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">RFC $rfcnumber</a>"
Fred Draked52879c1999-09-22 19:58:51 +0000251 . $_);
Fred Drake6659c301998-03-03 22:02:19 +0000252}
253
Fred Drakec9f5fe01999-11-09 16:59:42 +0000254sub do_cmd_citetitle{
255 local($_) = @_;
256 my $url = next_optional_argument();
257 my $title = next_argument();
258 my $repl = '';
259 if ($url) {
260 $repl = ("<em class='citetitle'><a\n"
261 . " href='$url'\n"
262 . " title='$title'\n"
263 . " >$title</a></em>");
264 }
265 else {
266 $repl = "<em class='citetitle'\n >$title</em>";
267 }
268 return $repl . $_;
269}
270
Fred Drake6659c301998-03-03 22:02:19 +0000271sub do_cmd_deprecated{
272 # two parameters: \deprecated{version}{whattodo}
273 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000274 my $release = next_argument();
275 my $reason = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000276 return "<b>Deprecated since release $release.</b>\n$reason<p>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000277}
278
Fred Drake897d12b1998-07-27 20:33:17 +0000279sub do_cmd_versionadded{
280 # one parameter: \versionadded{version}
281 local($_) = @_;
282 my $release = next_argument();
Fred Drake2116d981999-02-02 18:02:48 +0000283 return "\nNew in version $release.\n" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000284}
285
286sub do_cmd_versionchanged{
287 # one parameter: \versionchanged{version}
288 local($_) = @_;
Fred Drake52e76842000-05-02 17:37:42 +0000289 my $explanation = next_optional_argument();
Fred Drake897d12b1998-07-27 20:33:17 +0000290 my $release = next_argument();
Fred Drake52e76842000-05-02 17:37:42 +0000291 my $text = "\nChanged in version $release.\n";
292 if ($release) {
293 $text = "\nChanged in version $release:\n$explanation.\n";
294 }
295 return $text . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000296}
297
Fred Drake557460c1999-03-02 16:05:35 +0000298#
Fred Drake2cafcbb1999-03-25 16:57:04 +0000299# These function handle platform dependency tracking.
Fred Drake557460c1999-03-02 16:05:35 +0000300#
301sub do_cmd_platform{
302 local($_) = @_;
303 my $platform = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000304 $ModulePlatforms{"<tt class='module'>$THIS_MODULE</tt>"} = $platform;
Fred Drake557460c1999-03-02 16:05:35 +0000305 $platform = "Macintosh"
Fred Drake085b8121999-04-21 14:00:29 +0000306 if $platform eq 'Mac';
Fred Drakee15956b2000-04-03 04:51:13 +0000307 return "\n<p class='availability'>Availability: <span"
308 . "\n class='platform'>$platform</span>.</p>\n" . $_;
Fred Drake557460c1999-03-02 16:05:35 +0000309}
310
Fred Drake557460c1999-03-02 16:05:35 +0000311$IGNORE_PLATFORM_ANNOTATION = '';
312sub do_cmd_ignorePlatformAnnotation{
313 local($_) = @_;
314 $IGNORE_PLATFORM_ANNOTATION = next_argument();
315 return $_;
316}
317
Fred Drake6659c301998-03-03 22:02:19 +0000318
319# index commands
320
321$INDEX_SUBITEM = "";
322
323sub get_indexsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000324 return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
Fred Drake6659c301998-03-03 22:02:19 +0000325}
326
327sub do_cmd_setindexsubitem{
328 local($_) = @_;
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000329 $INDEX_SUBITEM = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000330 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000331}
332
Fred Drakefc16e781998-03-12 21:03:26 +0000333sub do_cmd_withsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000334 # We can't really do the right thing, because LaTeX2HTML doesn't
Fred Drakefc16e781998-03-12 21:03:26 +0000335 # do things in the right order, but we need to at least strip this stuff
336 # out, and leave anything that the second argument expanded out to.
337 #
338 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000339 my $oldsubitem = $INDEX_SUBITEM;
340 $INDEX_SUBITEM = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000341 my $stuff = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000342 my $br_id = ++$globals{'max_id'};
343 my $marker = "$O$br_id$C";
Fred Drake7d45f6d1999-01-05 14:39:27 +0000344 return
345 $stuff
Fred Drakeccc62721999-01-05 22:16:29 +0000346 . "\\setindexsubitem$marker$oldsubitem$marker"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000347 . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000348}
349
Fred Drake08932051998-04-17 02:15:42 +0000350# This is the prologue macro which is required to start writing the
Fred Drakeab032151999-05-13 18:36:54 +0000351# mod\jobname.idx file; we can just ignore it. (Defining this suppresses
352# a warning that \makemodindex is unknown.)
Fred Drake08932051998-04-17 02:15:42 +0000353#
Fred Drake62e43691998-08-10 19:40:44 +0000354sub do_cmd_makemodindex{ return @_[0]; }
Fred Drakefc16e781998-03-12 21:03:26 +0000355
Fred Drake42b31a51998-03-27 05:16:10 +0000356# We're in the document subdirectory when this happens!
Fred Drake166abba1998-04-08 23:10:54 +0000357#
Fred Drake08932051998-04-17 02:15:42 +0000358open(IDXFILE, '>index.dat') || die "\n$!\n";
359open(INTLABELS, '>intlabels.pl') || die "\n$!\n";
Fred Drake166abba1998-04-08 23:10:54 +0000360print INTLABELS "%internal_labels = ();\n";
361print INTLABELS "1; # hack in case there are no entries\n\n";
362
363# Using \0 for this is bad because we can't use common tools to work with the
364# resulting files. Things like grep can be useful with this stuff!
365#
366$IDXFILE_FIELD_SEP = "\1";
367
Fred Drakeccc62721999-01-05 22:16:29 +0000368sub write_idxfile{
369 my ($ahref, $str) = @_;
370 print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n";
Fred Drake42b31a51998-03-27 05:16:10 +0000371}
372
Fred Drake42b31a51998-03-27 05:16:10 +0000373
374sub gen_link{
375 my($node,$target) = @_;
376 print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
Fred Drakee15956b2000-04-03 04:51:13 +0000377 return "<a href='$node#$target'>";
Fred Drake42b31a51998-03-27 05:16:10 +0000378}
379
Fred Drake42b31a51998-03-27 05:16:10 +0000380sub add_index_entry{
381 # add an entry to the index structures; ignore the return value
382 my($str,$ahref) = @_;
383 $str = gen_index_id($str, '');
384 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000385 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000386}
387
Fred Drakeccc62721999-01-05 22:16:29 +0000388sub new_link_info{
389 my $name = "l2h-" . ++$globals{'max_id'};
Fred Drakee15956b2000-04-03 04:51:13 +0000390 my $aname = "<a name='$name'>";
Fred Drake42b31a51998-03-27 05:16:10 +0000391 my $ahref = gen_link($CURRENT_FILE, $name);
392 return ($name, $aname, $ahref);
393}
394
Fred Drakeab032151999-05-13 18:36:54 +0000395$IndexMacroPattern = '';
396sub define_indexing_macro{
397 my $count = @_;
398 my $i = 0;
399 for (; $i < $count; ++$i) {
400 my $name = @_[$i];
401 my $cmd = "idx_cmd_$name";
402 die "\nNo function $cmd() defined!\n"
403 if (!defined &$cmd);
404 eval ("sub do_cmd_$name { return process_index_macros("
405 . "\@_[0], '$name'); }");
406 if (length($IndexMacroPattern) == 0) {
407 $IndexMacroPattern = "$name";
408 }
409 else {
410 $IndexMacroPattern .= "|$name";
411 }
412 }
413}
414
415$DEBUG_INDEXING = 0;
416sub process_index_macros{
Fred Drake42b31a51998-03-27 05:16:10 +0000417 local($_) = @_;
Fred Drakeab032151999-05-13 18:36:54 +0000418 my $cmdname = @_[1]; # This is what triggered us in the first place;
419 # we know it's real, so just process it.
Fred Drakeccc62721999-01-05 22:16:29 +0000420 my($name,$aname,$ahref) = new_link_info();
Fred Drakeab032151999-05-13 18:36:54 +0000421 my $cmd = "idx_cmd_$cmdname";
422 print "\nIndexing: \\$cmdname"
423 if $DEBUG_INDEXING;
424 &$cmd($ahref); # modifies $_ and adds index entries
425 while (/^[\s\n]*\\($IndexMacroPattern)</) {
426 $cmdname = "$1";
427 print " \\$cmdname"
428 if $DEBUG_INDEXING;
429 $cmd = "idx_cmd_$cmdname";
430 if (!defined &$cmd) {
431 last;
432 }
433 else {
434 s/^[\s\n]*\\$cmdname//;
435 &$cmd($ahref);
436 }
437 }
Fred Drake62e43691998-08-10 19:40:44 +0000438 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake42b31a51998-03-27 05:16:10 +0000439}
440
Fred Drakeab032151999-05-13 18:36:54 +0000441define_indexing_macro('index');
442sub idx_cmd_index{
Fred Drakeccc62721999-01-05 22:16:29 +0000443 my $str = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000444 add_index_entry("$str", @_[0]);
Fred Drake2e7edb81998-05-11 18:31:17 +0000445}
446
Fred Drakeab032151999-05-13 18:36:54 +0000447define_indexing_macro('kwindex');
448sub idx_cmd_kwindex{
449 my $str = next_argument();
450 add_index_entry("<tt>$str</tt>!keyword", @_[0]);
451 add_index_entry("keyword!<tt>$str</tt>", @_[0]);
452}
453
454define_indexing_macro('indexii');
455sub idx_cmd_indexii{
Fred Drakeccc62721999-01-05 22:16:29 +0000456 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000457 my $str2 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000458 add_index_entry("$str1!$str2", @_[0]);
459 add_index_entry("$str2!$str1", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000460}
461
Fred Drakeab032151999-05-13 18:36:54 +0000462define_indexing_macro('indexiii');
463sub idx_cmd_indexiii{
Fred Drakeccc62721999-01-05 22:16:29 +0000464 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000465 my $str2 = next_argument();
466 my $str3 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000467 add_index_entry("$str1!$str2 $str3", @_[0]);
468 add_index_entry("$str2!$str3, $str1", @_[0]);
469 add_index_entry("$str3!$str1 $str2", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000470}
471
Fred Drakeab032151999-05-13 18:36:54 +0000472define_indexing_macro('indexiv');
473sub idx_cmd_indexiv{
Fred Drakeccc62721999-01-05 22:16:29 +0000474 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000475 my $str2 = next_argument();
476 my $str3 = next_argument();
477 my $str4 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000478 add_index_entry("$str1!$str2 $str3 $str4", @_[0]);
479 add_index_entry("$str2!$str3 $str4, $str1", @_[0]);
480 add_index_entry("$str3!$str4, $str1 $str2", @_[0]);
481 add_index_entry("$str4!$$str1 $str2 $str3", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000482}
483
Fred Drakeab032151999-05-13 18:36:54 +0000484define_indexing_macro('ttindex');
485sub idx_cmd_ttindex{
Fred Drakeccc62721999-01-05 22:16:29 +0000486 my $str = next_argument();
487 my $entry = $str . get_indexsubitem();
Fred Drakeab032151999-05-13 18:36:54 +0000488 add_index_entry($entry, @_[0]);
Fred Drakec9a44381998-03-17 06:29:13 +0000489}
Fred Drake6659c301998-03-03 22:02:19 +0000490
491sub my_typed_index_helper{
Fred Drakeab032151999-05-13 18:36:54 +0000492 my($word,$ahref) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000493 my $str = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000494 add_index_entry("$str $word", $ahref);
495 add_index_entry("$word!$str", $ahref);
Fred Drake6659c301998-03-03 22:02:19 +0000496}
497
Fred Drakeab032151999-05-13 18:36:54 +0000498define_indexing_macro('stindex', 'opindex', 'exindex', 'obindex');
499sub idx_cmd_stindex{ my_typed_index_helper('statement', @_[0]); }
500sub idx_cmd_opindex{ my_typed_index_helper('operator', @_[0]); }
501sub idx_cmd_exindex{ my_typed_index_helper('exception', @_[0]); }
502sub idx_cmd_obindex{ my_typed_index_helper('object', @_[0]); }
Fred Drake6659c301998-03-03 22:02:19 +0000503
Fred Drakeab032151999-05-13 18:36:54 +0000504define_indexing_macro('bifuncindex');
505sub idx_cmd_bifuncindex{
Fred Drakeccc62721999-01-05 22:16:29 +0000506 my $str = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000507 add_index_entry("<tt class='function'>$str()</tt> (built-in function)",
508 @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000509}
510
511
Fred Drake6659c301998-03-03 22:02:19 +0000512sub make_mod_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000513 my($str,$define) = @_;
514 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000515 # equivalent of add_index_entry() using $define instead of ''
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000516 $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/
517 if ($define eq 'DEF');
Fred Drake42b31a51998-03-27 05:16:10 +0000518 $str = gen_index_id($str, $define);
519 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000520 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000521
Fred Drakec9a44381998-03-17 06:29:13 +0000522 if ($define eq 'DEF') {
Fred Drake42b31a51998-03-27 05:16:10 +0000523 # add to the module index
Fred Drakee15956b2000-04-03 04:51:13 +0000524 $str =~ /(<tt.*<\/tt>)/;
525 my $nstr = $1;
Fred Drake42b31a51998-03-27 05:16:10 +0000526 $Modules{$nstr} .= $ahref;
Fred Drake6659c301998-03-03 22:02:19 +0000527 }
Fred Drake62e43691998-08-10 19:40:44 +0000528 return "$aname$anchor_invisible_mark</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000529}
530
Fred Drake557460c1999-03-02 16:05:35 +0000531
Fred Drakec9a44381998-03-17 06:29:13 +0000532$THIS_MODULE = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000533$THIS_CLASS = '';
Fred Drakec9a44381998-03-17 06:29:13 +0000534
Fred Drakea0f4c941998-07-24 22:16:04 +0000535sub define_module{
536 my($word,$name) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000537 my $section_tag = join('', @curr_sec_id);
Fred Drake3e4c6141999-05-17 15:00:32 +0000538 if ($word ne "built-in" && $word ne "extension"
539 && $word ne "standard" && $word ne "") {
540 write_warnings("Bad module type '$word'"
541 . " for \\declaremodule (module $name)");
542 $word = "";
543 }
Fred Drake6659c301998-03-03 22:02:19 +0000544 $word = "$word " if $word;
Fred Drakea0f4c941998-07-24 22:16:04 +0000545 $THIS_MODULE = "$name";
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000546 $INDEX_SUBITEM = "(in $name)";
547 print "[$name]";
Fred Drakee15956b2000-04-03 04:51:13 +0000548 return make_mod_index_entry(
549 "<tt class='module'>$name</tt> (${word}module)", 'DEF');
Fred Drakea0f4c941998-07-24 22:16:04 +0000550}
551
552sub my_module_index_helper{
553 local($word, $_) = @_;
554 my $name = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000555 return define_module($word, $name) . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000556}
557
Fred Drake62e43691998-08-10 19:40:44 +0000558sub do_cmd_modindex{ return my_module_index_helper('', @_); }
559sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); }
560sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); }
561sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000562
Fred Drakeab032151999-05-13 18:36:54 +0000563sub ref_module_index_helper{
Fred Drake37cc0c02000-04-26 18:05:24 +0000564 my($word, $ahref) = @_;
Fred Drakeab032151999-05-13 18:36:54 +0000565 my $str = next_argument();
566 $word = "$word " if $word;
Fred Drakee15956b2000-04-03 04:51:13 +0000567 $str = "<tt class='module'>$str</tt> (${word}module)";
Fred Drakeab032151999-05-13 18:36:54 +0000568 # can't use add_index_entry() since the 2nd arg to gen_index_id() is used;
569 # just inline it all here
570 $str = gen_index_id($str, 'REF');
571 $index{$str} .= $ahref;
572 write_idxfile($ahref, $str);
573}
574
Fred Drake6659c301998-03-03 22:02:19 +0000575# these should be adjusted a bit....
Fred Drakeab032151999-05-13 18:36:54 +0000576define_indexing_macro('refmodindex', 'refbimodindex',
577 'refexmodindex', 'refstmodindex');
578sub idx_cmd_refmodindex{ return ref_module_index_helper('', @_); }
579sub idx_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); }
580sub idx_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); }
581sub idx_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000582
Fred Drake62e43691998-08-10 19:40:44 +0000583sub do_cmd_nodename{ return do_cmd_label(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000584
585sub init_myformat{
Fred Drake08932051998-04-17 02:15:42 +0000586# $anchor_invisible_mark = '';
Fred Drake6659c301998-03-03 22:02:19 +0000587 $anchor_mark = '';
588 $icons{'anchor_mark'} = '';
Fred Drake6659c301998-03-03 22:02:19 +0000589}
Fred Drake42b31a51998-03-27 05:16:10 +0000590init_myformat();
Fred Drake6659c301998-03-03 22:02:19 +0000591
Fred Drakeab032151999-05-13 18:36:54 +0000592# Create an index entry, but include the string in the target anchor
Fred Drake6659c301998-03-03 22:02:19 +0000593# instead of the dummy filler.
594#
595sub make_str_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000596 my($str) = @_;
597 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000598 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000599 return "$aname$str</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000600}
601
Fred Drakee15956b2000-04-03 04:51:13 +0000602$REFCOUNTS_LOADED = 0;
603
604sub load_refcounts{
605 $REFCOUNTS_LOADED = 1;
606
607 use File::Basename;
608 my $myname, $mydir, $myext;
609 ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*');
610 chop $mydir; # remove trailing '/'
611 ($myname, $mydir, $myext) = fileparse($mydir, '\..*');
612 chop $mydir; # remove trailing '/'
613 $mydir = getcwd() . "$dd$mydir"
614 unless $mydir =~ s|^/|/|;
615 local $_;
616 my $filename = "$mydir${dd}api${dd}refcounts.dat";
617 open(REFCOUNT_FILE, "<$filename") || die "\n$!\n";
618 print "[loading API refcount data]";
619 while (<REFCOUNT_FILE>) {
Fred Drakec2578c52000-04-10 18:26:45 +0000620 if (/([a-zA-Z0-9_]+):PyObject\*:([a-zA-Z0-9_]*):(0|[-+]1|null):(.*)$/) {
Fred Drakee15956b2000-04-03 04:51:13 +0000621 my($func, $param, $count, $comment) = ($1, $2, $3, $4);
622 #print "\n$func($param) --> $count";
623 $REFCOUNTS{"$func:$param"} = $count;
624 }
625 }
626}
627
628sub get_refcount{
629 my ($func, $param) = @_;
630 load_refcounts()
631 unless $REFCOUNTS_LOADED;
632 return $REFCOUNTS{"$func:$param"};
633}
634
Fred Drake6659c301998-03-03 22:02:19 +0000635sub do_env_cfuncdesc{
636 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000637 my $return_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000638 my $function_name = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000639 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000640 my $idx = make_str_index_entry(
641 "<tt class='cfunction'>$function_name()</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000642 $idx =~ s/ \(.*\)//;
643 $idx =~ s/\(\)//; # ????
Fred Drakee15956b2000-04-03 04:51:13 +0000644 my $result_rc = get_refcount($function_name, '');
645 my $rcinfo = '';
646 if ($result_rc eq '+1') {
647 $rcinfo = '<span class="label">Return value:</span>'
648 . "\n <span class=\"value\">New reference.</span>";
649 }
650 elsif ($result_rc eq '0') {
651 $rcinfo = '<span class="label">Return value:</span>'
652 . "\n <span class=\"value\">Borrowed reference.</span>";
653 }
Fred Drakec2578c52000-04-10 18:26:45 +0000654 elsif ($result_rc eq 'null') {
655 $rcinfo = '<span class="label">Return value:</span>'
656 . "\n <span class=\"value\">Always NULL.</span>";
657 }
Fred Drakee15956b2000-04-03 04:51:13 +0000658 if ($rcinfo ne '') {
659 $rcinfo = "\n<div class=\"refcount-info\">\n $rcinfo\n</div>";
660 }
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000661 return "<dl><dt>$return_type <b>$idx</b> (<var>$arg_list</var>)\n<dd>"
Fred Drakee15956b2000-04-03 04:51:13 +0000662 . $rcinfo
Fred Drake62e43691998-08-10 19:40:44 +0000663 . $_
664 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000665}
666
Fred Drakee15956b2000-04-03 04:51:13 +0000667sub do_env_csimplemacrodesc{
668 local($_) = @_;
669 my $name = next_argument();
670 my $idx = make_str_index_entry("<tt class='macro'>$name</tt>");
671 return "<dl><dt><b>$idx</b>\n<dd>"
672 . $_
673 . '</dl>'
674}
675
Fred Drake6659c301998-03-03 22:02:19 +0000676sub do_env_ctypedesc{
677 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +0000678 my $index_name = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000679 my $type_name = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000680 $index_name = $type_name
681 unless $index_name;
682 my($name,$aname,$ahref) = new_link_info();
683 add_index_entry("<tt class='ctype'>$index_name</tt> (C type)", $ahref);
684 return "<dl><dt><b><tt class='ctype'>$aname$type_name</a></tt></b>\n<dd>"
Fred Drake62e43691998-08-10 19:40:44 +0000685 . $_
686 . '</dl>'
Fred Drake6659c301998-03-03 22:02:19 +0000687}
688
689sub do_env_cvardesc{
690 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000691 my $var_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000692 my $var_name = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000693 my $idx = make_str_index_entry("<tt class='cdata'>$var_name</tt>"
Fred Drake90fdda51999-02-16 20:27:42 +0000694 . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000695 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000696 return "<dl><dt>$var_type <b>$idx</b>\n"
697 . '<dd>'
698 . $_
699 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000700}
701
702sub do_env_funcdesc{
703 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000704 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000705 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000706 my $idx = make_str_index_entry("<tt class='function'>$function_name()</tt>"
Fred Drake08932051998-04-17 02:15:42 +0000707 . get_indexsubitem());
708 $idx =~ s/ \(.*\)//;
Fred Drakeccc62721999-01-05 22:16:29 +0000709 $idx =~ s/\(\)<\/tt>/<\/tt>/;
Fred Drake62e43691998-08-10 19:40:44 +0000710 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000711}
712
713sub do_env_funcdescni{
714 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000715 my $function_name = next_argument();
716 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000717 return "<dl><dt><b><tt class='function'>$function_name</tt></b>"
Fred Drake90fdda51999-02-16 20:27:42 +0000718 . " (<var>$arg_list</var>)\n"
719 . '<dd>'
720 . $_
721 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000722}
723
724sub do_cmd_funcline{
725 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000726 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000727 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000728 my $prefix = "<tt class='function'>$function_name()</tt>";
Fred Drakeca675e41999-04-21 15:58:58 +0000729 my $idx = make_str_index_entry($prefix . get_indexsubitem());
730 $prefix =~ s/\(\)//;
731
732 return "<dt><b>$prefix</b> (<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000733}
734
Fred Drake6b3fb781999-07-12 16:50:09 +0000735sub do_cmd_funclineni{
736 local($_) = @_;
737 my $function_name = next_argument();
738 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000739 my $prefix = "<tt class='function'>$function_name</tt>";
Fred Drake6b3fb781999-07-12 16:50:09 +0000740
741 return "<dt><b>$prefix</b> (<var>$arg_list</var>)\n<dd>" . $_;
742}
743
Fred Drake6659c301998-03-03 22:02:19 +0000744# Change this flag to index the opcode entries. I don't think it's very
745# useful to index them, since they're only presented to describe the dis
746# module.
747#
748$INDEX_OPCODES = 0;
749
750sub do_env_opcodedesc{
751 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000752 my $opcode_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000753 my $arg_list = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000754 my $idx;
755 if ($INDEX_OPCODES) {
Fred Drakee15956b2000-04-03 04:51:13 +0000756 $idx = make_str_index_entry("<tt class='opcode'>$opcode_name</tt>"
757 . " (byte code instruction)");
Fred Drake08932051998-04-17 02:15:42 +0000758 $idx =~ s/ \(byte code instruction\)//;
759 }
760 else {
Fred Drakee15956b2000-04-03 04:51:13 +0000761 $idx = "<tt class='opcode'>$opcode_name</tt>";
Fred Drake08932051998-04-17 02:15:42 +0000762 }
763 my $stuff = "<dl><dt><b>$idx</b>";
Fred Drake6659c301998-03-03 22:02:19 +0000764 if ($arg_list) {
765 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
766 }
Fred Drake62e43691998-08-10 19:40:44 +0000767 return $stuff . "\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000768}
769
770sub do_env_datadesc{
771 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000772 my $dataname = next_argument();
773 my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000774 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000775 return "<dl><dt><b>$idx</b>\n<dd>"
776 . $_
777 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000778}
779
780sub do_env_datadescni{
781 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000782 my $idx = next_argument();
783 if (! $STRING_INDEX_TT) {
784 $idx = "<tt>$idx</tt>";
Fred Drake6659c301998-03-03 22:02:19 +0000785 }
Fred Drake62e43691998-08-10 19:40:44 +0000786 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000787}
788
789sub do_cmd_dataline{
790 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000791 my $data_name = next_argument();
792 my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem());
Fred Drake6659c301998-03-03 22:02:19 +0000793 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000794 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000795}
796
Fred Drakeadb272c2000-04-10 17:47:14 +0000797sub do_cmd_datalineni{
798 local($_) = @_;
799 my $data_name = next_argument();
800 return "<dt><b><tt>$data_name</tt></b><dd>" . $_;
801}
802
Fred Drake42b31a51998-03-27 05:16:10 +0000803sub do_env_excdesc{
804 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000805 my $excname = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000806 my $idx = make_str_index_entry("<tt class='exception'>$excname</tt>");
Fred Drake62e43691998-08-10 19:40:44 +0000807 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'
Fred Drake42b31a51998-03-27 05:16:10 +0000808}
809
Fred Drake62e43691998-08-10 19:40:44 +0000810sub do_env_fulllineitems{ return do_env_itemize(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000811
812
Fred Drakec9a44381998-03-17 06:29:13 +0000813sub do_env_classdesc{
814 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000815 $THIS_CLASS = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000816 my $arg_list = next_argument();
817 $idx = make_str_index_entry(
Fred Drakee15956b2000-04-03 04:51:13 +0000818 "<tt class='class'>$THIS_CLASS</tt> (class in $THIS_MODULE)" );
Fred Drake08932051998-04-17 02:15:42 +0000819 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000820 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drakec9a44381998-03-17 06:29:13 +0000821}
822
Fred Drake42b31a51998-03-27 05:16:10 +0000823
824sub do_env_methoddesc{
825 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000826 my $class_name = next_optional_argument();
827 $class_name = $THIS_CLASS
828 unless $class_name;
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000829 my $method = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000830 my $arg_list = next_argument();
831 my $extra = '';
832 if ($class_name) {
833 $extra = " ($class_name method)";
Fred Drake42b31a51998-03-27 05:16:10 +0000834 }
Fred Drakee15956b2000-04-03 04:51:13 +0000835 my $idx = make_str_index_entry("<tt class='method'>$method()</tt>$extra");
Fred Drake08932051998-04-17 02:15:42 +0000836 $idx =~ s/ \(.*\)//;
837 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000838 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000839}
840
841
Fred Drake7d45f6d1999-01-05 14:39:27 +0000842sub do_cmd_methodline{
843 local($_) = @_;
844 my $class_name = next_optional_argument();
845 $class_name = $THIS_CLASS
846 unless $class_name;
847 my $method = next_argument();
848 my $arg_list = next_argument();
849 my $extra = '';
850 if ($class_name) {
851 $extra = " ($class_name method)";
852 }
Fred Drakee15956b2000-04-03 04:51:13 +0000853 my $idx = make_str_index_entry("<tt class='method'>$method()</tt>$extra");
Fred Drake7d45f6d1999-01-05 14:39:27 +0000854 $idx =~ s/ \(.*\)//;
855 $idx =~ s/\(\)//;
856 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>"
857 . $_;
858}
859
860
Fred Draked64a40d1998-09-10 18:59:13 +0000861sub do_cmd_methodlineni{
862 local($_) = @_;
863 next_optional_argument();
864 my $method = next_argument();
865 my $arg_list = next_argument();
866 return "<dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
867 . $_;
868}
869
Fred Drake42b31a51998-03-27 05:16:10 +0000870sub do_env_methoddescni{
871 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000872 next_optional_argument();
873 my $method = next_argument();
874 my $arg_list = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000875 return "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
876 . $_
877 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000878}
879
880
881sub do_env_memberdesc{
882 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000883 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000884 my $member = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000885 $class = $THIS_CLASS
886 unless $class;
Fred Drake08932051998-04-17 02:15:42 +0000887 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +0000888 $extra = " ($class attribute)"
889 if ($class ne '');
Fred Drakee15956b2000-04-03 04:51:13 +0000890 my $idx = make_str_index_entry("<tt class='member'>$member</tt>$extra");
Fred Drake42b31a51998-03-27 05:16:10 +0000891 $idx =~ s/ \(.*\)//;
892 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000893 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000894}
895
896
Fred Drake5ccf3301998-04-17 20:04:09 +0000897sub do_cmd_memberline{
898 local($_) = @_;
899 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000900 my $member = next_argument();
Fred Drake5ccf3301998-04-17 20:04:09 +0000901 $class = $THIS_CLASS
902 unless $class;
903 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +0000904 $extra = " ($class attribute)"
905 if ($class ne '');
Fred Drakee15956b2000-04-03 04:51:13 +0000906 my $idx = make_str_index_entry("<tt class='member'>$member</tt>$extra");
Fred Drake5ccf3301998-04-17 20:04:09 +0000907 $idx =~ s/ \(.*\)//;
908 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000909 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000910}
911
Fred Drake42b31a51998-03-27 05:16:10 +0000912sub do_env_memberdescni{
913 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000914 next_optional_argument();
915 my $member = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000916 return "<dl><dt><b><tt class='member'>$member</tt></b>\n<dd>"
917 . $_
918 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000919}
920
921
Fred Drake5ccf3301998-04-17 20:04:09 +0000922sub do_cmd_memberlineni{
923 local($_) = @_;
924 next_optional_argument();
925 my $member = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000926 return "<dt><b><tt class='member'>$member</tt></b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000927}
928
Fred Drakee15956b2000-04-03 04:51:13 +0000929@col_aligns = ('<td>', '<td>', '<td>', '<td>');
Fred Drake6659c301998-03-03 22:02:19 +0000930
Fred Drake15799ed1999-02-12 19:23:17 +0000931$TABLE_HEADER_BGCOLOR = $NAV_BGCOLOR;
932
Fred Drakef74e5b71999-04-28 14:58:49 +0000933sub fix_font{
934 # do a little magic on a font name to get the right behavior in the first
935 # column of the output table
936 my $font = @_[0];
937 if ($font eq 'textrm') {
938 $font = '';
939 }
940 elsif ($font eq 'file' || $font eq 'filenq') {
Fred Drakee15956b2000-04-03 04:51:13 +0000941 $font = 'tt class="file"';
942 }
943 elsif ($font eq 'member') {
944 $font = 'tt class="member"';
Fred Drakef74e5b71999-04-28 14:58:49 +0000945 }
946 return $font;
947}
948
Fred Drakee15956b2000-04-03 04:51:13 +0000949sub figure_column_alignment{
950 my $a = @_[0];
951 my $mark = substr($a, 0, 1);
952 my $r = '';
953 if ($mark eq 'c')
954 { $r = ' align="center"'; }
955 elsif ($mark eq 'r')
956 { $r = ' align="right"'; }
957 elsif ($mark eq 'l')
958 { $r = ' align="left"'; }
959 elsif ($mark eq 'p')
960 { $r = ' align="left"'; }
961 return $r;
962}
963
Fred Drake6659c301998-03-03 22:02:19 +0000964sub setup_column_alignments{
965 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +0000966 my($s1,$s2,$s3,$s4) = split(/[|]/,$_);
967 my $a1 = figure_column_alignment($s1);
968 my $a2 = figure_column_alignment($s2);
969 my $a3 = figure_column_alignment($s3);
970 my $a4 = figure_column_alignment($s4);
971 $col_aligns[0] = "<td$a1 valign=\"baseline\">";
972 $col_aligns[1] = "<td$a2>";
973 $col_aligns[2] = "<td$a3>";
974 $col_aligns[3] = "<td$a4>";
Fred Drake79189b51999-04-28 13:54:30 +0000975 # return the aligned header start tags
Fred Drakee15956b2000-04-03 04:51:13 +0000976 return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>");
977}
978
979sub get_table_col1_fonts{
980 my $font = $globals{'lineifont'};
981 my ($sfont,$efont) = ('', '');
982 if ($font) {
983 $sfont = "<$font>";
984 $efont = "</$font>";
985 $efont =~ s/ .*>/>/;
986 }
987 return ($font, $sfont, $efont);
Fred Drake6659c301998-03-03 22:02:19 +0000988}
989
990sub do_env_tableii{
991 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000992 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +0000993 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000994 my $h1 = next_argument();
995 my $h2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +0000996 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +0000997 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +0000998 my $a1 = $col_aligns[0];
999 my $a2 = $col_aligns[1];
1000 s/\\lineii</\\lineii[$a1|$a2]</g;
1001 return '<table border align="center" style="border-collapse: collapse">'
Fred Drakef74e5b71999-04-28 14:58:49 +00001002 . "\n <thead>"
1003 . "\n <tr$TABLE_HEADER_BGCOLOR>"
Fred Drakee15956b2000-04-03 04:51:13 +00001004 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1005 . "\n $th2<b>$h2</b>\&nbsp;</th>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001006 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001007 . "\n <tbody valign='baseline'>"
1008 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001009 . "\n </tbody>"
1010 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001011}
1012
1013sub do_cmd_lineii{
1014 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001015 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001016 my $c1 = next_argument();
1017 my $c2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001018 s/[\s\n]+//;
Fred Drakee15956b2000-04-03 04:51:13 +00001019 my($font,$sfont,$efont) = get_table_col1_fonts();
1020 $c2 = '&nbsp;' if ($c2 eq '');
1021 my($c1align,$c2align) = split('\|', $aligns);
1022 my $padding = '';
1023 if ($c1align =~ /align="right"/) {
1024 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001025 }
Fred Drakee15956b2000-04-03 04:51:13 +00001026 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
1027 . " $c2align$c2</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001028 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001029}
1030
1031sub do_env_tableiii{
1032 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001033 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001034 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001035 my $h1 = next_argument();
1036 my $h2 = next_argument();
1037 my $h3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001038 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001039 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001040 my $a1 = $col_aligns[0];
1041 my $a2 = $col_aligns[1];
1042 my $a3 = $col_aligns[2];
1043 s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g;
1044 return '<table border align="center" style="border-collapse: collapse">'
Fred Drakef74e5b71999-04-28 14:58:49 +00001045 . "\n <thead>"
1046 . "\n <tr$TABLE_HEADER_BGCOLOR>"
Fred Drakee15956b2000-04-03 04:51:13 +00001047 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1048 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1049 . "\n $th3<b>$h3</b>\&nbsp;</th>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001050 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001051 . "\n <tbody valign='baseline'>"
Fred Drake62e43691998-08-10 19:40:44 +00001052 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001053 . "\n </tbody>"
1054 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001055}
1056
1057sub do_cmd_lineiii{
1058 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001059 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001060 my $c1 = next_argument();
1061 my $c2 = next_argument();
1062 my $c3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001063 s/[\s\n]+//;
Fred Drakee15956b2000-04-03 04:51:13 +00001064 my($font,$sfont,$efont) = get_table_col1_fonts();
1065 $c3 = '&nbsp;' if ($c3 eq '');
1066 my($c1align,$c2align,$c3align) = split('\|', $aligns);
1067 my $padding = '';
1068 if ($c1align =~ /align="right"/) {
1069 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001070 }
Fred Drakee15956b2000-04-03 04:51:13 +00001071 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001072 . " $c2align$c2</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001073 . " $c3align$c3</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001074 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001075}
1076
Fred Drakea0f4c941998-07-24 22:16:04 +00001077sub do_env_tableiv{
1078 local($_) = @_;
1079 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001080 my $font = fix_font(next_argument());
Fred Drakea0f4c941998-07-24 22:16:04 +00001081 my $h1 = next_argument();
1082 my $h2 = next_argument();
1083 my $h3 = next_argument();
1084 my $h4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001085 s/[\s\n]+//;
Fred Drakea0f4c941998-07-24 22:16:04 +00001086 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001087 my $a1 = $col_aligns[0];
1088 my $a2 = $col_aligns[1];
1089 my $a3 = $col_aligns[2];
1090 my $a4 = $col_aligns[3];
1091 s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g;
1092 return '<table border align="center" style="border-collapse: collapse">'
Fred Drakef74e5b71999-04-28 14:58:49 +00001093 . "\n <thead>"
1094 . "\n <tr$TABLE_HEADER_BGCOLOR>"
Fred Drakee15956b2000-04-03 04:51:13 +00001095 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1096 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1097 . "\n $th3<b>$h3</b>\&nbsp;</th>"
1098 . "\n $th4<b>$h4</b>\&nbsp;</th>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001099 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001100 . "\n <tbody valign='baseline'>"
Fred Drake62e43691998-08-10 19:40:44 +00001101 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001102 . "\n </tbody>"
1103 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001104}
1105
Fred Drakea0f4c941998-07-24 22:16:04 +00001106sub do_cmd_lineiv{
Fred Drake6659c301998-03-03 22:02:19 +00001107 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001108 my $aligns = next_optional_argument();
Fred Drakea0f4c941998-07-24 22:16:04 +00001109 my $c1 = next_argument();
1110 my $c2 = next_argument();
1111 my $c3 = next_argument();
1112 my $c4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001113 s/[\s\n]+//;
Fred Drakee15956b2000-04-03 04:51:13 +00001114 my($font,$sfont,$efont) = get_table_col1_fonts();
1115 $c4 = '&nbsp;' if ($c4 eq '');
1116 my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns);
1117 my $padding = '';
1118 if ($c1align =~ /align="right"/) {
1119 $padding = '&nbsp;';
Fred Drakea0f4c941998-07-24 22:16:04 +00001120 }
Fred Drakee15956b2000-04-03 04:51:13 +00001121 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001122 . " $c2align$c2</td>\n"
1123 . " $c3align$c3</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001124 . " $c4align$c4</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001125 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001126}
1127
Fred Drake6659c301998-03-03 22:02:19 +00001128sub do_cmd_maketitle {
1129 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001130 my $the_title = "\n<div class='titlepage'><center>";
Fred Drake6659c301998-03-03 22:02:19 +00001131 if ($t_title) {
Fred Drake90fdda51999-02-16 20:27:42 +00001132 $the_title .= "\n<h1>$t_title</h1>";
Fred Drake08932051998-04-17 02:15:42 +00001133 } else { write_warnings("\nThis document has no title."); }
Fred Drake6659c301998-03-03 22:02:19 +00001134 if ($t_author) {
1135 if ($t_authorURL) {
Fred Drake08932051998-04-17 02:15:42 +00001136 my $href = translate_commands($t_authorURL);
Fred Drake2d1f81e1999-02-09 16:03:31 +00001137 $href = make_named_href('author', $href,
1138 "<b><font size='+2'>$t_author</font></b>");
Fred Drakec9a44381998-03-17 06:29:13 +00001139 $the_title .= "\n<p>$href</p>";
Fred Drake6659c301998-03-03 22:02:19 +00001140 } else {
Fred Drake2d1f81e1999-02-09 16:03:31 +00001141 $the_title .= ("\n<p><b><font size='+2'>$t_author</font></b></p>");
Fred Drake6659c301998-03-03 22:02:19 +00001142 }
Fred Drake08932051998-04-17 02:15:42 +00001143 } else { write_warnings("\nThere is no author for this document."); }
Fred Drake6659c301998-03-03 22:02:19 +00001144 if ($t_institute) {
Fred Drakec9a44381998-03-17 06:29:13 +00001145 $the_title .= "\n<p>$t_institute</p>";}
Fred Draked07868a1998-05-14 21:00:28 +00001146 if ($DEVELOPER_ADDRESS) {
1147 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";}
Fred Drake6659c301998-03-03 22:02:19 +00001148 if ($t_affil) {
Fred Drakec9a44381998-03-17 06:29:13 +00001149 $the_title .= "\n<p><i>$t_affil</i></p>";}
Fred Drake6659c301998-03-03 22:02:19 +00001150 if ($t_date) {
Fred Drakec9a44381998-03-17 06:29:13 +00001151 $the_title .= "\n<p><strong>$t_date</strong>";
Fred Drake6659c301998-03-03 22:02:19 +00001152 if ($PYTHON_VERSION) {
1153 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";}
1154 $the_title .= "</p>"
1155 }
1156 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +00001157 $the_title .= "\n<p>$t_address</p>";
1158 } else { $the_title .= "\n<p>"}
Fred Drake6659c301998-03-03 22:02:19 +00001159 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +00001160 $the_title .= "\n<p>$t_email</p>";
1161 }# else { $the_title .= "</p>" }
Fred Drake90fdda51999-02-16 20:27:42 +00001162 $the_title .= "\n</center></div>";
Fred Drake62e43691998-08-10 19:40:44 +00001163 return $the_title . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +00001164}
1165
1166
Fred Drake885215c1998-05-20 21:32:09 +00001167#
Fred Drakea0f4c941998-07-24 22:16:04 +00001168# Module synopsis support
1169#
1170
1171require SynopsisTable;
1172
Fred Drakef7685d71998-07-25 03:31:46 +00001173sub get_chapter_id(){
1174 my $id = do_cmd_thechapter('');
Fred Drake45f26011998-08-04 22:07:18 +00001175 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
1176 $id =~ s/\.//;
Fred Drakef7685d71998-07-25 03:31:46 +00001177 return $id;
Fred Drakea0f4c941998-07-24 22:16:04 +00001178}
1179
Fred Drakef7685d71998-07-25 03:31:46 +00001180%ModuleSynopses = ('chapter' => 'SynopsisTable instance');
1181
1182sub get_synopsis_table($){
1183 my($chap) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001184 my $st = $ModuleSynopses{$chap};
Fred Drakef7685d71998-07-25 03:31:46 +00001185 my $key;
1186 foreach $key (keys %ModuleSynopses) {
1187 if ($key eq $chap) {
1188 return $ModuleSynopses{$chap};
1189 }
Fred Drakea0f4c941998-07-24 22:16:04 +00001190 }
Fred Drakef7685d71998-07-25 03:31:46 +00001191 $st = SynopsisTable->new();
1192 $ModuleSynopses{$chap} = $st;
Fred Drakea0f4c941998-07-24 22:16:04 +00001193 return $st;
1194}
1195
Fred Drake62e43691998-08-10 19:40:44 +00001196sub do_cmd_moduleauthor{
1197 local($_) = @_;
1198 next_argument();
1199 next_argument();
1200 return $_;
1201}
1202
1203sub do_cmd_sectionauthor{
1204 local($_) = @_;
1205 next_argument();
1206 next_argument();
1207 return $_;
1208}
1209
Fred Drakea0f4c941998-07-24 22:16:04 +00001210sub do_cmd_declaremodule{
1211 local($_) = @_;
1212 my $key = next_optional_argument();
1213 my $type = next_argument();
1214 my $name = next_argument();
1215 my $st = get_synopsis_table(get_chapter_id());
1216 #
1217 $key = $name unless $key;
1218 $type = 'built-in' if $type eq 'builtin';
1219 $st->declare($name, $key, $type);
1220 define_module($type, $name);
Fred Drake62e43691998-08-10 19:40:44 +00001221 return anchor_label("module-$key",$CURRENT_FILE,$_)
Fred Drakea0f4c941998-07-24 22:16:04 +00001222}
1223
1224sub do_cmd_modulesynopsis{
1225 local($_) = @_;
1226 my $st = get_synopsis_table(get_chapter_id());
Fred Drake1cc58991999-04-13 22:08:59 +00001227 $st->set_synopsis($THIS_MODULE, translate_commands(next_argument()));
Fred Drake62e43691998-08-10 19:40:44 +00001228 return $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001229}
1230
1231sub do_cmd_localmoduletable{
1232 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001233 my $chap = get_chapter_id();
Fred Drake557460c1999-03-02 16:05:35 +00001234 return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001235}
1236
1237sub process_all_localmoduletables{
Fred Drake557460c1999-03-02 16:05:35 +00001238 while (/<tex2html-localmoduletable><(\d+)>/) {
Fred Drakef7685d71998-07-25 03:31:46 +00001239 my $match = $&;
Fred Drakea0f4c941998-07-24 22:16:04 +00001240 my $chap = $1;
1241 my $st = get_synopsis_table($chap);
1242 my $data = $st->tohtml();
Fred Drakef7685d71998-07-25 03:31:46 +00001243 s/$match/$data/;
Fred Drakea0f4c941998-07-24 22:16:04 +00001244 }
1245}
Fred Drake557460c1999-03-02 16:05:35 +00001246sub process_python_state{
1247 process_all_localmoduletables();
Fred Drake557460c1999-03-02 16:05:35 +00001248}
Fred Drakea0f4c941998-07-24 22:16:04 +00001249
1250
1251#
1252# "See also:" -- references placed at the end of a \section
1253#
1254
1255sub do_env_seealso{
Fred Drakee15956b2000-04-03 04:51:13 +00001256 return "<div class='seealso'>\n "
1257 . "<p class='heading'><b>See Also:</b></p>\n"
Fred Drake90fdda51999-02-16 20:27:42 +00001258 . @_[0]
1259 . '</div>';
Fred Drakea0f4c941998-07-24 22:16:04 +00001260}
1261
1262sub do_cmd_seemodule{
1263 # Insert the right magic to jump to the module definition. This should
1264 # work most of the time, at least for repeat builds....
1265 local($_) = @_;
1266 my $key = next_optional_argument();
1267 my $module = next_argument();
1268 my $text = next_argument();
Fred Drake84bd6f31999-05-11 15:42:51 +00001269 my $period = '.';
Fred Drakea0f4c941998-07-24 22:16:04 +00001270 $key = $module
1271 unless $key;
Fred Drake84bd6f31999-05-11 15:42:51 +00001272 if ($text =~ /\.$/) {
1273 $period = '';
1274 }
Fred Drakee15956b2000-04-03 04:51:13 +00001275 return '<dl compact class="seemodule">'
1276 . "\n <dt>Module <b><tt class='module'><a href='module-$key.html'>"
Fred Drake84bd6f31999-05-11 15:42:51 +00001277 . "$module</a></tt>:</b>"
1278 . "\n <dd>$text$period\n </dl>"
Fred Drake90fdda51999-02-16 20:27:42 +00001279 . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001280}
1281
Fred Drake37cc0c02000-04-26 18:05:24 +00001282sub do_cmd_seerfc{
1283 local($_) = @_;
1284 my $rfcnum = next_argument();
1285 my $title = next_argument();
1286 my $text = next_argument();
1287 my $url = get_rfc_url($rfcnum);
1288 return '<dl compact class="seerfc">'
1289 . "\n <dt><a href=\"$url\""
1290 . "\n title=\"$title\""
1291 . "\n >RFC $rfcnum, <em>$title</em></a>:"
1292 . "\n <dd>$text\n </dl>"
1293 . $_;
1294}
1295
Fred Drakeef4d1112000-05-09 16:17:51 +00001296sub do_cmd_seeurl{
1297 local($_) = @_;
1298 my $url = next_argument();
1299 my $text = next_argument();
1300 return '<dl compact class="seeurl">'
1301 . "\n <dt><a href=\"$url\""
1302 . "\n class=\"url\">$url</a>"
1303 . "\n <dd>$text\n </dl>"
1304 . $_;
1305}
1306
Fred Drakea0f4c941998-07-24 22:16:04 +00001307sub do_cmd_seetext{
Fred Drake79189b51999-04-28 13:54:30 +00001308 local($_) = @_;
1309 my $content = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +00001310 return '<div class="seetext"><p>' . $content . '</div>' . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001311}
1312
1313
1314#
Fred Drake885215c1998-05-20 21:32:09 +00001315# Definition list support.
1316#
1317
1318sub do_env_definitions{
Fred Drake37cc0c02000-04-26 18:05:24 +00001319 return "<dl class='definitions'>" . @_[0] . "</dl>\n";
Fred Drake885215c1998-05-20 21:32:09 +00001320}
1321
1322sub do_cmd_term{
1323 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001324 my $term = next_argument();
1325 my($name,$aname,$ahref) = new_link_info();
Fred Drake885215c1998-05-20 21:32:09 +00001326 # could easily add an index entry here...
Fred Drake62e43691998-08-10 19:40:44 +00001327 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
Fred Drake885215c1998-05-20 21:32:09 +00001328}
1329
1330
Fred Drake2ff880e1999-02-05 18:31:29 +00001331process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_);
1332code # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001333declaremodule # [] # {} # {}
1334memberline # [] # {}
1335methodline # [] # {} # {}
1336modulesynopsis # {}
Fred Drake557460c1999-03-02 16:05:35 +00001337platform # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001338samp # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001339setindexsubitem # {}
Fred Drakef32834c1999-02-12 22:06:32 +00001340withsubitem # {} # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001341_RAW_ARG_DEFERRED_CMDS_
1342
1343
Fred Drake6659c301998-03-03 22:02:19 +000013441; # This must be the last line