blob: 2866a36c765c56f9697b1a501c89782d4ce449b6 [file] [log] [blame]
Fred Drake6659c301998-03-03 22:02:19 +00001# python.perl by Fred L. Drake, Jr. <fdrake@acm.org> -*- perl -*-
2#
3# Heavily based on Guido van Rossum's myformat.perl (now obsolete).
4#
5# Extension to LaTeX2HTML for documents using myformat.sty.
6# Subroutines of the form do_cmd_<name> here define translations
7# for LaTeX commands \<name> defined in the corresponding .sty file.
8
9package main;
10
11
Fred Drake08932051998-04-17 02:15:42 +000012sub next_argument{
Fred Drakeccc62721999-01-05 22:16:29 +000013 my $param;
14 $param = missing_braces()
15 unless ((s/$next_pair_pr_rx/$param=$2;''/eo)
16 ||(s/$next_pair_rx/$param=$2;''/eo));
Fred Drake62e43691998-08-10 19:40:44 +000017 return $param;
Fred Drake08932051998-04-17 02:15:42 +000018}
19
20sub next_optional_argument{
21 my($param,$rx) = ('', "^\\s*(\\[([^]]*)\\])?");
Fred Drake5ccf3301998-04-17 20:04:09 +000022 s/$rx/$param=$2;''/eo;
Fred Drake62e43691998-08-10 19:40:44 +000023 return $param;
Fred Drake08932051998-04-17 02:15:42 +000024}
25
Fred Drakee16f6791998-05-15 04:28:37 +000026
27# This is a fairly simple hack; it supports \let when it is used to create
28# (or redefine) a macro to exactly be some other macro: \let\newname=\oldname.
Fred Drake5b73cdf1998-05-15 16:59:38 +000029# Many possible uses of \let aren't supported or aren't supported correctly.
Fred Drakee16f6791998-05-15 04:28:37 +000030#
31sub do_cmd_let{
32 local($_) = @_;
33 my $matched = 0;
Fred Drake7a4ad0f1998-05-15 13:45:54 +000034 s/[\\]([a-zA-Z]+)\s*(=\s*)?[\\]([a-zA-Z]*)/$matched=1; ''/e;
Fred Drakee16f6791998-05-15 04:28:37 +000035 if ($matched) {
36 my($new, $old) = ($1, $3);
37 eval "sub do_cmd_$new { do_cmd_$old" . '(@_); }';
38 print "\ndefining handler for \\$new using \\$old\n";
39 }
Fred Drake7a4ad0f1998-05-15 13:45:54 +000040 else {
41 s/[\\]([a-zA-Z]+)\s*(=\s*)?([^\\])/$matched=1; ''/es;
42 if ($matched) {
43 my($new, $char) = ($1, $3);
44 eval "sub do_cmd_$new { \"\\$char\" . \@_[0]; }";
45 print "\ndefining handler for \\$new to insert '$char'\n";
46 }
47 else {
48 write_warnings("Could not interpret \\let construct...");
49 }
50 }
Fred Drake62e43691998-08-10 19:40:44 +000051 return $_;
Fred Drakee16f6791998-05-15 04:28:37 +000052}
53
54
Fred Drake6659c301998-03-03 22:02:19 +000055# words typeset in a special way (not in HTML though)
56
57sub do_cmd_ABC{ 'ABC' . @_[0]; }
58sub do_cmd_UNIX{ 'Unix'. @_[0]; }
59sub do_cmd_ASCII{ 'ASCII' . @_[0]; }
60sub do_cmd_POSIX{ 'POSIX' . @_[0]; }
61sub do_cmd_C{ 'C' . @_[0]; }
62sub do_cmd_Cpp{ 'C++' . @_[0]; }
63sub do_cmd_EOF{ 'EOF' . @_[0]; }
Fred Drakee15956b2000-04-03 04:51:13 +000064sub do_cmd_NULL{ '<tt class="constant">NULL</tt>' . @_[0]; }
Fred Drake6659c301998-03-03 22:02:19 +000065
66sub do_cmd_e{ '&#92;' . @_[0]; }
67
Fred Draked07868a1998-05-14 21:00:28 +000068$DEVELOPER_ADDRESS = '';
Fred Drake6659c301998-03-03 22:02:19 +000069$PYTHON_VERSION = '';
70
71sub do_cmd_version{ $PYTHON_VERSION . @_[0]; }
72sub do_cmd_release{
73 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +000074 $PYTHON_VERSION = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000075 return $_;
Fred Drake6659c301998-03-03 22:02:19 +000076}
77
78sub do_cmd_authoraddress{
79 local($_) = @_;
Fred Draked07868a1998-05-14 21:00:28 +000080 $DEVELOPER_ADDRESS = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000081 return $_;
Fred Drake6659c301998-03-03 22:02:19 +000082}
83
Fred Drakee16f6791998-05-15 04:28:37 +000084#sub do_cmd_developer{ do_cmd_author(@_[0]); }
85#sub do_cmd_developers{ do_cmd_author(@_[0]); }
86#sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); }
Fred Draked07868a1998-05-14 21:00:28 +000087
Fred Drake6659c301998-03-03 22:02:19 +000088sub do_cmd_hackscore{
89 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +000090 next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000091 return '_' . $_;
Fred Drake6659c301998-03-03 22:02:19 +000092}
93
Fred Drake08932051998-04-17 02:15:42 +000094sub use_wrappers{
95 local($_,$before,$after) = @_;
96 my $stuff = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000097 return $before . $stuff . $after . $_;
Fred Drake08932051998-04-17 02:15:42 +000098}
99
Fred Drake62e43691998-08-10 19:40:44 +0000100sub use_sans_serif{
Fred Drakeccc62721999-01-05 22:16:29 +0000101 return use_wrappers(@_[0], '<font face="sans-serif">', '</font>');
Fred Drake62e43691998-08-10 19:40:44 +0000102}
103sub use_italics{
104 return use_wrappers(@_[0], '<i>', '</i>');
105}
Fred Drake08932051998-04-17 02:15:42 +0000106
Fred Drake6659c301998-03-03 22:02:19 +0000107sub do_cmd_optional{
Fred Drake62e43691998-08-10 19:40:44 +0000108 return use_wrappers(@_[0], "</var><big>\[</big><var>",
109 "</var><big>\]</big><var>");
Fred Drake6659c301998-03-03 22:02:19 +0000110}
111
Fred Drakec9a44381998-03-17 06:29:13 +0000112# Logical formatting (some based on texinfo), needs to be converted to
113# minimalist HTML. The "minimalist" is primarily to reduce the size of
114# output files for users that read them over the network rather than
115# from local repositories.
Fred Drake6659c301998-03-03 22:02:19 +0000116
Fred Drake2cafcbb1999-03-25 16:57:04 +0000117# \file and \samp are at the end of this file since they screw up fontlock.
118
Fred Drake2ff880e1999-02-05 18:31:29 +0000119sub do_cmd_pytype{ return @_[0]; }
120sub do_cmd_makevar{ return @_[0]; }
Fred Drake90fdda51999-02-16 20:27:42 +0000121sub do_cmd_code{
Fred Drakee15956b2000-04-03 04:51:13 +0000122 return use_wrappers(@_[0], '<code>', '</code>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000123sub do_cmd_module{
Fred Drakee15956b2000-04-03 04:51:13 +0000124 return use_wrappers(@_[0], '<tt class="module">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000125sub do_cmd_keyword{
Fred Drakee15956b2000-04-03 04:51:13 +0000126 return use_wrappers(@_[0], '<tt class="keyword">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000127sub do_cmd_exception{
Fred Drakee15956b2000-04-03 04:51:13 +0000128 return use_wrappers(@_[0], '<tt class="exception">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000129sub do_cmd_class{
Fred Drakee15956b2000-04-03 04:51:13 +0000130 return use_wrappers(@_[0], '<tt class="class">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000131sub do_cmd_function{
Fred Drakee15956b2000-04-03 04:51:13 +0000132 return use_wrappers(@_[0], '<tt class="function">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000133sub do_cmd_constant{
Fred Drakee15956b2000-04-03 04:51:13 +0000134 return use_wrappers(@_[0], '<tt class="constant">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000135sub do_cmd_member{
Fred Drakee15956b2000-04-03 04:51:13 +0000136 return use_wrappers(@_[0], '<tt class="member">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000137sub do_cmd_method{
Fred Drakee15956b2000-04-03 04:51:13 +0000138 return use_wrappers(@_[0], '<tt class="method">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000139sub do_cmd_cfunction{
Fred Drakee15956b2000-04-03 04:51:13 +0000140 return use_wrappers(@_[0], '<tt class="cfunction">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000141sub do_cmd_cdata{
Fred Drakee15956b2000-04-03 04:51:13 +0000142 return use_wrappers(@_[0], '<tt class="cdata">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000143sub do_cmd_ctype{
Fred Drakee15956b2000-04-03 04:51:13 +0000144 return use_wrappers(@_[0], '<tt class="ctype">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000145sub do_cmd_regexp{
Fred Drakee15956b2000-04-03 04:51:13 +0000146 return use_wrappers(@_[0], '<tt class="regexp">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000147sub do_cmd_character{
Fred Drakee15956b2000-04-03 04:51:13 +0000148 return use_wrappers(@_[0], '"<tt class="character">', '</tt>"'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000149sub do_cmd_program{
Fred Drakee15956b2000-04-03 04:51:13 +0000150 return use_wrappers(@_[0], '<b class="program">', '</b>'); }
Fred Drakec9f5fe01999-11-09 16:59:42 +0000151sub do_cmd_programopt{
152 return use_wrappers(@_[0], '<b class="programopt">', '</b>'); }
Fred Drake0cd60212000-04-11 18:46:59 +0000153sub do_cmd_longprogramopt{
154 # note that the --- will be later converted to -- by LaTeX2HTML
155 return use_wrappers(@_[0], '<b class="programopt">---', '</b>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000156sub do_cmd_email{
Fred Drakee15956b2000-04-03 04:51:13 +0000157 return use_wrappers(@_[0], '<span class="email">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000158sub do_cmd_mimetype{
Fred Drakee15956b2000-04-03 04:51:13 +0000159 return use_wrappers(@_[0], '<span class="mimetype">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000160sub do_cmd_var{
161 return use_wrappers(@_[0], "<var>", "</var>"); }
162sub do_cmd_dfn{
Fred Drakee15956b2000-04-03 04:51:13 +0000163 return use_wrappers(@_[0], '<i class="dfn">', '</i>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000164sub do_cmd_emph{
165 return use_italics(@_); }
166sub do_cmd_file{
Fred Drakee15956b2000-04-03 04:51:13 +0000167 return use_wrappers(@_[0],
168 '<font class="file" face="sans-serif">',
169 '</font>'); }
Fred Drakef74e5b71999-04-28 14:58:49 +0000170sub do_cmd_filenq{
Fred Drakee15956b2000-04-03 04:51:13 +0000171 return do_cmd_file(@_[0]); }
Fred Drake90fdda51999-02-16 20:27:42 +0000172sub do_cmd_samp{
Fred Drakee15956b2000-04-03 04:51:13 +0000173 return use_wrappers(@_[0], '"<tt class="samp">', '</tt>"'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000174sub do_cmd_kbd{
175 return use_wrappers(@_[0], '<kbd>', '</kbd>'); }
176sub do_cmd_strong{
177 return use_wrappers(@_[0], '<b>', '</b>'); }
Fred Drake2cafcbb1999-03-25 16:57:04 +0000178sub do_cmd_textbf{
179 return use_wrappers(@_[0], '<b>', '</b>'); }
180sub do_cmd_textit{
181 return use_wrappers(@_[0], '<i>', '</i>'); }
182
Fred Drakec9a44381998-03-17 06:29:13 +0000183
Fred Drake25817041999-01-13 17:06:34 +0000184sub do_cmd_refmodule{
185 # Insert the right magic to jump to the module definition.
186 local($_) = @_;
187 my $key = next_optional_argument();
188 my $module = next_argument();
189 $key = $module
190 unless $key;
Fred Drakee15956b2000-04-03 04:51:13 +0000191 return "<tt class='module'><a href='module-$key.html'>$module</a></tt>"
192 . $_;
Fred Drake25817041999-01-13 17:06:34 +0000193}
194
Fred Drake1a7af391998-04-01 22:44:56 +0000195sub do_cmd_newsgroup{
196 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000197 my $newsgroup = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000198 my $stuff = "<span class='newsgroup'><a href='news:$newsgroup'>"
199 . "$newsgroup</a></span>";
Fred Drake62e43691998-08-10 19:40:44 +0000200 return $stuff . $_;
Fred Drake1a7af391998-04-01 22:44:56 +0000201}
Fred Drakefc16e781998-03-12 21:03:26 +0000202
203sub do_cmd_envvar{
204 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000205 my $envvar = next_argument();
206 my($name,$aname,$ahref) = new_link_info();
Fred Drake166abba1998-04-08 23:10:54 +0000207 # The <tt> here is really to keep buildindex.py from making
208 # the variable name case-insensitive.
209 add_index_entry("environment variables!$envvar@<tt>\$$envvar</tt>",
210 $ahref);
Fred Drake42b31a51998-03-27 05:16:10 +0000211 add_index_entry("$envvar@\$$envvar", $ahref);
Fred Drakee15956b2000-04-03 04:51:13 +0000212 $aname =~ s/<a/<a class="envvar"/;
Fred Draked37cecf1999-09-23 16:45:08 +0000213 return "$aname\$$envvar</a>" . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000214}
215
Fred Drake6659c301998-03-03 22:02:19 +0000216sub do_cmd_url{
217 # use the URL as both text and hyperlink
218 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000219 my $url = next_argument();
Fred Drake6659c301998-03-03 22:02:19 +0000220 $url =~ s/~/&#126;/g;
Fred Drakee15956b2000-04-03 04:51:13 +0000221 return "<a class=\"url\" href=\"$url\">$url</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000222}
223
224sub do_cmd_manpage{
225 # two parameters: \manpage{name}{section}
226 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000227 my $page = next_argument();
228 my $section = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000229 return "<span class='manpage'><i>$page</i>($section)</span>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000230}
231
Fred Drake37cc0c02000-04-26 18:05:24 +0000232sub get_rfc_url{
233 my $rfcnum = sprintf("%04d", @_[0]);
234 return "http://www.ietf.org/rfc/rfc$rfcnum.txt";
235}
236
Fred Drake6659c301998-03-03 22:02:19 +0000237sub do_cmd_rfc{
238 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000239 my $rfcnumber = next_argument();
240 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drake37cc0c02000-04-26 18:05:24 +0000241 my $href = get_rfc_url($rfcnumber);
Fred Drake6659c301998-03-03 22:02:19 +0000242 # Save the reference
Fred Drake08932051998-04-17 02:15:42 +0000243 my $nstr = gen_index_id("RFC!RFC $rfcnumber", '');
Fred Drakeccc62721999-01-05 22:16:29 +0000244 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
Fred Drakee15956b2000-04-03 04:51:13 +0000245 return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">RFC $rfcnumber</a>"
Fred Draked52879c1999-09-22 19:58:51 +0000246 . $_);
Fred Drake6659c301998-03-03 22:02:19 +0000247}
248
Fred Drakec9f5fe01999-11-09 16:59:42 +0000249sub do_cmd_citetitle{
250 local($_) = @_;
251 my $url = next_optional_argument();
252 my $title = next_argument();
253 my $repl = '';
254 if ($url) {
255 $repl = ("<em class='citetitle'><a\n"
256 . " href='$url'\n"
257 . " title='$title'\n"
258 . " >$title</a></em>");
259 }
260 else {
261 $repl = "<em class='citetitle'\n >$title</em>";
262 }
263 return $repl . $_;
264}
265
Fred Drake6659c301998-03-03 22:02:19 +0000266sub do_cmd_deprecated{
267 # two parameters: \deprecated{version}{whattodo}
268 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000269 my $release = next_argument();
270 my $reason = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000271 return "<b>Deprecated since release $release.</b>\n$reason<p>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000272}
273
Fred Drake897d12b1998-07-27 20:33:17 +0000274sub do_cmd_versionadded{
275 # one parameter: \versionadded{version}
276 local($_) = @_;
277 my $release = next_argument();
Fred Drake2116d981999-02-02 18:02:48 +0000278 return "\nNew in version $release.\n" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000279}
280
281sub do_cmd_versionchanged{
282 # one parameter: \versionchanged{version}
283 local($_) = @_;
284 my $release = next_argument();
Fred Drake2116d981999-02-02 18:02:48 +0000285 return "\nChanged in version $release.\n" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000286}
287
Fred Drake557460c1999-03-02 16:05:35 +0000288#
Fred Drake2cafcbb1999-03-25 16:57:04 +0000289# These function handle platform dependency tracking.
Fred Drake557460c1999-03-02 16:05:35 +0000290#
291sub do_cmd_platform{
292 local($_) = @_;
293 my $platform = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000294 $ModulePlatforms{"<tt class='module'>$THIS_MODULE</tt>"} = $platform;
Fred Drake557460c1999-03-02 16:05:35 +0000295 $platform = "Macintosh"
Fred Drake085b8121999-04-21 14:00:29 +0000296 if $platform eq 'Mac';
Fred Drakee15956b2000-04-03 04:51:13 +0000297 return "\n<p class='availability'>Availability: <span"
298 . "\n class='platform'>$platform</span>.</p>\n" . $_;
Fred Drake557460c1999-03-02 16:05:35 +0000299}
300
Fred Drake557460c1999-03-02 16:05:35 +0000301$IGNORE_PLATFORM_ANNOTATION = '';
302sub do_cmd_ignorePlatformAnnotation{
303 local($_) = @_;
304 $IGNORE_PLATFORM_ANNOTATION = next_argument();
305 return $_;
306}
307
Fred Drake6659c301998-03-03 22:02:19 +0000308
309# index commands
310
311$INDEX_SUBITEM = "";
312
313sub get_indexsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000314 return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
Fred Drake6659c301998-03-03 22:02:19 +0000315}
316
317sub do_cmd_setindexsubitem{
318 local($_) = @_;
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000319 $INDEX_SUBITEM = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000320 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000321}
322
Fred Drakefc16e781998-03-12 21:03:26 +0000323sub do_cmd_withsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000324 # We can't really do the right thing, because LaTeX2HTML doesn't
Fred Drakefc16e781998-03-12 21:03:26 +0000325 # do things in the right order, but we need to at least strip this stuff
326 # out, and leave anything that the second argument expanded out to.
327 #
328 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000329 my $oldsubitem = $INDEX_SUBITEM;
330 $INDEX_SUBITEM = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000331 my $stuff = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000332 my $br_id = ++$globals{'max_id'};
333 my $marker = "$O$br_id$C";
Fred Drake7d45f6d1999-01-05 14:39:27 +0000334 return
335 $stuff
Fred Drakeccc62721999-01-05 22:16:29 +0000336 . "\\setindexsubitem$marker$oldsubitem$marker"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000337 . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000338}
339
Fred Drake08932051998-04-17 02:15:42 +0000340# This is the prologue macro which is required to start writing the
Fred Drakeab032151999-05-13 18:36:54 +0000341# mod\jobname.idx file; we can just ignore it. (Defining this suppresses
342# a warning that \makemodindex is unknown.)
Fred Drake08932051998-04-17 02:15:42 +0000343#
Fred Drake62e43691998-08-10 19:40:44 +0000344sub do_cmd_makemodindex{ return @_[0]; }
Fred Drakefc16e781998-03-12 21:03:26 +0000345
Fred Drake42b31a51998-03-27 05:16:10 +0000346# We're in the document subdirectory when this happens!
Fred Drake166abba1998-04-08 23:10:54 +0000347#
Fred Drake08932051998-04-17 02:15:42 +0000348open(IDXFILE, '>index.dat') || die "\n$!\n";
349open(INTLABELS, '>intlabels.pl') || die "\n$!\n";
Fred Drake166abba1998-04-08 23:10:54 +0000350print INTLABELS "%internal_labels = ();\n";
351print INTLABELS "1; # hack in case there are no entries\n\n";
352
353# Using \0 for this is bad because we can't use common tools to work with the
354# resulting files. Things like grep can be useful with this stuff!
355#
356$IDXFILE_FIELD_SEP = "\1";
357
Fred Drakeccc62721999-01-05 22:16:29 +0000358sub write_idxfile{
359 my ($ahref, $str) = @_;
360 print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n";
Fred Drake42b31a51998-03-27 05:16:10 +0000361}
362
Fred Drake42b31a51998-03-27 05:16:10 +0000363
364sub gen_link{
365 my($node,$target) = @_;
366 print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
Fred Drakee15956b2000-04-03 04:51:13 +0000367 return "<a href='$node#$target'>";
Fred Drake42b31a51998-03-27 05:16:10 +0000368}
369
Fred Drake42b31a51998-03-27 05:16:10 +0000370sub add_index_entry{
371 # add an entry to the index structures; ignore the return value
372 my($str,$ahref) = @_;
373 $str = gen_index_id($str, '');
374 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000375 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000376}
377
Fred Drakeccc62721999-01-05 22:16:29 +0000378sub new_link_info{
379 my $name = "l2h-" . ++$globals{'max_id'};
Fred Drakee15956b2000-04-03 04:51:13 +0000380 my $aname = "<a name='$name'>";
Fred Drake42b31a51998-03-27 05:16:10 +0000381 my $ahref = gen_link($CURRENT_FILE, $name);
382 return ($name, $aname, $ahref);
383}
384
Fred Drakeab032151999-05-13 18:36:54 +0000385$IndexMacroPattern = '';
386sub define_indexing_macro{
387 my $count = @_;
388 my $i = 0;
389 for (; $i < $count; ++$i) {
390 my $name = @_[$i];
391 my $cmd = "idx_cmd_$name";
392 die "\nNo function $cmd() defined!\n"
393 if (!defined &$cmd);
394 eval ("sub do_cmd_$name { return process_index_macros("
395 . "\@_[0], '$name'); }");
396 if (length($IndexMacroPattern) == 0) {
397 $IndexMacroPattern = "$name";
398 }
399 else {
400 $IndexMacroPattern .= "|$name";
401 }
402 }
403}
404
405$DEBUG_INDEXING = 0;
406sub process_index_macros{
Fred Drake42b31a51998-03-27 05:16:10 +0000407 local($_) = @_;
Fred Drakeab032151999-05-13 18:36:54 +0000408 my $cmdname = @_[1]; # This is what triggered us in the first place;
409 # we know it's real, so just process it.
Fred Drakeccc62721999-01-05 22:16:29 +0000410 my($name,$aname,$ahref) = new_link_info();
Fred Drakeab032151999-05-13 18:36:54 +0000411 my $cmd = "idx_cmd_$cmdname";
412 print "\nIndexing: \\$cmdname"
413 if $DEBUG_INDEXING;
414 &$cmd($ahref); # modifies $_ and adds index entries
415 while (/^[\s\n]*\\($IndexMacroPattern)</) {
416 $cmdname = "$1";
417 print " \\$cmdname"
418 if $DEBUG_INDEXING;
419 $cmd = "idx_cmd_$cmdname";
420 if (!defined &$cmd) {
421 last;
422 }
423 else {
424 s/^[\s\n]*\\$cmdname//;
425 &$cmd($ahref);
426 }
427 }
Fred Drake62e43691998-08-10 19:40:44 +0000428 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake42b31a51998-03-27 05:16:10 +0000429}
430
Fred Drakeab032151999-05-13 18:36:54 +0000431define_indexing_macro('index');
432sub idx_cmd_index{
Fred Drakeccc62721999-01-05 22:16:29 +0000433 my $str = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000434 add_index_entry("$str", @_[0]);
Fred Drake2e7edb81998-05-11 18:31:17 +0000435}
436
Fred Drakeab032151999-05-13 18:36:54 +0000437define_indexing_macro('kwindex');
438sub idx_cmd_kwindex{
439 my $str = next_argument();
440 add_index_entry("<tt>$str</tt>!keyword", @_[0]);
441 add_index_entry("keyword!<tt>$str</tt>", @_[0]);
442}
443
444define_indexing_macro('indexii');
445sub idx_cmd_indexii{
Fred Drakeccc62721999-01-05 22:16:29 +0000446 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000447 my $str2 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000448 add_index_entry("$str1!$str2", @_[0]);
449 add_index_entry("$str2!$str1", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000450}
451
Fred Drakeab032151999-05-13 18:36:54 +0000452define_indexing_macro('indexiii');
453sub idx_cmd_indexiii{
Fred Drakeccc62721999-01-05 22:16:29 +0000454 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000455 my $str2 = next_argument();
456 my $str3 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000457 add_index_entry("$str1!$str2 $str3", @_[0]);
458 add_index_entry("$str2!$str3, $str1", @_[0]);
459 add_index_entry("$str3!$str1 $str2", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000460}
461
Fred Drakeab032151999-05-13 18:36:54 +0000462define_indexing_macro('indexiv');
463sub idx_cmd_indexiv{
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();
467 my $str4 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000468 add_index_entry("$str1!$str2 $str3 $str4", @_[0]);
469 add_index_entry("$str2!$str3 $str4, $str1", @_[0]);
470 add_index_entry("$str3!$str4, $str1 $str2", @_[0]);
471 add_index_entry("$str4!$$str1 $str2 $str3", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000472}
473
Fred Drakeab032151999-05-13 18:36:54 +0000474define_indexing_macro('ttindex');
475sub idx_cmd_ttindex{
Fred Drakeccc62721999-01-05 22:16:29 +0000476 my $str = next_argument();
477 my $entry = $str . get_indexsubitem();
Fred Drakeab032151999-05-13 18:36:54 +0000478 add_index_entry($entry, @_[0]);
Fred Drakec9a44381998-03-17 06:29:13 +0000479}
Fred Drake6659c301998-03-03 22:02:19 +0000480
481sub my_typed_index_helper{
Fred Drakeab032151999-05-13 18:36:54 +0000482 my($word,$ahref) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000483 my $str = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000484 add_index_entry("$str $word", $ahref);
485 add_index_entry("$word!$str", $ahref);
Fred Drake6659c301998-03-03 22:02:19 +0000486}
487
Fred Drakeab032151999-05-13 18:36:54 +0000488define_indexing_macro('stindex', 'opindex', 'exindex', 'obindex');
489sub idx_cmd_stindex{ my_typed_index_helper('statement', @_[0]); }
490sub idx_cmd_opindex{ my_typed_index_helper('operator', @_[0]); }
491sub idx_cmd_exindex{ my_typed_index_helper('exception', @_[0]); }
492sub idx_cmd_obindex{ my_typed_index_helper('object', @_[0]); }
Fred Drake6659c301998-03-03 22:02:19 +0000493
Fred Drakeab032151999-05-13 18:36:54 +0000494define_indexing_macro('bifuncindex');
495sub idx_cmd_bifuncindex{
Fred Drakeccc62721999-01-05 22:16:29 +0000496 my $str = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000497 add_index_entry("<tt class='function'>$str()</tt> (built-in function)",
498 @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000499}
500
501
Fred Drake6659c301998-03-03 22:02:19 +0000502sub make_mod_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000503 my($str,$define) = @_;
504 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000505 # equivalent of add_index_entry() using $define instead of ''
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000506 $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/
507 if ($define eq 'DEF');
Fred Drake42b31a51998-03-27 05:16:10 +0000508 $str = gen_index_id($str, $define);
509 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000510 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000511
Fred Drakec9a44381998-03-17 06:29:13 +0000512 if ($define eq 'DEF') {
Fred Drake42b31a51998-03-27 05:16:10 +0000513 # add to the module index
Fred Drakee15956b2000-04-03 04:51:13 +0000514 $str =~ /(<tt.*<\/tt>)/;
515 my $nstr = $1;
Fred Drake42b31a51998-03-27 05:16:10 +0000516 $Modules{$nstr} .= $ahref;
Fred Drake6659c301998-03-03 22:02:19 +0000517 }
Fred Drake62e43691998-08-10 19:40:44 +0000518 return "$aname$anchor_invisible_mark</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000519}
520
Fred Drake557460c1999-03-02 16:05:35 +0000521
Fred Drakec9a44381998-03-17 06:29:13 +0000522$THIS_MODULE = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000523$THIS_CLASS = '';
Fred Drakec9a44381998-03-17 06:29:13 +0000524
Fred Drakea0f4c941998-07-24 22:16:04 +0000525sub define_module{
526 my($word,$name) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000527 my $section_tag = join('', @curr_sec_id);
Fred Drake3e4c6141999-05-17 15:00:32 +0000528 if ($word ne "built-in" && $word ne "extension"
529 && $word ne "standard" && $word ne "") {
530 write_warnings("Bad module type '$word'"
531 . " for \\declaremodule (module $name)");
532 $word = "";
533 }
Fred Drake6659c301998-03-03 22:02:19 +0000534 $word = "$word " if $word;
Fred Drakea0f4c941998-07-24 22:16:04 +0000535 $THIS_MODULE = "$name";
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000536 $INDEX_SUBITEM = "(in $name)";
537 print "[$name]";
Fred Drakee15956b2000-04-03 04:51:13 +0000538 return make_mod_index_entry(
539 "<tt class='module'>$name</tt> (${word}module)", 'DEF');
Fred Drakea0f4c941998-07-24 22:16:04 +0000540}
541
542sub my_module_index_helper{
543 local($word, $_) = @_;
544 my $name = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000545 return define_module($word, $name) . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000546}
547
Fred Drake62e43691998-08-10 19:40:44 +0000548sub do_cmd_modindex{ return my_module_index_helper('', @_); }
549sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); }
550sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); }
551sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000552
Fred Drakeab032151999-05-13 18:36:54 +0000553sub ref_module_index_helper{
Fred Drake37cc0c02000-04-26 18:05:24 +0000554 my($word, $ahref) = @_;
Fred Drakeab032151999-05-13 18:36:54 +0000555 my $str = next_argument();
556 $word = "$word " if $word;
Fred Drakee15956b2000-04-03 04:51:13 +0000557 $str = "<tt class='module'>$str</tt> (${word}module)";
Fred Drakeab032151999-05-13 18:36:54 +0000558 # can't use add_index_entry() since the 2nd arg to gen_index_id() is used;
559 # just inline it all here
560 $str = gen_index_id($str, 'REF');
561 $index{$str} .= $ahref;
562 write_idxfile($ahref, $str);
563}
564
Fred Drake6659c301998-03-03 22:02:19 +0000565# these should be adjusted a bit....
Fred Drakeab032151999-05-13 18:36:54 +0000566define_indexing_macro('refmodindex', 'refbimodindex',
567 'refexmodindex', 'refstmodindex');
568sub idx_cmd_refmodindex{ return ref_module_index_helper('', @_); }
569sub idx_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); }
570sub idx_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); }
571sub idx_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000572
Fred Drake62e43691998-08-10 19:40:44 +0000573sub do_cmd_nodename{ return do_cmd_label(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000574
575sub init_myformat{
Fred Drake08932051998-04-17 02:15:42 +0000576# $anchor_invisible_mark = '';
Fred Drake6659c301998-03-03 22:02:19 +0000577 $anchor_mark = '';
578 $icons{'anchor_mark'} = '';
Fred Drake6659c301998-03-03 22:02:19 +0000579}
Fred Drake42b31a51998-03-27 05:16:10 +0000580init_myformat();
Fred Drake6659c301998-03-03 22:02:19 +0000581
Fred Drakeab032151999-05-13 18:36:54 +0000582# Create an index entry, but include the string in the target anchor
Fred Drake6659c301998-03-03 22:02:19 +0000583# instead of the dummy filler.
584#
585sub make_str_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000586 my($str) = @_;
587 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000588 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000589 return "$aname$str</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000590}
591
Fred Drakee15956b2000-04-03 04:51:13 +0000592$REFCOUNTS_LOADED = 0;
593
594sub load_refcounts{
595 $REFCOUNTS_LOADED = 1;
596
597 use File::Basename;
598 my $myname, $mydir, $myext;
599 ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*');
600 chop $mydir; # remove trailing '/'
601 ($myname, $mydir, $myext) = fileparse($mydir, '\..*');
602 chop $mydir; # remove trailing '/'
603 $mydir = getcwd() . "$dd$mydir"
604 unless $mydir =~ s|^/|/|;
605 local $_;
606 my $filename = "$mydir${dd}api${dd}refcounts.dat";
607 open(REFCOUNT_FILE, "<$filename") || die "\n$!\n";
608 print "[loading API refcount data]";
609 while (<REFCOUNT_FILE>) {
Fred Drakec2578c52000-04-10 18:26:45 +0000610 if (/([a-zA-Z0-9_]+):PyObject\*:([a-zA-Z0-9_]*):(0|[-+]1|null):(.*)$/) {
Fred Drakee15956b2000-04-03 04:51:13 +0000611 my($func, $param, $count, $comment) = ($1, $2, $3, $4);
612 #print "\n$func($param) --> $count";
613 $REFCOUNTS{"$func:$param"} = $count;
614 }
615 }
616}
617
618sub get_refcount{
619 my ($func, $param) = @_;
620 load_refcounts()
621 unless $REFCOUNTS_LOADED;
622 return $REFCOUNTS{"$func:$param"};
623}
624
Fred Drake6659c301998-03-03 22:02:19 +0000625sub do_env_cfuncdesc{
626 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000627 my $return_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000628 my $function_name = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000629 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000630 my $idx = make_str_index_entry(
631 "<tt class='cfunction'>$function_name()</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000632 $idx =~ s/ \(.*\)//;
633 $idx =~ s/\(\)//; # ????
Fred Drakee15956b2000-04-03 04:51:13 +0000634 my $result_rc = get_refcount($function_name, '');
635 my $rcinfo = '';
636 if ($result_rc eq '+1') {
637 $rcinfo = '<span class="label">Return value:</span>'
638 . "\n <span class=\"value\">New reference.</span>";
639 }
640 elsif ($result_rc eq '0') {
641 $rcinfo = '<span class="label">Return value:</span>'
642 . "\n <span class=\"value\">Borrowed reference.</span>";
643 }
Fred Drakec2578c52000-04-10 18:26:45 +0000644 elsif ($result_rc eq 'null') {
645 $rcinfo = '<span class="label">Return value:</span>'
646 . "\n <span class=\"value\">Always NULL.</span>";
647 }
Fred Drakee15956b2000-04-03 04:51:13 +0000648 if ($rcinfo ne '') {
649 $rcinfo = "\n<div class=\"refcount-info\">\n $rcinfo\n</div>";
650 }
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000651 return "<dl><dt>$return_type <b>$idx</b> (<var>$arg_list</var>)\n<dd>"
Fred Drakee15956b2000-04-03 04:51:13 +0000652 . $rcinfo
Fred Drake62e43691998-08-10 19:40:44 +0000653 . $_
654 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000655}
656
Fred Drakee15956b2000-04-03 04:51:13 +0000657sub do_env_csimplemacrodesc{
658 local($_) = @_;
659 my $name = next_argument();
660 my $idx = make_str_index_entry("<tt class='macro'>$name</tt>");
661 return "<dl><dt><b>$idx</b>\n<dd>"
662 . $_
663 . '</dl>'
664}
665
Fred Drake6659c301998-03-03 22:02:19 +0000666sub do_env_ctypedesc{
667 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +0000668 my $index_name = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000669 my $type_name = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000670 $index_name = $type_name
671 unless $index_name;
672 my($name,$aname,$ahref) = new_link_info();
673 add_index_entry("<tt class='ctype'>$index_name</tt> (C type)", $ahref);
674 return "<dl><dt><b><tt class='ctype'>$aname$type_name</a></tt></b>\n<dd>"
Fred Drake62e43691998-08-10 19:40:44 +0000675 . $_
676 . '</dl>'
Fred Drake6659c301998-03-03 22:02:19 +0000677}
678
679sub do_env_cvardesc{
680 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000681 my $var_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000682 my $var_name = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000683 my $idx = make_str_index_entry("<tt class='cdata'>$var_name</tt>"
Fred Drake90fdda51999-02-16 20:27:42 +0000684 . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000685 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000686 return "<dl><dt>$var_type <b>$idx</b>\n"
687 . '<dd>'
688 . $_
689 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000690}
691
692sub do_env_funcdesc{
693 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000694 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000695 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000696 my $idx = make_str_index_entry("<tt class='function'>$function_name()</tt>"
Fred Drake08932051998-04-17 02:15:42 +0000697 . get_indexsubitem());
698 $idx =~ s/ \(.*\)//;
Fred Drakeccc62721999-01-05 22:16:29 +0000699 $idx =~ s/\(\)<\/tt>/<\/tt>/;
Fred Drake62e43691998-08-10 19:40:44 +0000700 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000701}
702
703sub do_env_funcdescni{
704 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000705 my $function_name = next_argument();
706 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000707 return "<dl><dt><b><tt class='function'>$function_name</tt></b>"
Fred Drake90fdda51999-02-16 20:27:42 +0000708 . " (<var>$arg_list</var>)\n"
709 . '<dd>'
710 . $_
711 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000712}
713
714sub do_cmd_funcline{
715 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000716 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000717 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000718 my $prefix = "<tt class='function'>$function_name()</tt>";
Fred Drakeca675e41999-04-21 15:58:58 +0000719 my $idx = make_str_index_entry($prefix . get_indexsubitem());
720 $prefix =~ s/\(\)//;
721
722 return "<dt><b>$prefix</b> (<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000723}
724
Fred Drake6b3fb781999-07-12 16:50:09 +0000725sub do_cmd_funclineni{
726 local($_) = @_;
727 my $function_name = next_argument();
728 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000729 my $prefix = "<tt class='function'>$function_name</tt>";
Fred Drake6b3fb781999-07-12 16:50:09 +0000730
731 return "<dt><b>$prefix</b> (<var>$arg_list</var>)\n<dd>" . $_;
732}
733
Fred Drake6659c301998-03-03 22:02:19 +0000734# Change this flag to index the opcode entries. I don't think it's very
735# useful to index them, since they're only presented to describe the dis
736# module.
737#
738$INDEX_OPCODES = 0;
739
740sub do_env_opcodedesc{
741 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000742 my $opcode_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000743 my $arg_list = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000744 my $idx;
745 if ($INDEX_OPCODES) {
Fred Drakee15956b2000-04-03 04:51:13 +0000746 $idx = make_str_index_entry("<tt class='opcode'>$opcode_name</tt>"
747 . " (byte code instruction)");
Fred Drake08932051998-04-17 02:15:42 +0000748 $idx =~ s/ \(byte code instruction\)//;
749 }
750 else {
Fred Drakee15956b2000-04-03 04:51:13 +0000751 $idx = "<tt class='opcode'>$opcode_name</tt>";
Fred Drake08932051998-04-17 02:15:42 +0000752 }
753 my $stuff = "<dl><dt><b>$idx</b>";
Fred Drake6659c301998-03-03 22:02:19 +0000754 if ($arg_list) {
755 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
756 }
Fred Drake62e43691998-08-10 19:40:44 +0000757 return $stuff . "\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000758}
759
760sub do_env_datadesc{
761 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000762 my $dataname = next_argument();
763 my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000764 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000765 return "<dl><dt><b>$idx</b>\n<dd>"
766 . $_
767 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000768}
769
770sub do_env_datadescni{
771 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000772 my $idx = next_argument();
773 if (! $STRING_INDEX_TT) {
774 $idx = "<tt>$idx</tt>";
Fred Drake6659c301998-03-03 22:02:19 +0000775 }
Fred Drake62e43691998-08-10 19:40:44 +0000776 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000777}
778
779sub do_cmd_dataline{
780 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000781 my $data_name = next_argument();
782 my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem());
Fred Drake6659c301998-03-03 22:02:19 +0000783 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000784 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000785}
786
Fred Drakeadb272c2000-04-10 17:47:14 +0000787sub do_cmd_datalineni{
788 local($_) = @_;
789 my $data_name = next_argument();
790 return "<dt><b><tt>$data_name</tt></b><dd>" . $_;
791}
792
Fred Drake42b31a51998-03-27 05:16:10 +0000793sub do_env_excdesc{
794 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000795 my $excname = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000796 my $idx = make_str_index_entry("<tt class='exception'>$excname</tt>");
Fred Drake62e43691998-08-10 19:40:44 +0000797 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'
Fred Drake42b31a51998-03-27 05:16:10 +0000798}
799
Fred Drake62e43691998-08-10 19:40:44 +0000800sub do_env_fulllineitems{ return do_env_itemize(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000801
802
Fred Drakec9a44381998-03-17 06:29:13 +0000803sub do_env_classdesc{
804 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000805 $THIS_CLASS = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000806 my $arg_list = next_argument();
807 $idx = make_str_index_entry(
Fred Drakee15956b2000-04-03 04:51:13 +0000808 "<tt class='class'>$THIS_CLASS</tt> (class in $THIS_MODULE)" );
Fred Drake08932051998-04-17 02:15:42 +0000809 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000810 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drakec9a44381998-03-17 06:29:13 +0000811}
812
Fred Drake42b31a51998-03-27 05:16:10 +0000813
814sub do_env_methoddesc{
815 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000816 my $class_name = next_optional_argument();
817 $class_name = $THIS_CLASS
818 unless $class_name;
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000819 my $method = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000820 my $arg_list = next_argument();
821 my $extra = '';
822 if ($class_name) {
823 $extra = " ($class_name method)";
Fred Drake42b31a51998-03-27 05:16:10 +0000824 }
Fred Drakee15956b2000-04-03 04:51:13 +0000825 my $idx = make_str_index_entry("<tt class='method'>$method()</tt>$extra");
Fred Drake08932051998-04-17 02:15:42 +0000826 $idx =~ s/ \(.*\)//;
827 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000828 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000829}
830
831
Fred Drake7d45f6d1999-01-05 14:39:27 +0000832sub do_cmd_methodline{
833 local($_) = @_;
834 my $class_name = next_optional_argument();
835 $class_name = $THIS_CLASS
836 unless $class_name;
837 my $method = next_argument();
838 my $arg_list = next_argument();
839 my $extra = '';
840 if ($class_name) {
841 $extra = " ($class_name method)";
842 }
Fred Drakee15956b2000-04-03 04:51:13 +0000843 my $idx = make_str_index_entry("<tt class='method'>$method()</tt>$extra");
Fred Drake7d45f6d1999-01-05 14:39:27 +0000844 $idx =~ s/ \(.*\)//;
845 $idx =~ s/\(\)//;
846 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>"
847 . $_;
848}
849
850
Fred Draked64a40d1998-09-10 18:59:13 +0000851sub do_cmd_methodlineni{
852 local($_) = @_;
853 next_optional_argument();
854 my $method = next_argument();
855 my $arg_list = next_argument();
856 return "<dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
857 . $_;
858}
859
Fred Drake42b31a51998-03-27 05:16:10 +0000860sub do_env_methoddescni{
861 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000862 next_optional_argument();
863 my $method = next_argument();
864 my $arg_list = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000865 return "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
866 . $_
867 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000868}
869
870
871sub do_env_memberdesc{
872 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000873 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000874 my $member = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000875 $class = $THIS_CLASS
876 unless $class;
Fred Drake08932051998-04-17 02:15:42 +0000877 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +0000878 $extra = " ($class attribute)"
879 if ($class ne '');
Fred Drakee15956b2000-04-03 04:51:13 +0000880 my $idx = make_str_index_entry("<tt class='member'>$member</tt>$extra");
Fred Drake42b31a51998-03-27 05:16:10 +0000881 $idx =~ s/ \(.*\)//;
882 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000883 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000884}
885
886
Fred Drake5ccf3301998-04-17 20:04:09 +0000887sub do_cmd_memberline{
888 local($_) = @_;
889 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000890 my $member = next_argument();
Fred Drake5ccf3301998-04-17 20:04:09 +0000891 $class = $THIS_CLASS
892 unless $class;
893 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +0000894 $extra = " ($class attribute)"
895 if ($class ne '');
Fred Drakee15956b2000-04-03 04:51:13 +0000896 my $idx = make_str_index_entry("<tt class='member'>$member</tt>$extra");
Fred Drake5ccf3301998-04-17 20:04:09 +0000897 $idx =~ s/ \(.*\)//;
898 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000899 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000900}
901
Fred Drake42b31a51998-03-27 05:16:10 +0000902sub do_env_memberdescni{
903 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000904 next_optional_argument();
905 my $member = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000906 return "<dl><dt><b><tt class='member'>$member</tt></b>\n<dd>"
907 . $_
908 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000909}
910
911
Fred Drake5ccf3301998-04-17 20:04:09 +0000912sub do_cmd_memberlineni{
913 local($_) = @_;
914 next_optional_argument();
915 my $member = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000916 return "<dt><b><tt class='member'>$member</tt></b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000917}
918
Fred Drakee15956b2000-04-03 04:51:13 +0000919@col_aligns = ('<td>', '<td>', '<td>', '<td>');
Fred Drake6659c301998-03-03 22:02:19 +0000920
Fred Drake15799ed1999-02-12 19:23:17 +0000921$TABLE_HEADER_BGCOLOR = $NAV_BGCOLOR;
922
Fred Drakef74e5b71999-04-28 14:58:49 +0000923sub fix_font{
924 # do a little magic on a font name to get the right behavior in the first
925 # column of the output table
926 my $font = @_[0];
927 if ($font eq 'textrm') {
928 $font = '';
929 }
930 elsif ($font eq 'file' || $font eq 'filenq') {
Fred Drakee15956b2000-04-03 04:51:13 +0000931 $font = 'tt class="file"';
932 }
933 elsif ($font eq 'member') {
934 $font = 'tt class="member"';
Fred Drakef74e5b71999-04-28 14:58:49 +0000935 }
936 return $font;
937}
938
Fred Drakee15956b2000-04-03 04:51:13 +0000939sub figure_column_alignment{
940 my $a = @_[0];
941 my $mark = substr($a, 0, 1);
942 my $r = '';
943 if ($mark eq 'c')
944 { $r = ' align="center"'; }
945 elsif ($mark eq 'r')
946 { $r = ' align="right"'; }
947 elsif ($mark eq 'l')
948 { $r = ' align="left"'; }
949 elsif ($mark eq 'p')
950 { $r = ' align="left"'; }
951 return $r;
952}
953
Fred Drake6659c301998-03-03 22:02:19 +0000954sub setup_column_alignments{
955 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +0000956 my($s1,$s2,$s3,$s4) = split(/[|]/,$_);
957 my $a1 = figure_column_alignment($s1);
958 my $a2 = figure_column_alignment($s2);
959 my $a3 = figure_column_alignment($s3);
960 my $a4 = figure_column_alignment($s4);
961 $col_aligns[0] = "<td$a1 valign=\"baseline\">";
962 $col_aligns[1] = "<td$a2>";
963 $col_aligns[2] = "<td$a3>";
964 $col_aligns[3] = "<td$a4>";
Fred Drake79189b51999-04-28 13:54:30 +0000965 # return the aligned header start tags
Fred Drakee15956b2000-04-03 04:51:13 +0000966 return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>");
967}
968
969sub get_table_col1_fonts{
970 my $font = $globals{'lineifont'};
971 my ($sfont,$efont) = ('', '');
972 if ($font) {
973 $sfont = "<$font>";
974 $efont = "</$font>";
975 $efont =~ s/ .*>/>/;
976 }
977 return ($font, $sfont, $efont);
Fred Drake6659c301998-03-03 22:02:19 +0000978}
979
980sub do_env_tableii{
981 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000982 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +0000983 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000984 my $h1 = next_argument();
985 my $h2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +0000986 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +0000987 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +0000988 my $a1 = $col_aligns[0];
989 my $a2 = $col_aligns[1];
990 s/\\lineii</\\lineii[$a1|$a2]</g;
991 return '<table border align="center" style="border-collapse: collapse">'
Fred Drakef74e5b71999-04-28 14:58:49 +0000992 . "\n <thead>"
993 . "\n <tr$TABLE_HEADER_BGCOLOR>"
Fred Drakee15956b2000-04-03 04:51:13 +0000994 . "\n $th1<b>$h1</b>\&nbsp;</th>"
995 . "\n $th2<b>$h2</b>\&nbsp;</th>"
Fred Drakef74e5b71999-04-28 14:58:49 +0000996 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +0000997 . "\n <tbody valign='baseline'>"
998 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +0000999 . "\n </tbody>"
1000 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001001}
1002
1003sub do_cmd_lineii{
1004 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001005 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001006 my $c1 = next_argument();
1007 my $c2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001008 s/[\s\n]+//;
Fred Drakee15956b2000-04-03 04:51:13 +00001009 my($font,$sfont,$efont) = get_table_col1_fonts();
1010 $c2 = '&nbsp;' if ($c2 eq '');
1011 my($c1align,$c2align) = split('\|', $aligns);
1012 my $padding = '';
1013 if ($c1align =~ /align="right"/) {
1014 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001015 }
Fred Drakee15956b2000-04-03 04:51:13 +00001016 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
1017 . " $c2align$c2</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001018 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001019}
1020
1021sub do_env_tableiii{
1022 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001023 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001024 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001025 my $h1 = next_argument();
1026 my $h2 = next_argument();
1027 my $h3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001028 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001029 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001030 my $a1 = $col_aligns[0];
1031 my $a2 = $col_aligns[1];
1032 my $a3 = $col_aligns[2];
1033 s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g;
1034 return '<table border align="center" style="border-collapse: collapse">'
Fred Drakef74e5b71999-04-28 14:58:49 +00001035 . "\n <thead>"
1036 . "\n <tr$TABLE_HEADER_BGCOLOR>"
Fred Drakee15956b2000-04-03 04:51:13 +00001037 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1038 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1039 . "\n $th3<b>$h3</b>\&nbsp;</th>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001040 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001041 . "\n <tbody valign='baseline'>"
Fred Drake62e43691998-08-10 19:40:44 +00001042 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001043 . "\n </tbody>"
1044 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001045}
1046
1047sub do_cmd_lineiii{
1048 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001049 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001050 my $c1 = next_argument();
1051 my $c2 = next_argument();
1052 my $c3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001053 s/[\s\n]+//;
Fred Drakee15956b2000-04-03 04:51:13 +00001054 my($font,$sfont,$efont) = get_table_col1_fonts();
1055 $c3 = '&nbsp;' if ($c3 eq '');
1056 my($c1align,$c2align,$c3align) = split('\|', $aligns);
1057 my $padding = '';
1058 if ($c1align =~ /align="right"/) {
1059 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001060 }
Fred Drakee15956b2000-04-03 04:51:13 +00001061 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001062 . " $c2align$c2</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001063 . " $c3align$c3</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001064 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001065}
1066
Fred Drakea0f4c941998-07-24 22:16:04 +00001067sub do_env_tableiv{
1068 local($_) = @_;
1069 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001070 my $font = fix_font(next_argument());
Fred Drakea0f4c941998-07-24 22:16:04 +00001071 my $h1 = next_argument();
1072 my $h2 = next_argument();
1073 my $h3 = next_argument();
1074 my $h4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001075 s/[\s\n]+//;
Fred Drakea0f4c941998-07-24 22:16:04 +00001076 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001077 my $a1 = $col_aligns[0];
1078 my $a2 = $col_aligns[1];
1079 my $a3 = $col_aligns[2];
1080 my $a4 = $col_aligns[3];
1081 s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g;
1082 return '<table border align="center" style="border-collapse: collapse">'
Fred Drakef74e5b71999-04-28 14:58:49 +00001083 . "\n <thead>"
1084 . "\n <tr$TABLE_HEADER_BGCOLOR>"
Fred Drakee15956b2000-04-03 04:51:13 +00001085 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1086 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1087 . "\n $th3<b>$h3</b>\&nbsp;</th>"
1088 . "\n $th4<b>$h4</b>\&nbsp;</th>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001089 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001090 . "\n <tbody valign='baseline'>"
Fred Drake62e43691998-08-10 19:40:44 +00001091 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001092 . "\n </tbody>"
1093 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001094}
1095
Fred Drakea0f4c941998-07-24 22:16:04 +00001096sub do_cmd_lineiv{
Fred Drake6659c301998-03-03 22:02:19 +00001097 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001098 my $aligns = next_optional_argument();
Fred Drakea0f4c941998-07-24 22:16:04 +00001099 my $c1 = next_argument();
1100 my $c2 = next_argument();
1101 my $c3 = next_argument();
1102 my $c4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001103 s/[\s\n]+//;
Fred Drakee15956b2000-04-03 04:51:13 +00001104 my($font,$sfont,$efont) = get_table_col1_fonts();
1105 $c4 = '&nbsp;' if ($c4 eq '');
1106 my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns);
1107 my $padding = '';
1108 if ($c1align =~ /align="right"/) {
1109 $padding = '&nbsp;';
Fred Drakea0f4c941998-07-24 22:16:04 +00001110 }
Fred Drakee15956b2000-04-03 04:51:13 +00001111 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001112 . " $c2align$c2</td>\n"
1113 . " $c3align$c3</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001114 . " $c4align$c4</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001115 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001116}
1117
Fred Drake6659c301998-03-03 22:02:19 +00001118sub do_cmd_maketitle {
1119 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001120 my $the_title = "\n<div class='titlepage'><center>";
Fred Drake6659c301998-03-03 22:02:19 +00001121 if ($t_title) {
Fred Drake90fdda51999-02-16 20:27:42 +00001122 $the_title .= "\n<h1>$t_title</h1>";
Fred Drake08932051998-04-17 02:15:42 +00001123 } else { write_warnings("\nThis document has no title."); }
Fred Drake6659c301998-03-03 22:02:19 +00001124 if ($t_author) {
1125 if ($t_authorURL) {
Fred Drake08932051998-04-17 02:15:42 +00001126 my $href = translate_commands($t_authorURL);
Fred Drake2d1f81e1999-02-09 16:03:31 +00001127 $href = make_named_href('author', $href,
1128 "<b><font size='+2'>$t_author</font></b>");
Fred Drakec9a44381998-03-17 06:29:13 +00001129 $the_title .= "\n<p>$href</p>";
Fred Drake6659c301998-03-03 22:02:19 +00001130 } else {
Fred Drake2d1f81e1999-02-09 16:03:31 +00001131 $the_title .= ("\n<p><b><font size='+2'>$t_author</font></b></p>");
Fred Drake6659c301998-03-03 22:02:19 +00001132 }
Fred Drake08932051998-04-17 02:15:42 +00001133 } else { write_warnings("\nThere is no author for this document."); }
Fred Drake6659c301998-03-03 22:02:19 +00001134 if ($t_institute) {
Fred Drakec9a44381998-03-17 06:29:13 +00001135 $the_title .= "\n<p>$t_institute</p>";}
Fred Draked07868a1998-05-14 21:00:28 +00001136 if ($DEVELOPER_ADDRESS) {
1137 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";}
Fred Drake6659c301998-03-03 22:02:19 +00001138 if ($t_affil) {
Fred Drakec9a44381998-03-17 06:29:13 +00001139 $the_title .= "\n<p><i>$t_affil</i></p>";}
Fred Drake6659c301998-03-03 22:02:19 +00001140 if ($t_date) {
Fred Drakec9a44381998-03-17 06:29:13 +00001141 $the_title .= "\n<p><strong>$t_date</strong>";
Fred Drake6659c301998-03-03 22:02:19 +00001142 if ($PYTHON_VERSION) {
1143 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";}
1144 $the_title .= "</p>"
1145 }
1146 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +00001147 $the_title .= "\n<p>$t_address</p>";
1148 } else { $the_title .= "\n<p>"}
Fred Drake6659c301998-03-03 22:02:19 +00001149 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +00001150 $the_title .= "\n<p>$t_email</p>";
1151 }# else { $the_title .= "</p>" }
Fred Drake90fdda51999-02-16 20:27:42 +00001152 $the_title .= "\n</center></div>";
Fred Drake62e43691998-08-10 19:40:44 +00001153 return $the_title . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +00001154}
1155
1156
Fred Drake885215c1998-05-20 21:32:09 +00001157#
Fred Drakea0f4c941998-07-24 22:16:04 +00001158# Module synopsis support
1159#
1160
1161require SynopsisTable;
1162
Fred Drakef7685d71998-07-25 03:31:46 +00001163sub get_chapter_id(){
1164 my $id = do_cmd_thechapter('');
Fred Drake45f26011998-08-04 22:07:18 +00001165 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
1166 $id =~ s/\.//;
Fred Drakef7685d71998-07-25 03:31:46 +00001167 return $id;
Fred Drakea0f4c941998-07-24 22:16:04 +00001168}
1169
Fred Drakef7685d71998-07-25 03:31:46 +00001170%ModuleSynopses = ('chapter' => 'SynopsisTable instance');
1171
1172sub get_synopsis_table($){
1173 my($chap) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001174 my $st = $ModuleSynopses{$chap};
Fred Drakef7685d71998-07-25 03:31:46 +00001175 my $key;
1176 foreach $key (keys %ModuleSynopses) {
1177 if ($key eq $chap) {
1178 return $ModuleSynopses{$chap};
1179 }
Fred Drakea0f4c941998-07-24 22:16:04 +00001180 }
Fred Drakef7685d71998-07-25 03:31:46 +00001181 $st = SynopsisTable->new();
1182 $ModuleSynopses{$chap} = $st;
Fred Drakea0f4c941998-07-24 22:16:04 +00001183 return $st;
1184}
1185
Fred Drake62e43691998-08-10 19:40:44 +00001186sub do_cmd_moduleauthor{
1187 local($_) = @_;
1188 next_argument();
1189 next_argument();
1190 return $_;
1191}
1192
1193sub do_cmd_sectionauthor{
1194 local($_) = @_;
1195 next_argument();
1196 next_argument();
1197 return $_;
1198}
1199
Fred Drakea0f4c941998-07-24 22:16:04 +00001200sub do_cmd_declaremodule{
1201 local($_) = @_;
1202 my $key = next_optional_argument();
1203 my $type = next_argument();
1204 my $name = next_argument();
1205 my $st = get_synopsis_table(get_chapter_id());
1206 #
1207 $key = $name unless $key;
1208 $type = 'built-in' if $type eq 'builtin';
1209 $st->declare($name, $key, $type);
1210 define_module($type, $name);
Fred Drake62e43691998-08-10 19:40:44 +00001211 return anchor_label("module-$key",$CURRENT_FILE,$_)
Fred Drakea0f4c941998-07-24 22:16:04 +00001212}
1213
1214sub do_cmd_modulesynopsis{
1215 local($_) = @_;
1216 my $st = get_synopsis_table(get_chapter_id());
Fred Drake1cc58991999-04-13 22:08:59 +00001217 $st->set_synopsis($THIS_MODULE, translate_commands(next_argument()));
Fred Drake62e43691998-08-10 19:40:44 +00001218 return $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001219}
1220
1221sub do_cmd_localmoduletable{
1222 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001223 my $chap = get_chapter_id();
Fred Drake557460c1999-03-02 16:05:35 +00001224 return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001225}
1226
1227sub process_all_localmoduletables{
Fred Drake557460c1999-03-02 16:05:35 +00001228 while (/<tex2html-localmoduletable><(\d+)>/) {
Fred Drakef7685d71998-07-25 03:31:46 +00001229 my $match = $&;
Fred Drakea0f4c941998-07-24 22:16:04 +00001230 my $chap = $1;
1231 my $st = get_synopsis_table($chap);
1232 my $data = $st->tohtml();
Fred Drakef7685d71998-07-25 03:31:46 +00001233 s/$match/$data/;
Fred Drakea0f4c941998-07-24 22:16:04 +00001234 }
1235}
Fred Drake557460c1999-03-02 16:05:35 +00001236sub process_python_state{
1237 process_all_localmoduletables();
Fred Drake557460c1999-03-02 16:05:35 +00001238}
Fred Drakea0f4c941998-07-24 22:16:04 +00001239
1240
1241#
1242# "See also:" -- references placed at the end of a \section
1243#
1244
1245sub do_env_seealso{
Fred Drakee15956b2000-04-03 04:51:13 +00001246 return "<div class='seealso'>\n "
1247 . "<p class='heading'><b>See Also:</b></p>\n"
Fred Drake90fdda51999-02-16 20:27:42 +00001248 . @_[0]
1249 . '</div>';
Fred Drakea0f4c941998-07-24 22:16:04 +00001250}
1251
1252sub do_cmd_seemodule{
1253 # Insert the right magic to jump to the module definition. This should
1254 # work most of the time, at least for repeat builds....
1255 local($_) = @_;
1256 my $key = next_optional_argument();
1257 my $module = next_argument();
1258 my $text = next_argument();
Fred Drake84bd6f31999-05-11 15:42:51 +00001259 my $period = '.';
Fred Drakea0f4c941998-07-24 22:16:04 +00001260 $key = $module
1261 unless $key;
Fred Drake84bd6f31999-05-11 15:42:51 +00001262 if ($text =~ /\.$/) {
1263 $period = '';
1264 }
Fred Drakee15956b2000-04-03 04:51:13 +00001265 return '<dl compact class="seemodule">'
1266 . "\n <dt>Module <b><tt class='module'><a href='module-$key.html'>"
Fred Drake84bd6f31999-05-11 15:42:51 +00001267 . "$module</a></tt>:</b>"
1268 . "\n <dd>$text$period\n </dl>"
Fred Drake90fdda51999-02-16 20:27:42 +00001269 . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001270}
1271
Fred Drake37cc0c02000-04-26 18:05:24 +00001272sub do_cmd_seerfc{
1273 local($_) = @_;
1274 my $rfcnum = next_argument();
1275 my $title = next_argument();
1276 my $text = next_argument();
1277 my $url = get_rfc_url($rfcnum);
1278 return '<dl compact class="seerfc">'
1279 . "\n <dt><a href=\"$url\""
1280 . "\n title=\"$title\""
1281 . "\n >RFC $rfcnum, <em>$title</em></a>:"
1282 . "\n <dd>$text\n </dl>"
1283 . $_;
1284}
1285
Fred Drakea0f4c941998-07-24 22:16:04 +00001286sub do_cmd_seetext{
Fred Drake79189b51999-04-28 13:54:30 +00001287 local($_) = @_;
1288 my $content = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +00001289 return '<div class="seetext"><p>' . $content . '</div>' . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001290}
1291
1292
1293#
Fred Drake885215c1998-05-20 21:32:09 +00001294# Definition list support.
1295#
1296
1297sub do_env_definitions{
Fred Drake37cc0c02000-04-26 18:05:24 +00001298 return "<dl class='definitions'>" . @_[0] . "</dl>\n";
Fred Drake885215c1998-05-20 21:32:09 +00001299}
1300
1301sub do_cmd_term{
1302 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001303 my $term = next_argument();
1304 my($name,$aname,$ahref) = new_link_info();
Fred Drake885215c1998-05-20 21:32:09 +00001305 # could easily add an index entry here...
Fred Drake62e43691998-08-10 19:40:44 +00001306 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
Fred Drake885215c1998-05-20 21:32:09 +00001307}
1308
1309
Fred Drake2ff880e1999-02-05 18:31:29 +00001310process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_);
1311code # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001312declaremodule # [] # {} # {}
1313memberline # [] # {}
1314methodline # [] # {} # {}
1315modulesynopsis # {}
Fred Drake557460c1999-03-02 16:05:35 +00001316platform # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001317samp # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001318setindexsubitem # {}
Fred Drakef32834c1999-02-12 22:06:32 +00001319withsubitem # {} # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001320_RAW_ARG_DEFERRED_CMDS_
1321
1322
Fred Drake6659c301998-03-03 22:02:19 +000013231; # This must be the last line