blob: 4431ec712de6007b8b2695049e22643187d90ec1 [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);
Fred Drakef1927a62001-06-20 21:29:30 +000044 return (" <img src=\"$icon\"\n"
45 . ' border="0" class="offsitelink"'
Fred Drake5f84c9b2000-10-03 06:05:25 +000046 . ($OFF_SITE_LINK_ICON_HEIGHT
Fred Drakef1927a62001-06-20 21:29:30 +000047 ? " height=\"$OFF_SITE_LINK_ICON_HEIGHT\""
Fred Drake5f84c9b2000-10-03 06:05:25 +000048 : '')
49 . ($OFF_SITE_LINK_ICON_WIDTH
Fred Drakef1927a62001-06-20 21:29:30 +000050 ? " width=\"$OFF_SITE_LINK_ICON_WIDTH\""
Fred Drake5f84c9b2000-10-03 06:05:25 +000051 : '')
Fred Drakef1927a62001-06-20 21:29:30 +000052 . " 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 Drakef1927a62001-06-20 21:29:30 +0000107$RELEASE_INFO = '';
Fred Draked04592a2000-10-25 16:15:13 +0000108$PACKAGE_VERSION = '';
Fred Drake6659c301998-03-03 22:02:19 +0000109
Fred Draked04592a2000-10-25 16:15:13 +0000110sub do_cmd_version{ $PACKAGE_VERSION . @_[0]; }
Fred Drake3cdb89d2000-09-14 20:17:23 +0000111sub do_cmd_shortversion{ $SHORT_VERSION . @_[0]; }
Fred Drake6659c301998-03-03 22:02:19 +0000112sub do_cmd_release{
113 local($_) = @_;
Fred Draked04592a2000-10-25 16:15:13 +0000114 $PACKAGE_VERSION = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000115 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000116}
117
Fred Drakef1927a62001-06-20 21:29:30 +0000118sub do_cmd_setreleaseinfo{
119 local($_) = @_;
120 $RELEASE_INFO = next_argument();
121 return $_;
122}
123
Fred Drake3cdb89d2000-09-14 20:17:23 +0000124sub do_cmd_setshortversion{
125 local($_) = @_;
126 $SHORT_VERSION = next_argument();
127 return $_;
128}
129
Fred Drake6659c301998-03-03 22:02:19 +0000130sub do_cmd_authoraddress{
131 local($_) = @_;
Fred Draked07868a1998-05-14 21:00:28 +0000132 $DEVELOPER_ADDRESS = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000133 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000134}
135
Fred Drakee16f6791998-05-15 04:28:37 +0000136#sub do_cmd_developer{ do_cmd_author(@_[0]); }
137#sub do_cmd_developers{ do_cmd_author(@_[0]); }
138#sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); }
Fred Draked07868a1998-05-14 21:00:28 +0000139
Fred Drake6659c301998-03-03 22:02:19 +0000140sub do_cmd_hackscore{
141 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000142 next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000143 return '_' . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000144}
145
Fred Drake08932051998-04-17 02:15:42 +0000146sub use_wrappers{
147 local($_,$before,$after) = @_;
148 my $stuff = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000149 return $before . $stuff . $after . $_;
Fred Drake08932051998-04-17 02:15:42 +0000150}
151
Fred Drake3cdb89d2000-09-14 20:17:23 +0000152$IN_DESC_HANDLER = 0;
Fred Drake6659c301998-03-03 22:02:19 +0000153sub do_cmd_optional{
Fred Drake3cdb89d2000-09-14 20:17:23 +0000154 if ($IN_DESC_HANDLER) {
155 return use_wrappers(@_[0], "</var><big>\[</big><var>",
156 "</var><big>\]</big><var>");
157 }
158 else {
159 return use_wrappers(@_[0], "<big>\[</big>", "<big>\]</big>");
160 }
Fred Drake6659c301998-03-03 22:02:19 +0000161}
162
Fred Drakec9a44381998-03-17 06:29:13 +0000163# Logical formatting (some based on texinfo), needs to be converted to
164# minimalist HTML. The "minimalist" is primarily to reduce the size of
165# output files for users that read them over the network rather than
166# from local repositories.
Fred Drake6659c301998-03-03 22:02:19 +0000167
Fred Drake2cafcbb1999-03-25 16:57:04 +0000168# \file and \samp are at the end of this file since they screw up fontlock.
169
Fred Drake2ff880e1999-02-05 18:31:29 +0000170sub do_cmd_pytype{ return @_[0]; }
Fred Drake3d5a04a2000-08-03 17:25:44 +0000171sub do_cmd_makevar{
172 return use_wrappers(@_[0], '<span class="makevar">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000173sub do_cmd_code{
Fred Drakee15956b2000-04-03 04:51:13 +0000174 return use_wrappers(@_[0], '<code>', '</code>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000175sub do_cmd_module{
Fred Drakee15956b2000-04-03 04:51:13 +0000176 return use_wrappers(@_[0], '<tt class="module">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000177sub do_cmd_keyword{
Fred Drakee15956b2000-04-03 04:51:13 +0000178 return use_wrappers(@_[0], '<tt class="keyword">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000179sub do_cmd_exception{
Fred Drakee15956b2000-04-03 04:51:13 +0000180 return use_wrappers(@_[0], '<tt class="exception">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000181sub do_cmd_class{
Fred Drakee15956b2000-04-03 04:51:13 +0000182 return use_wrappers(@_[0], '<tt class="class">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000183sub do_cmd_function{
Fred Drakee15956b2000-04-03 04:51:13 +0000184 return use_wrappers(@_[0], '<tt class="function">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000185sub do_cmd_constant{
Fred Drakee15956b2000-04-03 04:51:13 +0000186 return use_wrappers(@_[0], '<tt class="constant">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000187sub do_cmd_member{
Fred Drakee15956b2000-04-03 04:51:13 +0000188 return use_wrappers(@_[0], '<tt class="member">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000189sub do_cmd_method{
Fred Drakee15956b2000-04-03 04:51:13 +0000190 return use_wrappers(@_[0], '<tt class="method">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000191sub do_cmd_cfunction{
Fred Drakee15956b2000-04-03 04:51:13 +0000192 return use_wrappers(@_[0], '<tt class="cfunction">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000193sub do_cmd_cdata{
Fred Drakee15956b2000-04-03 04:51:13 +0000194 return use_wrappers(@_[0], '<tt class="cdata">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000195sub do_cmd_ctype{
Fred Drakee15956b2000-04-03 04:51:13 +0000196 return use_wrappers(@_[0], '<tt class="ctype">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000197sub do_cmd_regexp{
Fred Drakee15956b2000-04-03 04:51:13 +0000198 return use_wrappers(@_[0], '<tt class="regexp">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000199sub do_cmd_character{
Fred Drakee15956b2000-04-03 04:51:13 +0000200 return use_wrappers(@_[0], '"<tt class="character">', '</tt>"'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000201sub do_cmd_program{
Fred Drakee15956b2000-04-03 04:51:13 +0000202 return use_wrappers(@_[0], '<b class="program">', '</b>'); }
Fred Drakec9f5fe01999-11-09 16:59:42 +0000203sub do_cmd_programopt{
204 return use_wrappers(@_[0], '<b class="programopt">', '</b>'); }
Fred Drake0cd60212000-04-11 18:46:59 +0000205sub do_cmd_longprogramopt{
206 # note that the --- will be later converted to -- by LaTeX2HTML
207 return use_wrappers(@_[0], '<b class="programopt">---', '</b>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000208sub do_cmd_email{
Fred Drakee15956b2000-04-03 04:51:13 +0000209 return use_wrappers(@_[0], '<span class="email">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000210sub do_cmd_mimetype{
Fred Drakee15956b2000-04-03 04:51:13 +0000211 return use_wrappers(@_[0], '<span class="mimetype">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000212sub do_cmd_var{
213 return use_wrappers(@_[0], "<var>", "</var>"); }
214sub do_cmd_dfn{
Fred Drakee15956b2000-04-03 04:51:13 +0000215 return use_wrappers(@_[0], '<i class="dfn">', '</i>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000216sub do_cmd_emph{
Fred Drake38178fd2000-09-22 17:05:04 +0000217 return use_wrappers(@_[0], '<i>', '</i>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000218sub do_cmd_file{
Fred Drake3d5a04a2000-08-03 17:25:44 +0000219 return use_wrappers(@_[0], '<span class="file">', '</span>'); }
Fred Drakef74e5b71999-04-28 14:58:49 +0000220sub do_cmd_filenq{
Fred Drakee15956b2000-04-03 04:51:13 +0000221 return do_cmd_file(@_[0]); }
Fred Drake90fdda51999-02-16 20:27:42 +0000222sub do_cmd_samp{
Fred Drakee15956b2000-04-03 04:51:13 +0000223 return use_wrappers(@_[0], '"<tt class="samp">', '</tt>"'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000224sub do_cmd_kbd{
225 return use_wrappers(@_[0], '<kbd>', '</kbd>'); }
226sub do_cmd_strong{
227 return use_wrappers(@_[0], '<b>', '</b>'); }
Fred Drake2cafcbb1999-03-25 16:57:04 +0000228sub do_cmd_textbf{
229 return use_wrappers(@_[0], '<b>', '</b>'); }
230sub do_cmd_textit{
231 return use_wrappers(@_[0], '<i>', '</i>'); }
232
Fred Drake3d5a04a2000-08-03 17:25:44 +0000233sub do_cmd_moreargs{
234 return '...' . @_[0]; }
235sub do_cmd_unspecified{
236 return '...' . @_[0]; }
237
Fred Drakec9a44381998-03-17 06:29:13 +0000238
Fred Drake25817041999-01-13 17:06:34 +0000239sub do_cmd_refmodule{
240 # Insert the right magic to jump to the module definition.
241 local($_) = @_;
242 my $key = next_optional_argument();
243 my $module = next_argument();
244 $key = $module
245 unless $key;
Fred Drakef1927a62001-06-20 21:29:30 +0000246 return "<tt class=\"module\"><a href=\"module-$key.html\">$module</a></tt>"
Fred Drakee15956b2000-04-03 04:51:13 +0000247 . $_;
Fred Drake25817041999-01-13 17:06:34 +0000248}
249
Fred Drake1a7af391998-04-01 22:44:56 +0000250sub do_cmd_newsgroup{
251 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000252 my $newsgroup = next_argument();
Fred Drake7a40c072000-10-02 14:43:38 +0000253 my $icon = get_link_icon("news:$newsgroup");
Fred Drakef1927a62001-06-20 21:29:30 +0000254 my $stuff = ("<a class=\"newsgroup\" href=\"news:$newsgroup\">"
255 . "$newsgroup$icon</a>");
Fred Drake62e43691998-08-10 19:40:44 +0000256 return $stuff . $_;
Fred Drake1a7af391998-04-01 22:44:56 +0000257}
Fred Drakefc16e781998-03-12 21:03:26 +0000258
259sub do_cmd_envvar{
260 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000261 my $envvar = next_argument();
262 my($name,$aname,$ahref) = new_link_info();
Fred Drake166abba1998-04-08 23:10:54 +0000263 # The <tt> here is really to keep buildindex.py from making
264 # the variable name case-insensitive.
Fred Drakeafc7ce12001-01-22 17:33:24 +0000265 add_index_entry("environment variables!$envvar@<tt>$envvar</tt>",
Fred Drake166abba1998-04-08 23:10:54 +0000266 $ahref);
Fred Drakeafc7ce12001-01-22 17:33:24 +0000267 add_index_entry("$envvar (environment variable)", $ahref);
Fred Drakee15956b2000-04-03 04:51:13 +0000268 $aname =~ s/<a/<a class="envvar"/;
Fred Drakeafc7ce12001-01-22 17:33:24 +0000269 return "$aname$envvar</a>" . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000270}
271
Fred Drake6659c301998-03-03 22:02:19 +0000272sub do_cmd_url{
273 # use the URL as both text and hyperlink
274 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000275 my $url = next_argument();
Fred Drake7a40c072000-10-02 14:43:38 +0000276 my $icon = get_link_icon($url);
Fred Drake6659c301998-03-03 22:02:19 +0000277 $url =~ s/~/&#126;/g;
Fred Drake7a40c072000-10-02 14:43:38 +0000278 return "<a class=\"url\" href=\"$url\">$url$icon</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000279}
280
281sub do_cmd_manpage{
282 # two parameters: \manpage{name}{section}
283 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000284 my $page = next_argument();
285 my $section = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +0000286 return "<span class=\"manpage\"><i>$page</i>($section)</span>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000287}
288
Fred Drakef1927a62001-06-20 21:29:30 +0000289$PEP_FORMAT = "http://python.sourceforge.net/peps/pep-%04d.html";
290#$RFC_FORMAT = "http://www.ietf.org/rfc/rfc%04d.txt";
291$RFC_FORMAT = "http://www.faqs.org/rfcs/rfc%d.html";
Fred Drakeafc7ce12001-01-22 17:33:24 +0000292
293sub get_rfc_url($$){
294 my($rfcnum, $format) = @_;
Fred Drakef1927a62001-06-20 21:29:30 +0000295 return sprintf($format, $rfcnum);
Fred Drake643d76d2000-09-09 06:07:37 +0000296}
297
298sub do_cmd_pep{
299 local($_) = @_;
300 my $rfcnumber = next_argument();
301 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drakeafc7ce12001-01-22 17:33:24 +0000302 my $href = get_rfc_url($rfcnumber, $PEP_FORMAT);
Fred Drake7a40c072000-10-02 14:43:38 +0000303 my $icon = get_link_icon($href);
Fred Drake643d76d2000-09-09 06:07:37 +0000304 # Save the reference
305 my $nstr = gen_index_id("Python Enhancement Proposals!PEP $rfcnumber", '');
306 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
Fred Drake7a40c072000-10-02 14:43:38 +0000307 return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">PEP $rfcnumber"
308 . "$icon</a>" . $_);
Fred Drake643d76d2000-09-09 06:07:37 +0000309}
310
Fred Drake6659c301998-03-03 22:02:19 +0000311sub do_cmd_rfc{
312 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000313 my $rfcnumber = next_argument();
314 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drakeafc7ce12001-01-22 17:33:24 +0000315 my $href = get_rfc_url($rfcnumber, $RFC_FORMAT);
Fred Drake7a40c072000-10-02 14:43:38 +0000316 my $icon = get_link_icon($href);
Fred Drake6659c301998-03-03 22:02:19 +0000317 # Save the reference
Fred Drake08932051998-04-17 02:15:42 +0000318 my $nstr = gen_index_id("RFC!RFC $rfcnumber", '');
Fred Drakeccc62721999-01-05 22:16:29 +0000319 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
Fred Drake7a40c072000-10-02 14:43:38 +0000320 return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">RFC $rfcnumber"
321 . "$icon</a>" . $_);
Fred Drake6659c301998-03-03 22:02:19 +0000322}
323
Fred Drakec9f5fe01999-11-09 16:59:42 +0000324sub do_cmd_citetitle{
325 local($_) = @_;
326 my $url = next_optional_argument();
327 my $title = next_argument();
Fred Drake7a40c072000-10-02 14:43:38 +0000328 my $icon = get_link_icon($url);
Fred Drakec9f5fe01999-11-09 16:59:42 +0000329 my $repl = '';
330 if ($url) {
Fred Drakef1927a62001-06-20 21:29:30 +0000331 $repl = ("<em class=\"citetitle\"><a\n"
332 . " href=\"$url\"\n"
333 . " title=\"$title\"\n"
Fred Drake7a40c072000-10-02 14:43:38 +0000334 . " >$title$icon</a></em>");
Fred Drakec9f5fe01999-11-09 16:59:42 +0000335 }
336 else {
Fred Drakef1927a62001-06-20 21:29:30 +0000337 $repl = "<em class=\"citetitle\"\n >$title</em>";
Fred Drakec9f5fe01999-11-09 16:59:42 +0000338 }
339 return $repl . $_;
340}
341
Fred Drake6659c301998-03-03 22:02:19 +0000342sub do_cmd_deprecated{
343 # two parameters: \deprecated{version}{whattodo}
344 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000345 my $release = next_argument();
346 my $reason = next_argument();
Fred Drakeafc7ce12001-01-22 17:33:24 +0000347 return ('<div class="versionnote">'
348 . "<b>Deprecated since release $release.</b>"
349 . "\n$reason</div><p>"
350 . $_);
Fred Drake6659c301998-03-03 22:02:19 +0000351}
352
Fred Drakec2b29d02001-04-18 03:11:04 +0000353sub versionnote{
354 # one or two parameters: \versionnote[explanation]{version}
355 my $type = @_[0];
356 local $_ = @_[1];
357 my $explanation = next_optional_argument();
Fred Drake897d12b1998-07-27 20:33:17 +0000358 my $release = next_argument();
Fred Drakec2b29d02001-04-18 03:11:04 +0000359 my $text = "$type in version $release.";
360 if ($explanation) {
361 $text = "$type in version $release:\n$explanation.";
362 }
Fred Drakef1927a62001-06-20 21:29:30 +0000363 return "\n<span class=\"versionnote\">$text</span>\n" . $_;
Fred Drakec2b29d02001-04-18 03:11:04 +0000364}
365
366sub do_cmd_versionadded{
367 return versionnote('New', @_);
Fred Drake897d12b1998-07-27 20:33:17 +0000368}
369
370sub do_cmd_versionchanged{
Fred Drakec2b29d02001-04-18 03:11:04 +0000371 return versionnote('Changed', @_);
Fred Drake897d12b1998-07-27 20:33:17 +0000372}
373
Fred Drake557460c1999-03-02 16:05:35 +0000374#
Fred Drake2cafcbb1999-03-25 16:57:04 +0000375# These function handle platform dependency tracking.
Fred Drake557460c1999-03-02 16:05:35 +0000376#
377sub do_cmd_platform{
378 local($_) = @_;
379 my $platform = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +0000380 $ModulePlatforms{"<tt class=\"module\">$THIS_MODULE</tt>"} = $platform;
Fred Drake557460c1999-03-02 16:05:35 +0000381 $platform = "Macintosh"
Fred Drake085b8121999-04-21 14:00:29 +0000382 if $platform eq 'Mac';
Fred Drakef1927a62001-06-20 21:29:30 +0000383 return "\n<p class=\"availability\">Availability: <span"
384 . "\n class=\"platform\">$platform</span>.</p>\n" . $_;
Fred Drake557460c1999-03-02 16:05:35 +0000385}
386
Fred Drake557460c1999-03-02 16:05:35 +0000387$IGNORE_PLATFORM_ANNOTATION = '';
388sub do_cmd_ignorePlatformAnnotation{
389 local($_) = @_;
390 $IGNORE_PLATFORM_ANNOTATION = next_argument();
391 return $_;
392}
393
Fred Drake6659c301998-03-03 22:02:19 +0000394
395# index commands
396
397$INDEX_SUBITEM = "";
398
399sub get_indexsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000400 return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
Fred Drake6659c301998-03-03 22:02:19 +0000401}
402
403sub do_cmd_setindexsubitem{
404 local($_) = @_;
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000405 $INDEX_SUBITEM = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000406 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000407}
408
Fred Drakefc16e781998-03-12 21:03:26 +0000409sub do_cmd_withsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000410 # We can't really do the right thing, because LaTeX2HTML doesn't
Fred Drakefc16e781998-03-12 21:03:26 +0000411 # do things in the right order, but we need to at least strip this stuff
412 # out, and leave anything that the second argument expanded out to.
413 #
414 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000415 my $oldsubitem = $INDEX_SUBITEM;
416 $INDEX_SUBITEM = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000417 my $stuff = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000418 my $br_id = ++$globals{'max_id'};
419 my $marker = "$O$br_id$C";
Fred Drake7d45f6d1999-01-05 14:39:27 +0000420 return
421 $stuff
Fred Drakeccc62721999-01-05 22:16:29 +0000422 . "\\setindexsubitem$marker$oldsubitem$marker"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000423 . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000424}
425
Fred Drake08932051998-04-17 02:15:42 +0000426# This is the prologue macro which is required to start writing the
Fred Drakeab032151999-05-13 18:36:54 +0000427# mod\jobname.idx file; we can just ignore it. (Defining this suppresses
428# a warning that \makemodindex is unknown.)
Fred Drake08932051998-04-17 02:15:42 +0000429#
Fred Drake62e43691998-08-10 19:40:44 +0000430sub do_cmd_makemodindex{ return @_[0]; }
Fred Drakefc16e781998-03-12 21:03:26 +0000431
Fred Drake42b31a51998-03-27 05:16:10 +0000432# We're in the document subdirectory when this happens!
Fred Drake166abba1998-04-08 23:10:54 +0000433#
Fred Drake08932051998-04-17 02:15:42 +0000434open(IDXFILE, '>index.dat') || die "\n$!\n";
435open(INTLABELS, '>intlabels.pl') || die "\n$!\n";
Fred Drake166abba1998-04-08 23:10:54 +0000436print INTLABELS "%internal_labels = ();\n";
437print INTLABELS "1; # hack in case there are no entries\n\n";
438
439# Using \0 for this is bad because we can't use common tools to work with the
440# resulting files. Things like grep can be useful with this stuff!
441#
442$IDXFILE_FIELD_SEP = "\1";
443
Fred Drakeccc62721999-01-05 22:16:29 +0000444sub write_idxfile{
445 my ($ahref, $str) = @_;
446 print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n";
Fred Drake42b31a51998-03-27 05:16:10 +0000447}
448
Fred Drake42b31a51998-03-27 05:16:10 +0000449
450sub gen_link{
451 my($node,$target) = @_;
452 print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
Fred Drakef1927a62001-06-20 21:29:30 +0000453 return "<a href=\"$node#$target\">";
Fred Drake42b31a51998-03-27 05:16:10 +0000454}
455
Fred Drake42b31a51998-03-27 05:16:10 +0000456sub add_index_entry{
457 # add an entry to the index structures; ignore the return value
458 my($str,$ahref) = @_;
459 $str = gen_index_id($str, '');
460 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000461 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000462}
463
Fred Drakeccc62721999-01-05 22:16:29 +0000464sub new_link_info{
465 my $name = "l2h-" . ++$globals{'max_id'};
Fred Drakef1927a62001-06-20 21:29:30 +0000466 my $aname = "<a name=\"$name\">";
Fred Drake42b31a51998-03-27 05:16:10 +0000467 my $ahref = gen_link($CURRENT_FILE, $name);
468 return ($name, $aname, $ahref);
469}
470
Fred Drakeab032151999-05-13 18:36:54 +0000471$IndexMacroPattern = '';
472sub define_indexing_macro{
473 my $count = @_;
474 my $i = 0;
475 for (; $i < $count; ++$i) {
476 my $name = @_[$i];
477 my $cmd = "idx_cmd_$name";
478 die "\nNo function $cmd() defined!\n"
479 if (!defined &$cmd);
480 eval ("sub do_cmd_$name { return process_index_macros("
481 . "\@_[0], '$name'); }");
482 if (length($IndexMacroPattern) == 0) {
483 $IndexMacroPattern = "$name";
484 }
485 else {
486 $IndexMacroPattern .= "|$name";
487 }
488 }
489}
490
491$DEBUG_INDEXING = 0;
492sub process_index_macros{
Fred Drake42b31a51998-03-27 05:16:10 +0000493 local($_) = @_;
Fred Drakeab032151999-05-13 18:36:54 +0000494 my $cmdname = @_[1]; # This is what triggered us in the first place;
495 # we know it's real, so just process it.
Fred Drakeccc62721999-01-05 22:16:29 +0000496 my($name,$aname,$ahref) = new_link_info();
Fred Drakeab032151999-05-13 18:36:54 +0000497 my $cmd = "idx_cmd_$cmdname";
498 print "\nIndexing: \\$cmdname"
499 if $DEBUG_INDEXING;
500 &$cmd($ahref); # modifies $_ and adds index entries
501 while (/^[\s\n]*\\($IndexMacroPattern)</) {
502 $cmdname = "$1";
503 print " \\$cmdname"
504 if $DEBUG_INDEXING;
505 $cmd = "idx_cmd_$cmdname";
506 if (!defined &$cmd) {
507 last;
508 }
509 else {
510 s/^[\s\n]*\\$cmdname//;
511 &$cmd($ahref);
512 }
513 }
Fred Drakeafc7ce12001-01-22 17:33:24 +0000514 if (/^[ \t\r\n]/) {
515 $_ = substr($_, 1);
516 }
Fred Drake62e43691998-08-10 19:40:44 +0000517 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake42b31a51998-03-27 05:16:10 +0000518}
519
Fred Drakeab032151999-05-13 18:36:54 +0000520define_indexing_macro('index');
521sub idx_cmd_index{
Fred Drakeccc62721999-01-05 22:16:29 +0000522 my $str = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000523 add_index_entry("$str", @_[0]);
Fred Drake2e7edb81998-05-11 18:31:17 +0000524}
525
Fred Drakeab032151999-05-13 18:36:54 +0000526define_indexing_macro('kwindex');
527sub idx_cmd_kwindex{
528 my $str = next_argument();
529 add_index_entry("<tt>$str</tt>!keyword", @_[0]);
530 add_index_entry("keyword!<tt>$str</tt>", @_[0]);
531}
532
533define_indexing_macro('indexii');
534sub idx_cmd_indexii{
Fred Drakeccc62721999-01-05 22:16:29 +0000535 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000536 my $str2 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000537 add_index_entry("$str1!$str2", @_[0]);
538 add_index_entry("$str2!$str1", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000539}
540
Fred Drakeab032151999-05-13 18:36:54 +0000541define_indexing_macro('indexiii');
542sub idx_cmd_indexiii{
Fred Drakeccc62721999-01-05 22:16:29 +0000543 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000544 my $str2 = next_argument();
545 my $str3 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000546 add_index_entry("$str1!$str2 $str3", @_[0]);
547 add_index_entry("$str2!$str3, $str1", @_[0]);
548 add_index_entry("$str3!$str1 $str2", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000549}
550
Fred Drakeab032151999-05-13 18:36:54 +0000551define_indexing_macro('indexiv');
552sub idx_cmd_indexiv{
Fred Drakeccc62721999-01-05 22:16:29 +0000553 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000554 my $str2 = next_argument();
555 my $str3 = next_argument();
556 my $str4 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000557 add_index_entry("$str1!$str2 $str3 $str4", @_[0]);
558 add_index_entry("$str2!$str3 $str4, $str1", @_[0]);
559 add_index_entry("$str3!$str4, $str1 $str2", @_[0]);
560 add_index_entry("$str4!$$str1 $str2 $str3", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000561}
562
Fred Drakeab032151999-05-13 18:36:54 +0000563define_indexing_macro('ttindex');
564sub idx_cmd_ttindex{
Fred Drakeccc62721999-01-05 22:16:29 +0000565 my $str = next_argument();
566 my $entry = $str . get_indexsubitem();
Fred Drakeab032151999-05-13 18:36:54 +0000567 add_index_entry($entry, @_[0]);
Fred Drakec9a44381998-03-17 06:29:13 +0000568}
Fred Drake6659c301998-03-03 22:02:19 +0000569
570sub my_typed_index_helper{
Fred Drakeab032151999-05-13 18:36:54 +0000571 my($word,$ahref) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000572 my $str = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000573 add_index_entry("$str $word", $ahref);
574 add_index_entry("$word!$str", $ahref);
Fred Drake6659c301998-03-03 22:02:19 +0000575}
576
Fred Drakeab032151999-05-13 18:36:54 +0000577define_indexing_macro('stindex', 'opindex', 'exindex', 'obindex');
578sub idx_cmd_stindex{ my_typed_index_helper('statement', @_[0]); }
579sub idx_cmd_opindex{ my_typed_index_helper('operator', @_[0]); }
580sub idx_cmd_exindex{ my_typed_index_helper('exception', @_[0]); }
581sub idx_cmd_obindex{ my_typed_index_helper('object', @_[0]); }
Fred Drake6659c301998-03-03 22:02:19 +0000582
Fred Drakeab032151999-05-13 18:36:54 +0000583define_indexing_macro('bifuncindex');
584sub idx_cmd_bifuncindex{
Fred Drakeccc62721999-01-05 22:16:29 +0000585 my $str = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +0000586 add_index_entry("<tt class=\"function\">$str()</tt> (built-in function)",
Fred Drakee15956b2000-04-03 04:51:13 +0000587 @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000588}
589
590
Fred Drake6659c301998-03-03 22:02:19 +0000591sub make_mod_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000592 my($str,$define) = @_;
593 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000594 # equivalent of add_index_entry() using $define instead of ''
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000595 $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/
596 if ($define eq 'DEF');
Fred Drake42b31a51998-03-27 05:16:10 +0000597 $str = gen_index_id($str, $define);
598 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000599 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000600
Fred Drakec9a44381998-03-17 06:29:13 +0000601 if ($define eq 'DEF') {
Fred Drake42b31a51998-03-27 05:16:10 +0000602 # add to the module index
Fred Drakee15956b2000-04-03 04:51:13 +0000603 $str =~ /(<tt.*<\/tt>)/;
604 my $nstr = $1;
Fred Drake42b31a51998-03-27 05:16:10 +0000605 $Modules{$nstr} .= $ahref;
Fred Drake6659c301998-03-03 22:02:19 +0000606 }
Fred Drakeafc7ce12001-01-22 17:33:24 +0000607 return "$aname$anchor_invisible_mark2</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000608}
609
Fred Drake557460c1999-03-02 16:05:35 +0000610
Fred Drakec9a44381998-03-17 06:29:13 +0000611$THIS_MODULE = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000612$THIS_CLASS = '';
Fred Drakec9a44381998-03-17 06:29:13 +0000613
Fred Drakea0f4c941998-07-24 22:16:04 +0000614sub define_module{
615 my($word,$name) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000616 my $section_tag = join('', @curr_sec_id);
Fred Drake3e4c6141999-05-17 15:00:32 +0000617 if ($word ne "built-in" && $word ne "extension"
618 && $word ne "standard" && $word ne "") {
619 write_warnings("Bad module type '$word'"
620 . " for \\declaremodule (module $name)");
621 $word = "";
622 }
Fred Drake6659c301998-03-03 22:02:19 +0000623 $word = "$word " if $word;
Fred Drakea0f4c941998-07-24 22:16:04 +0000624 $THIS_MODULE = "$name";
Fred Drake5942b432000-10-30 06:24:56 +0000625 $INDEX_SUBITEM = "(in module $name)";
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000626 print "[$name]";
Fred Drakee15956b2000-04-03 04:51:13 +0000627 return make_mod_index_entry(
Fred Drakef1927a62001-06-20 21:29:30 +0000628 "<tt class=\"module\">$name</tt> (${word}module)", 'DEF');
Fred Drakea0f4c941998-07-24 22:16:04 +0000629}
630
631sub my_module_index_helper{
632 local($word, $_) = @_;
633 my $name = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000634 return define_module($word, $name) . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000635}
636
Fred Drake62e43691998-08-10 19:40:44 +0000637sub do_cmd_modindex{ return my_module_index_helper('', @_); }
638sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); }
639sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); }
640sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000641
Fred Drakeab032151999-05-13 18:36:54 +0000642sub ref_module_index_helper{
Fred Drake37cc0c02000-04-26 18:05:24 +0000643 my($word, $ahref) = @_;
Fred Drakeab032151999-05-13 18:36:54 +0000644 my $str = next_argument();
645 $word = "$word " if $word;
Fred Drakef1927a62001-06-20 21:29:30 +0000646 $str = "<tt class=\"module\">$str</tt> (${word}module)";
Fred Drakeab032151999-05-13 18:36:54 +0000647 # can't use add_index_entry() since the 2nd arg to gen_index_id() is used;
648 # just inline it all here
649 $str = gen_index_id($str, 'REF');
650 $index{$str} .= $ahref;
651 write_idxfile($ahref, $str);
652}
653
Fred Drake6659c301998-03-03 22:02:19 +0000654# these should be adjusted a bit....
Fred Drakeab032151999-05-13 18:36:54 +0000655define_indexing_macro('refmodindex', 'refbimodindex',
656 'refexmodindex', 'refstmodindex');
657sub idx_cmd_refmodindex{ return ref_module_index_helper('', @_); }
658sub idx_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); }
659sub idx_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); }
660sub idx_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000661
Fred Drake62e43691998-08-10 19:40:44 +0000662sub do_cmd_nodename{ return do_cmd_label(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000663
664sub init_myformat{
Fred Drakeafc7ce12001-01-22 17:33:24 +0000665 $anchor_invisible_mark = '&nbsp;';
666 $anchor_invisible_mark2 = '';
Fred Drake6659c301998-03-03 22:02:19 +0000667 $anchor_mark = '';
668 $icons{'anchor_mark'} = '';
Fred Drake6659c301998-03-03 22:02:19 +0000669}
Fred Drake42b31a51998-03-27 05:16:10 +0000670init_myformat();
Fred Drake6659c301998-03-03 22:02:19 +0000671
Fred Drakeab032151999-05-13 18:36:54 +0000672# Create an index entry, but include the string in the target anchor
Fred Drake6659c301998-03-03 22:02:19 +0000673# instead of the dummy filler.
674#
675sub make_str_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000676 my($str) = @_;
677 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000678 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000679 return "$aname$str</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000680}
681
Fred Drakee15956b2000-04-03 04:51:13 +0000682$REFCOUNTS_LOADED = 0;
683
684sub load_refcounts{
685 $REFCOUNTS_LOADED = 1;
686
Fred Drakee15956b2000-04-03 04:51:13 +0000687 my $myname, $mydir, $myext;
688 ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*');
689 chop $mydir; # remove trailing '/'
690 ($myname, $mydir, $myext) = fileparse($mydir, '\..*');
691 chop $mydir; # remove trailing '/'
692 $mydir = getcwd() . "$dd$mydir"
693 unless $mydir =~ s|^/|/|;
694 local $_;
695 my $filename = "$mydir${dd}api${dd}refcounts.dat";
696 open(REFCOUNT_FILE, "<$filename") || die "\n$!\n";
697 print "[loading API refcount data]";
698 while (<REFCOUNT_FILE>) {
Fred Drakec2578c52000-04-10 18:26:45 +0000699 if (/([a-zA-Z0-9_]+):PyObject\*:([a-zA-Z0-9_]*):(0|[-+]1|null):(.*)$/) {
Fred Drakee15956b2000-04-03 04:51:13 +0000700 my($func, $param, $count, $comment) = ($1, $2, $3, $4);
701 #print "\n$func($param) --> $count";
702 $REFCOUNTS{"$func:$param"} = $count;
703 }
704 }
705}
706
707sub get_refcount{
708 my ($func, $param) = @_;
709 load_refcounts()
710 unless $REFCOUNTS_LOADED;
711 return $REFCOUNTS{"$func:$param"};
712}
713
Fred Drake6659c301998-03-03 22:02:19 +0000714sub do_env_cfuncdesc{
715 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000716 my $return_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000717 my $function_name = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000718 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000719 my $idx = make_str_index_entry(
Fred Drakef1927a62001-06-20 21:29:30 +0000720 "<tt class=\"cfunction\">$function_name()</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000721 $idx =~ s/ \(.*\)//;
Fred Drake241551c2000-08-11 20:04:19 +0000722 $idx =~ s/\(\)//; # ???? - why both of these?
Fred Drakee15956b2000-04-03 04:51:13 +0000723 my $result_rc = get_refcount($function_name, '');
724 my $rcinfo = '';
725 if ($result_rc eq '+1') {
Fred Drake241551c2000-08-11 20:04:19 +0000726 $rcinfo = 'New reference';
Fred Drakee15956b2000-04-03 04:51:13 +0000727 }
728 elsif ($result_rc eq '0') {
Fred Drake241551c2000-08-11 20:04:19 +0000729 $rcinfo = 'Borrowed reference';
Fred Drakee15956b2000-04-03 04:51:13 +0000730 }
Fred Drakec2578c52000-04-10 18:26:45 +0000731 elsif ($result_rc eq 'null') {
Fred Drake241551c2000-08-11 20:04:19 +0000732 $rcinfo = 'Always <tt class="constant">NULL</tt>';
Fred Drakec2578c52000-04-10 18:26:45 +0000733 }
Fred Drakee15956b2000-04-03 04:51:13 +0000734 if ($rcinfo ne '') {
Fred Drake241551c2000-08-11 20:04:19 +0000735 $rcinfo = ( "\n<div class=\"refcount-info\">"
736 . "\n <span class=\"label\">Return value:</span>"
737 . "\n <span class=\"value\">$rcinfo.</span>"
738 . "\n</div>");
Fred Drakee15956b2000-04-03 04:51:13 +0000739 }
Fred Drakec612a142001-03-29 18:24:08 +0000740 return "<dl><dt>$return_type <b>$idx</b>(<var>$arg_list</var>)\n<dd>"
Fred Drakee15956b2000-04-03 04:51:13 +0000741 . $rcinfo
Fred Drake62e43691998-08-10 19:40:44 +0000742 . $_
743 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000744}
745
Fred Drakee15956b2000-04-03 04:51:13 +0000746sub do_env_csimplemacrodesc{
747 local($_) = @_;
748 my $name = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +0000749 my $idx = make_str_index_entry("<tt class=\"macro\">$name</tt>");
Fred Drakee15956b2000-04-03 04:51:13 +0000750 return "<dl><dt><b>$idx</b>\n<dd>"
751 . $_
752 . '</dl>'
753}
754
Fred Drake6659c301998-03-03 22:02:19 +0000755sub do_env_ctypedesc{
756 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +0000757 my $index_name = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000758 my $type_name = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000759 $index_name = $type_name
760 unless $index_name;
761 my($name,$aname,$ahref) = new_link_info();
Fred Drakef1927a62001-06-20 21:29:30 +0000762 add_index_entry("<tt class=\"ctype\">$index_name</tt> (C type)", $ahref);
763 return "<dl><dt><b><tt class=\"ctype\">$aname$type_name</a></tt></b>\n<dd>"
Fred Drake62e43691998-08-10 19:40:44 +0000764 . $_
765 . '</dl>'
Fred Drake6659c301998-03-03 22:02:19 +0000766}
767
768sub do_env_cvardesc{
769 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000770 my $var_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000771 my $var_name = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +0000772 my $idx = make_str_index_entry("<tt class=\"cdata\">$var_name</tt>"
Fred Drake90fdda51999-02-16 20:27:42 +0000773 . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000774 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000775 return "<dl><dt>$var_type <b>$idx</b>\n"
776 . '<dd>'
777 . $_
778 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000779}
780
Fred Drake3cdb89d2000-09-14 20:17:23 +0000781sub convert_args($){
782 local($IN_DESC_HANDLER) = 1;
783 local($_) = @_;
784 return translate_commands($_);
785}
786
Fred Drake6659c301998-03-03 22:02:19 +0000787sub do_env_funcdesc{
788 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000789 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000790 my $arg_list = convert_args(next_argument());
Fred Drakef1927a62001-06-20 21:29:30 +0000791 my $idx = make_str_index_entry("<tt class=\"function\">$function_name()"
792 . '</tt>'
Fred Drake08932051998-04-17 02:15:42 +0000793 . get_indexsubitem());
794 $idx =~ s/ \(.*\)//;
Fred Drakeccc62721999-01-05 22:16:29 +0000795 $idx =~ s/\(\)<\/tt>/<\/tt>/;
Fred Drakec612a142001-03-29 18:24:08 +0000796 return "<dl><dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000797}
798
799sub do_env_funcdescni{
800 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000801 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000802 my $arg_list = convert_args(next_argument());
Fred Drakef1927a62001-06-20 21:29:30 +0000803 return "<dl><dt><b><tt class=\"function\">$function_name</tt></b>"
Fred Drakec612a142001-03-29 18:24:08 +0000804 . "(<var>$arg_list</var>)\n"
Fred Drake90fdda51999-02-16 20:27:42 +0000805 . '<dd>'
806 . $_
807 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000808}
809
810sub do_cmd_funcline{
811 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000812 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000813 my $arg_list = convert_args(next_argument());
Fred Drakef1927a62001-06-20 21:29:30 +0000814 my $prefix = "<tt class=\"function\">$function_name()</tt>";
Fred Drakeca675e41999-04-21 15:58:58 +0000815 my $idx = make_str_index_entry($prefix . get_indexsubitem());
816 $prefix =~ s/\(\)//;
817
Fred Drakec612a142001-03-29 18:24:08 +0000818 return "<dt><b>$prefix</b>(<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000819}
820
Fred Drake6b3fb781999-07-12 16:50:09 +0000821sub do_cmd_funclineni{
822 local($_) = @_;
823 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000824 my $arg_list = convert_args(next_argument());
Fred Drakef1927a62001-06-20 21:29:30 +0000825 my $prefix = "<tt class=\"function\">$function_name</tt>";
Fred Drake6b3fb781999-07-12 16:50:09 +0000826
Fred Drakec612a142001-03-29 18:24:08 +0000827 return "<dt><b>$prefix</b>(<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6b3fb781999-07-12 16:50:09 +0000828}
829
Fred Drake6659c301998-03-03 22:02:19 +0000830# Change this flag to index the opcode entries. I don't think it's very
831# useful to index them, since they're only presented to describe the dis
832# module.
833#
834$INDEX_OPCODES = 0;
835
836sub do_env_opcodedesc{
837 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000838 my $opcode_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000839 my $arg_list = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000840 my $idx;
841 if ($INDEX_OPCODES) {
Fred Drakef1927a62001-06-20 21:29:30 +0000842 $idx = make_str_index_entry("<tt class=\"opcode\">$opcode_name</tt>"
843 . ' (byte code instruction)');
Fred Drake08932051998-04-17 02:15:42 +0000844 $idx =~ s/ \(byte code instruction\)//;
845 }
846 else {
Fred Drakef1927a62001-06-20 21:29:30 +0000847 $idx = "<tt class=\"opcode\">$opcode_name</tt>";
Fred Drake08932051998-04-17 02:15:42 +0000848 }
849 my $stuff = "<dl><dt><b>$idx</b>";
Fred Drake6659c301998-03-03 22:02:19 +0000850 if ($arg_list) {
851 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
852 }
Fred Drake62e43691998-08-10 19:40:44 +0000853 return $stuff . "\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000854}
855
856sub do_env_datadesc{
857 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000858 my $dataname = next_argument();
859 my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000860 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000861 return "<dl><dt><b>$idx</b>\n<dd>"
862 . $_
863 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000864}
865
866sub do_env_datadescni{
867 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000868 my $idx = next_argument();
869 if (! $STRING_INDEX_TT) {
870 $idx = "<tt>$idx</tt>";
Fred Drake6659c301998-03-03 22:02:19 +0000871 }
Fred Drake62e43691998-08-10 19:40:44 +0000872 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000873}
874
875sub do_cmd_dataline{
876 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000877 my $data_name = next_argument();
878 my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem());
Fred Drake6659c301998-03-03 22:02:19 +0000879 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000880 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000881}
882
Fred Drakeadb272c2000-04-10 17:47:14 +0000883sub do_cmd_datalineni{
884 local($_) = @_;
885 my $data_name = next_argument();
886 return "<dt><b><tt>$data_name</tt></b><dd>" . $_;
887}
888
Fred Drake42b31a51998-03-27 05:16:10 +0000889sub do_env_excdesc{
890 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000891 my $excname = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +0000892 my $idx = make_str_index_entry("<tt class=\"exception\">$excname</tt>");
Fred Drakeab357ec2001-03-02 18:57:05 +0000893 return "<dl><dt><b>exception $idx</b>\n<dd>" . $_ . '</dl>'
Fred Drake42b31a51998-03-27 05:16:10 +0000894}
895
Fred Drake62e43691998-08-10 19:40:44 +0000896sub do_env_fulllineitems{ return do_env_itemize(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000897
898
Fred Drake643d76d2000-09-09 06:07:37 +0000899sub handle_classlike_descriptor{
900 local($_, $what) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000901 $THIS_CLASS = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000902 my $arg_list = convert_args(next_argument());
Fred Drakeccc62721999-01-05 22:16:29 +0000903 $idx = make_str_index_entry(
Fred Drakef1927a62001-06-20 21:29:30 +0000904 "<tt class=\"$what\">$THIS_CLASS</tt> ($what in $THIS_MODULE)" );
Fred Drake08932051998-04-17 02:15:42 +0000905 $idx =~ s/ \(.*\)//;
Fred Drakec612a142001-03-29 18:24:08 +0000906 return ("<dl><dt><b>$what $idx</b>(<var>$arg_list</var>)\n<dd>"
Fred Drakeab357ec2001-03-02 18:57:05 +0000907 . $_
908 . '</dl>');
Fred Drakec9a44381998-03-17 06:29:13 +0000909}
910
Fred Drake643d76d2000-09-09 06:07:37 +0000911sub do_env_classdesc{
912 return handle_classlike_descriptor(@_[0], "class");
913}
914
Fred Drake06a01e82001-05-11 01:00:30 +0000915sub do_env_classdescstar{
916 local($_) = @_;
917 $THIS_CLASS = next_argument();
918 $idx = make_str_index_entry(
Fred Drakef1927a62001-06-20 21:29:30 +0000919 "<tt class=\"class\">$THIS_CLASS</tt> (class in $THIS_MODULE)");
Fred Drake06a01e82001-05-11 01:00:30 +0000920 $idx =~ s/ \(.*\)//;
921 return ("<dl><dt><b>class $idx</b>\n<dd>"
922 . $_
923 . '</dl>');
924}
925
Fred Drake643d76d2000-09-09 06:07:37 +0000926sub do_env_excclassdesc{
927 return handle_classlike_descriptor(@_[0], "exception");
928}
929
Fred Drake42b31a51998-03-27 05:16:10 +0000930
931sub do_env_methoddesc{
932 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000933 my $class_name = next_optional_argument();
934 $class_name = $THIS_CLASS
935 unless $class_name;
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000936 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000937 my $arg_list = convert_args(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000938 my $extra = '';
939 if ($class_name) {
940 $extra = " ($class_name method)";
Fred Drake42b31a51998-03-27 05:16:10 +0000941 }
Fred Drakef1927a62001-06-20 21:29:30 +0000942 my $idx = make_str_index_entry(
943 "<tt class=\"method\">$method()</tt>$extra");
Fred Drake08932051998-04-17 02:15:42 +0000944 $idx =~ s/ \(.*\)//;
945 $idx =~ s/\(\)//;
Fred Drakec612a142001-03-29 18:24:08 +0000946 return "<dl><dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000947}
948
949
Fred Drake7d45f6d1999-01-05 14:39:27 +0000950sub do_cmd_methodline{
951 local($_) = @_;
952 my $class_name = next_optional_argument();
953 $class_name = $THIS_CLASS
954 unless $class_name;
955 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000956 my $arg_list = convert_args(next_argument());
Fred Drake7d45f6d1999-01-05 14:39:27 +0000957 my $extra = '';
958 if ($class_name) {
959 $extra = " ($class_name method)";
960 }
Fred Drakef1927a62001-06-20 21:29:30 +0000961 my $idx = make_str_index_entry(
962 "<tt class=\"method\">$method()</tt>$extra");
Fred Drake7d45f6d1999-01-05 14:39:27 +0000963 $idx =~ s/ \(.*\)//;
964 $idx =~ s/\(\)//;
Fred Drakec612a142001-03-29 18:24:08 +0000965 return "<dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000966 . $_;
967}
968
969
Fred Draked64a40d1998-09-10 18:59:13 +0000970sub do_cmd_methodlineni{
971 local($_) = @_;
972 next_optional_argument();
973 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000974 my $arg_list = convert_args(next_argument());
Fred Drakec612a142001-03-29 18:24:08 +0000975 return "<dt><b>$method</b>(<var>$arg_list</var>)\n<dd>"
Fred Draked64a40d1998-09-10 18:59:13 +0000976 . $_;
977}
978
Fred Drake42b31a51998-03-27 05:16:10 +0000979sub do_env_methoddescni{
980 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000981 next_optional_argument();
982 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000983 my $arg_list = convert_args(next_argument());
Fred Drakec612a142001-03-29 18:24:08 +0000984 return "<dl><dt><b>$method</b>(<var>$arg_list</var>)\n<dd>"
Fred Drake62e43691998-08-10 19:40:44 +0000985 . $_
986 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000987}
988
989
990sub do_env_memberdesc{
991 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000992 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000993 my $member = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000994 $class = $THIS_CLASS
995 unless $class;
Fred Drake08932051998-04-17 02:15:42 +0000996 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +0000997 $extra = " ($class attribute)"
998 if ($class ne '');
Fred Drakef1927a62001-06-20 21:29:30 +0000999 my $idx = make_str_index_entry("<tt class=\"member\">$member</tt>$extra");
Fred Drake42b31a51998-03-27 05:16:10 +00001000 $idx =~ s/ \(.*\)//;
1001 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +00001002 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +00001003}
1004
1005
Fred Drake5ccf3301998-04-17 20:04:09 +00001006sub do_cmd_memberline{
1007 local($_) = @_;
1008 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +00001009 my $member = next_argument();
Fred Drake5ccf3301998-04-17 20:04:09 +00001010 $class = $THIS_CLASS
1011 unless $class;
1012 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +00001013 $extra = " ($class attribute)"
1014 if ($class ne '');
Fred Drakef1927a62001-06-20 21:29:30 +00001015 my $idx = make_str_index_entry("<tt class=\"member\">$member</tt>$extra");
Fred Drake5ccf3301998-04-17 20:04:09 +00001016 $idx =~ s/ \(.*\)//;
1017 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +00001018 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +00001019}
1020
Fred Drake42b31a51998-03-27 05:16:10 +00001021sub do_env_memberdescni{
1022 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001023 next_optional_argument();
1024 my $member = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +00001025 return "<dl><dt><b><tt class=\"member\">$member</tt></b>\n<dd>"
Fred Drakee15956b2000-04-03 04:51:13 +00001026 . $_
1027 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +00001028}
1029
1030
Fred Drake5ccf3301998-04-17 20:04:09 +00001031sub do_cmd_memberlineni{
1032 local($_) = @_;
1033 next_optional_argument();
1034 my $member = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +00001035 return "<dt><b><tt class=\"member\">$member</tt></b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +00001036}
1037
Fred Drakee15956b2000-04-03 04:51:13 +00001038@col_aligns = ('<td>', '<td>', '<td>', '<td>');
Fred Drake6659c301998-03-03 22:02:19 +00001039
Fred Drakef74e5b71999-04-28 14:58:49 +00001040sub fix_font{
1041 # do a little magic on a font name to get the right behavior in the first
1042 # column of the output table
1043 my $font = @_[0];
1044 if ($font eq 'textrm') {
1045 $font = '';
1046 }
1047 elsif ($font eq 'file' || $font eq 'filenq') {
Fred Drakee15956b2000-04-03 04:51:13 +00001048 $font = 'tt class="file"';
1049 }
1050 elsif ($font eq 'member') {
1051 $font = 'tt class="member"';
Fred Drakef74e5b71999-04-28 14:58:49 +00001052 }
Fred Drakee463f8e2000-11-30 07:17:27 +00001053 elsif ($font eq 'class') {
1054 $font = 'tt class="class"';
1055 }
Fred Drake7388f732000-06-28 21:06:08 +00001056 elsif ($font eq 'constant') {
1057 $font = 'tt class="constant"';
1058 }
Fred Drakecb0fc9c2000-08-09 13:45:04 +00001059 elsif ($font eq 'kbd') {
1060 $font = 'kbd';
1061 }
Fred Draked04592a2000-10-25 16:15:13 +00001062 elsif ($font eq 'programopt') {
1063 $font = 'b';
1064 }
Fred Drakeafc7ce12001-01-22 17:33:24 +00001065 elsif ($font eq 'exception') {
1066 $font = 'tt class="exception"';
1067 }
Fred Drakef74e5b71999-04-28 14:58:49 +00001068 return $font;
1069}
1070
Fred Drakee15956b2000-04-03 04:51:13 +00001071sub figure_column_alignment{
1072 my $a = @_[0];
1073 my $mark = substr($a, 0, 1);
1074 my $r = '';
1075 if ($mark eq 'c')
1076 { $r = ' align="center"'; }
1077 elsif ($mark eq 'r')
1078 { $r = ' align="right"'; }
1079 elsif ($mark eq 'l')
1080 { $r = ' align="left"'; }
1081 elsif ($mark eq 'p')
1082 { $r = ' align="left"'; }
1083 return $r;
1084}
1085
Fred Drake6659c301998-03-03 22:02:19 +00001086sub setup_column_alignments{
1087 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001088 my($s1,$s2,$s3,$s4) = split(/[|]/,$_);
1089 my $a1 = figure_column_alignment($s1);
1090 my $a2 = figure_column_alignment($s2);
1091 my $a3 = figure_column_alignment($s3);
1092 my $a4 = figure_column_alignment($s4);
1093 $col_aligns[0] = "<td$a1 valign=\"baseline\">";
1094 $col_aligns[1] = "<td$a2>";
1095 $col_aligns[2] = "<td$a3>";
1096 $col_aligns[3] = "<td$a4>";
Fred Drake79189b51999-04-28 13:54:30 +00001097 # return the aligned header start tags
Fred Drakee15956b2000-04-03 04:51:13 +00001098 return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>");
1099}
1100
1101sub get_table_col1_fonts{
1102 my $font = $globals{'lineifont'};
1103 my ($sfont,$efont) = ('', '');
1104 if ($font) {
1105 $sfont = "<$font>";
1106 $efont = "</$font>";
1107 $efont =~ s/ .*>/>/;
1108 }
Fred Drakee463f8e2000-11-30 07:17:27 +00001109 return ($sfont, $efont);
Fred Drake6659c301998-03-03 22:02:19 +00001110}
1111
1112sub do_env_tableii{
1113 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001114 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001115 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001116 my $h1 = next_argument();
1117 my $h2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001118 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001119 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001120 my $a1 = $col_aligns[0];
1121 my $a2 = $col_aligns[1];
1122 s/\\lineii</\\lineii[$a1|$a2]</g;
1123 return '<table border align="center" style="border-collapse: collapse">'
Fred Drake351960d2000-10-26 20:14:58 +00001124 . "\n <thead>"
1125 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001126 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1127 . "\n $th2<b>$h2</b>\&nbsp;</th>"
Fred Drake351960d2000-10-26 20:14:58 +00001128 . "\n </tr>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001129 . "\n </thead>"
Fred Drakef1927a62001-06-20 21:29:30 +00001130 . "\n <tbody valign=\"baseline\">"
Fred Drake351960d2000-10-26 20:14:58 +00001131 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001132 . "\n </tbody>"
1133 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001134}
1135
Fred Drakeda72b932000-09-21 15:58:02 +00001136sub do_env_longtableii{
1137 return do_env_tableii(@_);
1138}
1139
Fred Drake6659c301998-03-03 22:02:19 +00001140sub do_cmd_lineii{
1141 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001142 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001143 my $c1 = next_argument();
1144 my $c2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001145 s/[\s\n]+//;
Fred Drakee463f8e2000-11-30 07:17:27 +00001146 my($sfont,$efont) = get_table_col1_fonts();
Fred Drakee15956b2000-04-03 04:51:13 +00001147 $c2 = '&nbsp;' if ($c2 eq '');
1148 my($c1align,$c2align) = split('\|', $aligns);
1149 my $padding = '';
Fred Drakee463f8e2000-11-30 07:17:27 +00001150 if ($c1align =~ /align="right"/ || $c1 eq '') {
Fred Drakee15956b2000-04-03 04:51:13 +00001151 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001152 }
Fred Drakee15956b2000-04-03 04:51:13 +00001153 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
1154 . " $c2align$c2</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001155 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001156}
1157
1158sub do_env_tableiii{
1159 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001160 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001161 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001162 my $h1 = next_argument();
1163 my $h2 = next_argument();
1164 my $h3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001165 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001166 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001167 my $a1 = $col_aligns[0];
1168 my $a2 = $col_aligns[1];
1169 my $a3 = $col_aligns[2];
1170 s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g;
1171 return '<table border align="center" style="border-collapse: collapse">'
Fred Drake351960d2000-10-26 20:14:58 +00001172 . "\n <thead>"
1173 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001174 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1175 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1176 . "\n $th3<b>$h3</b>\&nbsp;</th>"
Fred Drake351960d2000-10-26 20:14:58 +00001177 . "\n </tr>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001178 . "\n </thead>"
Fred Drakef1927a62001-06-20 21:29:30 +00001179 . "\n <tbody valign=\"baseline\">"
Fred Drake62e43691998-08-10 19:40:44 +00001180 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001181 . "\n </tbody>"
1182 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001183}
1184
Fred Drakeda72b932000-09-21 15:58:02 +00001185sub do_env_longtableiii{
1186 return do_env_tableiii(@_);
1187}
1188
Fred Drake6659c301998-03-03 22:02:19 +00001189sub do_cmd_lineiii{
1190 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001191 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001192 my $c1 = next_argument();
1193 my $c2 = next_argument();
1194 my $c3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001195 s/[\s\n]+//;
Fred Drakee463f8e2000-11-30 07:17:27 +00001196 my($sfont,$efont) = get_table_col1_fonts();
Fred Drakee15956b2000-04-03 04:51:13 +00001197 $c3 = '&nbsp;' if ($c3 eq '');
1198 my($c1align,$c2align,$c3align) = split('\|', $aligns);
1199 my $padding = '';
Fred Drakee463f8e2000-11-30 07:17:27 +00001200 if ($c1align =~ /align="right"/ || $c1 eq '') {
Fred Drakee15956b2000-04-03 04:51:13 +00001201 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001202 }
Fred Drakee15956b2000-04-03 04:51:13 +00001203 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001204 . " $c2align$c2</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001205 . " $c3align$c3</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001206 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001207}
1208
Fred Drakea0f4c941998-07-24 22:16:04 +00001209sub do_env_tableiv{
1210 local($_) = @_;
1211 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001212 my $font = fix_font(next_argument());
Fred Drakea0f4c941998-07-24 22:16:04 +00001213 my $h1 = next_argument();
1214 my $h2 = next_argument();
1215 my $h3 = next_argument();
1216 my $h4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001217 s/[\s\n]+//;
Fred Drakea0f4c941998-07-24 22:16:04 +00001218 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001219 my $a1 = $col_aligns[0];
1220 my $a2 = $col_aligns[1];
1221 my $a3 = $col_aligns[2];
1222 my $a4 = $col_aligns[3];
1223 s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g;
1224 return '<table border align="center" style="border-collapse: collapse">'
Fred Drake351960d2000-10-26 20:14:58 +00001225 . "\n <thead>"
1226 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001227 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1228 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1229 . "\n $th3<b>$h3</b>\&nbsp;</th>"
1230 . "\n $th4<b>$h4</b>\&nbsp;</th>"
Fred Drake351960d2000-10-26 20:14:58 +00001231 . "\n </tr>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001232 . "\n </thead>"
Fred Drakef1927a62001-06-20 21:29:30 +00001233 . "\n <tbody valign=\"baseline\">"
Fred Drake62e43691998-08-10 19:40:44 +00001234 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001235 . "\n </tbody>"
1236 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001237}
1238
Fred Drakeda72b932000-09-21 15:58:02 +00001239sub do_env_longtableiv{
1240 return do_env_tableiv(@_);
1241}
1242
Fred Drakea0f4c941998-07-24 22:16:04 +00001243sub do_cmd_lineiv{
Fred Drake6659c301998-03-03 22:02:19 +00001244 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001245 my $aligns = next_optional_argument();
Fred Drakea0f4c941998-07-24 22:16:04 +00001246 my $c1 = next_argument();
1247 my $c2 = next_argument();
1248 my $c3 = next_argument();
1249 my $c4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001250 s/[\s\n]+//;
Fred Drakee463f8e2000-11-30 07:17:27 +00001251 my($sfont,$efont) = get_table_col1_fonts();
Fred Drakee15956b2000-04-03 04:51:13 +00001252 $c4 = '&nbsp;' if ($c4 eq '');
1253 my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns);
1254 my $padding = '';
Fred Drakee463f8e2000-11-30 07:17:27 +00001255 if ($c1align =~ /align="right"/ || $c1 eq '') {
Fred Drakee15956b2000-04-03 04:51:13 +00001256 $padding = '&nbsp;';
Fred Drakea0f4c941998-07-24 22:16:04 +00001257 }
Fred Drakee15956b2000-04-03 04:51:13 +00001258 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001259 . " $c2align$c2</td>\n"
1260 . " $c3align$c3</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001261 . " $c4align$c4</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001262 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001263}
1264
Fred Drake3be20742000-08-31 06:22:54 +00001265
1266# These can be used to control the title page appearance;
1267# they need a little bit of documentation.
1268#
1269# If $TITLE_PAGE_GRAPHIC is set, it should be the name of a file in the
1270# $ICONSERVER directory, or include path information (other than "./"). The
1271# default image type will be assumed if an extension is not provided.
1272#
1273# If specified, the "title page" will contain two colums: one containing the
1274# title/author/etc., and the other containing the graphic. Use the other
1275# four variables listed here to control specific details of the layout; all
1276# are optional.
1277#
1278# $TITLE_PAGE_GRAPHIC = "my-company-logo";
1279# $TITLE_PAGE_GRAPHIC_COLWIDTH = "30%";
1280# $TITLE_PAGE_GRAPHIC_WIDTH = 150;
1281# $TITLE_PAGE_GRAPHIC_HEIGHT = 150;
1282# $TITLE_PAGE_GRAPHIC_ON_RIGHT = 0;
1283
1284sub make_my_titlepage() {
1285 my $the_title = "";
Fred Drake6659c301998-03-03 22:02:19 +00001286 if ($t_title) {
Fred Drake90fdda51999-02-16 20:27:42 +00001287 $the_title .= "\n<h1>$t_title</h1>";
Fred Drake3be20742000-08-31 06:22:54 +00001288 }
1289 else {
1290 write_warnings("\nThis document has no title.");
1291 }
Fred Drake6659c301998-03-03 22:02:19 +00001292 if ($t_author) {
1293 if ($t_authorURL) {
Fred Drake08932051998-04-17 02:15:42 +00001294 my $href = translate_commands($t_authorURL);
Fred Drake2d1f81e1999-02-09 16:03:31 +00001295 $href = make_named_href('author', $href,
Fred Drakef1927a62001-06-20 21:29:30 +00001296 "<b><font size=\"+2\">$t_author"
1297 . '</font></b>');
Fred Drakec9a44381998-03-17 06:29:13 +00001298 $the_title .= "\n<p>$href</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001299 }
1300 else {
Fred Drakef1927a62001-06-20 21:29:30 +00001301 $the_title .= ("\n<p><b><font size=\"+2\">$t_author"
1302 . '</font></b></p>');
Fred Drake6659c301998-03-03 22:02:19 +00001303 }
Fred Drake3be20742000-08-31 06:22:54 +00001304 }
1305 else {
1306 write_warnings("\nThere is no author for this document.");
1307 }
Fred Drake6659c301998-03-03 22:02:19 +00001308 if ($t_institute) {
Fred Drake3be20742000-08-31 06:22:54 +00001309 $the_title .= "\n<p>$t_institute</p>";
1310 }
Fred Draked07868a1998-05-14 21:00:28 +00001311 if ($DEVELOPER_ADDRESS) {
Fred Drake3be20742000-08-31 06:22:54 +00001312 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";
1313 }
Fred Drake6659c301998-03-03 22:02:19 +00001314 if ($t_affil) {
Fred Drake3be20742000-08-31 06:22:54 +00001315 $the_title .= "\n<p><i>$t_affil</i></p>";
1316 }
Fred Drake6659c301998-03-03 22:02:19 +00001317 if ($t_date) {
Fred Drakede77bc52000-12-14 18:36:12 +00001318 $the_title .= "\n<p>";
Fred Draked04592a2000-10-25 16:15:13 +00001319 if ($PACKAGE_VERSION) {
Fred Drakef1927a62001-06-20 21:29:30 +00001320 $the_title .= ('<strong>Release '
1321 . "$PACKAGE_VERSION$RELEASE_INFO</strong><br>\n");
Fred Drake3be20742000-08-31 06:22:54 +00001322 }
Fred Drakede77bc52000-12-14 18:36:12 +00001323 $the_title .= "<strong>$t_date</strong></p>"
Fred Drake6659c301998-03-03 22:02:19 +00001324 }
1325 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +00001326 $the_title .= "\n<p>$t_address</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001327 }
1328 else {
1329 $the_title .= "\n<p>";
1330 }
Fred Drake6659c301998-03-03 22:02:19 +00001331 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +00001332 $the_title .= "\n<p>$t_email</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001333 }
1334 return $the_title;
1335}
1336
Fred Drake3be20742000-08-31 06:22:54 +00001337sub make_my_titlegraphic() {
Fred Drake7a40c072000-10-02 14:43:38 +00001338 my $filename = make_icon_filename($TITLE_PAGE_GRAPHIC);
Fred Drake3be20742000-08-31 06:22:54 +00001339 my $graphic = "<td class=\"titlegraphic\"";
1340 $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_COLWIDTH\""
1341 if ($TITLE_PAGE_GRAPHIC_COLWIDTH);
1342 $graphic .= "><img";
1343 $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_WIDTH\""
1344 if ($TITLE_PAGE_GRAPHIC_WIDTH);
1345 $graphic .= " height=\"$TITLE_PAGE_GRAPHIC_HEIGHT\""
1346 if ($TITLE_PAGE_GRAPHIC_HEIGHT);
Fred Drake5f84c9b2000-10-03 06:05:25 +00001347 $graphic .= "\n src=\"$filename\"></td>\n";
Fred Drake3be20742000-08-31 06:22:54 +00001348 return $graphic;
1349}
1350
1351sub do_cmd_maketitle {
1352 local($_) = @_;
1353 my $the_title = "\n<div class=\"titlepage\">";
1354 if ($TITLE_PAGE_GRAPHIC) {
1355 if ($TITLE_PAGE_GRAPHIC_ON_RIGHT) {
1356 $the_title .= ("\n<table border=\"0\" width=\"100%\">"
1357 . "<tr align=\"right\">\n<td>"
1358 . make_my_titlepage()
1359 . "</td>\n"
1360 . make_my_titlegraphic()
1361 . "</tr>\n</table>");
1362 }
1363 else {
1364 $the_title .= ("\n<table border=\"0\" width=\"100%\"><tr>\n"
1365 . make_my_titlegraphic()
1366 . "<td>"
1367 . make_my_titlepage()
1368 . "</td></tr>\n</table>");
1369 }
1370 }
1371 else {
1372 $the_title .= ("\n<center>"
1373 . make_my_titlepage()
1374 . "\n</center>");
1375 }
1376 $the_title .= "\n</div>";
1377 return $the_title . $_;
Fred Drake90fdda51999-02-16 20:27:42 +00001378 $the_title .= "\n</center></div>";
Fred Drake62e43691998-08-10 19:40:44 +00001379 return $the_title . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +00001380}
1381
1382
Fred Drake885215c1998-05-20 21:32:09 +00001383#
Fred Drakea0f4c941998-07-24 22:16:04 +00001384# Module synopsis support
1385#
1386
1387require SynopsisTable;
1388
Fred Drakef7685d71998-07-25 03:31:46 +00001389sub get_chapter_id(){
1390 my $id = do_cmd_thechapter('');
Fred Drake45f26011998-08-04 22:07:18 +00001391 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
1392 $id =~ s/\.//;
Fred Drakef7685d71998-07-25 03:31:46 +00001393 return $id;
Fred Drakea0f4c941998-07-24 22:16:04 +00001394}
1395
Fred Drake643d76d2000-09-09 06:07:37 +00001396# 'chapter' => 'SynopsisTable instance'
1397%ModuleSynopses = ();
Fred Drakef7685d71998-07-25 03:31:46 +00001398
1399sub get_synopsis_table($){
1400 my($chap) = @_;
Fred Drakef7685d71998-07-25 03:31:46 +00001401 my $key;
1402 foreach $key (keys %ModuleSynopses) {
1403 if ($key eq $chap) {
1404 return $ModuleSynopses{$chap};
1405 }
Fred Drakea0f4c941998-07-24 22:16:04 +00001406 }
Fred Drake643d76d2000-09-09 06:07:37 +00001407 my $st = SynopsisTable->new();
Fred Drakef7685d71998-07-25 03:31:46 +00001408 $ModuleSynopses{$chap} = $st;
Fred Drakea0f4c941998-07-24 22:16:04 +00001409 return $st;
1410}
1411
Fred Drake62e43691998-08-10 19:40:44 +00001412sub do_cmd_moduleauthor{
1413 local($_) = @_;
1414 next_argument();
1415 next_argument();
1416 return $_;
1417}
1418
1419sub do_cmd_sectionauthor{
1420 local($_) = @_;
1421 next_argument();
1422 next_argument();
1423 return $_;
1424}
1425
Fred Drakea0f4c941998-07-24 22:16:04 +00001426sub do_cmd_declaremodule{
1427 local($_) = @_;
1428 my $key = next_optional_argument();
1429 my $type = next_argument();
1430 my $name = next_argument();
1431 my $st = get_synopsis_table(get_chapter_id());
1432 #
1433 $key = $name unless $key;
1434 $type = 'built-in' if $type eq 'builtin';
1435 $st->declare($name, $key, $type);
1436 define_module($type, $name);
Fred Drake62e43691998-08-10 19:40:44 +00001437 return anchor_label("module-$key",$CURRENT_FILE,$_)
Fred Drakea0f4c941998-07-24 22:16:04 +00001438}
1439
1440sub do_cmd_modulesynopsis{
1441 local($_) = @_;
1442 my $st = get_synopsis_table(get_chapter_id());
Fred Drake1cc58991999-04-13 22:08:59 +00001443 $st->set_synopsis($THIS_MODULE, translate_commands(next_argument()));
Fred Drake62e43691998-08-10 19:40:44 +00001444 return $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001445}
1446
1447sub do_cmd_localmoduletable{
1448 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001449 my $chap = get_chapter_id();
Fred Drake643d76d2000-09-09 06:07:37 +00001450 my $st = get_synopsis_table($chap);
1451 $st->set_file("$CURRENT_FILE");
Fred Drake557460c1999-03-02 16:05:35 +00001452 return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001453}
1454
1455sub process_all_localmoduletables{
Fred Drake643d76d2000-09-09 06:07:37 +00001456 my $key;
1457 my $st, $file;
1458 foreach $key (keys %ModuleSynopses) {
1459 $st = $ModuleSynopses{$key};
1460 $file = $st->get_file();
1461 if ($file) {
1462 process_localmoduletables_in_file($file);
1463 }
1464 else {
1465 print "\nsynopsis table $key has no file association";
1466 }
1467 }
1468}
1469
1470sub process_localmoduletables_in_file{
1471 my $file = @_[0];
1472 open(MYFILE, "<$file");
1473 local($_);
1474 sysread(MYFILE, $_, 1024*1024);
1475 close(MYFILE);
1476 # need to get contents of file in $_
Fred Drake557460c1999-03-02 16:05:35 +00001477 while (/<tex2html-localmoduletable><(\d+)>/) {
Fred Drakef7685d71998-07-25 03:31:46 +00001478 my $match = $&;
Fred Drakea0f4c941998-07-24 22:16:04 +00001479 my $chap = $1;
1480 my $st = get_synopsis_table($chap);
1481 my $data = $st->tohtml();
Fred Drakef7685d71998-07-25 03:31:46 +00001482 s/$match/$data/;
Fred Drakea0f4c941998-07-24 22:16:04 +00001483 }
Fred Drake643d76d2000-09-09 06:07:37 +00001484 open(MYFILE,">$file");
1485 print MYFILE $_;
1486 close(MYFILE);
Fred Drakea0f4c941998-07-24 22:16:04 +00001487}
Fred Drake557460c1999-03-02 16:05:35 +00001488sub process_python_state{
1489 process_all_localmoduletables();
Fred Drake557460c1999-03-02 16:05:35 +00001490}
Fred Drakea0f4c941998-07-24 22:16:04 +00001491
1492
1493#
1494# "See also:" -- references placed at the end of a \section
1495#
1496
1497sub do_env_seealso{
Fred Drakef1927a62001-06-20 21:29:30 +00001498 return ("<div class=\"seealso\">\n "
1499 . "<p class=\"heading\"><b>See Also:</b></p>\n"
1500 . @_[0]
1501 . '</div>');
Fred Drakea0f4c941998-07-24 22:16:04 +00001502}
1503
1504sub do_cmd_seemodule{
1505 # Insert the right magic to jump to the module definition. This should
1506 # work most of the time, at least for repeat builds....
1507 local($_) = @_;
1508 my $key = next_optional_argument();
1509 my $module = next_argument();
1510 my $text = next_argument();
Fred Drake84bd6f31999-05-11 15:42:51 +00001511 my $period = '.';
Fred Drakea0f4c941998-07-24 22:16:04 +00001512 $key = $module
1513 unless $key;
Fred Drake84bd6f31999-05-11 15:42:51 +00001514 if ($text =~ /\.$/) {
1515 $period = '';
1516 }
Fred Drakef1927a62001-06-20 21:29:30 +00001517 return ('<dl compact class="seemodule">'
1518 . "\n <dt>Module <b><tt class=\"module\">"
1519 . "<a href=\"module-$key.html\">$module</a></tt>:</b>"
1520 . "\n <dd>$text$period\n </dl>"
1521 . $_);
Fred Drakea0f4c941998-07-24 22:16:04 +00001522}
1523
Fred Drakee0197bf2001-04-12 04:03:22 +00001524sub strip_html_markup($){
1525 my $str = @_[0];
1526 my $s = "$str";
1527 $s =~ s/<[a-zA-Z0-9]+(\s+[a-zA-Z0-9]+(\s*=\s*(\'[^\']*\'|\"[^\"]*\"|[a-zA-Z0-9]+))?)*\s*>//g;
1528 $s =~ s/<\/[a-zA-Z0-9]+>//g;
1529 return $s;
1530}
1531
Fred Drake643d76d2000-09-09 06:07:37 +00001532sub handle_rfclike_reference{
Fred Drakeafc7ce12001-01-22 17:33:24 +00001533 local($_, $what, $format) = @_;
Fred Drake37cc0c02000-04-26 18:05:24 +00001534 my $rfcnum = next_argument();
1535 my $title = next_argument();
1536 my $text = next_argument();
Fred Drakeafc7ce12001-01-22 17:33:24 +00001537 my $url = get_rfc_url($rfcnum, $format);
Fred Drake7a40c072000-10-02 14:43:38 +00001538 my $icon = get_link_icon($url);
Fred Drakee0197bf2001-04-12 04:03:22 +00001539 my $attrtitle = strip_html_markup($title);
Fred Drake37cc0c02000-04-26 18:05:24 +00001540 return '<dl compact class="seerfc">'
1541 . "\n <dt><a href=\"$url\""
Fred Drakee0197bf2001-04-12 04:03:22 +00001542 . "\n title=\"$attrtitle\""
Fred Drake5f84c9b2000-10-03 06:05:25 +00001543 . "\n >$what $rfcnum, <em>$title</em>$icon</a>"
Fred Drake37cc0c02000-04-26 18:05:24 +00001544 . "\n <dd>$text\n </dl>"
1545 . $_;
1546}
1547
Fred Drake643d76d2000-09-09 06:07:37 +00001548sub do_cmd_seepep{
Fred Drakeafc7ce12001-01-22 17:33:24 +00001549 return handle_rfclike_reference(@_[0], "PEP", $PEP_FORMAT);
Fred Drake643d76d2000-09-09 06:07:37 +00001550}
1551
1552sub do_cmd_seerfc{
Fred Drakeafc7ce12001-01-22 17:33:24 +00001553 return handle_rfclike_reference(@_[0], "RFC", $RFC_FORMAT);
Fred Drake643d76d2000-09-09 06:07:37 +00001554}
1555
Fred Drake48449982000-09-12 17:52:33 +00001556sub do_cmd_seetitle{
1557 local($_) = @_;
1558 my $url = next_optional_argument();
1559 my $title = next_argument();
1560 my $text = next_argument();
1561 if ($url) {
Fred Drake5f84c9b2000-10-03 06:05:25 +00001562 my $icon = get_link_icon($url);
Fred Drake48449982000-09-12 17:52:33 +00001563 return '<dl compact class="seetitle">'
1564 . "\n <dt><em class=\"citetitle\"><a href=\"$url\""
Fred Drake7a40c072000-10-02 14:43:38 +00001565 . "\n >$title$icon</a></em>"
Fred Drake48449982000-09-12 17:52:33 +00001566 . "\n <dd>$text\n </dl>"
1567 . $_;
1568 }
1569 return '<dl compact class="seetitle">'
1570 . "\n <dt><em class=\"citetitle\""
1571 . "\n >$title</em>"
1572 . "\n <dd>$text\n </dl>"
1573 . $_;
1574}
1575
Fred Drakeef4d1112000-05-09 16:17:51 +00001576sub do_cmd_seeurl{
1577 local($_) = @_;
1578 my $url = next_argument();
1579 my $text = next_argument();
Fred Drake7a40c072000-10-02 14:43:38 +00001580 my $icon = get_link_icon($url);
Fred Drakeef4d1112000-05-09 16:17:51 +00001581 return '<dl compact class="seeurl">'
1582 . "\n <dt><a href=\"$url\""
Fred Drake7a40c072000-10-02 14:43:38 +00001583 . "\n class=\"url\">$url$icon</a>"
Fred Drakeef4d1112000-05-09 16:17:51 +00001584 . "\n <dd>$text\n </dl>"
1585 . $_;
1586}
1587
Fred Drakea0f4c941998-07-24 22:16:04 +00001588sub do_cmd_seetext{
Fred Drake79189b51999-04-28 13:54:30 +00001589 local($_) = @_;
1590 my $content = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +00001591 return '<div class="seetext"><p>' . $content . '</div>' . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001592}
1593
1594
1595#
Fred Drake885215c1998-05-20 21:32:09 +00001596# Definition list support.
1597#
1598
1599sub do_env_definitions{
Fred Drakef1927a62001-06-20 21:29:30 +00001600 return "<dl class=\"definitions\">" . @_[0] . "</dl>\n";
Fred Drake885215c1998-05-20 21:32:09 +00001601}
1602
1603sub do_cmd_term{
1604 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001605 my $term = next_argument();
1606 my($name,$aname,$ahref) = new_link_info();
Fred Drake885215c1998-05-20 21:32:09 +00001607 # could easily add an index entry here...
Fred Drake62e43691998-08-10 19:40:44 +00001608 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
Fred Drake885215c1998-05-20 21:32:09 +00001609}
1610
1611
Fred Drake38178fd2000-09-22 17:05:04 +00001612# I don't recall exactly why this was needed, but it was very much needed.
1613# We'll see if anything breaks when I move the "code" line out -- some
1614# things broke with it in.
1615
1616#code # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001617process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_);
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001618declaremodule # [] # {} # {}
1619memberline # [] # {}
1620methodline # [] # {} # {}
1621modulesynopsis # {}
Fred Drake557460c1999-03-02 16:05:35 +00001622platform # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001623samp # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001624setindexsubitem # {}
Fred Drakef32834c1999-02-12 22:06:32 +00001625withsubitem # {} # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001626_RAW_ARG_DEFERRED_CMDS_
1627
1628
Fred Drake86333602001-04-10 17:13:39 +00001629$alltt_start = '<dl><dd><pre class="verbatim">';
1630$alltt_end = '</pre></dl>';
1631
1632sub do_env_alltt {
1633 local ($_) = @_;
1634 local($closures,$reopens,@open_block_tags);
1635
1636 # get the tag-strings for all open tags
1637 local(@keep_open_tags) = @$open_tags_R;
1638 ($closures,$reopens) = &preserve_open_tags() if (@$open_tags_R);
1639
1640 # get the tags for text-level tags only
1641 $open_tags_R = [ @keep_open_tags ];
1642 local($local_closures, $local_reopens);
1643 ($local_closures, $local_reopens,@open_block_tags)
1644 = &preserve_open_block_tags
1645 if (@$open_tags_R);
1646
1647 $open_tags_R = [ @open_block_tags ];
1648
1649 do {
1650 local($open_tags_R) = [ @open_block_tags ];
1651 local(@save_open_tags) = ();
1652
1653 local($cnt) = ++$global{'max_id'};
1654 $_ = join('',"$O$cnt$C\\tt$O", ++$global{'max_id'}, $C
1655 , $_ , $O, $global{'max_id'}, "$C$O$cnt$C");
1656
1657 $_ = &translate_environments($_);
1658 $_ = &translate_commands($_) if (/\\/);
1659
1660 # preserve space-runs, using &nbsp;
1661 while (s/(\S) ( +)/$1$2;SPMnbsp;/g){};
1662 s/(<BR>) /$1;SPMnbsp;/g;
1663
1664 $_ = join('', $closures, $alltt_start, $local_reopens
1665 , $_
1666 , &balance_tags() #, $local_closures
1667 , $alltt_end, $reopens);
1668 undef $open_tags_R; undef @save_open_tags;
1669 };
1670 $open_tags_R = [ @keep_open_tags ];
1671 $_;
1672}
1673
Fred Drake57e52ef2001-06-15 21:31:57 +00001674sub do_cmd_verbatiminput{
1675 local($_) = @_;
1676 my $fname = next_argument();
1677 my $file;
1678 my $found = 0;
1679 my $texpath;
1680 # Search TEXINPUTS for the input file, the way we're supposed to:
1681 foreach $texpath (split /$envkey/, $TEXINPUTS) {
1682 $file = "$texpath$dd$fname";
1683 last if ($found = (-f $file));
1684 }
1685 my $text;
1686 if ($found) {
1687 open(MYFILE, "<$file") || die "\n$!\n";
1688 read(MYFILE, $text, 1024*1024);
1689 close(MYFILE);
1690 #
1691 # These rewrites convert the raw text to something that will
1692 # be properly visible as HTML and also will pass through the
1693 # vagaries of conversion through LaTeX2HTML. The order in
1694 # which the specific rewrites are performed is significant.
1695 #
1696 $text =~ s/\&/\&amp;/g;
1697 # These need to happen before the normal < and > re-writes,
1698 # since we need to avoid LaTeX2HTML's attempt to perform
1699 # ligature processing without regard to context (since it
1700 # doesn't have font information).
1701 $text =~ s/--/-&\#45;/g;
1702 $text =~ s/<</\&lt;\&\#60;/g;
1703 $text =~ s/>>/\&gt;\&\#62;/g;
1704 # Just normal re-writes...
1705 $text =~ s/</\&lt;/g;
1706 $text =~ s/>/\&gt;/g;
1707 # These last isn't needed for the HTML, but is needed to get
1708 # past LaTeX2HTML processing TeX macros. We use &#92; instead
1709 # of &sol; since many browsers don't support that.
1710 $text =~ s/\\/\&\#92;/g;
1711 }
1712 else {
1713 $text = '<b>Could not locate requested file <i>$fname</i>!</b>\n';
1714 }
1715 return ($alltt_start
1716 . $text
1717 . $alltt_end
1718 . $_);
1719}
Fred Drake86333602001-04-10 17:13:39 +00001720
Fred Drake6659c301998-03-03 22:02:19 +000017211; # This must be the last line