blob: 39c99317e059b6f80efc31668f7132508b122597 [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
Fred Drake7a40c072000-10-02 14:43:38 +000011use File::Basename;
12
Fred Drake6659c301998-03-03 22:02:19 +000013
Fred Drake08932051998-04-17 02:15:42 +000014sub next_argument{
Fred Drakeccc62721999-01-05 22:16:29 +000015 my $param;
16 $param = missing_braces()
17 unless ((s/$next_pair_pr_rx/$param=$2;''/eo)
18 ||(s/$next_pair_rx/$param=$2;''/eo));
Fred Drake62e43691998-08-10 19:40:44 +000019 return $param;
Fred Drake08932051998-04-17 02:15:42 +000020}
21
22sub next_optional_argument{
23 my($param,$rx) = ('', "^\\s*(\\[([^]]*)\\])?");
Fred Drake5ccf3301998-04-17 20:04:09 +000024 s/$rx/$param=$2;''/eo;
Fred Drake62e43691998-08-10 19:40:44 +000025 return $param;
Fred Drake08932051998-04-17 02:15:42 +000026}
27
Fred Drake7a40c072000-10-02 14:43:38 +000028sub make_icon_filename($){
29 my($myname, $mydir, $myext) = fileparse(@_[0], '\..*');
30 chop $mydir;
31 if ($mydir eq '.') {
32 $mydir = $ICONSERVER;
33 }
34 $myext = ".$IMAGE_TYPE"
35 unless $myext;
36 return "$mydir$dd$myname$myext";
37}
38
Fred Drake7a40c072000-10-02 14:43:38 +000039sub get_link_icon($){
40 my $url = @_[0];
41 if ($OFF_SITE_LINK_ICON && ($url =~ /^[-a-zA-Z0-9.]+:/)) {
42 # absolute URL; assume it points off-site
43 my $icon = make_icon_filename($OFF_SITE_LINK_ICON);
44 return (" <img src='$icon'\n"
Fred Drake5f84c9b2000-10-03 06:05:25 +000045 . " border='0' class='offsitelink'"
46 . ($OFF_SITE_LINK_ICON_HEIGHT
47 ? " height='$OFF_SITE_LINK_ICON_HEIGHT'"
48 : '')
49 . ($OFF_SITE_LINK_ICON_WIDTH
50 ? " width='$OFF_SITE_LINK_ICON_WIDTH'"
51 : '')
52 . " alt='[off-site link]'\n"
Fred Drake7a40c072000-10-02 14:43:38 +000053 . " >");
54 }
55 return '';
56}
Fred Drakee16f6791998-05-15 04:28:37 +000057
58# This is a fairly simple hack; it supports \let when it is used to create
59# (or redefine) a macro to exactly be some other macro: \let\newname=\oldname.
Fred Drake5b73cdf1998-05-15 16:59:38 +000060# Many possible uses of \let aren't supported or aren't supported correctly.
Fred Drakee16f6791998-05-15 04:28:37 +000061#
62sub do_cmd_let{
63 local($_) = @_;
64 my $matched = 0;
Fred Drake7a4ad0f1998-05-15 13:45:54 +000065 s/[\\]([a-zA-Z]+)\s*(=\s*)?[\\]([a-zA-Z]*)/$matched=1; ''/e;
Fred Drakee16f6791998-05-15 04:28:37 +000066 if ($matched) {
67 my($new, $old) = ($1, $3);
68 eval "sub do_cmd_$new { do_cmd_$old" . '(@_); }';
69 print "\ndefining handler for \\$new using \\$old\n";
70 }
Fred Drake7a4ad0f1998-05-15 13:45:54 +000071 else {
72 s/[\\]([a-zA-Z]+)\s*(=\s*)?([^\\])/$matched=1; ''/es;
73 if ($matched) {
74 my($new, $char) = ($1, $3);
75 eval "sub do_cmd_$new { \"\\$char\" . \@_[0]; }";
76 print "\ndefining handler for \\$new to insert '$char'\n";
77 }
78 else {
79 write_warnings("Could not interpret \\let construct...");
80 }
81 }
Fred Drake62e43691998-08-10 19:40:44 +000082 return $_;
Fred Drakee16f6791998-05-15 04:28:37 +000083}
84
85
Fred Drakec3fd45f2000-06-15 22:41:48 +000086# the older version of LaTeX2HTML we use doesn't support this, but we use it:
87
88sub do_cmd_textasciitilde{ '~' . @_[0]; }
Fred Drake056a71d2001-04-21 05:48:07 +000089sub do_cmd_textasciicircum{ '^' . @_[0]; }
Fred Drakec3fd45f2000-06-15 22:41:48 +000090
91
Fred Drake6659c301998-03-03 22:02:19 +000092# words typeset in a special way (not in HTML though)
93
94sub do_cmd_ABC{ 'ABC' . @_[0]; }
95sub do_cmd_UNIX{ 'Unix'. @_[0]; }
96sub do_cmd_ASCII{ 'ASCII' . @_[0]; }
97sub do_cmd_POSIX{ 'POSIX' . @_[0]; }
98sub do_cmd_C{ 'C' . @_[0]; }
99sub do_cmd_Cpp{ 'C++' . @_[0]; }
100sub do_cmd_EOF{ 'EOF' . @_[0]; }
Fred Drakee15956b2000-04-03 04:51:13 +0000101sub do_cmd_NULL{ '<tt class="constant">NULL</tt>' . @_[0]; }
Fred Drake6659c301998-03-03 22:02:19 +0000102
103sub do_cmd_e{ '&#92;' . @_[0]; }
104
Fred Draked07868a1998-05-14 21:00:28 +0000105$DEVELOPER_ADDRESS = '';
Fred Drake3cdb89d2000-09-14 20:17:23 +0000106$SHORT_VERSION = '';
Fred Draked04592a2000-10-25 16:15:13 +0000107$PACKAGE_VERSION = '';
Fred Drake6659c301998-03-03 22:02:19 +0000108
Fred Draked04592a2000-10-25 16:15:13 +0000109sub do_cmd_version{ $PACKAGE_VERSION . @_[0]; }
Fred Drake3cdb89d2000-09-14 20:17:23 +0000110sub do_cmd_shortversion{ $SHORT_VERSION . @_[0]; }
Fred Drake6659c301998-03-03 22:02:19 +0000111sub do_cmd_release{
112 local($_) = @_;
Fred Draked04592a2000-10-25 16:15:13 +0000113 $PACKAGE_VERSION = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000114 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000115}
116
Fred Drake3cdb89d2000-09-14 20:17:23 +0000117sub do_cmd_setshortversion{
118 local($_) = @_;
119 $SHORT_VERSION = next_argument();
120 return $_;
121}
122
Fred Drake6659c301998-03-03 22:02:19 +0000123sub do_cmd_authoraddress{
124 local($_) = @_;
Fred Draked07868a1998-05-14 21:00:28 +0000125 $DEVELOPER_ADDRESS = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000126 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000127}
128
Fred Drakee16f6791998-05-15 04:28:37 +0000129#sub do_cmd_developer{ do_cmd_author(@_[0]); }
130#sub do_cmd_developers{ do_cmd_author(@_[0]); }
131#sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); }
Fred Draked07868a1998-05-14 21:00:28 +0000132
Fred Drake6659c301998-03-03 22:02:19 +0000133sub do_cmd_hackscore{
134 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000135 next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000136 return '_' . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000137}
138
Fred Drake08932051998-04-17 02:15:42 +0000139sub use_wrappers{
140 local($_,$before,$after) = @_;
141 my $stuff = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000142 return $before . $stuff . $after . $_;
Fred Drake08932051998-04-17 02:15:42 +0000143}
144
Fred Drake3cdb89d2000-09-14 20:17:23 +0000145$IN_DESC_HANDLER = 0;
Fred Drake6659c301998-03-03 22:02:19 +0000146sub do_cmd_optional{
Fred Drake3cdb89d2000-09-14 20:17:23 +0000147 if ($IN_DESC_HANDLER) {
148 return use_wrappers(@_[0], "</var><big>\[</big><var>",
149 "</var><big>\]</big><var>");
150 }
151 else {
152 return use_wrappers(@_[0], "<big>\[</big>", "<big>\]</big>");
153 }
Fred Drake6659c301998-03-03 22:02:19 +0000154}
155
Fred Drakec9a44381998-03-17 06:29:13 +0000156# Logical formatting (some based on texinfo), needs to be converted to
157# minimalist HTML. The "minimalist" is primarily to reduce the size of
158# output files for users that read them over the network rather than
159# from local repositories.
Fred Drake6659c301998-03-03 22:02:19 +0000160
Fred Drake2cafcbb1999-03-25 16:57:04 +0000161# \file and \samp are at the end of this file since they screw up fontlock.
162
Fred Drake2ff880e1999-02-05 18:31:29 +0000163sub do_cmd_pytype{ return @_[0]; }
Fred Drake3d5a04a2000-08-03 17:25:44 +0000164sub do_cmd_makevar{
165 return use_wrappers(@_[0], '<span class="makevar">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000166sub do_cmd_code{
Fred Drakee15956b2000-04-03 04:51:13 +0000167 return use_wrappers(@_[0], '<code>', '</code>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000168sub do_cmd_module{
Fred Drakee15956b2000-04-03 04:51:13 +0000169 return use_wrappers(@_[0], '<tt class="module">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000170sub do_cmd_keyword{
Fred Drakee15956b2000-04-03 04:51:13 +0000171 return use_wrappers(@_[0], '<tt class="keyword">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000172sub do_cmd_exception{
Fred Drakee15956b2000-04-03 04:51:13 +0000173 return use_wrappers(@_[0], '<tt class="exception">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000174sub do_cmd_class{
Fred Drakee15956b2000-04-03 04:51:13 +0000175 return use_wrappers(@_[0], '<tt class="class">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000176sub do_cmd_function{
Fred Drakee15956b2000-04-03 04:51:13 +0000177 return use_wrappers(@_[0], '<tt class="function">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000178sub do_cmd_constant{
Fred Drakee15956b2000-04-03 04:51:13 +0000179 return use_wrappers(@_[0], '<tt class="constant">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000180sub do_cmd_member{
Fred Drakee15956b2000-04-03 04:51:13 +0000181 return use_wrappers(@_[0], '<tt class="member">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000182sub do_cmd_method{
Fred Drakee15956b2000-04-03 04:51:13 +0000183 return use_wrappers(@_[0], '<tt class="method">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000184sub do_cmd_cfunction{
Fred Drakee15956b2000-04-03 04:51:13 +0000185 return use_wrappers(@_[0], '<tt class="cfunction">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000186sub do_cmd_cdata{
Fred Drakee15956b2000-04-03 04:51:13 +0000187 return use_wrappers(@_[0], '<tt class="cdata">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000188sub do_cmd_ctype{
Fred Drakee15956b2000-04-03 04:51:13 +0000189 return use_wrappers(@_[0], '<tt class="ctype">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000190sub do_cmd_regexp{
Fred Drakee15956b2000-04-03 04:51:13 +0000191 return use_wrappers(@_[0], '<tt class="regexp">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000192sub do_cmd_character{
Fred Drakee15956b2000-04-03 04:51:13 +0000193 return use_wrappers(@_[0], '"<tt class="character">', '</tt>"'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000194sub do_cmd_program{
Fred Drakee15956b2000-04-03 04:51:13 +0000195 return use_wrappers(@_[0], '<b class="program">', '</b>'); }
Fred Drakec9f5fe01999-11-09 16:59:42 +0000196sub do_cmd_programopt{
197 return use_wrappers(@_[0], '<b class="programopt">', '</b>'); }
Fred Drake0cd60212000-04-11 18:46:59 +0000198sub do_cmd_longprogramopt{
199 # note that the --- will be later converted to -- by LaTeX2HTML
200 return use_wrappers(@_[0], '<b class="programopt">---', '</b>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000201sub do_cmd_email{
Fred Drakee15956b2000-04-03 04:51:13 +0000202 return use_wrappers(@_[0], '<span class="email">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000203sub do_cmd_mimetype{
Fred Drakee15956b2000-04-03 04:51:13 +0000204 return use_wrappers(@_[0], '<span class="mimetype">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000205sub do_cmd_var{
206 return use_wrappers(@_[0], "<var>", "</var>"); }
207sub do_cmd_dfn{
Fred Drakee15956b2000-04-03 04:51:13 +0000208 return use_wrappers(@_[0], '<i class="dfn">', '</i>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000209sub do_cmd_emph{
Fred Drake38178fd2000-09-22 17:05:04 +0000210 return use_wrappers(@_[0], '<i>', '</i>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000211sub do_cmd_file{
Fred Drake3d5a04a2000-08-03 17:25:44 +0000212 return use_wrappers(@_[0], '<span class="file">', '</span>'); }
Fred Drakef74e5b71999-04-28 14:58:49 +0000213sub do_cmd_filenq{
Fred Drakee15956b2000-04-03 04:51:13 +0000214 return do_cmd_file(@_[0]); }
Fred Drake90fdda51999-02-16 20:27:42 +0000215sub do_cmd_samp{
Fred Drakee15956b2000-04-03 04:51:13 +0000216 return use_wrappers(@_[0], '"<tt class="samp">', '</tt>"'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000217sub do_cmd_kbd{
218 return use_wrappers(@_[0], '<kbd>', '</kbd>'); }
219sub do_cmd_strong{
220 return use_wrappers(@_[0], '<b>', '</b>'); }
Fred Drake2cafcbb1999-03-25 16:57:04 +0000221sub do_cmd_textbf{
222 return use_wrappers(@_[0], '<b>', '</b>'); }
223sub do_cmd_textit{
224 return use_wrappers(@_[0], '<i>', '</i>'); }
225
Fred Drake3d5a04a2000-08-03 17:25:44 +0000226sub do_cmd_moreargs{
227 return '...' . @_[0]; }
228sub do_cmd_unspecified{
229 return '...' . @_[0]; }
230
Fred Drakec9a44381998-03-17 06:29:13 +0000231
Fred Drake25817041999-01-13 17:06:34 +0000232sub do_cmd_refmodule{
233 # Insert the right magic to jump to the module definition.
234 local($_) = @_;
235 my $key = next_optional_argument();
236 my $module = next_argument();
237 $key = $module
238 unless $key;
Fred Drakee15956b2000-04-03 04:51:13 +0000239 return "<tt class='module'><a href='module-$key.html'>$module</a></tt>"
240 . $_;
Fred Drake25817041999-01-13 17:06:34 +0000241}
242
Fred Drake1a7af391998-04-01 22:44:56 +0000243sub do_cmd_newsgroup{
244 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000245 my $newsgroup = next_argument();
Fred Drake7a40c072000-10-02 14:43:38 +0000246 my $icon = get_link_icon("news:$newsgroup");
Fred Drakeafc7ce12001-01-22 17:33:24 +0000247 my $stuff = "<a class='newsgroup' href='news:$newsgroup'>"
248 . "$newsgroup$icon</a>";
Fred Drake62e43691998-08-10 19:40:44 +0000249 return $stuff . $_;
Fred Drake1a7af391998-04-01 22:44:56 +0000250}
Fred Drakefc16e781998-03-12 21:03:26 +0000251
252sub do_cmd_envvar{
253 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000254 my $envvar = next_argument();
255 my($name,$aname,$ahref) = new_link_info();
Fred Drake166abba1998-04-08 23:10:54 +0000256 # The <tt> here is really to keep buildindex.py from making
257 # the variable name case-insensitive.
Fred Drakeafc7ce12001-01-22 17:33:24 +0000258 add_index_entry("environment variables!$envvar@<tt>$envvar</tt>",
Fred Drake166abba1998-04-08 23:10:54 +0000259 $ahref);
Fred Drakeafc7ce12001-01-22 17:33:24 +0000260 add_index_entry("$envvar (environment variable)", $ahref);
Fred Drakee15956b2000-04-03 04:51:13 +0000261 $aname =~ s/<a/<a class="envvar"/;
Fred Drakeafc7ce12001-01-22 17:33:24 +0000262 return "$aname$envvar</a>" . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000263}
264
Fred Drake6659c301998-03-03 22:02:19 +0000265sub do_cmd_url{
266 # use the URL as both text and hyperlink
267 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000268 my $url = next_argument();
Fred Drake7a40c072000-10-02 14:43:38 +0000269 my $icon = get_link_icon($url);
Fred Drake6659c301998-03-03 22:02:19 +0000270 $url =~ s/~/&#126;/g;
Fred Drake7a40c072000-10-02 14:43:38 +0000271 return "<a class=\"url\" href=\"$url\">$url$icon</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000272}
273
274sub do_cmd_manpage{
275 # two parameters: \manpage{name}{section}
276 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000277 my $page = next_argument();
278 my $section = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000279 return "<span class='manpage'><i>$page</i>($section)</span>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000280}
281
Fred Drakeafc7ce12001-01-22 17:33:24 +0000282$PEP_FORMAT = "http://python.sourceforge.net/peps/pep-XXXX.html";
283$RFC_FORMAT = "http://www.ietf.org/rfc/rfcXXXX.txt";
284
285sub get_rfc_url($$){
286 my($rfcnum, $format) = @_;
287 $rfcnum = sprintf("%04d", $rfcnum);
288 $format = "$format";
289 $format =~ s/XXXX/$rfcnum/;
290 return $format;
Fred Drake643d76d2000-09-09 06:07:37 +0000291}
292
293sub do_cmd_pep{
294 local($_) = @_;
295 my $rfcnumber = next_argument();
296 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drakeafc7ce12001-01-22 17:33:24 +0000297 my $href = get_rfc_url($rfcnumber, $PEP_FORMAT);
Fred Drake7a40c072000-10-02 14:43:38 +0000298 my $icon = get_link_icon($href);
Fred Drake643d76d2000-09-09 06:07:37 +0000299 # Save the reference
300 my $nstr = gen_index_id("Python Enhancement Proposals!PEP $rfcnumber", '');
301 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
Fred Drake7a40c072000-10-02 14:43:38 +0000302 return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">PEP $rfcnumber"
303 . "$icon</a>" . $_);
Fred Drake643d76d2000-09-09 06:07:37 +0000304}
305
Fred Drake6659c301998-03-03 22:02:19 +0000306sub do_cmd_rfc{
307 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000308 my $rfcnumber = next_argument();
309 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drakeafc7ce12001-01-22 17:33:24 +0000310 my $href = get_rfc_url($rfcnumber, $RFC_FORMAT);
Fred Drake7a40c072000-10-02 14:43:38 +0000311 my $icon = get_link_icon($href);
Fred Drake6659c301998-03-03 22:02:19 +0000312 # Save the reference
Fred Drake08932051998-04-17 02:15:42 +0000313 my $nstr = gen_index_id("RFC!RFC $rfcnumber", '');
Fred Drakeccc62721999-01-05 22:16:29 +0000314 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
Fred Drake7a40c072000-10-02 14:43:38 +0000315 return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">RFC $rfcnumber"
316 . "$icon</a>" . $_);
Fred Drake6659c301998-03-03 22:02:19 +0000317}
318
Fred Drakec9f5fe01999-11-09 16:59:42 +0000319sub do_cmd_citetitle{
320 local($_) = @_;
321 my $url = next_optional_argument();
322 my $title = next_argument();
Fred Drake7a40c072000-10-02 14:43:38 +0000323 my $icon = get_link_icon($url);
Fred Drakec9f5fe01999-11-09 16:59:42 +0000324 my $repl = '';
325 if ($url) {
326 $repl = ("<em class='citetitle'><a\n"
327 . " href='$url'\n"
328 . " title='$title'\n"
Fred Drake7a40c072000-10-02 14:43:38 +0000329 . " >$title$icon</a></em>");
Fred Drakec9f5fe01999-11-09 16:59:42 +0000330 }
331 else {
332 $repl = "<em class='citetitle'\n >$title</em>";
333 }
334 return $repl . $_;
335}
336
Fred Drake6659c301998-03-03 22:02:19 +0000337sub do_cmd_deprecated{
338 # two parameters: \deprecated{version}{whattodo}
339 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000340 my $release = next_argument();
341 my $reason = next_argument();
Fred Drakeafc7ce12001-01-22 17:33:24 +0000342 return ('<div class="versionnote">'
343 . "<b>Deprecated since release $release.</b>"
344 . "\n$reason</div><p>"
345 . $_);
Fred Drake6659c301998-03-03 22:02:19 +0000346}
347
Fred Drakec2b29d02001-04-18 03:11:04 +0000348sub versionnote{
349 # one or two parameters: \versionnote[explanation]{version}
350 my $type = @_[0];
351 local $_ = @_[1];
352 my $explanation = next_optional_argument();
Fred Drake897d12b1998-07-27 20:33:17 +0000353 my $release = next_argument();
Fred Drakec2b29d02001-04-18 03:11:04 +0000354 my $text = "$type in version $release.";
355 if ($explanation) {
356 $text = "$type in version $release:\n$explanation.";
357 }
358 return "\n<span class='versionnote'>$text</span>\n" . $_;
359}
360
361sub do_cmd_versionadded{
362 return versionnote('New', @_);
Fred Drake897d12b1998-07-27 20:33:17 +0000363}
364
365sub do_cmd_versionchanged{
Fred Drakec2b29d02001-04-18 03:11:04 +0000366 return versionnote('Changed', @_);
Fred Drake897d12b1998-07-27 20:33:17 +0000367}
368
Fred Drake557460c1999-03-02 16:05:35 +0000369#
Fred Drake2cafcbb1999-03-25 16:57:04 +0000370# These function handle platform dependency tracking.
Fred Drake557460c1999-03-02 16:05:35 +0000371#
372sub do_cmd_platform{
373 local($_) = @_;
374 my $platform = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000375 $ModulePlatforms{"<tt class='module'>$THIS_MODULE</tt>"} = $platform;
Fred Drake557460c1999-03-02 16:05:35 +0000376 $platform = "Macintosh"
Fred Drake085b8121999-04-21 14:00:29 +0000377 if $platform eq 'Mac';
Fred Drakee15956b2000-04-03 04:51:13 +0000378 return "\n<p class='availability'>Availability: <span"
379 . "\n class='platform'>$platform</span>.</p>\n" . $_;
Fred Drake557460c1999-03-02 16:05:35 +0000380}
381
Fred Drake557460c1999-03-02 16:05:35 +0000382$IGNORE_PLATFORM_ANNOTATION = '';
383sub do_cmd_ignorePlatformAnnotation{
384 local($_) = @_;
385 $IGNORE_PLATFORM_ANNOTATION = next_argument();
386 return $_;
387}
388
Fred Drake6659c301998-03-03 22:02:19 +0000389
390# index commands
391
392$INDEX_SUBITEM = "";
393
394sub get_indexsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000395 return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
Fred Drake6659c301998-03-03 22:02:19 +0000396}
397
398sub do_cmd_setindexsubitem{
399 local($_) = @_;
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000400 $INDEX_SUBITEM = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000401 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000402}
403
Fred Drakefc16e781998-03-12 21:03:26 +0000404sub do_cmd_withsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000405 # We can't really do the right thing, because LaTeX2HTML doesn't
Fred Drakefc16e781998-03-12 21:03:26 +0000406 # do things in the right order, but we need to at least strip this stuff
407 # out, and leave anything that the second argument expanded out to.
408 #
409 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000410 my $oldsubitem = $INDEX_SUBITEM;
411 $INDEX_SUBITEM = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000412 my $stuff = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000413 my $br_id = ++$globals{'max_id'};
414 my $marker = "$O$br_id$C";
Fred Drake7d45f6d1999-01-05 14:39:27 +0000415 return
416 $stuff
Fred Drakeccc62721999-01-05 22:16:29 +0000417 . "\\setindexsubitem$marker$oldsubitem$marker"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000418 . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000419}
420
Fred Drake08932051998-04-17 02:15:42 +0000421# This is the prologue macro which is required to start writing the
Fred Drakeab032151999-05-13 18:36:54 +0000422# mod\jobname.idx file; we can just ignore it. (Defining this suppresses
423# a warning that \makemodindex is unknown.)
Fred Drake08932051998-04-17 02:15:42 +0000424#
Fred Drake62e43691998-08-10 19:40:44 +0000425sub do_cmd_makemodindex{ return @_[0]; }
Fred Drakefc16e781998-03-12 21:03:26 +0000426
Fred Drake42b31a51998-03-27 05:16:10 +0000427# We're in the document subdirectory when this happens!
Fred Drake166abba1998-04-08 23:10:54 +0000428#
Fred Drake08932051998-04-17 02:15:42 +0000429open(IDXFILE, '>index.dat') || die "\n$!\n";
430open(INTLABELS, '>intlabels.pl') || die "\n$!\n";
Fred Drake166abba1998-04-08 23:10:54 +0000431print INTLABELS "%internal_labels = ();\n";
432print INTLABELS "1; # hack in case there are no entries\n\n";
433
434# Using \0 for this is bad because we can't use common tools to work with the
435# resulting files. Things like grep can be useful with this stuff!
436#
437$IDXFILE_FIELD_SEP = "\1";
438
Fred Drakeccc62721999-01-05 22:16:29 +0000439sub write_idxfile{
440 my ($ahref, $str) = @_;
441 print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n";
Fred Drake42b31a51998-03-27 05:16:10 +0000442}
443
Fred Drake42b31a51998-03-27 05:16:10 +0000444
445sub gen_link{
446 my($node,$target) = @_;
447 print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
Fred Drakee15956b2000-04-03 04:51:13 +0000448 return "<a href='$node#$target'>";
Fred Drake42b31a51998-03-27 05:16:10 +0000449}
450
Fred Drake42b31a51998-03-27 05:16:10 +0000451sub add_index_entry{
452 # add an entry to the index structures; ignore the return value
453 my($str,$ahref) = @_;
454 $str = gen_index_id($str, '');
455 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000456 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000457}
458
Fred Drakeccc62721999-01-05 22:16:29 +0000459sub new_link_info{
460 my $name = "l2h-" . ++$globals{'max_id'};
Fred Drakee15956b2000-04-03 04:51:13 +0000461 my $aname = "<a name='$name'>";
Fred Drake42b31a51998-03-27 05:16:10 +0000462 my $ahref = gen_link($CURRENT_FILE, $name);
463 return ($name, $aname, $ahref);
464}
465
Fred Drakeab032151999-05-13 18:36:54 +0000466$IndexMacroPattern = '';
467sub define_indexing_macro{
468 my $count = @_;
469 my $i = 0;
470 for (; $i < $count; ++$i) {
471 my $name = @_[$i];
472 my $cmd = "idx_cmd_$name";
473 die "\nNo function $cmd() defined!\n"
474 if (!defined &$cmd);
475 eval ("sub do_cmd_$name { return process_index_macros("
476 . "\@_[0], '$name'); }");
477 if (length($IndexMacroPattern) == 0) {
478 $IndexMacroPattern = "$name";
479 }
480 else {
481 $IndexMacroPattern .= "|$name";
482 }
483 }
484}
485
486$DEBUG_INDEXING = 0;
487sub process_index_macros{
Fred Drake42b31a51998-03-27 05:16:10 +0000488 local($_) = @_;
Fred Drakeab032151999-05-13 18:36:54 +0000489 my $cmdname = @_[1]; # This is what triggered us in the first place;
490 # we know it's real, so just process it.
Fred Drakeccc62721999-01-05 22:16:29 +0000491 my($name,$aname,$ahref) = new_link_info();
Fred Drakeab032151999-05-13 18:36:54 +0000492 my $cmd = "idx_cmd_$cmdname";
493 print "\nIndexing: \\$cmdname"
494 if $DEBUG_INDEXING;
495 &$cmd($ahref); # modifies $_ and adds index entries
496 while (/^[\s\n]*\\($IndexMacroPattern)</) {
497 $cmdname = "$1";
498 print " \\$cmdname"
499 if $DEBUG_INDEXING;
500 $cmd = "idx_cmd_$cmdname";
501 if (!defined &$cmd) {
502 last;
503 }
504 else {
505 s/^[\s\n]*\\$cmdname//;
506 &$cmd($ahref);
507 }
508 }
Fred Drakeafc7ce12001-01-22 17:33:24 +0000509 if (/^[ \t\r\n]/) {
510 $_ = substr($_, 1);
511 }
Fred Drake62e43691998-08-10 19:40:44 +0000512 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake42b31a51998-03-27 05:16:10 +0000513}
514
Fred Drakeab032151999-05-13 18:36:54 +0000515define_indexing_macro('index');
516sub idx_cmd_index{
Fred Drakeccc62721999-01-05 22:16:29 +0000517 my $str = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000518 add_index_entry("$str", @_[0]);
Fred Drake2e7edb81998-05-11 18:31:17 +0000519}
520
Fred Drakeab032151999-05-13 18:36:54 +0000521define_indexing_macro('kwindex');
522sub idx_cmd_kwindex{
523 my $str = next_argument();
524 add_index_entry("<tt>$str</tt>!keyword", @_[0]);
525 add_index_entry("keyword!<tt>$str</tt>", @_[0]);
526}
527
528define_indexing_macro('indexii');
529sub idx_cmd_indexii{
Fred Drakeccc62721999-01-05 22:16:29 +0000530 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000531 my $str2 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000532 add_index_entry("$str1!$str2", @_[0]);
533 add_index_entry("$str2!$str1", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000534}
535
Fred Drakeab032151999-05-13 18:36:54 +0000536define_indexing_macro('indexiii');
537sub idx_cmd_indexiii{
Fred Drakeccc62721999-01-05 22:16:29 +0000538 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000539 my $str2 = next_argument();
540 my $str3 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000541 add_index_entry("$str1!$str2 $str3", @_[0]);
542 add_index_entry("$str2!$str3, $str1", @_[0]);
543 add_index_entry("$str3!$str1 $str2", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000544}
545
Fred Drakeab032151999-05-13 18:36:54 +0000546define_indexing_macro('indexiv');
547sub idx_cmd_indexiv{
Fred Drakeccc62721999-01-05 22:16:29 +0000548 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000549 my $str2 = next_argument();
550 my $str3 = next_argument();
551 my $str4 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000552 add_index_entry("$str1!$str2 $str3 $str4", @_[0]);
553 add_index_entry("$str2!$str3 $str4, $str1", @_[0]);
554 add_index_entry("$str3!$str4, $str1 $str2", @_[0]);
555 add_index_entry("$str4!$$str1 $str2 $str3", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000556}
557
Fred Drakeab032151999-05-13 18:36:54 +0000558define_indexing_macro('ttindex');
559sub idx_cmd_ttindex{
Fred Drakeccc62721999-01-05 22:16:29 +0000560 my $str = next_argument();
561 my $entry = $str . get_indexsubitem();
Fred Drakeab032151999-05-13 18:36:54 +0000562 add_index_entry($entry, @_[0]);
Fred Drakec9a44381998-03-17 06:29:13 +0000563}
Fred Drake6659c301998-03-03 22:02:19 +0000564
565sub my_typed_index_helper{
Fred Drakeab032151999-05-13 18:36:54 +0000566 my($word,$ahref) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000567 my $str = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000568 add_index_entry("$str $word", $ahref);
569 add_index_entry("$word!$str", $ahref);
Fred Drake6659c301998-03-03 22:02:19 +0000570}
571
Fred Drakeab032151999-05-13 18:36:54 +0000572define_indexing_macro('stindex', 'opindex', 'exindex', 'obindex');
573sub idx_cmd_stindex{ my_typed_index_helper('statement', @_[0]); }
574sub idx_cmd_opindex{ my_typed_index_helper('operator', @_[0]); }
575sub idx_cmd_exindex{ my_typed_index_helper('exception', @_[0]); }
576sub idx_cmd_obindex{ my_typed_index_helper('object', @_[0]); }
Fred Drake6659c301998-03-03 22:02:19 +0000577
Fred Drakeab032151999-05-13 18:36:54 +0000578define_indexing_macro('bifuncindex');
579sub idx_cmd_bifuncindex{
Fred Drakeccc62721999-01-05 22:16:29 +0000580 my $str = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000581 add_index_entry("<tt class='function'>$str()</tt> (built-in function)",
582 @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000583}
584
585
Fred Drake6659c301998-03-03 22:02:19 +0000586sub make_mod_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000587 my($str,$define) = @_;
588 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000589 # equivalent of add_index_entry() using $define instead of ''
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000590 $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/
591 if ($define eq 'DEF');
Fred Drake42b31a51998-03-27 05:16:10 +0000592 $str = gen_index_id($str, $define);
593 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000594 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000595
Fred Drakec9a44381998-03-17 06:29:13 +0000596 if ($define eq 'DEF') {
Fred Drake42b31a51998-03-27 05:16:10 +0000597 # add to the module index
Fred Drakee15956b2000-04-03 04:51:13 +0000598 $str =~ /(<tt.*<\/tt>)/;
599 my $nstr = $1;
Fred Drake42b31a51998-03-27 05:16:10 +0000600 $Modules{$nstr} .= $ahref;
Fred Drake6659c301998-03-03 22:02:19 +0000601 }
Fred Drakeafc7ce12001-01-22 17:33:24 +0000602 return "$aname$anchor_invisible_mark2</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000603}
604
Fred Drake557460c1999-03-02 16:05:35 +0000605
Fred Drakec9a44381998-03-17 06:29:13 +0000606$THIS_MODULE = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000607$THIS_CLASS = '';
Fred Drakec9a44381998-03-17 06:29:13 +0000608
Fred Drakea0f4c941998-07-24 22:16:04 +0000609sub define_module{
610 my($word,$name) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000611 my $section_tag = join('', @curr_sec_id);
Fred Drake3e4c6141999-05-17 15:00:32 +0000612 if ($word ne "built-in" && $word ne "extension"
613 && $word ne "standard" && $word ne "") {
614 write_warnings("Bad module type '$word'"
615 . " for \\declaremodule (module $name)");
616 $word = "";
617 }
Fred Drake6659c301998-03-03 22:02:19 +0000618 $word = "$word " if $word;
Fred Drakea0f4c941998-07-24 22:16:04 +0000619 $THIS_MODULE = "$name";
Fred Drake5942b432000-10-30 06:24:56 +0000620 $INDEX_SUBITEM = "(in module $name)";
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000621 print "[$name]";
Fred Drakee15956b2000-04-03 04:51:13 +0000622 return make_mod_index_entry(
623 "<tt class='module'>$name</tt> (${word}module)", 'DEF');
Fred Drakea0f4c941998-07-24 22:16:04 +0000624}
625
626sub my_module_index_helper{
627 local($word, $_) = @_;
628 my $name = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000629 return define_module($word, $name) . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000630}
631
Fred Drake62e43691998-08-10 19:40:44 +0000632sub do_cmd_modindex{ return my_module_index_helper('', @_); }
633sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); }
634sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); }
635sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000636
Fred Drakeab032151999-05-13 18:36:54 +0000637sub ref_module_index_helper{
Fred Drake37cc0c02000-04-26 18:05:24 +0000638 my($word, $ahref) = @_;
Fred Drakeab032151999-05-13 18:36:54 +0000639 my $str = next_argument();
640 $word = "$word " if $word;
Fred Drakee15956b2000-04-03 04:51:13 +0000641 $str = "<tt class='module'>$str</tt> (${word}module)";
Fred Drakeab032151999-05-13 18:36:54 +0000642 # can't use add_index_entry() since the 2nd arg to gen_index_id() is used;
643 # just inline it all here
644 $str = gen_index_id($str, 'REF');
645 $index{$str} .= $ahref;
646 write_idxfile($ahref, $str);
647}
648
Fred Drake6659c301998-03-03 22:02:19 +0000649# these should be adjusted a bit....
Fred Drakeab032151999-05-13 18:36:54 +0000650define_indexing_macro('refmodindex', 'refbimodindex',
651 'refexmodindex', 'refstmodindex');
652sub idx_cmd_refmodindex{ return ref_module_index_helper('', @_); }
653sub idx_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); }
654sub idx_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); }
655sub idx_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000656
Fred Drake62e43691998-08-10 19:40:44 +0000657sub do_cmd_nodename{ return do_cmd_label(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000658
659sub init_myformat{
Fred Drakeafc7ce12001-01-22 17:33:24 +0000660 $anchor_invisible_mark = '&nbsp;';
661 $anchor_invisible_mark2 = '';
Fred Drake6659c301998-03-03 22:02:19 +0000662 $anchor_mark = '';
663 $icons{'anchor_mark'} = '';
Fred Drake6659c301998-03-03 22:02:19 +0000664}
Fred Drake42b31a51998-03-27 05:16:10 +0000665init_myformat();
Fred Drake6659c301998-03-03 22:02:19 +0000666
Fred Drakeab032151999-05-13 18:36:54 +0000667# Create an index entry, but include the string in the target anchor
Fred Drake6659c301998-03-03 22:02:19 +0000668# instead of the dummy filler.
669#
670sub make_str_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000671 my($str) = @_;
672 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000673 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000674 return "$aname$str</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000675}
676
Fred Drakee15956b2000-04-03 04:51:13 +0000677$REFCOUNTS_LOADED = 0;
678
679sub load_refcounts{
680 $REFCOUNTS_LOADED = 1;
681
Fred Drakee15956b2000-04-03 04:51:13 +0000682 my $myname, $mydir, $myext;
683 ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*');
684 chop $mydir; # remove trailing '/'
685 ($myname, $mydir, $myext) = fileparse($mydir, '\..*');
686 chop $mydir; # remove trailing '/'
687 $mydir = getcwd() . "$dd$mydir"
688 unless $mydir =~ s|^/|/|;
689 local $_;
690 my $filename = "$mydir${dd}api${dd}refcounts.dat";
691 open(REFCOUNT_FILE, "<$filename") || die "\n$!\n";
692 print "[loading API refcount data]";
693 while (<REFCOUNT_FILE>) {
Fred Drakec2578c52000-04-10 18:26:45 +0000694 if (/([a-zA-Z0-9_]+):PyObject\*:([a-zA-Z0-9_]*):(0|[-+]1|null):(.*)$/) {
Fred Drakee15956b2000-04-03 04:51:13 +0000695 my($func, $param, $count, $comment) = ($1, $2, $3, $4);
696 #print "\n$func($param) --> $count";
697 $REFCOUNTS{"$func:$param"} = $count;
698 }
699 }
700}
701
702sub get_refcount{
703 my ($func, $param) = @_;
704 load_refcounts()
705 unless $REFCOUNTS_LOADED;
706 return $REFCOUNTS{"$func:$param"};
707}
708
Fred Drake6659c301998-03-03 22:02:19 +0000709sub do_env_cfuncdesc{
710 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000711 my $return_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000712 my $function_name = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000713 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000714 my $idx = make_str_index_entry(
715 "<tt class='cfunction'>$function_name()</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000716 $idx =~ s/ \(.*\)//;
Fred Drake241551c2000-08-11 20:04:19 +0000717 $idx =~ s/\(\)//; # ???? - why both of these?
Fred Drakee15956b2000-04-03 04:51:13 +0000718 my $result_rc = get_refcount($function_name, '');
719 my $rcinfo = '';
720 if ($result_rc eq '+1') {
Fred Drake241551c2000-08-11 20:04:19 +0000721 $rcinfo = 'New reference';
Fred Drakee15956b2000-04-03 04:51:13 +0000722 }
723 elsif ($result_rc eq '0') {
Fred Drake241551c2000-08-11 20:04:19 +0000724 $rcinfo = 'Borrowed reference';
Fred Drakee15956b2000-04-03 04:51:13 +0000725 }
Fred Drakec2578c52000-04-10 18:26:45 +0000726 elsif ($result_rc eq 'null') {
Fred Drake241551c2000-08-11 20:04:19 +0000727 $rcinfo = 'Always <tt class="constant">NULL</tt>';
Fred Drakec2578c52000-04-10 18:26:45 +0000728 }
Fred Drakee15956b2000-04-03 04:51:13 +0000729 if ($rcinfo ne '') {
Fred Drake241551c2000-08-11 20:04:19 +0000730 $rcinfo = ( "\n<div class=\"refcount-info\">"
731 . "\n <span class=\"label\">Return value:</span>"
732 . "\n <span class=\"value\">$rcinfo.</span>"
733 . "\n</div>");
Fred Drakee15956b2000-04-03 04:51:13 +0000734 }
Fred Drakec612a142001-03-29 18:24:08 +0000735 return "<dl><dt>$return_type <b>$idx</b>(<var>$arg_list</var>)\n<dd>"
Fred Drakee15956b2000-04-03 04:51:13 +0000736 . $rcinfo
Fred Drake62e43691998-08-10 19:40:44 +0000737 . $_
738 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000739}
740
Fred Drakee15956b2000-04-03 04:51:13 +0000741sub do_env_csimplemacrodesc{
742 local($_) = @_;
743 my $name = next_argument();
744 my $idx = make_str_index_entry("<tt class='macro'>$name</tt>");
745 return "<dl><dt><b>$idx</b>\n<dd>"
746 . $_
747 . '</dl>'
748}
749
Fred Drake6659c301998-03-03 22:02:19 +0000750sub do_env_ctypedesc{
751 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +0000752 my $index_name = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000753 my $type_name = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000754 $index_name = $type_name
755 unless $index_name;
756 my($name,$aname,$ahref) = new_link_info();
757 add_index_entry("<tt class='ctype'>$index_name</tt> (C type)", $ahref);
758 return "<dl><dt><b><tt class='ctype'>$aname$type_name</a></tt></b>\n<dd>"
Fred Drake62e43691998-08-10 19:40:44 +0000759 . $_
760 . '</dl>'
Fred Drake6659c301998-03-03 22:02:19 +0000761}
762
763sub do_env_cvardesc{
764 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000765 my $var_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000766 my $var_name = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000767 my $idx = make_str_index_entry("<tt class='cdata'>$var_name</tt>"
Fred Drake90fdda51999-02-16 20:27:42 +0000768 . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000769 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000770 return "<dl><dt>$var_type <b>$idx</b>\n"
771 . '<dd>'
772 . $_
773 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000774}
775
Fred Drake3cdb89d2000-09-14 20:17:23 +0000776sub convert_args($){
777 local($IN_DESC_HANDLER) = 1;
778 local($_) = @_;
779 return translate_commands($_);
780}
781
Fred Drake6659c301998-03-03 22:02:19 +0000782sub do_env_funcdesc{
783 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000784 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000785 my $arg_list = convert_args(next_argument());
Fred Drakee15956b2000-04-03 04:51:13 +0000786 my $idx = make_str_index_entry("<tt class='function'>$function_name()</tt>"
Fred Drake08932051998-04-17 02:15:42 +0000787 . get_indexsubitem());
788 $idx =~ s/ \(.*\)//;
Fred Drakeccc62721999-01-05 22:16:29 +0000789 $idx =~ s/\(\)<\/tt>/<\/tt>/;
Fred Drakec612a142001-03-29 18:24:08 +0000790 return "<dl><dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000791}
792
793sub do_env_funcdescni{
794 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000795 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000796 my $arg_list = convert_args(next_argument());
Fred Drakee15956b2000-04-03 04:51:13 +0000797 return "<dl><dt><b><tt class='function'>$function_name</tt></b>"
Fred Drakec612a142001-03-29 18:24:08 +0000798 . "(<var>$arg_list</var>)\n"
Fred Drake90fdda51999-02-16 20:27:42 +0000799 . '<dd>'
800 . $_
801 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000802}
803
804sub do_cmd_funcline{
805 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000806 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000807 my $arg_list = convert_args(next_argument());
Fred Drakee15956b2000-04-03 04:51:13 +0000808 my $prefix = "<tt class='function'>$function_name()</tt>";
Fred Drakeca675e41999-04-21 15:58:58 +0000809 my $idx = make_str_index_entry($prefix . get_indexsubitem());
810 $prefix =~ s/\(\)//;
811
Fred Drakec612a142001-03-29 18:24:08 +0000812 return "<dt><b>$prefix</b>(<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000813}
814
Fred Drake6b3fb781999-07-12 16:50:09 +0000815sub do_cmd_funclineni{
816 local($_) = @_;
817 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000818 my $arg_list = convert_args(next_argument());
Fred Drakee15956b2000-04-03 04:51:13 +0000819 my $prefix = "<tt class='function'>$function_name</tt>";
Fred Drake6b3fb781999-07-12 16:50:09 +0000820
Fred Drakec612a142001-03-29 18:24:08 +0000821 return "<dt><b>$prefix</b>(<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6b3fb781999-07-12 16:50:09 +0000822}
823
Fred Drake6659c301998-03-03 22:02:19 +0000824# Change this flag to index the opcode entries. I don't think it's very
825# useful to index them, since they're only presented to describe the dis
826# module.
827#
828$INDEX_OPCODES = 0;
829
830sub do_env_opcodedesc{
831 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000832 my $opcode_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000833 my $arg_list = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000834 my $idx;
835 if ($INDEX_OPCODES) {
Fred Drakee15956b2000-04-03 04:51:13 +0000836 $idx = make_str_index_entry("<tt class='opcode'>$opcode_name</tt>"
837 . " (byte code instruction)");
Fred Drake08932051998-04-17 02:15:42 +0000838 $idx =~ s/ \(byte code instruction\)//;
839 }
840 else {
Fred Drakee15956b2000-04-03 04:51:13 +0000841 $idx = "<tt class='opcode'>$opcode_name</tt>";
Fred Drake08932051998-04-17 02:15:42 +0000842 }
843 my $stuff = "<dl><dt><b>$idx</b>";
Fred Drake6659c301998-03-03 22:02:19 +0000844 if ($arg_list) {
845 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
846 }
Fred Drake62e43691998-08-10 19:40:44 +0000847 return $stuff . "\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000848}
849
850sub do_env_datadesc{
851 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000852 my $dataname = next_argument();
853 my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000854 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000855 return "<dl><dt><b>$idx</b>\n<dd>"
856 . $_
857 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000858}
859
860sub do_env_datadescni{
861 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000862 my $idx = next_argument();
863 if (! $STRING_INDEX_TT) {
864 $idx = "<tt>$idx</tt>";
Fred Drake6659c301998-03-03 22:02:19 +0000865 }
Fred Drake62e43691998-08-10 19:40:44 +0000866 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000867}
868
869sub do_cmd_dataline{
870 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000871 my $data_name = next_argument();
872 my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem());
Fred Drake6659c301998-03-03 22:02:19 +0000873 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000874 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000875}
876
Fred Drakeadb272c2000-04-10 17:47:14 +0000877sub do_cmd_datalineni{
878 local($_) = @_;
879 my $data_name = next_argument();
880 return "<dt><b><tt>$data_name</tt></b><dd>" . $_;
881}
882
Fred Drake42b31a51998-03-27 05:16:10 +0000883sub do_env_excdesc{
884 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000885 my $excname = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000886 my $idx = make_str_index_entry("<tt class='exception'>$excname</tt>");
Fred Drakeab357ec2001-03-02 18:57:05 +0000887 return "<dl><dt><b>exception $idx</b>\n<dd>" . $_ . '</dl>'
Fred Drake42b31a51998-03-27 05:16:10 +0000888}
889
Fred Drake62e43691998-08-10 19:40:44 +0000890sub do_env_fulllineitems{ return do_env_itemize(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000891
892
Fred Drake643d76d2000-09-09 06:07:37 +0000893sub handle_classlike_descriptor{
894 local($_, $what) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000895 $THIS_CLASS = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000896 my $arg_list = convert_args(next_argument());
Fred Drakeccc62721999-01-05 22:16:29 +0000897 $idx = make_str_index_entry(
Fred Drake643d76d2000-09-09 06:07:37 +0000898 "<tt class='$what'>$THIS_CLASS</tt> ($what in $THIS_MODULE)" );
Fred Drake08932051998-04-17 02:15:42 +0000899 $idx =~ s/ \(.*\)//;
Fred Drakec612a142001-03-29 18:24:08 +0000900 return ("<dl><dt><b>$what $idx</b>(<var>$arg_list</var>)\n<dd>"
Fred Drakeab357ec2001-03-02 18:57:05 +0000901 . $_
902 . '</dl>');
Fred Drakec9a44381998-03-17 06:29:13 +0000903}
904
Fred Drake643d76d2000-09-09 06:07:37 +0000905sub do_env_classdesc{
906 return handle_classlike_descriptor(@_[0], "class");
907}
908
Fred Drake06a01e82001-05-11 01:00:30 +0000909sub do_env_classdescstar{
910 local($_) = @_;
911 $THIS_CLASS = next_argument();
912 $idx = make_str_index_entry(
913 "<tt class='class'>$THIS_CLASS</tt> (class in $THIS_MODULE)" );
914 $idx =~ s/ \(.*\)//;
915 return ("<dl><dt><b>class $idx</b>\n<dd>"
916 . $_
917 . '</dl>');
918}
919
Fred Drake643d76d2000-09-09 06:07:37 +0000920sub do_env_excclassdesc{
921 return handle_classlike_descriptor(@_[0], "exception");
922}
923
Fred Drake42b31a51998-03-27 05:16:10 +0000924
925sub do_env_methoddesc{
926 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000927 my $class_name = next_optional_argument();
928 $class_name = $THIS_CLASS
929 unless $class_name;
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000930 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000931 my $arg_list = convert_args(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000932 my $extra = '';
933 if ($class_name) {
934 $extra = " ($class_name method)";
Fred Drake42b31a51998-03-27 05:16:10 +0000935 }
Fred Drakee15956b2000-04-03 04:51:13 +0000936 my $idx = make_str_index_entry("<tt class='method'>$method()</tt>$extra");
Fred Drake08932051998-04-17 02:15:42 +0000937 $idx =~ s/ \(.*\)//;
938 $idx =~ s/\(\)//;
Fred Drakec612a142001-03-29 18:24:08 +0000939 return "<dl><dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000940}
941
942
Fred Drake7d45f6d1999-01-05 14:39:27 +0000943sub do_cmd_methodline{
944 local($_) = @_;
945 my $class_name = next_optional_argument();
946 $class_name = $THIS_CLASS
947 unless $class_name;
948 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000949 my $arg_list = convert_args(next_argument());
Fred Drake7d45f6d1999-01-05 14:39:27 +0000950 my $extra = '';
951 if ($class_name) {
952 $extra = " ($class_name method)";
953 }
Fred Drakee15956b2000-04-03 04:51:13 +0000954 my $idx = make_str_index_entry("<tt class='method'>$method()</tt>$extra");
Fred Drake7d45f6d1999-01-05 14:39:27 +0000955 $idx =~ s/ \(.*\)//;
956 $idx =~ s/\(\)//;
Fred Drakec612a142001-03-29 18:24:08 +0000957 return "<dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000958 . $_;
959}
960
961
Fred Draked64a40d1998-09-10 18:59:13 +0000962sub do_cmd_methodlineni{
963 local($_) = @_;
964 next_optional_argument();
965 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000966 my $arg_list = convert_args(next_argument());
Fred Drakec612a142001-03-29 18:24:08 +0000967 return "<dt><b>$method</b>(<var>$arg_list</var>)\n<dd>"
Fred Draked64a40d1998-09-10 18:59:13 +0000968 . $_;
969}
970
Fred Drake42b31a51998-03-27 05:16:10 +0000971sub do_env_methoddescni{
972 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000973 next_optional_argument();
974 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000975 my $arg_list = convert_args(next_argument());
Fred Drakec612a142001-03-29 18:24:08 +0000976 return "<dl><dt><b>$method</b>(<var>$arg_list</var>)\n<dd>"
Fred Drake62e43691998-08-10 19:40:44 +0000977 . $_
978 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000979}
980
981
982sub do_env_memberdesc{
983 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000984 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000985 my $member = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000986 $class = $THIS_CLASS
987 unless $class;
Fred Drake08932051998-04-17 02:15:42 +0000988 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +0000989 $extra = " ($class attribute)"
990 if ($class ne '');
Fred Drakee15956b2000-04-03 04:51:13 +0000991 my $idx = make_str_index_entry("<tt class='member'>$member</tt>$extra");
Fred Drake42b31a51998-03-27 05:16:10 +0000992 $idx =~ s/ \(.*\)//;
993 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000994 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000995}
996
997
Fred Drake5ccf3301998-04-17 20:04:09 +0000998sub do_cmd_memberline{
999 local($_) = @_;
1000 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +00001001 my $member = next_argument();
Fred Drake5ccf3301998-04-17 20:04:09 +00001002 $class = $THIS_CLASS
1003 unless $class;
1004 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +00001005 $extra = " ($class attribute)"
1006 if ($class ne '');
Fred Drakee15956b2000-04-03 04:51:13 +00001007 my $idx = make_str_index_entry("<tt class='member'>$member</tt>$extra");
Fred Drake5ccf3301998-04-17 20:04:09 +00001008 $idx =~ s/ \(.*\)//;
1009 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +00001010 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +00001011}
1012
Fred Drake42b31a51998-03-27 05:16:10 +00001013sub do_env_memberdescni{
1014 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001015 next_optional_argument();
1016 my $member = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +00001017 return "<dl><dt><b><tt class='member'>$member</tt></b>\n<dd>"
1018 . $_
1019 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +00001020}
1021
1022
Fred Drake5ccf3301998-04-17 20:04:09 +00001023sub do_cmd_memberlineni{
1024 local($_) = @_;
1025 next_optional_argument();
1026 my $member = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +00001027 return "<dt><b><tt class='member'>$member</tt></b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +00001028}
1029
Fred Drakee15956b2000-04-03 04:51:13 +00001030@col_aligns = ('<td>', '<td>', '<td>', '<td>');
Fred Drake6659c301998-03-03 22:02:19 +00001031
Fred Drakef74e5b71999-04-28 14:58:49 +00001032sub fix_font{
1033 # do a little magic on a font name to get the right behavior in the first
1034 # column of the output table
1035 my $font = @_[0];
1036 if ($font eq 'textrm') {
1037 $font = '';
1038 }
1039 elsif ($font eq 'file' || $font eq 'filenq') {
Fred Drakee15956b2000-04-03 04:51:13 +00001040 $font = 'tt class="file"';
1041 }
1042 elsif ($font eq 'member') {
1043 $font = 'tt class="member"';
Fred Drakef74e5b71999-04-28 14:58:49 +00001044 }
Fred Drakee463f8e2000-11-30 07:17:27 +00001045 elsif ($font eq 'class') {
1046 $font = 'tt class="class"';
1047 }
Fred Drake7388f732000-06-28 21:06:08 +00001048 elsif ($font eq 'constant') {
1049 $font = 'tt class="constant"';
1050 }
Fred Drakecb0fc9c2000-08-09 13:45:04 +00001051 elsif ($font eq 'kbd') {
1052 $font = 'kbd';
1053 }
Fred Draked04592a2000-10-25 16:15:13 +00001054 elsif ($font eq 'programopt') {
1055 $font = 'b';
1056 }
Fred Drakeafc7ce12001-01-22 17:33:24 +00001057 elsif ($font eq 'exception') {
1058 $font = 'tt class="exception"';
1059 }
Fred Drakef74e5b71999-04-28 14:58:49 +00001060 return $font;
1061}
1062
Fred Drakee15956b2000-04-03 04:51:13 +00001063sub figure_column_alignment{
1064 my $a = @_[0];
1065 my $mark = substr($a, 0, 1);
1066 my $r = '';
1067 if ($mark eq 'c')
1068 { $r = ' align="center"'; }
1069 elsif ($mark eq 'r')
1070 { $r = ' align="right"'; }
1071 elsif ($mark eq 'l')
1072 { $r = ' align="left"'; }
1073 elsif ($mark eq 'p')
1074 { $r = ' align="left"'; }
1075 return $r;
1076}
1077
Fred Drake6659c301998-03-03 22:02:19 +00001078sub setup_column_alignments{
1079 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001080 my($s1,$s2,$s3,$s4) = split(/[|]/,$_);
1081 my $a1 = figure_column_alignment($s1);
1082 my $a2 = figure_column_alignment($s2);
1083 my $a3 = figure_column_alignment($s3);
1084 my $a4 = figure_column_alignment($s4);
1085 $col_aligns[0] = "<td$a1 valign=\"baseline\">";
1086 $col_aligns[1] = "<td$a2>";
1087 $col_aligns[2] = "<td$a3>";
1088 $col_aligns[3] = "<td$a4>";
Fred Drake79189b51999-04-28 13:54:30 +00001089 # return the aligned header start tags
Fred Drakee15956b2000-04-03 04:51:13 +00001090 return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>");
1091}
1092
1093sub get_table_col1_fonts{
1094 my $font = $globals{'lineifont'};
1095 my ($sfont,$efont) = ('', '');
1096 if ($font) {
1097 $sfont = "<$font>";
1098 $efont = "</$font>";
1099 $efont =~ s/ .*>/>/;
1100 }
Fred Drakee463f8e2000-11-30 07:17:27 +00001101 return ($sfont, $efont);
Fred Drake6659c301998-03-03 22:02:19 +00001102}
1103
1104sub do_env_tableii{
1105 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001106 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001107 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001108 my $h1 = next_argument();
1109 my $h2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001110 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001111 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001112 my $a1 = $col_aligns[0];
1113 my $a2 = $col_aligns[1];
1114 s/\\lineii</\\lineii[$a1|$a2]</g;
1115 return '<table border align="center" style="border-collapse: collapse">'
Fred Drake351960d2000-10-26 20:14:58 +00001116 . "\n <thead>"
1117 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001118 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1119 . "\n $th2<b>$h2</b>\&nbsp;</th>"
Fred Drake351960d2000-10-26 20:14:58 +00001120 . "\n </tr>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001121 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001122 . "\n <tbody valign='baseline'>"
Fred Drake351960d2000-10-26 20:14:58 +00001123 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001124 . "\n </tbody>"
1125 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001126}
1127
Fred Drakeda72b932000-09-21 15:58:02 +00001128sub do_env_longtableii{
1129 return do_env_tableii(@_);
1130}
1131
Fred Drake6659c301998-03-03 22:02:19 +00001132sub do_cmd_lineii{
1133 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001134 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001135 my $c1 = next_argument();
1136 my $c2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001137 s/[\s\n]+//;
Fred Drakee463f8e2000-11-30 07:17:27 +00001138 my($sfont,$efont) = get_table_col1_fonts();
Fred Drakee15956b2000-04-03 04:51:13 +00001139 $c2 = '&nbsp;' if ($c2 eq '');
1140 my($c1align,$c2align) = split('\|', $aligns);
1141 my $padding = '';
Fred Drakee463f8e2000-11-30 07:17:27 +00001142 if ($c1align =~ /align="right"/ || $c1 eq '') {
Fred Drakee15956b2000-04-03 04:51:13 +00001143 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001144 }
Fred Drakee15956b2000-04-03 04:51:13 +00001145 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
1146 . " $c2align$c2</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001147 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001148}
1149
1150sub do_env_tableiii{
1151 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001152 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001153 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001154 my $h1 = next_argument();
1155 my $h2 = next_argument();
1156 my $h3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001157 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001158 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001159 my $a1 = $col_aligns[0];
1160 my $a2 = $col_aligns[1];
1161 my $a3 = $col_aligns[2];
1162 s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g;
1163 return '<table border align="center" style="border-collapse: collapse">'
Fred Drake351960d2000-10-26 20:14:58 +00001164 . "\n <thead>"
1165 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001166 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1167 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1168 . "\n $th3<b>$h3</b>\&nbsp;</th>"
Fred Drake351960d2000-10-26 20:14:58 +00001169 . "\n </tr>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001170 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001171 . "\n <tbody valign='baseline'>"
Fred Drake62e43691998-08-10 19:40:44 +00001172 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001173 . "\n </tbody>"
1174 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001175}
1176
Fred Drakeda72b932000-09-21 15:58:02 +00001177sub do_env_longtableiii{
1178 return do_env_tableiii(@_);
1179}
1180
Fred Drake6659c301998-03-03 22:02:19 +00001181sub do_cmd_lineiii{
1182 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001183 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001184 my $c1 = next_argument();
1185 my $c2 = next_argument();
1186 my $c3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001187 s/[\s\n]+//;
Fred Drakee463f8e2000-11-30 07:17:27 +00001188 my($sfont,$efont) = get_table_col1_fonts();
Fred Drakee15956b2000-04-03 04:51:13 +00001189 $c3 = '&nbsp;' if ($c3 eq '');
1190 my($c1align,$c2align,$c3align) = split('\|', $aligns);
1191 my $padding = '';
Fred Drakee463f8e2000-11-30 07:17:27 +00001192 if ($c1align =~ /align="right"/ || $c1 eq '') {
Fred Drakee15956b2000-04-03 04:51:13 +00001193 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001194 }
Fred Drakee15956b2000-04-03 04:51:13 +00001195 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001196 . " $c2align$c2</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001197 . " $c3align$c3</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001198 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001199}
1200
Fred Drakea0f4c941998-07-24 22:16:04 +00001201sub do_env_tableiv{
1202 local($_) = @_;
1203 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001204 my $font = fix_font(next_argument());
Fred Drakea0f4c941998-07-24 22:16:04 +00001205 my $h1 = next_argument();
1206 my $h2 = next_argument();
1207 my $h3 = next_argument();
1208 my $h4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001209 s/[\s\n]+//;
Fred Drakea0f4c941998-07-24 22:16:04 +00001210 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001211 my $a1 = $col_aligns[0];
1212 my $a2 = $col_aligns[1];
1213 my $a3 = $col_aligns[2];
1214 my $a4 = $col_aligns[3];
1215 s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g;
1216 return '<table border align="center" style="border-collapse: collapse">'
Fred Drake351960d2000-10-26 20:14:58 +00001217 . "\n <thead>"
1218 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001219 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1220 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1221 . "\n $th3<b>$h3</b>\&nbsp;</th>"
1222 . "\n $th4<b>$h4</b>\&nbsp;</th>"
Fred Drake351960d2000-10-26 20:14:58 +00001223 . "\n </tr>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001224 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001225 . "\n <tbody valign='baseline'>"
Fred Drake62e43691998-08-10 19:40:44 +00001226 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001227 . "\n </tbody>"
1228 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001229}
1230
Fred Drakeda72b932000-09-21 15:58:02 +00001231sub do_env_longtableiv{
1232 return do_env_tableiv(@_);
1233}
1234
Fred Drakea0f4c941998-07-24 22:16:04 +00001235sub do_cmd_lineiv{
Fred Drake6659c301998-03-03 22:02:19 +00001236 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001237 my $aligns = next_optional_argument();
Fred Drakea0f4c941998-07-24 22:16:04 +00001238 my $c1 = next_argument();
1239 my $c2 = next_argument();
1240 my $c3 = next_argument();
1241 my $c4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001242 s/[\s\n]+//;
Fred Drakee463f8e2000-11-30 07:17:27 +00001243 my($sfont,$efont) = get_table_col1_fonts();
Fred Drakee15956b2000-04-03 04:51:13 +00001244 $c4 = '&nbsp;' if ($c4 eq '');
1245 my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns);
1246 my $padding = '';
Fred Drakee463f8e2000-11-30 07:17:27 +00001247 if ($c1align =~ /align="right"/ || $c1 eq '') {
Fred Drakee15956b2000-04-03 04:51:13 +00001248 $padding = '&nbsp;';
Fred Drakea0f4c941998-07-24 22:16:04 +00001249 }
Fred Drakee15956b2000-04-03 04:51:13 +00001250 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001251 . " $c2align$c2</td>\n"
1252 . " $c3align$c3</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001253 . " $c4align$c4</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001254 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001255}
1256
Fred Drake3be20742000-08-31 06:22:54 +00001257
1258# These can be used to control the title page appearance;
1259# they need a little bit of documentation.
1260#
1261# If $TITLE_PAGE_GRAPHIC is set, it should be the name of a file in the
1262# $ICONSERVER directory, or include path information (other than "./"). The
1263# default image type will be assumed if an extension is not provided.
1264#
1265# If specified, the "title page" will contain two colums: one containing the
1266# title/author/etc., and the other containing the graphic. Use the other
1267# four variables listed here to control specific details of the layout; all
1268# are optional.
1269#
1270# $TITLE_PAGE_GRAPHIC = "my-company-logo";
1271# $TITLE_PAGE_GRAPHIC_COLWIDTH = "30%";
1272# $TITLE_PAGE_GRAPHIC_WIDTH = 150;
1273# $TITLE_PAGE_GRAPHIC_HEIGHT = 150;
1274# $TITLE_PAGE_GRAPHIC_ON_RIGHT = 0;
1275
1276sub make_my_titlepage() {
1277 my $the_title = "";
Fred Drake6659c301998-03-03 22:02:19 +00001278 if ($t_title) {
Fred Drake90fdda51999-02-16 20:27:42 +00001279 $the_title .= "\n<h1>$t_title</h1>";
Fred Drake3be20742000-08-31 06:22:54 +00001280 }
1281 else {
1282 write_warnings("\nThis document has no title.");
1283 }
Fred Drake6659c301998-03-03 22:02:19 +00001284 if ($t_author) {
1285 if ($t_authorURL) {
Fred Drake08932051998-04-17 02:15:42 +00001286 my $href = translate_commands($t_authorURL);
Fred Drake2d1f81e1999-02-09 16:03:31 +00001287 $href = make_named_href('author', $href,
1288 "<b><font size='+2'>$t_author</font></b>");
Fred Drakec9a44381998-03-17 06:29:13 +00001289 $the_title .= "\n<p>$href</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001290 }
1291 else {
Fred Drake2d1f81e1999-02-09 16:03:31 +00001292 $the_title .= ("\n<p><b><font size='+2'>$t_author</font></b></p>");
Fred Drake6659c301998-03-03 22:02:19 +00001293 }
Fred Drake3be20742000-08-31 06:22:54 +00001294 }
1295 else {
1296 write_warnings("\nThere is no author for this document.");
1297 }
Fred Drake6659c301998-03-03 22:02:19 +00001298 if ($t_institute) {
Fred Drake3be20742000-08-31 06:22:54 +00001299 $the_title .= "\n<p>$t_institute</p>";
1300 }
Fred Draked07868a1998-05-14 21:00:28 +00001301 if ($DEVELOPER_ADDRESS) {
Fred Drake3be20742000-08-31 06:22:54 +00001302 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";
1303 }
Fred Drake6659c301998-03-03 22:02:19 +00001304 if ($t_affil) {
Fred Drake3be20742000-08-31 06:22:54 +00001305 $the_title .= "\n<p><i>$t_affil</i></p>";
1306 }
Fred Drake6659c301998-03-03 22:02:19 +00001307 if ($t_date) {
Fred Drakede77bc52000-12-14 18:36:12 +00001308 $the_title .= "\n<p>";
Fred Draked04592a2000-10-25 16:15:13 +00001309 if ($PACKAGE_VERSION) {
Fred Drakede77bc52000-12-14 18:36:12 +00001310 $the_title .= "<strong>Release $PACKAGE_VERSION</strong><br>\n";
Fred Drake3be20742000-08-31 06:22:54 +00001311 }
Fred Drakede77bc52000-12-14 18:36:12 +00001312 $the_title .= "<strong>$t_date</strong></p>"
Fred Drake6659c301998-03-03 22:02:19 +00001313 }
1314 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +00001315 $the_title .= "\n<p>$t_address</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001316 }
1317 else {
1318 $the_title .= "\n<p>";
1319 }
Fred Drake6659c301998-03-03 22:02:19 +00001320 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +00001321 $the_title .= "\n<p>$t_email</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001322 }
1323 return $the_title;
1324}
1325
Fred Drake3be20742000-08-31 06:22:54 +00001326sub make_my_titlegraphic() {
Fred Drake7a40c072000-10-02 14:43:38 +00001327 my $filename = make_icon_filename($TITLE_PAGE_GRAPHIC);
Fred Drake3be20742000-08-31 06:22:54 +00001328 my $graphic = "<td class=\"titlegraphic\"";
1329 $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_COLWIDTH\""
1330 if ($TITLE_PAGE_GRAPHIC_COLWIDTH);
1331 $graphic .= "><img";
1332 $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_WIDTH\""
1333 if ($TITLE_PAGE_GRAPHIC_WIDTH);
1334 $graphic .= " height=\"$TITLE_PAGE_GRAPHIC_HEIGHT\""
1335 if ($TITLE_PAGE_GRAPHIC_HEIGHT);
Fred Drake5f84c9b2000-10-03 06:05:25 +00001336 $graphic .= "\n src=\"$filename\"></td>\n";
Fred Drake3be20742000-08-31 06:22:54 +00001337 return $graphic;
1338}
1339
1340sub do_cmd_maketitle {
1341 local($_) = @_;
1342 my $the_title = "\n<div class=\"titlepage\">";
1343 if ($TITLE_PAGE_GRAPHIC) {
1344 if ($TITLE_PAGE_GRAPHIC_ON_RIGHT) {
1345 $the_title .= ("\n<table border=\"0\" width=\"100%\">"
1346 . "<tr align=\"right\">\n<td>"
1347 . make_my_titlepage()
1348 . "</td>\n"
1349 . make_my_titlegraphic()
1350 . "</tr>\n</table>");
1351 }
1352 else {
1353 $the_title .= ("\n<table border=\"0\" width=\"100%\"><tr>\n"
1354 . make_my_titlegraphic()
1355 . "<td>"
1356 . make_my_titlepage()
1357 . "</td></tr>\n</table>");
1358 }
1359 }
1360 else {
1361 $the_title .= ("\n<center>"
1362 . make_my_titlepage()
1363 . "\n</center>");
1364 }
1365 $the_title .= "\n</div>";
1366 return $the_title . $_;
Fred Drake90fdda51999-02-16 20:27:42 +00001367 $the_title .= "\n</center></div>";
Fred Drake62e43691998-08-10 19:40:44 +00001368 return $the_title . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +00001369}
1370
1371
Fred Drake885215c1998-05-20 21:32:09 +00001372#
Fred Drakea0f4c941998-07-24 22:16:04 +00001373# Module synopsis support
1374#
1375
1376require SynopsisTable;
1377
Fred Drakef7685d71998-07-25 03:31:46 +00001378sub get_chapter_id(){
1379 my $id = do_cmd_thechapter('');
Fred Drake45f26011998-08-04 22:07:18 +00001380 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
1381 $id =~ s/\.//;
Fred Drakef7685d71998-07-25 03:31:46 +00001382 return $id;
Fred Drakea0f4c941998-07-24 22:16:04 +00001383}
1384
Fred Drake643d76d2000-09-09 06:07:37 +00001385# 'chapter' => 'SynopsisTable instance'
1386%ModuleSynopses = ();
Fred Drakef7685d71998-07-25 03:31:46 +00001387
1388sub get_synopsis_table($){
1389 my($chap) = @_;
Fred Drakef7685d71998-07-25 03:31:46 +00001390 my $key;
1391 foreach $key (keys %ModuleSynopses) {
1392 if ($key eq $chap) {
1393 return $ModuleSynopses{$chap};
1394 }
Fred Drakea0f4c941998-07-24 22:16:04 +00001395 }
Fred Drake643d76d2000-09-09 06:07:37 +00001396 my $st = SynopsisTable->new();
Fred Drakef7685d71998-07-25 03:31:46 +00001397 $ModuleSynopses{$chap} = $st;
Fred Drakea0f4c941998-07-24 22:16:04 +00001398 return $st;
1399}
1400
Fred Drake62e43691998-08-10 19:40:44 +00001401sub do_cmd_moduleauthor{
1402 local($_) = @_;
1403 next_argument();
1404 next_argument();
1405 return $_;
1406}
1407
1408sub do_cmd_sectionauthor{
1409 local($_) = @_;
1410 next_argument();
1411 next_argument();
1412 return $_;
1413}
1414
Fred Drakea0f4c941998-07-24 22:16:04 +00001415sub do_cmd_declaremodule{
1416 local($_) = @_;
1417 my $key = next_optional_argument();
1418 my $type = next_argument();
1419 my $name = next_argument();
1420 my $st = get_synopsis_table(get_chapter_id());
1421 #
1422 $key = $name unless $key;
1423 $type = 'built-in' if $type eq 'builtin';
1424 $st->declare($name, $key, $type);
1425 define_module($type, $name);
Fred Drake62e43691998-08-10 19:40:44 +00001426 return anchor_label("module-$key",$CURRENT_FILE,$_)
Fred Drakea0f4c941998-07-24 22:16:04 +00001427}
1428
1429sub do_cmd_modulesynopsis{
1430 local($_) = @_;
1431 my $st = get_synopsis_table(get_chapter_id());
Fred Drake1cc58991999-04-13 22:08:59 +00001432 $st->set_synopsis($THIS_MODULE, translate_commands(next_argument()));
Fred Drake62e43691998-08-10 19:40:44 +00001433 return $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001434}
1435
1436sub do_cmd_localmoduletable{
1437 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001438 my $chap = get_chapter_id();
Fred Drake643d76d2000-09-09 06:07:37 +00001439 my $st = get_synopsis_table($chap);
1440 $st->set_file("$CURRENT_FILE");
Fred Drake557460c1999-03-02 16:05:35 +00001441 return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001442}
1443
1444sub process_all_localmoduletables{
Fred Drake643d76d2000-09-09 06:07:37 +00001445 my $key;
1446 my $st, $file;
1447 foreach $key (keys %ModuleSynopses) {
1448 $st = $ModuleSynopses{$key};
1449 $file = $st->get_file();
1450 if ($file) {
1451 process_localmoduletables_in_file($file);
1452 }
1453 else {
1454 print "\nsynopsis table $key has no file association";
1455 }
1456 }
1457}
1458
1459sub process_localmoduletables_in_file{
1460 my $file = @_[0];
1461 open(MYFILE, "<$file");
1462 local($_);
1463 sysread(MYFILE, $_, 1024*1024);
1464 close(MYFILE);
1465 # need to get contents of file in $_
Fred Drake557460c1999-03-02 16:05:35 +00001466 while (/<tex2html-localmoduletable><(\d+)>/) {
Fred Drakef7685d71998-07-25 03:31:46 +00001467 my $match = $&;
Fred Drakea0f4c941998-07-24 22:16:04 +00001468 my $chap = $1;
1469 my $st = get_synopsis_table($chap);
1470 my $data = $st->tohtml();
Fred Drakef7685d71998-07-25 03:31:46 +00001471 s/$match/$data/;
Fred Drakea0f4c941998-07-24 22:16:04 +00001472 }
Fred Drake643d76d2000-09-09 06:07:37 +00001473 open(MYFILE,">$file");
1474 print MYFILE $_;
1475 close(MYFILE);
Fred Drakea0f4c941998-07-24 22:16:04 +00001476}
Fred Drake557460c1999-03-02 16:05:35 +00001477sub process_python_state{
1478 process_all_localmoduletables();
Fred Drake557460c1999-03-02 16:05:35 +00001479}
Fred Drakea0f4c941998-07-24 22:16:04 +00001480
1481
1482#
1483# "See also:" -- references placed at the end of a \section
1484#
1485
1486sub do_env_seealso{
Fred Drakee15956b2000-04-03 04:51:13 +00001487 return "<div class='seealso'>\n "
1488 . "<p class='heading'><b>See Also:</b></p>\n"
Fred Drake90fdda51999-02-16 20:27:42 +00001489 . @_[0]
1490 . '</div>';
Fred Drakea0f4c941998-07-24 22:16:04 +00001491}
1492
1493sub do_cmd_seemodule{
1494 # Insert the right magic to jump to the module definition. This should
1495 # work most of the time, at least for repeat builds....
1496 local($_) = @_;
1497 my $key = next_optional_argument();
1498 my $module = next_argument();
1499 my $text = next_argument();
Fred Drake84bd6f31999-05-11 15:42:51 +00001500 my $period = '.';
Fred Drakea0f4c941998-07-24 22:16:04 +00001501 $key = $module
1502 unless $key;
Fred Drake84bd6f31999-05-11 15:42:51 +00001503 if ($text =~ /\.$/) {
1504 $period = '';
1505 }
Fred Drakee15956b2000-04-03 04:51:13 +00001506 return '<dl compact class="seemodule">'
1507 . "\n <dt>Module <b><tt class='module'><a href='module-$key.html'>"
Fred Drake84bd6f31999-05-11 15:42:51 +00001508 . "$module</a></tt>:</b>"
1509 . "\n <dd>$text$period\n </dl>"
Fred Drake90fdda51999-02-16 20:27:42 +00001510 . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001511}
1512
Fred Drakee0197bf2001-04-12 04:03:22 +00001513sub strip_html_markup($){
1514 my $str = @_[0];
1515 my $s = "$str";
1516 $s =~ s/<[a-zA-Z0-9]+(\s+[a-zA-Z0-9]+(\s*=\s*(\'[^\']*\'|\"[^\"]*\"|[a-zA-Z0-9]+))?)*\s*>//g;
1517 $s =~ s/<\/[a-zA-Z0-9]+>//g;
1518 return $s;
1519}
1520
Fred Drake643d76d2000-09-09 06:07:37 +00001521sub handle_rfclike_reference{
Fred Drakeafc7ce12001-01-22 17:33:24 +00001522 local($_, $what, $format) = @_;
Fred Drake37cc0c02000-04-26 18:05:24 +00001523 my $rfcnum = next_argument();
1524 my $title = next_argument();
1525 my $text = next_argument();
Fred Drakeafc7ce12001-01-22 17:33:24 +00001526 my $url = get_rfc_url($rfcnum, $format);
Fred Drake7a40c072000-10-02 14:43:38 +00001527 my $icon = get_link_icon($url);
Fred Drakee0197bf2001-04-12 04:03:22 +00001528 my $attrtitle = strip_html_markup($title);
Fred Drake37cc0c02000-04-26 18:05:24 +00001529 return '<dl compact class="seerfc">'
1530 . "\n <dt><a href=\"$url\""
Fred Drakee0197bf2001-04-12 04:03:22 +00001531 . "\n title=\"$attrtitle\""
Fred Drake5f84c9b2000-10-03 06:05:25 +00001532 . "\n >$what $rfcnum, <em>$title</em>$icon</a>"
Fred Drake37cc0c02000-04-26 18:05:24 +00001533 . "\n <dd>$text\n </dl>"
1534 . $_;
1535}
1536
Fred Drake643d76d2000-09-09 06:07:37 +00001537sub do_cmd_seepep{
Fred Drakeafc7ce12001-01-22 17:33:24 +00001538 return handle_rfclike_reference(@_[0], "PEP", $PEP_FORMAT);
Fred Drake643d76d2000-09-09 06:07:37 +00001539}
1540
1541sub do_cmd_seerfc{
Fred Drakeafc7ce12001-01-22 17:33:24 +00001542 return handle_rfclike_reference(@_[0], "RFC", $RFC_FORMAT);
Fred Drake643d76d2000-09-09 06:07:37 +00001543}
1544
Fred Drake48449982000-09-12 17:52:33 +00001545sub do_cmd_seetitle{
1546 local($_) = @_;
1547 my $url = next_optional_argument();
1548 my $title = next_argument();
1549 my $text = next_argument();
1550 if ($url) {
Fred Drake5f84c9b2000-10-03 06:05:25 +00001551 my $icon = get_link_icon($url);
Fred Drake48449982000-09-12 17:52:33 +00001552 return '<dl compact class="seetitle">'
1553 . "\n <dt><em class=\"citetitle\"><a href=\"$url\""
Fred Drake7a40c072000-10-02 14:43:38 +00001554 . "\n >$title$icon</a></em>"
Fred Drake48449982000-09-12 17:52:33 +00001555 . "\n <dd>$text\n </dl>"
1556 . $_;
1557 }
1558 return '<dl compact class="seetitle">'
1559 . "\n <dt><em class=\"citetitle\""
1560 . "\n >$title</em>"
1561 . "\n <dd>$text\n </dl>"
1562 . $_;
1563}
1564
Fred Drakeef4d1112000-05-09 16:17:51 +00001565sub do_cmd_seeurl{
1566 local($_) = @_;
1567 my $url = next_argument();
1568 my $text = next_argument();
Fred Drake7a40c072000-10-02 14:43:38 +00001569 my $icon = get_link_icon($url);
Fred Drakeef4d1112000-05-09 16:17:51 +00001570 return '<dl compact class="seeurl">'
1571 . "\n <dt><a href=\"$url\""
Fred Drake7a40c072000-10-02 14:43:38 +00001572 . "\n class=\"url\">$url$icon</a>"
Fred Drakeef4d1112000-05-09 16:17:51 +00001573 . "\n <dd>$text\n </dl>"
1574 . $_;
1575}
1576
Fred Drakea0f4c941998-07-24 22:16:04 +00001577sub do_cmd_seetext{
Fred Drake79189b51999-04-28 13:54:30 +00001578 local($_) = @_;
1579 my $content = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +00001580 return '<div class="seetext"><p>' . $content . '</div>' . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001581}
1582
1583
1584#
Fred Drake885215c1998-05-20 21:32:09 +00001585# Definition list support.
1586#
1587
1588sub do_env_definitions{
Fred Drake37cc0c02000-04-26 18:05:24 +00001589 return "<dl class='definitions'>" . @_[0] . "</dl>\n";
Fred Drake885215c1998-05-20 21:32:09 +00001590}
1591
1592sub do_cmd_term{
1593 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001594 my $term = next_argument();
1595 my($name,$aname,$ahref) = new_link_info();
Fred Drake885215c1998-05-20 21:32:09 +00001596 # could easily add an index entry here...
Fred Drake62e43691998-08-10 19:40:44 +00001597 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
Fred Drake885215c1998-05-20 21:32:09 +00001598}
1599
1600
Fred Drake38178fd2000-09-22 17:05:04 +00001601# I don't recall exactly why this was needed, but it was very much needed.
1602# We'll see if anything breaks when I move the "code" line out -- some
1603# things broke with it in.
1604
1605#code # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001606process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_);
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001607declaremodule # [] # {} # {}
1608memberline # [] # {}
1609methodline # [] # {} # {}
1610modulesynopsis # {}
Fred Drake557460c1999-03-02 16:05:35 +00001611platform # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001612samp # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001613setindexsubitem # {}
Fred Drakef32834c1999-02-12 22:06:32 +00001614withsubitem # {} # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001615_RAW_ARG_DEFERRED_CMDS_
1616
1617
Fred Drake86333602001-04-10 17:13:39 +00001618$alltt_start = '<dl><dd><pre class="verbatim">';
1619$alltt_end = '</pre></dl>';
1620
1621sub do_env_alltt {
1622 local ($_) = @_;
1623 local($closures,$reopens,@open_block_tags);
1624
1625 # get the tag-strings for all open tags
1626 local(@keep_open_tags) = @$open_tags_R;
1627 ($closures,$reopens) = &preserve_open_tags() if (@$open_tags_R);
1628
1629 # get the tags for text-level tags only
1630 $open_tags_R = [ @keep_open_tags ];
1631 local($local_closures, $local_reopens);
1632 ($local_closures, $local_reopens,@open_block_tags)
1633 = &preserve_open_block_tags
1634 if (@$open_tags_R);
1635
1636 $open_tags_R = [ @open_block_tags ];
1637
1638 do {
1639 local($open_tags_R) = [ @open_block_tags ];
1640 local(@save_open_tags) = ();
1641
1642 local($cnt) = ++$global{'max_id'};
1643 $_ = join('',"$O$cnt$C\\tt$O", ++$global{'max_id'}, $C
1644 , $_ , $O, $global{'max_id'}, "$C$O$cnt$C");
1645
1646 $_ = &translate_environments($_);
1647 $_ = &translate_commands($_) if (/\\/);
1648
1649 # preserve space-runs, using &nbsp;
1650 while (s/(\S) ( +)/$1$2;SPMnbsp;/g){};
1651 s/(<BR>) /$1;SPMnbsp;/g;
1652
1653 $_ = join('', $closures, $alltt_start, $local_reopens
1654 , $_
1655 , &balance_tags() #, $local_closures
1656 , $alltt_end, $reopens);
1657 undef $open_tags_R; undef @save_open_tags;
1658 };
1659 $open_tags_R = [ @keep_open_tags ];
1660 $_;
1661}
1662
1663
Fred Drake6659c301998-03-03 22:02:19 +000016641; # This must be the last line