blob: 7b58d6a0de1ff5ef9fcb77d1baceb8c84a9430da [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
909sub do_env_excclassdesc{
910 return handle_classlike_descriptor(@_[0], "exception");
911}
912
Fred Drake42b31a51998-03-27 05:16:10 +0000913
914sub do_env_methoddesc{
915 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000916 my $class_name = next_optional_argument();
917 $class_name = $THIS_CLASS
918 unless $class_name;
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000919 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000920 my $arg_list = convert_args(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000921 my $extra = '';
922 if ($class_name) {
923 $extra = " ($class_name method)";
Fred Drake42b31a51998-03-27 05:16:10 +0000924 }
Fred Drakee15956b2000-04-03 04:51:13 +0000925 my $idx = make_str_index_entry("<tt class='method'>$method()</tt>$extra");
Fred Drake08932051998-04-17 02:15:42 +0000926 $idx =~ s/ \(.*\)//;
927 $idx =~ s/\(\)//;
Fred Drakec612a142001-03-29 18:24:08 +0000928 return "<dl><dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000929}
930
931
Fred Drake7d45f6d1999-01-05 14:39:27 +0000932sub do_cmd_methodline{
933 local($_) = @_;
934 my $class_name = next_optional_argument();
935 $class_name = $THIS_CLASS
936 unless $class_name;
937 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000938 my $arg_list = convert_args(next_argument());
Fred Drake7d45f6d1999-01-05 14:39:27 +0000939 my $extra = '';
940 if ($class_name) {
941 $extra = " ($class_name method)";
942 }
Fred Drakee15956b2000-04-03 04:51:13 +0000943 my $idx = make_str_index_entry("<tt class='method'>$method()</tt>$extra");
Fred Drake7d45f6d1999-01-05 14:39:27 +0000944 $idx =~ s/ \(.*\)//;
945 $idx =~ s/\(\)//;
Fred Drakec612a142001-03-29 18:24:08 +0000946 return "<dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000947 . $_;
948}
949
950
Fred Draked64a40d1998-09-10 18:59:13 +0000951sub do_cmd_methodlineni{
952 local($_) = @_;
953 next_optional_argument();
954 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000955 my $arg_list = convert_args(next_argument());
Fred Drakec612a142001-03-29 18:24:08 +0000956 return "<dt><b>$method</b>(<var>$arg_list</var>)\n<dd>"
Fred Draked64a40d1998-09-10 18:59:13 +0000957 . $_;
958}
959
Fred Drake42b31a51998-03-27 05:16:10 +0000960sub do_env_methoddescni{
961 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000962 next_optional_argument();
963 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000964 my $arg_list = convert_args(next_argument());
Fred Drakec612a142001-03-29 18:24:08 +0000965 return "<dl><dt><b>$method</b>(<var>$arg_list</var>)\n<dd>"
Fred Drake62e43691998-08-10 19:40:44 +0000966 . $_
967 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000968}
969
970
971sub do_env_memberdesc{
972 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000973 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000974 my $member = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000975 $class = $THIS_CLASS
976 unless $class;
Fred Drake08932051998-04-17 02:15:42 +0000977 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +0000978 $extra = " ($class attribute)"
979 if ($class ne '');
Fred Drakee15956b2000-04-03 04:51:13 +0000980 my $idx = make_str_index_entry("<tt class='member'>$member</tt>$extra");
Fred Drake42b31a51998-03-27 05:16:10 +0000981 $idx =~ s/ \(.*\)//;
982 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000983 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000984}
985
986
Fred Drake5ccf3301998-04-17 20:04:09 +0000987sub do_cmd_memberline{
988 local($_) = @_;
989 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000990 my $member = next_argument();
Fred Drake5ccf3301998-04-17 20:04:09 +0000991 $class = $THIS_CLASS
992 unless $class;
993 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +0000994 $extra = " ($class attribute)"
995 if ($class ne '');
Fred Drakee15956b2000-04-03 04:51:13 +0000996 my $idx = make_str_index_entry("<tt class='member'>$member</tt>$extra");
Fred Drake5ccf3301998-04-17 20:04:09 +0000997 $idx =~ s/ \(.*\)//;
998 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000999 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +00001000}
1001
Fred Drake42b31a51998-03-27 05:16:10 +00001002sub do_env_memberdescni{
1003 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001004 next_optional_argument();
1005 my $member = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +00001006 return "<dl><dt><b><tt class='member'>$member</tt></b>\n<dd>"
1007 . $_
1008 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +00001009}
1010
1011
Fred Drake5ccf3301998-04-17 20:04:09 +00001012sub do_cmd_memberlineni{
1013 local($_) = @_;
1014 next_optional_argument();
1015 my $member = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +00001016 return "<dt><b><tt class='member'>$member</tt></b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +00001017}
1018
Fred Drakee15956b2000-04-03 04:51:13 +00001019@col_aligns = ('<td>', '<td>', '<td>', '<td>');
Fred Drake6659c301998-03-03 22:02:19 +00001020
Fred Drakef74e5b71999-04-28 14:58:49 +00001021sub fix_font{
1022 # do a little magic on a font name to get the right behavior in the first
1023 # column of the output table
1024 my $font = @_[0];
1025 if ($font eq 'textrm') {
1026 $font = '';
1027 }
1028 elsif ($font eq 'file' || $font eq 'filenq') {
Fred Drakee15956b2000-04-03 04:51:13 +00001029 $font = 'tt class="file"';
1030 }
1031 elsif ($font eq 'member') {
1032 $font = 'tt class="member"';
Fred Drakef74e5b71999-04-28 14:58:49 +00001033 }
Fred Drakee463f8e2000-11-30 07:17:27 +00001034 elsif ($font eq 'class') {
1035 $font = 'tt class="class"';
1036 }
Fred Drake7388f732000-06-28 21:06:08 +00001037 elsif ($font eq 'constant') {
1038 $font = 'tt class="constant"';
1039 }
Fred Drakecb0fc9c2000-08-09 13:45:04 +00001040 elsif ($font eq 'kbd') {
1041 $font = 'kbd';
1042 }
Fred Draked04592a2000-10-25 16:15:13 +00001043 elsif ($font eq 'programopt') {
1044 $font = 'b';
1045 }
Fred Drakeafc7ce12001-01-22 17:33:24 +00001046 elsif ($font eq 'exception') {
1047 $font = 'tt class="exception"';
1048 }
Fred Drakef74e5b71999-04-28 14:58:49 +00001049 return $font;
1050}
1051
Fred Drakee15956b2000-04-03 04:51:13 +00001052sub figure_column_alignment{
1053 my $a = @_[0];
1054 my $mark = substr($a, 0, 1);
1055 my $r = '';
1056 if ($mark eq 'c')
1057 { $r = ' align="center"'; }
1058 elsif ($mark eq 'r')
1059 { $r = ' align="right"'; }
1060 elsif ($mark eq 'l')
1061 { $r = ' align="left"'; }
1062 elsif ($mark eq 'p')
1063 { $r = ' align="left"'; }
1064 return $r;
1065}
1066
Fred Drake6659c301998-03-03 22:02:19 +00001067sub setup_column_alignments{
1068 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001069 my($s1,$s2,$s3,$s4) = split(/[|]/,$_);
1070 my $a1 = figure_column_alignment($s1);
1071 my $a2 = figure_column_alignment($s2);
1072 my $a3 = figure_column_alignment($s3);
1073 my $a4 = figure_column_alignment($s4);
1074 $col_aligns[0] = "<td$a1 valign=\"baseline\">";
1075 $col_aligns[1] = "<td$a2>";
1076 $col_aligns[2] = "<td$a3>";
1077 $col_aligns[3] = "<td$a4>";
Fred Drake79189b51999-04-28 13:54:30 +00001078 # return the aligned header start tags
Fred Drakee15956b2000-04-03 04:51:13 +00001079 return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>");
1080}
1081
1082sub get_table_col1_fonts{
1083 my $font = $globals{'lineifont'};
1084 my ($sfont,$efont) = ('', '');
1085 if ($font) {
1086 $sfont = "<$font>";
1087 $efont = "</$font>";
1088 $efont =~ s/ .*>/>/;
1089 }
Fred Drakee463f8e2000-11-30 07:17:27 +00001090 return ($sfont, $efont);
Fred Drake6659c301998-03-03 22:02:19 +00001091}
1092
1093sub do_env_tableii{
1094 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001095 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001096 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001097 my $h1 = next_argument();
1098 my $h2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001099 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001100 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001101 my $a1 = $col_aligns[0];
1102 my $a2 = $col_aligns[1];
1103 s/\\lineii</\\lineii[$a1|$a2]</g;
1104 return '<table border align="center" style="border-collapse: collapse">'
Fred Drake351960d2000-10-26 20:14:58 +00001105 . "\n <thead>"
1106 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001107 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1108 . "\n $th2<b>$h2</b>\&nbsp;</th>"
Fred Drake351960d2000-10-26 20:14:58 +00001109 . "\n </tr>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001110 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001111 . "\n <tbody valign='baseline'>"
Fred Drake351960d2000-10-26 20:14:58 +00001112 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001113 . "\n </tbody>"
1114 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001115}
1116
Fred Drakeda72b932000-09-21 15:58:02 +00001117sub do_env_longtableii{
1118 return do_env_tableii(@_);
1119}
1120
Fred Drake6659c301998-03-03 22:02:19 +00001121sub do_cmd_lineii{
1122 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001123 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001124 my $c1 = next_argument();
1125 my $c2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001126 s/[\s\n]+//;
Fred Drakee463f8e2000-11-30 07:17:27 +00001127 my($sfont,$efont) = get_table_col1_fonts();
Fred Drakee15956b2000-04-03 04:51:13 +00001128 $c2 = '&nbsp;' if ($c2 eq '');
1129 my($c1align,$c2align) = split('\|', $aligns);
1130 my $padding = '';
Fred Drakee463f8e2000-11-30 07:17:27 +00001131 if ($c1align =~ /align="right"/ || $c1 eq '') {
Fred Drakee15956b2000-04-03 04:51:13 +00001132 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001133 }
Fred Drakee15956b2000-04-03 04:51:13 +00001134 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
1135 . " $c2align$c2</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001136 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001137}
1138
1139sub do_env_tableiii{
1140 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001141 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001142 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001143 my $h1 = next_argument();
1144 my $h2 = next_argument();
1145 my $h3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001146 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001147 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001148 my $a1 = $col_aligns[0];
1149 my $a2 = $col_aligns[1];
1150 my $a3 = $col_aligns[2];
1151 s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g;
1152 return '<table border align="center" style="border-collapse: collapse">'
Fred Drake351960d2000-10-26 20:14:58 +00001153 . "\n <thead>"
1154 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001155 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1156 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1157 . "\n $th3<b>$h3</b>\&nbsp;</th>"
Fred Drake351960d2000-10-26 20:14:58 +00001158 . "\n </tr>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001159 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001160 . "\n <tbody valign='baseline'>"
Fred Drake62e43691998-08-10 19:40:44 +00001161 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001162 . "\n </tbody>"
1163 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001164}
1165
Fred Drakeda72b932000-09-21 15:58:02 +00001166sub do_env_longtableiii{
1167 return do_env_tableiii(@_);
1168}
1169
Fred Drake6659c301998-03-03 22:02:19 +00001170sub do_cmd_lineiii{
1171 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001172 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001173 my $c1 = next_argument();
1174 my $c2 = next_argument();
1175 my $c3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001176 s/[\s\n]+//;
Fred Drakee463f8e2000-11-30 07:17:27 +00001177 my($sfont,$efont) = get_table_col1_fonts();
Fred Drakee15956b2000-04-03 04:51:13 +00001178 $c3 = '&nbsp;' if ($c3 eq '');
1179 my($c1align,$c2align,$c3align) = split('\|', $aligns);
1180 my $padding = '';
Fred Drakee463f8e2000-11-30 07:17:27 +00001181 if ($c1align =~ /align="right"/ || $c1 eq '') {
Fred Drakee15956b2000-04-03 04:51:13 +00001182 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001183 }
Fred Drakee15956b2000-04-03 04:51:13 +00001184 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001185 . " $c2align$c2</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001186 . " $c3align$c3</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001187 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001188}
1189
Fred Drakea0f4c941998-07-24 22:16:04 +00001190sub do_env_tableiv{
1191 local($_) = @_;
1192 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001193 my $font = fix_font(next_argument());
Fred Drakea0f4c941998-07-24 22:16:04 +00001194 my $h1 = next_argument();
1195 my $h2 = next_argument();
1196 my $h3 = next_argument();
1197 my $h4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001198 s/[\s\n]+//;
Fred Drakea0f4c941998-07-24 22:16:04 +00001199 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001200 my $a1 = $col_aligns[0];
1201 my $a2 = $col_aligns[1];
1202 my $a3 = $col_aligns[2];
1203 my $a4 = $col_aligns[3];
1204 s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g;
1205 return '<table border align="center" style="border-collapse: collapse">'
Fred Drake351960d2000-10-26 20:14:58 +00001206 . "\n <thead>"
1207 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001208 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1209 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1210 . "\n $th3<b>$h3</b>\&nbsp;</th>"
1211 . "\n $th4<b>$h4</b>\&nbsp;</th>"
Fred Drake351960d2000-10-26 20:14:58 +00001212 . "\n </tr>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001213 . "\n </thead>"
Fred Drakee15956b2000-04-03 04:51:13 +00001214 . "\n <tbody valign='baseline'>"
Fred Drake62e43691998-08-10 19:40:44 +00001215 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001216 . "\n </tbody>"
1217 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001218}
1219
Fred Drakeda72b932000-09-21 15:58:02 +00001220sub do_env_longtableiv{
1221 return do_env_tableiv(@_);
1222}
1223
Fred Drakea0f4c941998-07-24 22:16:04 +00001224sub do_cmd_lineiv{
Fred Drake6659c301998-03-03 22:02:19 +00001225 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001226 my $aligns = next_optional_argument();
Fred Drakea0f4c941998-07-24 22:16:04 +00001227 my $c1 = next_argument();
1228 my $c2 = next_argument();
1229 my $c3 = next_argument();
1230 my $c4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001231 s/[\s\n]+//;
Fred Drakee463f8e2000-11-30 07:17:27 +00001232 my($sfont,$efont) = get_table_col1_fonts();
Fred Drakee15956b2000-04-03 04:51:13 +00001233 $c4 = '&nbsp;' if ($c4 eq '');
1234 my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns);
1235 my $padding = '';
Fred Drakee463f8e2000-11-30 07:17:27 +00001236 if ($c1align =~ /align="right"/ || $c1 eq '') {
Fred Drakee15956b2000-04-03 04:51:13 +00001237 $padding = '&nbsp;';
Fred Drakea0f4c941998-07-24 22:16:04 +00001238 }
Fred Drakee15956b2000-04-03 04:51:13 +00001239 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001240 . " $c2align$c2</td>\n"
1241 . " $c3align$c3</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001242 . " $c4align$c4</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001243 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001244}
1245
Fred Drake3be20742000-08-31 06:22:54 +00001246
1247# These can be used to control the title page appearance;
1248# they need a little bit of documentation.
1249#
1250# If $TITLE_PAGE_GRAPHIC is set, it should be the name of a file in the
1251# $ICONSERVER directory, or include path information (other than "./"). The
1252# default image type will be assumed if an extension is not provided.
1253#
1254# If specified, the "title page" will contain two colums: one containing the
1255# title/author/etc., and the other containing the graphic. Use the other
1256# four variables listed here to control specific details of the layout; all
1257# are optional.
1258#
1259# $TITLE_PAGE_GRAPHIC = "my-company-logo";
1260# $TITLE_PAGE_GRAPHIC_COLWIDTH = "30%";
1261# $TITLE_PAGE_GRAPHIC_WIDTH = 150;
1262# $TITLE_PAGE_GRAPHIC_HEIGHT = 150;
1263# $TITLE_PAGE_GRAPHIC_ON_RIGHT = 0;
1264
1265sub make_my_titlepage() {
1266 my $the_title = "";
Fred Drake6659c301998-03-03 22:02:19 +00001267 if ($t_title) {
Fred Drake90fdda51999-02-16 20:27:42 +00001268 $the_title .= "\n<h1>$t_title</h1>";
Fred Drake3be20742000-08-31 06:22:54 +00001269 }
1270 else {
1271 write_warnings("\nThis document has no title.");
1272 }
Fred Drake6659c301998-03-03 22:02:19 +00001273 if ($t_author) {
1274 if ($t_authorURL) {
Fred Drake08932051998-04-17 02:15:42 +00001275 my $href = translate_commands($t_authorURL);
Fred Drake2d1f81e1999-02-09 16:03:31 +00001276 $href = make_named_href('author', $href,
1277 "<b><font size='+2'>$t_author</font></b>");
Fred Drakec9a44381998-03-17 06:29:13 +00001278 $the_title .= "\n<p>$href</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001279 }
1280 else {
Fred Drake2d1f81e1999-02-09 16:03:31 +00001281 $the_title .= ("\n<p><b><font size='+2'>$t_author</font></b></p>");
Fred Drake6659c301998-03-03 22:02:19 +00001282 }
Fred Drake3be20742000-08-31 06:22:54 +00001283 }
1284 else {
1285 write_warnings("\nThere is no author for this document.");
1286 }
Fred Drake6659c301998-03-03 22:02:19 +00001287 if ($t_institute) {
Fred Drake3be20742000-08-31 06:22:54 +00001288 $the_title .= "\n<p>$t_institute</p>";
1289 }
Fred Draked07868a1998-05-14 21:00:28 +00001290 if ($DEVELOPER_ADDRESS) {
Fred Drake3be20742000-08-31 06:22:54 +00001291 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";
1292 }
Fred Drake6659c301998-03-03 22:02:19 +00001293 if ($t_affil) {
Fred Drake3be20742000-08-31 06:22:54 +00001294 $the_title .= "\n<p><i>$t_affil</i></p>";
1295 }
Fred Drake6659c301998-03-03 22:02:19 +00001296 if ($t_date) {
Fred Drakede77bc52000-12-14 18:36:12 +00001297 $the_title .= "\n<p>";
Fred Draked04592a2000-10-25 16:15:13 +00001298 if ($PACKAGE_VERSION) {
Fred Drakede77bc52000-12-14 18:36:12 +00001299 $the_title .= "<strong>Release $PACKAGE_VERSION</strong><br>\n";
Fred Drake3be20742000-08-31 06:22:54 +00001300 }
Fred Drakede77bc52000-12-14 18:36:12 +00001301 $the_title .= "<strong>$t_date</strong></p>"
Fred Drake6659c301998-03-03 22:02:19 +00001302 }
1303 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +00001304 $the_title .= "\n<p>$t_address</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001305 }
1306 else {
1307 $the_title .= "\n<p>";
1308 }
Fred Drake6659c301998-03-03 22:02:19 +00001309 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +00001310 $the_title .= "\n<p>$t_email</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001311 }
1312 return $the_title;
1313}
1314
Fred Drake3be20742000-08-31 06:22:54 +00001315sub make_my_titlegraphic() {
Fred Drake7a40c072000-10-02 14:43:38 +00001316 my $filename = make_icon_filename($TITLE_PAGE_GRAPHIC);
Fred Drake3be20742000-08-31 06:22:54 +00001317 my $graphic = "<td class=\"titlegraphic\"";
1318 $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_COLWIDTH\""
1319 if ($TITLE_PAGE_GRAPHIC_COLWIDTH);
1320 $graphic .= "><img";
1321 $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_WIDTH\""
1322 if ($TITLE_PAGE_GRAPHIC_WIDTH);
1323 $graphic .= " height=\"$TITLE_PAGE_GRAPHIC_HEIGHT\""
1324 if ($TITLE_PAGE_GRAPHIC_HEIGHT);
Fred Drake5f84c9b2000-10-03 06:05:25 +00001325 $graphic .= "\n src=\"$filename\"></td>\n";
Fred Drake3be20742000-08-31 06:22:54 +00001326 return $graphic;
1327}
1328
1329sub do_cmd_maketitle {
1330 local($_) = @_;
1331 my $the_title = "\n<div class=\"titlepage\">";
1332 if ($TITLE_PAGE_GRAPHIC) {
1333 if ($TITLE_PAGE_GRAPHIC_ON_RIGHT) {
1334 $the_title .= ("\n<table border=\"0\" width=\"100%\">"
1335 . "<tr align=\"right\">\n<td>"
1336 . make_my_titlepage()
1337 . "</td>\n"
1338 . make_my_titlegraphic()
1339 . "</tr>\n</table>");
1340 }
1341 else {
1342 $the_title .= ("\n<table border=\"0\" width=\"100%\"><tr>\n"
1343 . make_my_titlegraphic()
1344 . "<td>"
1345 . make_my_titlepage()
1346 . "</td></tr>\n</table>");
1347 }
1348 }
1349 else {
1350 $the_title .= ("\n<center>"
1351 . make_my_titlepage()
1352 . "\n</center>");
1353 }
1354 $the_title .= "\n</div>";
1355 return $the_title . $_;
Fred Drake90fdda51999-02-16 20:27:42 +00001356 $the_title .= "\n</center></div>";
Fred Drake62e43691998-08-10 19:40:44 +00001357 return $the_title . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +00001358}
1359
1360
Fred Drake885215c1998-05-20 21:32:09 +00001361#
Fred Drakea0f4c941998-07-24 22:16:04 +00001362# Module synopsis support
1363#
1364
1365require SynopsisTable;
1366
Fred Drakef7685d71998-07-25 03:31:46 +00001367sub get_chapter_id(){
1368 my $id = do_cmd_thechapter('');
Fred Drake45f26011998-08-04 22:07:18 +00001369 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
1370 $id =~ s/\.//;
Fred Drakef7685d71998-07-25 03:31:46 +00001371 return $id;
Fred Drakea0f4c941998-07-24 22:16:04 +00001372}
1373
Fred Drake643d76d2000-09-09 06:07:37 +00001374# 'chapter' => 'SynopsisTable instance'
1375%ModuleSynopses = ();
Fred Drakef7685d71998-07-25 03:31:46 +00001376
1377sub get_synopsis_table($){
1378 my($chap) = @_;
Fred Drakef7685d71998-07-25 03:31:46 +00001379 my $key;
1380 foreach $key (keys %ModuleSynopses) {
1381 if ($key eq $chap) {
1382 return $ModuleSynopses{$chap};
1383 }
Fred Drakea0f4c941998-07-24 22:16:04 +00001384 }
Fred Drake643d76d2000-09-09 06:07:37 +00001385 my $st = SynopsisTable->new();
Fred Drakef7685d71998-07-25 03:31:46 +00001386 $ModuleSynopses{$chap} = $st;
Fred Drakea0f4c941998-07-24 22:16:04 +00001387 return $st;
1388}
1389
Fred Drake62e43691998-08-10 19:40:44 +00001390sub do_cmd_moduleauthor{
1391 local($_) = @_;
1392 next_argument();
1393 next_argument();
1394 return $_;
1395}
1396
1397sub do_cmd_sectionauthor{
1398 local($_) = @_;
1399 next_argument();
1400 next_argument();
1401 return $_;
1402}
1403
Fred Drakea0f4c941998-07-24 22:16:04 +00001404sub do_cmd_declaremodule{
1405 local($_) = @_;
1406 my $key = next_optional_argument();
1407 my $type = next_argument();
1408 my $name = next_argument();
1409 my $st = get_synopsis_table(get_chapter_id());
1410 #
1411 $key = $name unless $key;
1412 $type = 'built-in' if $type eq 'builtin';
1413 $st->declare($name, $key, $type);
1414 define_module($type, $name);
Fred Drake62e43691998-08-10 19:40:44 +00001415 return anchor_label("module-$key",$CURRENT_FILE,$_)
Fred Drakea0f4c941998-07-24 22:16:04 +00001416}
1417
1418sub do_cmd_modulesynopsis{
1419 local($_) = @_;
1420 my $st = get_synopsis_table(get_chapter_id());
Fred Drake1cc58991999-04-13 22:08:59 +00001421 $st->set_synopsis($THIS_MODULE, translate_commands(next_argument()));
Fred Drake62e43691998-08-10 19:40:44 +00001422 return $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001423}
1424
1425sub do_cmd_localmoduletable{
1426 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001427 my $chap = get_chapter_id();
Fred Drake643d76d2000-09-09 06:07:37 +00001428 my $st = get_synopsis_table($chap);
1429 $st->set_file("$CURRENT_FILE");
Fred Drake557460c1999-03-02 16:05:35 +00001430 return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001431}
1432
1433sub process_all_localmoduletables{
Fred Drake643d76d2000-09-09 06:07:37 +00001434 my $key;
1435 my $st, $file;
1436 foreach $key (keys %ModuleSynopses) {
1437 $st = $ModuleSynopses{$key};
1438 $file = $st->get_file();
1439 if ($file) {
1440 process_localmoduletables_in_file($file);
1441 }
1442 else {
1443 print "\nsynopsis table $key has no file association";
1444 }
1445 }
1446}
1447
1448sub process_localmoduletables_in_file{
1449 my $file = @_[0];
1450 open(MYFILE, "<$file");
1451 local($_);
1452 sysread(MYFILE, $_, 1024*1024);
1453 close(MYFILE);
1454 # need to get contents of file in $_
Fred Drake557460c1999-03-02 16:05:35 +00001455 while (/<tex2html-localmoduletable><(\d+)>/) {
Fred Drakef7685d71998-07-25 03:31:46 +00001456 my $match = $&;
Fred Drakea0f4c941998-07-24 22:16:04 +00001457 my $chap = $1;
1458 my $st = get_synopsis_table($chap);
1459 my $data = $st->tohtml();
Fred Drakef7685d71998-07-25 03:31:46 +00001460 s/$match/$data/;
Fred Drakea0f4c941998-07-24 22:16:04 +00001461 }
Fred Drake643d76d2000-09-09 06:07:37 +00001462 open(MYFILE,">$file");
1463 print MYFILE $_;
1464 close(MYFILE);
Fred Drakea0f4c941998-07-24 22:16:04 +00001465}
Fred Drake557460c1999-03-02 16:05:35 +00001466sub process_python_state{
1467 process_all_localmoduletables();
Fred Drake557460c1999-03-02 16:05:35 +00001468}
Fred Drakea0f4c941998-07-24 22:16:04 +00001469
1470
1471#
1472# "See also:" -- references placed at the end of a \section
1473#
1474
1475sub do_env_seealso{
Fred Drakee15956b2000-04-03 04:51:13 +00001476 return "<div class='seealso'>\n "
1477 . "<p class='heading'><b>See Also:</b></p>\n"
Fred Drake90fdda51999-02-16 20:27:42 +00001478 . @_[0]
1479 . '</div>';
Fred Drakea0f4c941998-07-24 22:16:04 +00001480}
1481
1482sub do_cmd_seemodule{
1483 # Insert the right magic to jump to the module definition. This should
1484 # work most of the time, at least for repeat builds....
1485 local($_) = @_;
1486 my $key = next_optional_argument();
1487 my $module = next_argument();
1488 my $text = next_argument();
Fred Drake84bd6f31999-05-11 15:42:51 +00001489 my $period = '.';
Fred Drakea0f4c941998-07-24 22:16:04 +00001490 $key = $module
1491 unless $key;
Fred Drake84bd6f31999-05-11 15:42:51 +00001492 if ($text =~ /\.$/) {
1493 $period = '';
1494 }
Fred Drakee15956b2000-04-03 04:51:13 +00001495 return '<dl compact class="seemodule">'
1496 . "\n <dt>Module <b><tt class='module'><a href='module-$key.html'>"
Fred Drake84bd6f31999-05-11 15:42:51 +00001497 . "$module</a></tt>:</b>"
1498 . "\n <dd>$text$period\n </dl>"
Fred Drake90fdda51999-02-16 20:27:42 +00001499 . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001500}
1501
Fred Drakee0197bf2001-04-12 04:03:22 +00001502sub strip_html_markup($){
1503 my $str = @_[0];
1504 my $s = "$str";
1505 $s =~ s/<[a-zA-Z0-9]+(\s+[a-zA-Z0-9]+(\s*=\s*(\'[^\']*\'|\"[^\"]*\"|[a-zA-Z0-9]+))?)*\s*>//g;
1506 $s =~ s/<\/[a-zA-Z0-9]+>//g;
1507 return $s;
1508}
1509
Fred Drake643d76d2000-09-09 06:07:37 +00001510sub handle_rfclike_reference{
Fred Drakeafc7ce12001-01-22 17:33:24 +00001511 local($_, $what, $format) = @_;
Fred Drake37cc0c02000-04-26 18:05:24 +00001512 my $rfcnum = next_argument();
1513 my $title = next_argument();
1514 my $text = next_argument();
Fred Drakeafc7ce12001-01-22 17:33:24 +00001515 my $url = get_rfc_url($rfcnum, $format);
Fred Drake7a40c072000-10-02 14:43:38 +00001516 my $icon = get_link_icon($url);
Fred Drakee0197bf2001-04-12 04:03:22 +00001517 my $attrtitle = strip_html_markup($title);
Fred Drake37cc0c02000-04-26 18:05:24 +00001518 return '<dl compact class="seerfc">'
1519 . "\n <dt><a href=\"$url\""
Fred Drakee0197bf2001-04-12 04:03:22 +00001520 . "\n title=\"$attrtitle\""
Fred Drake5f84c9b2000-10-03 06:05:25 +00001521 . "\n >$what $rfcnum, <em>$title</em>$icon</a>"
Fred Drake37cc0c02000-04-26 18:05:24 +00001522 . "\n <dd>$text\n </dl>"
1523 . $_;
1524}
1525
Fred Drake643d76d2000-09-09 06:07:37 +00001526sub do_cmd_seepep{
Fred Drakeafc7ce12001-01-22 17:33:24 +00001527 return handle_rfclike_reference(@_[0], "PEP", $PEP_FORMAT);
Fred Drake643d76d2000-09-09 06:07:37 +00001528}
1529
1530sub do_cmd_seerfc{
Fred Drakeafc7ce12001-01-22 17:33:24 +00001531 return handle_rfclike_reference(@_[0], "RFC", $RFC_FORMAT);
Fred Drake643d76d2000-09-09 06:07:37 +00001532}
1533
Fred Drake48449982000-09-12 17:52:33 +00001534sub do_cmd_seetitle{
1535 local($_) = @_;
1536 my $url = next_optional_argument();
1537 my $title = next_argument();
1538 my $text = next_argument();
1539 if ($url) {
Fred Drake5f84c9b2000-10-03 06:05:25 +00001540 my $icon = get_link_icon($url);
Fred Drake48449982000-09-12 17:52:33 +00001541 return '<dl compact class="seetitle">'
1542 . "\n <dt><em class=\"citetitle\"><a href=\"$url\""
Fred Drake7a40c072000-10-02 14:43:38 +00001543 . "\n >$title$icon</a></em>"
Fred Drake48449982000-09-12 17:52:33 +00001544 . "\n <dd>$text\n </dl>"
1545 . $_;
1546 }
1547 return '<dl compact class="seetitle">'
1548 . "\n <dt><em class=\"citetitle\""
1549 . "\n >$title</em>"
1550 . "\n <dd>$text\n </dl>"
1551 . $_;
1552}
1553
Fred Drakeef4d1112000-05-09 16:17:51 +00001554sub do_cmd_seeurl{
1555 local($_) = @_;
1556 my $url = next_argument();
1557 my $text = next_argument();
Fred Drake7a40c072000-10-02 14:43:38 +00001558 my $icon = get_link_icon($url);
Fred Drakeef4d1112000-05-09 16:17:51 +00001559 return '<dl compact class="seeurl">'
1560 . "\n <dt><a href=\"$url\""
Fred Drake7a40c072000-10-02 14:43:38 +00001561 . "\n class=\"url\">$url$icon</a>"
Fred Drakeef4d1112000-05-09 16:17:51 +00001562 . "\n <dd>$text\n </dl>"
1563 . $_;
1564}
1565
Fred Drakea0f4c941998-07-24 22:16:04 +00001566sub do_cmd_seetext{
Fred Drake79189b51999-04-28 13:54:30 +00001567 local($_) = @_;
1568 my $content = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +00001569 return '<div class="seetext"><p>' . $content . '</div>' . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001570}
1571
1572
1573#
Fred Drake885215c1998-05-20 21:32:09 +00001574# Definition list support.
1575#
1576
1577sub do_env_definitions{
Fred Drake37cc0c02000-04-26 18:05:24 +00001578 return "<dl class='definitions'>" . @_[0] . "</dl>\n";
Fred Drake885215c1998-05-20 21:32:09 +00001579}
1580
1581sub do_cmd_term{
1582 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001583 my $term = next_argument();
1584 my($name,$aname,$ahref) = new_link_info();
Fred Drake885215c1998-05-20 21:32:09 +00001585 # could easily add an index entry here...
Fred Drake62e43691998-08-10 19:40:44 +00001586 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
Fred Drake885215c1998-05-20 21:32:09 +00001587}
1588
1589
Fred Drake38178fd2000-09-22 17:05:04 +00001590# I don't recall exactly why this was needed, but it was very much needed.
1591# We'll see if anything breaks when I move the "code" line out -- some
1592# things broke with it in.
1593
1594#code # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001595process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_);
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001596declaremodule # [] # {} # {}
1597memberline # [] # {}
1598methodline # [] # {} # {}
1599modulesynopsis # {}
Fred Drake557460c1999-03-02 16:05:35 +00001600platform # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001601samp # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001602setindexsubitem # {}
Fred Drakef32834c1999-02-12 22:06:32 +00001603withsubitem # {} # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001604_RAW_ARG_DEFERRED_CMDS_
1605
1606
Fred Drake86333602001-04-10 17:13:39 +00001607$alltt_start = '<dl><dd><pre class="verbatim">';
1608$alltt_end = '</pre></dl>';
1609
1610sub do_env_alltt {
1611 local ($_) = @_;
1612 local($closures,$reopens,@open_block_tags);
1613
1614 # get the tag-strings for all open tags
1615 local(@keep_open_tags) = @$open_tags_R;
1616 ($closures,$reopens) = &preserve_open_tags() if (@$open_tags_R);
1617
1618 # get the tags for text-level tags only
1619 $open_tags_R = [ @keep_open_tags ];
1620 local($local_closures, $local_reopens);
1621 ($local_closures, $local_reopens,@open_block_tags)
1622 = &preserve_open_block_tags
1623 if (@$open_tags_R);
1624
1625 $open_tags_R = [ @open_block_tags ];
1626
1627 do {
1628 local($open_tags_R) = [ @open_block_tags ];
1629 local(@save_open_tags) = ();
1630
1631 local($cnt) = ++$global{'max_id'};
1632 $_ = join('',"$O$cnt$C\\tt$O", ++$global{'max_id'}, $C
1633 , $_ , $O, $global{'max_id'}, "$C$O$cnt$C");
1634
1635 $_ = &translate_environments($_);
1636 $_ = &translate_commands($_) if (/\\/);
1637
1638 # preserve space-runs, using &nbsp;
1639 while (s/(\S) ( +)/$1$2;SPMnbsp;/g){};
1640 s/(<BR>) /$1;SPMnbsp;/g;
1641
1642 $_ = join('', $closures, $alltt_start, $local_reopens
1643 , $_
1644 , &balance_tags() #, $local_closures
1645 , $alltt_end, $reopens);
1646 undef $open_tags_R; undef @save_open_tags;
1647 };
1648 $open_tags_R = [ @keep_open_tags ];
1649 $_;
1650}
1651
1652
Fred Drake6659c301998-03-03 22:02:19 +000016531; # This must be the last line