Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1 | # 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 | |
| 9 | package main; |
| 10 | |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 11 | use File::Basename; |
| 12 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 13 | |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 14 | sub next_argument{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 15 | 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 Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 19 | return $param; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | sub next_optional_argument{ |
| 23 | my($param,$rx) = ('', "^\\s*(\\[([^]]*)\\])?"); |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 24 | s/$rx/$param=$2;''/eo; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 25 | return $param; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 26 | } |
| 27 | |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 28 | sub 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 Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 39 | sub 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 Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 44 | return (" <img src=\"$icon\"\n" |
| 45 | . ' border="0" class="offsitelink"' |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 46 | . ($OFF_SITE_LINK_ICON_HEIGHT |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 47 | ? " height=\"$OFF_SITE_LINK_ICON_HEIGHT\"" |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 48 | : '') |
| 49 | . ($OFF_SITE_LINK_ICON_WIDTH |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 50 | ? " width=\"$OFF_SITE_LINK_ICON_WIDTH\"" |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 51 | : '') |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 52 | . " alt=\"[off-site link]\"\n" |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 53 | . " >"); |
| 54 | } |
| 55 | return ''; |
| 56 | } |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 57 | |
| 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 Drake | 5b73cdf | 1998-05-15 16:59:38 +0000 | [diff] [blame] | 60 | # Many possible uses of \let aren't supported or aren't supported correctly. |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 61 | # |
| 62 | sub do_cmd_let{ |
| 63 | local($_) = @_; |
| 64 | my $matched = 0; |
Fred Drake | 7a4ad0f | 1998-05-15 13:45:54 +0000 | [diff] [blame] | 65 | s/[\\]([a-zA-Z]+)\s*(=\s*)?[\\]([a-zA-Z]*)/$matched=1; ''/e; |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 66 | 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 Drake | 7a4ad0f | 1998-05-15 13:45:54 +0000 | [diff] [blame] | 71 | 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 Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 82 | return $_; |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | |
Fred Drake | c3fd45f | 2000-06-15 22:41:48 +0000 | [diff] [blame] | 86 | # the older version of LaTeX2HTML we use doesn't support this, but we use it: |
| 87 | |
| 88 | sub do_cmd_textasciitilde{ '~' . @_[0]; } |
Fred Drake | 056a71d | 2001-04-21 05:48:07 +0000 | [diff] [blame] | 89 | sub do_cmd_textasciicircum{ '^' . @_[0]; } |
Fred Drake | c3fd45f | 2000-06-15 22:41:48 +0000 | [diff] [blame] | 90 | |
| 91 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 92 | # words typeset in a special way (not in HTML though) |
| 93 | |
| 94 | sub do_cmd_ABC{ 'ABC' . @_[0]; } |
| 95 | sub do_cmd_UNIX{ 'Unix'. @_[0]; } |
| 96 | sub do_cmd_ASCII{ 'ASCII' . @_[0]; } |
| 97 | sub do_cmd_POSIX{ 'POSIX' . @_[0]; } |
| 98 | sub do_cmd_C{ 'C' . @_[0]; } |
| 99 | sub do_cmd_Cpp{ 'C++' . @_[0]; } |
| 100 | sub do_cmd_EOF{ 'EOF' . @_[0]; } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 101 | sub do_cmd_NULL{ '<tt class="constant">NULL</tt>' . @_[0]; } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 102 | |
| 103 | sub do_cmd_e{ '\' . @_[0]; } |
| 104 | |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 105 | $DEVELOPER_ADDRESS = ''; |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 106 | $SHORT_VERSION = ''; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 107 | $RELEASE_INFO = ''; |
Fred Drake | d04592a | 2000-10-25 16:15:13 +0000 | [diff] [blame] | 108 | $PACKAGE_VERSION = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 109 | |
Fred Drake | d04592a | 2000-10-25 16:15:13 +0000 | [diff] [blame] | 110 | sub do_cmd_version{ $PACKAGE_VERSION . @_[0]; } |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 111 | sub do_cmd_shortversion{ $SHORT_VERSION . @_[0]; } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 112 | sub do_cmd_release{ |
| 113 | local($_) = @_; |
Fred Drake | d04592a | 2000-10-25 16:15:13 +0000 | [diff] [blame] | 114 | $PACKAGE_VERSION = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 115 | return $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 116 | } |
| 117 | |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 118 | sub do_cmd_setreleaseinfo{ |
| 119 | local($_) = @_; |
| 120 | $RELEASE_INFO = next_argument(); |
| 121 | return $_; |
| 122 | } |
| 123 | |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 124 | sub do_cmd_setshortversion{ |
| 125 | local($_) = @_; |
| 126 | $SHORT_VERSION = next_argument(); |
| 127 | return $_; |
| 128 | } |
| 129 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 130 | sub do_cmd_authoraddress{ |
| 131 | local($_) = @_; |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 132 | $DEVELOPER_ADDRESS = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 133 | return $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 134 | } |
| 135 | |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 136 | #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 Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 139 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 140 | sub do_cmd_hackscore{ |
| 141 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 142 | next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 143 | return '_' . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 144 | } |
| 145 | |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 146 | sub use_wrappers{ |
| 147 | local($_,$before,$after) = @_; |
| 148 | my $stuff = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 149 | return $before . $stuff . $after . $_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 150 | } |
| 151 | |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 152 | $IN_DESC_HANDLER = 0; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 153 | sub do_cmd_optional{ |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 154 | 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 Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 161 | } |
| 162 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 163 | # 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 Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 167 | |
Fred Drake | 2cafcbb | 1999-03-25 16:57:04 +0000 | [diff] [blame] | 168 | # \file and \samp are at the end of this file since they screw up fontlock. |
| 169 | |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 170 | sub do_cmd_pytype{ return @_[0]; } |
Fred Drake | 3d5a04a | 2000-08-03 17:25:44 +0000 | [diff] [blame] | 171 | sub do_cmd_makevar{ |
| 172 | return use_wrappers(@_[0], '<span class="makevar">', '</span>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 173 | sub do_cmd_code{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 174 | return use_wrappers(@_[0], '<code>', '</code>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 175 | sub do_cmd_module{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 176 | return use_wrappers(@_[0], '<tt class="module">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 177 | sub do_cmd_keyword{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 178 | return use_wrappers(@_[0], '<tt class="keyword">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 179 | sub do_cmd_exception{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 180 | return use_wrappers(@_[0], '<tt class="exception">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 181 | sub do_cmd_class{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 182 | return use_wrappers(@_[0], '<tt class="class">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 183 | sub do_cmd_function{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 184 | return use_wrappers(@_[0], '<tt class="function">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 185 | sub do_cmd_constant{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 186 | return use_wrappers(@_[0], '<tt class="constant">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 187 | sub do_cmd_member{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 188 | return use_wrappers(@_[0], '<tt class="member">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 189 | sub do_cmd_method{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 190 | return use_wrappers(@_[0], '<tt class="method">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 191 | sub do_cmd_cfunction{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 192 | return use_wrappers(@_[0], '<tt class="cfunction">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 193 | sub do_cmd_cdata{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 194 | return use_wrappers(@_[0], '<tt class="cdata">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 195 | sub do_cmd_ctype{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 196 | return use_wrappers(@_[0], '<tt class="ctype">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 197 | sub do_cmd_regexp{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 198 | return use_wrappers(@_[0], '<tt class="regexp">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 199 | sub do_cmd_character{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 200 | return use_wrappers(@_[0], '"<tt class="character">', '</tt>"'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 201 | sub do_cmd_program{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 202 | return use_wrappers(@_[0], '<b class="program">', '</b>'); } |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 203 | sub do_cmd_programopt{ |
| 204 | return use_wrappers(@_[0], '<b class="programopt">', '</b>'); } |
Fred Drake | 0cd6021 | 2000-04-11 18:46:59 +0000 | [diff] [blame] | 205 | sub do_cmd_longprogramopt{ |
| 206 | # note that the --- will be later converted to -- by LaTeX2HTML |
| 207 | return use_wrappers(@_[0], '<b class="programopt">---', '</b>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 208 | sub do_cmd_email{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 209 | return use_wrappers(@_[0], '<span class="email">', '</span>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 210 | sub do_cmd_mimetype{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 211 | return use_wrappers(@_[0], '<span class="mimetype">', '</span>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 212 | sub do_cmd_var{ |
| 213 | return use_wrappers(@_[0], "<var>", "</var>"); } |
| 214 | sub do_cmd_dfn{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 215 | return use_wrappers(@_[0], '<i class="dfn">', '</i>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 216 | sub do_cmd_emph{ |
Fred Drake | 38178fd | 2000-09-22 17:05:04 +0000 | [diff] [blame] | 217 | return use_wrappers(@_[0], '<i>', '</i>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 218 | sub do_cmd_file{ |
Fred Drake | 3d5a04a | 2000-08-03 17:25:44 +0000 | [diff] [blame] | 219 | return use_wrappers(@_[0], '<span class="file">', '</span>'); } |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 220 | sub do_cmd_filenq{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 221 | return do_cmd_file(@_[0]); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 222 | sub do_cmd_samp{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 223 | return use_wrappers(@_[0], '"<tt class="samp">', '</tt>"'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 224 | sub do_cmd_kbd{ |
| 225 | return use_wrappers(@_[0], '<kbd>', '</kbd>'); } |
| 226 | sub do_cmd_strong{ |
| 227 | return use_wrappers(@_[0], '<b>', '</b>'); } |
Fred Drake | 2cafcbb | 1999-03-25 16:57:04 +0000 | [diff] [blame] | 228 | sub do_cmd_textbf{ |
| 229 | return use_wrappers(@_[0], '<b>', '</b>'); } |
| 230 | sub do_cmd_textit{ |
| 231 | return use_wrappers(@_[0], '<i>', '</i>'); } |
| 232 | |
Fred Drake | 3d5a04a | 2000-08-03 17:25:44 +0000 | [diff] [blame] | 233 | sub do_cmd_moreargs{ |
| 234 | return '...' . @_[0]; } |
| 235 | sub do_cmd_unspecified{ |
| 236 | return '...' . @_[0]; } |
| 237 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 238 | |
Fred Drake | 2581704 | 1999-01-13 17:06:34 +0000 | [diff] [blame] | 239 | sub 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 Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 246 | return "<tt class=\"module\"><a href=\"module-$key.html\">$module</a></tt>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 247 | . $_; |
Fred Drake | 2581704 | 1999-01-13 17:06:34 +0000 | [diff] [blame] | 248 | } |
| 249 | |
Fred Drake | 1a7af39 | 1998-04-01 22:44:56 +0000 | [diff] [blame] | 250 | sub do_cmd_newsgroup{ |
| 251 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 252 | my $newsgroup = next_argument(); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 253 | my $icon = get_link_icon("news:$newsgroup"); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 254 | my $stuff = ("<a class=\"newsgroup\" href=\"news:$newsgroup\">" |
| 255 | . "$newsgroup$icon</a>"); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 256 | return $stuff . $_; |
Fred Drake | 1a7af39 | 1998-04-01 22:44:56 +0000 | [diff] [blame] | 257 | } |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 258 | |
| 259 | sub do_cmd_envvar{ |
| 260 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 261 | my $envvar = next_argument(); |
| 262 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 263 | # The <tt> here is really to keep buildindex.py from making |
| 264 | # the variable name case-insensitive. |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 265 | add_index_entry("environment variables!$envvar@<tt>$envvar</tt>", |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 266 | $ahref); |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 267 | add_index_entry("$envvar (environment variable)", $ahref); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 268 | $aname =~ s/<a/<a class="envvar"/; |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 269 | return "$aname$envvar</a>" . $_; |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 270 | } |
| 271 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 272 | sub do_cmd_url{ |
| 273 | # use the URL as both text and hyperlink |
| 274 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 275 | my $url = next_argument(); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 276 | my $icon = get_link_icon($url); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 277 | $url =~ s/~/~/g; |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 278 | return "<a class=\"url\" href=\"$url\">$url$icon</a>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | sub do_cmd_manpage{ |
| 282 | # two parameters: \manpage{name}{section} |
| 283 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 284 | my $page = next_argument(); |
| 285 | my $section = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 286 | return "<span class=\"manpage\"><i>$page</i>($section)</span>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 287 | } |
| 288 | |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 289 | $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 Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 292 | |
| 293 | sub get_rfc_url($$){ |
| 294 | my($rfcnum, $format) = @_; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 295 | return sprintf($format, $rfcnum); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | sub do_cmd_pep{ |
| 299 | local($_) = @_; |
| 300 | my $rfcnumber = next_argument(); |
| 301 | my $id = "rfcref-" . ++$global{'max_id'}; |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 302 | my $href = get_rfc_url($rfcnumber, $PEP_FORMAT); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 303 | my $icon = get_link_icon($href); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 304 | # Save the reference |
| 305 | my $nstr = gen_index_id("Python Enhancement Proposals!PEP $rfcnumber", ''); |
| 306 | $index{$nstr} .= make_half_href("$CURRENT_FILE#$id"); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 307 | return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">PEP $rfcnumber" |
| 308 | . "$icon</a>" . $_); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 309 | } |
| 310 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 311 | sub do_cmd_rfc{ |
| 312 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 313 | my $rfcnumber = next_argument(); |
| 314 | my $id = "rfcref-" . ++$global{'max_id'}; |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 315 | my $href = get_rfc_url($rfcnumber, $RFC_FORMAT); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 316 | my $icon = get_link_icon($href); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 317 | # Save the reference |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 318 | my $nstr = gen_index_id("RFC!RFC $rfcnumber", ''); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 319 | $index{$nstr} .= make_half_href("$CURRENT_FILE#$id"); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 320 | return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">RFC $rfcnumber" |
| 321 | . "$icon</a>" . $_); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 322 | } |
| 323 | |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 324 | sub do_cmd_citetitle{ |
| 325 | local($_) = @_; |
| 326 | my $url = next_optional_argument(); |
| 327 | my $title = next_argument(); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 328 | my $icon = get_link_icon($url); |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 329 | my $repl = ''; |
| 330 | if ($url) { |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 331 | $repl = ("<em class=\"citetitle\"><a\n" |
| 332 | . " href=\"$url\"\n" |
| 333 | . " title=\"$title\"\n" |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 334 | . " >$title$icon</a></em>"); |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 335 | } |
| 336 | else { |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 337 | $repl = "<em class=\"citetitle\"\n >$title</em>"; |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 338 | } |
| 339 | return $repl . $_; |
| 340 | } |
| 341 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 342 | sub do_cmd_deprecated{ |
| 343 | # two parameters: \deprecated{version}{whattodo} |
| 344 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 345 | my $release = next_argument(); |
| 346 | my $reason = next_argument(); |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 347 | return ('<div class="versionnote">' |
| 348 | . "<b>Deprecated since release $release.</b>" |
| 349 | . "\n$reason</div><p>" |
| 350 | . $_); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 351 | } |
| 352 | |
Fred Drake | c2b29d0 | 2001-04-18 03:11:04 +0000 | [diff] [blame] | 353 | sub versionnote{ |
| 354 | # one or two parameters: \versionnote[explanation]{version} |
| 355 | my $type = @_[0]; |
| 356 | local $_ = @_[1]; |
| 357 | my $explanation = next_optional_argument(); |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 358 | my $release = next_argument(); |
Fred Drake | c2b29d0 | 2001-04-18 03:11:04 +0000 | [diff] [blame] | 359 | my $text = "$type in version $release."; |
| 360 | if ($explanation) { |
| 361 | $text = "$type in version $release:\n$explanation."; |
| 362 | } |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 363 | return "\n<span class=\"versionnote\">$text</span>\n" . $_; |
Fred Drake | c2b29d0 | 2001-04-18 03:11:04 +0000 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | sub do_cmd_versionadded{ |
| 367 | return versionnote('New', @_); |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | sub do_cmd_versionchanged{ |
Fred Drake | c2b29d0 | 2001-04-18 03:11:04 +0000 | [diff] [blame] | 371 | return versionnote('Changed', @_); |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 372 | } |
| 373 | |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 374 | # |
Fred Drake | 2cafcbb | 1999-03-25 16:57:04 +0000 | [diff] [blame] | 375 | # These function handle platform dependency tracking. |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 376 | # |
| 377 | sub do_cmd_platform{ |
| 378 | local($_) = @_; |
| 379 | my $platform = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 380 | $ModulePlatforms{"<tt class=\"module\">$THIS_MODULE</tt>"} = $platform; |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 381 | $platform = "Macintosh" |
Fred Drake | 085b812 | 1999-04-21 14:00:29 +0000 | [diff] [blame] | 382 | if $platform eq 'Mac'; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 383 | return "\n<p class=\"availability\">Availability: <span" |
| 384 | . "\n class=\"platform\">$platform</span>.</p>\n" . $_; |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 385 | } |
| 386 | |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 387 | $IGNORE_PLATFORM_ANNOTATION = ''; |
| 388 | sub do_cmd_ignorePlatformAnnotation{ |
| 389 | local($_) = @_; |
| 390 | $IGNORE_PLATFORM_ANNOTATION = next_argument(); |
| 391 | return $_; |
| 392 | } |
| 393 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 394 | |
| 395 | # index commands |
| 396 | |
| 397 | $INDEX_SUBITEM = ""; |
| 398 | |
| 399 | sub get_indexsubitem{ |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 400 | return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | sub do_cmd_setindexsubitem{ |
| 404 | local($_) = @_; |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 405 | $INDEX_SUBITEM = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 406 | return $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 407 | } |
| 408 | |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 409 | sub do_cmd_withsubitem{ |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 410 | # We can't really do the right thing, because LaTeX2HTML doesn't |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 411 | # 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 Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 415 | my $oldsubitem = $INDEX_SUBITEM; |
| 416 | $INDEX_SUBITEM = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 417 | my $stuff = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 418 | my $br_id = ++$globals{'max_id'}; |
| 419 | my $marker = "$O$br_id$C"; |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 420 | return |
| 421 | $stuff |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 422 | . "\\setindexsubitem$marker$oldsubitem$marker" |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 423 | . $_; |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 424 | } |
| 425 | |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 426 | # This is the prologue macro which is required to start writing the |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 427 | # mod\jobname.idx file; we can just ignore it. (Defining this suppresses |
| 428 | # a warning that \makemodindex is unknown.) |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 429 | # |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 430 | sub do_cmd_makemodindex{ return @_[0]; } |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 431 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 432 | # We're in the document subdirectory when this happens! |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 433 | # |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 434 | open(IDXFILE, '>index.dat') || die "\n$!\n"; |
| 435 | open(INTLABELS, '>intlabels.pl') || die "\n$!\n"; |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 436 | print INTLABELS "%internal_labels = ();\n"; |
| 437 | print 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 Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 444 | sub write_idxfile{ |
| 445 | my ($ahref, $str) = @_; |
| 446 | print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 447 | } |
| 448 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 449 | |
| 450 | sub gen_link{ |
| 451 | my($node,$target) = @_; |
| 452 | print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n"; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 453 | return "<a href=\"$node#$target\">"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 454 | } |
| 455 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 456 | sub 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 Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 461 | write_idxfile($ahref, $str); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 462 | } |
| 463 | |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 464 | sub new_link_info{ |
| 465 | my $name = "l2h-" . ++$globals{'max_id'}; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 466 | my $aname = "<a name=\"$name\">"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 467 | my $ahref = gen_link($CURRENT_FILE, $name); |
| 468 | return ($name, $aname, $ahref); |
| 469 | } |
| 470 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 471 | $IndexMacroPattern = ''; |
| 472 | sub 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; |
| 492 | sub process_index_macros{ |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 493 | local($_) = @_; |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 494 | my $cmdname = @_[1]; # This is what triggered us in the first place; |
| 495 | # we know it's real, so just process it. |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 496 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 497 | 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 Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 514 | if (/^[ \t\r\n]/) { |
| 515 | $_ = substr($_, 1); |
| 516 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 517 | return "$aname$anchor_invisible_mark</a>" . $_; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 518 | } |
| 519 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 520 | define_indexing_macro('index'); |
| 521 | sub idx_cmd_index{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 522 | my $str = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 523 | add_index_entry("$str", @_[0]); |
Fred Drake | 2e7edb8 | 1998-05-11 18:31:17 +0000 | [diff] [blame] | 524 | } |
| 525 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 526 | define_indexing_macro('kwindex'); |
| 527 | sub 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 | |
| 533 | define_indexing_macro('indexii'); |
| 534 | sub idx_cmd_indexii{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 535 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 536 | my $str2 = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 537 | add_index_entry("$str1!$str2", @_[0]); |
| 538 | add_index_entry("$str2!$str1", @_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 539 | } |
| 540 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 541 | define_indexing_macro('indexiii'); |
| 542 | sub idx_cmd_indexiii{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 543 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 544 | my $str2 = next_argument(); |
| 545 | my $str3 = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 546 | add_index_entry("$str1!$str2 $str3", @_[0]); |
| 547 | add_index_entry("$str2!$str3, $str1", @_[0]); |
| 548 | add_index_entry("$str3!$str1 $str2", @_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 549 | } |
| 550 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 551 | define_indexing_macro('indexiv'); |
| 552 | sub idx_cmd_indexiv{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 553 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 554 | my $str2 = next_argument(); |
| 555 | my $str3 = next_argument(); |
| 556 | my $str4 = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 557 | 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 Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 561 | } |
| 562 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 563 | define_indexing_macro('ttindex'); |
| 564 | sub idx_cmd_ttindex{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 565 | my $str = next_argument(); |
| 566 | my $entry = $str . get_indexsubitem(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 567 | add_index_entry($entry, @_[0]); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 568 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 569 | |
| 570 | sub my_typed_index_helper{ |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 571 | my($word,$ahref) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 572 | my $str = next_argument(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 573 | add_index_entry("$str $word", $ahref); |
| 574 | add_index_entry("$word!$str", $ahref); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 575 | } |
| 576 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 577 | define_indexing_macro('stindex', 'opindex', 'exindex', 'obindex'); |
| 578 | sub idx_cmd_stindex{ my_typed_index_helper('statement', @_[0]); } |
| 579 | sub idx_cmd_opindex{ my_typed_index_helper('operator', @_[0]); } |
| 580 | sub idx_cmd_exindex{ my_typed_index_helper('exception', @_[0]); } |
| 581 | sub idx_cmd_obindex{ my_typed_index_helper('object', @_[0]); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 582 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 583 | define_indexing_macro('bifuncindex'); |
| 584 | sub idx_cmd_bifuncindex{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 585 | my $str = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 586 | add_index_entry("<tt class=\"function\">$str()</tt> (built-in function)", |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 587 | @_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 588 | } |
| 589 | |
| 590 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 591 | sub make_mod_index_entry{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 592 | my($str,$define) = @_; |
| 593 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 594 | # equivalent of add_index_entry() using $define instead of '' |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 595 | $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/ |
| 596 | if ($define eq 'DEF'); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 597 | $str = gen_index_id($str, $define); |
| 598 | $index{$str} .= $ahref; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 599 | write_idxfile($ahref, $str); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 600 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 601 | if ($define eq 'DEF') { |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 602 | # add to the module index |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 603 | $str =~ /(<tt.*<\/tt>)/; |
| 604 | my $nstr = $1; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 605 | $Modules{$nstr} .= $ahref; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 606 | } |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 607 | return "$aname$anchor_invisible_mark2</a>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 608 | } |
| 609 | |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 610 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 611 | $THIS_MODULE = ''; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 612 | $THIS_CLASS = ''; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 613 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 614 | sub define_module{ |
| 615 | my($word,$name) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 616 | my $section_tag = join('', @curr_sec_id); |
Fred Drake | 3e4c614 | 1999-05-17 15:00:32 +0000 | [diff] [blame] | 617 | 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 Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 623 | $word = "$word " if $word; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 624 | $THIS_MODULE = "$name"; |
Fred Drake | 5942b43 | 2000-10-30 06:24:56 +0000 | [diff] [blame] | 625 | $INDEX_SUBITEM = "(in module $name)"; |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 626 | print "[$name]"; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 627 | return make_mod_index_entry( |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 628 | "<tt class=\"module\">$name</tt> (${word}module)", 'DEF'); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 629 | } |
| 630 | |
| 631 | sub my_module_index_helper{ |
| 632 | local($word, $_) = @_; |
| 633 | my $name = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 634 | return define_module($word, $name) . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 635 | } |
| 636 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 637 | sub do_cmd_modindex{ return my_module_index_helper('', @_); } |
| 638 | sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); } |
| 639 | sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); } |
| 640 | sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 641 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 642 | sub ref_module_index_helper{ |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 643 | my($word, $ahref) = @_; |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 644 | my $str = next_argument(); |
| 645 | $word = "$word " if $word; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 646 | $str = "<tt class=\"module\">$str</tt> (${word}module)"; |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 647 | # 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 Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 654 | # these should be adjusted a bit.... |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 655 | define_indexing_macro('refmodindex', 'refbimodindex', |
| 656 | 'refexmodindex', 'refstmodindex'); |
| 657 | sub idx_cmd_refmodindex{ return ref_module_index_helper('', @_); } |
| 658 | sub idx_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); } |
| 659 | sub idx_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); } |
| 660 | sub idx_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 661 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 662 | sub do_cmd_nodename{ return do_cmd_label(@_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 663 | |
| 664 | sub init_myformat{ |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 665 | $anchor_invisible_mark = ' '; |
| 666 | $anchor_invisible_mark2 = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 667 | $anchor_mark = ''; |
| 668 | $icons{'anchor_mark'} = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 669 | } |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 670 | init_myformat(); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 671 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 672 | # Create an index entry, but include the string in the target anchor |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 673 | # instead of the dummy filler. |
| 674 | # |
| 675 | sub make_str_index_entry{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 676 | my($str) = @_; |
| 677 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 678 | add_index_entry($str, $ahref); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 679 | return "$aname$str</a>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 680 | } |
| 681 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 682 | $REFCOUNTS_LOADED = 0; |
| 683 | |
| 684 | sub load_refcounts{ |
| 685 | $REFCOUNTS_LOADED = 1; |
| 686 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 687 | 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 Drake | c2578c5 | 2000-04-10 18:26:45 +0000 | [diff] [blame] | 699 | if (/([a-zA-Z0-9_]+):PyObject\*:([a-zA-Z0-9_]*):(0|[-+]1|null):(.*)$/) { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 700 | my($func, $param, $count, $comment) = ($1, $2, $3, $4); |
| 701 | #print "\n$func($param) --> $count"; |
| 702 | $REFCOUNTS{"$func:$param"} = $count; |
| 703 | } |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | sub get_refcount{ |
| 708 | my ($func, $param) = @_; |
| 709 | load_refcounts() |
| 710 | unless $REFCOUNTS_LOADED; |
| 711 | return $REFCOUNTS{"$func:$param"}; |
| 712 | } |
| 713 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 714 | sub do_env_cfuncdesc{ |
| 715 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 716 | my $return_type = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 717 | my $function_name = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 718 | my $arg_list = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 719 | my $idx = make_str_index_entry( |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 720 | "<tt class=\"cfunction\">$function_name()</tt>" . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 721 | $idx =~ s/ \(.*\)//; |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 722 | $idx =~ s/\(\)//; # ???? - why both of these? |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 723 | my $result_rc = get_refcount($function_name, ''); |
| 724 | my $rcinfo = ''; |
| 725 | if ($result_rc eq '+1') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 726 | $rcinfo = 'New reference'; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 727 | } |
| 728 | elsif ($result_rc eq '0') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 729 | $rcinfo = 'Borrowed reference'; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 730 | } |
Fred Drake | c2578c5 | 2000-04-10 18:26:45 +0000 | [diff] [blame] | 731 | elsif ($result_rc eq 'null') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 732 | $rcinfo = 'Always <tt class="constant">NULL</tt>'; |
Fred Drake | c2578c5 | 2000-04-10 18:26:45 +0000 | [diff] [blame] | 733 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 734 | if ($rcinfo ne '') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 735 | $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 Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 739 | } |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 740 | return "<dl><dt>$return_type <b>$idx</b>(<var>$arg_list</var>)\n<dd>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 741 | . $rcinfo |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 742 | . $_ |
| 743 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 744 | } |
| 745 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 746 | sub do_env_csimplemacrodesc{ |
| 747 | local($_) = @_; |
| 748 | my $name = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 749 | my $idx = make_str_index_entry("<tt class=\"macro\">$name</tt>"); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 750 | return "<dl><dt><b>$idx</b>\n<dd>" |
| 751 | . $_ |
| 752 | . '</dl>' |
| 753 | } |
| 754 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 755 | sub do_env_ctypedesc{ |
| 756 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 757 | my $index_name = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 758 | my $type_name = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 759 | $index_name = $type_name |
| 760 | unless $index_name; |
| 761 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 762 | 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 Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 764 | . $_ |
| 765 | . '</dl>' |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 766 | } |
| 767 | |
| 768 | sub do_env_cvardesc{ |
| 769 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 770 | my $var_type = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 771 | my $var_name = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 772 | my $idx = make_str_index_entry("<tt class=\"cdata\">$var_name</tt>" |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 773 | . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 774 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 775 | return "<dl><dt>$var_type <b>$idx</b>\n" |
| 776 | . '<dd>' |
| 777 | . $_ |
| 778 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 779 | } |
| 780 | |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 781 | sub convert_args($){ |
| 782 | local($IN_DESC_HANDLER) = 1; |
| 783 | local($_) = @_; |
| 784 | return translate_commands($_); |
| 785 | } |
| 786 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 787 | sub do_env_funcdesc{ |
| 788 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 789 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 790 | my $arg_list = convert_args(next_argument()); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 791 | my $idx = make_str_index_entry("<tt class=\"function\">$function_name()" |
| 792 | . '</tt>' |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 793 | . get_indexsubitem()); |
| 794 | $idx =~ s/ \(.*\)//; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 795 | $idx =~ s/\(\)<\/tt>/<\/tt>/; |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 796 | return "<dl><dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" . $_ . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 797 | } |
| 798 | |
| 799 | sub do_env_funcdescni{ |
| 800 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 801 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 802 | my $arg_list = convert_args(next_argument()); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 803 | return "<dl><dt><b><tt class=\"function\">$function_name</tt></b>" |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 804 | . "(<var>$arg_list</var>)\n" |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 805 | . '<dd>' |
| 806 | . $_ |
| 807 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 808 | } |
| 809 | |
| 810 | sub do_cmd_funcline{ |
| 811 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 812 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 813 | my $arg_list = convert_args(next_argument()); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 814 | my $prefix = "<tt class=\"function\">$function_name()</tt>"; |
Fred Drake | ca675e4 | 1999-04-21 15:58:58 +0000 | [diff] [blame] | 815 | my $idx = make_str_index_entry($prefix . get_indexsubitem()); |
| 816 | $prefix =~ s/\(\)//; |
| 817 | |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 818 | return "<dt><b>$prefix</b>(<var>$arg_list</var>)\n<dd>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 819 | } |
| 820 | |
Fred Drake | 6b3fb78 | 1999-07-12 16:50:09 +0000 | [diff] [blame] | 821 | sub do_cmd_funclineni{ |
| 822 | local($_) = @_; |
| 823 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 824 | my $arg_list = convert_args(next_argument()); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 825 | my $prefix = "<tt class=\"function\">$function_name</tt>"; |
Fred Drake | 6b3fb78 | 1999-07-12 16:50:09 +0000 | [diff] [blame] | 826 | |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 827 | return "<dt><b>$prefix</b>(<var>$arg_list</var>)\n<dd>" . $_; |
Fred Drake | 6b3fb78 | 1999-07-12 16:50:09 +0000 | [diff] [blame] | 828 | } |
| 829 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 830 | # 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 | |
| 836 | sub do_env_opcodedesc{ |
| 837 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 838 | my $opcode_name = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 839 | my $arg_list = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 840 | my $idx; |
| 841 | if ($INDEX_OPCODES) { |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 842 | $idx = make_str_index_entry("<tt class=\"opcode\">$opcode_name</tt>" |
| 843 | . ' (byte code instruction)'); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 844 | $idx =~ s/ \(byte code instruction\)//; |
| 845 | } |
| 846 | else { |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 847 | $idx = "<tt class=\"opcode\">$opcode_name</tt>"; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 848 | } |
| 849 | my $stuff = "<dl><dt><b>$idx</b>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 850 | if ($arg_list) { |
| 851 | $stuff .= " <var>$arg_list</var>"; |
| 852 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 853 | return $stuff . "\n<dd>" . $_ . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | sub do_env_datadesc{ |
| 857 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 858 | my $dataname = next_argument(); |
| 859 | my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 860 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 861 | return "<dl><dt><b>$idx</b>\n<dd>" |
| 862 | . $_ |
| 863 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 864 | } |
| 865 | |
| 866 | sub do_env_datadescni{ |
| 867 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 868 | my $idx = next_argument(); |
| 869 | if (! $STRING_INDEX_TT) { |
| 870 | $idx = "<tt>$idx</tt>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 871 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 872 | return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 873 | } |
| 874 | |
| 875 | sub do_cmd_dataline{ |
| 876 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 877 | my $data_name = next_argument(); |
| 878 | my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem()); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 879 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 880 | return "<dt><b>$idx</b><dd>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 881 | } |
| 882 | |
Fred Drake | adb272c | 2000-04-10 17:47:14 +0000 | [diff] [blame] | 883 | sub do_cmd_datalineni{ |
| 884 | local($_) = @_; |
| 885 | my $data_name = next_argument(); |
| 886 | return "<dt><b><tt>$data_name</tt></b><dd>" . $_; |
| 887 | } |
| 888 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 889 | sub do_env_excdesc{ |
| 890 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 891 | my $excname = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 892 | my $idx = make_str_index_entry("<tt class=\"exception\">$excname</tt>"); |
Fred Drake | ab357ec | 2001-03-02 18:57:05 +0000 | [diff] [blame] | 893 | return "<dl><dt><b>exception $idx</b>\n<dd>" . $_ . '</dl>' |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 894 | } |
| 895 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 896 | sub do_env_fulllineitems{ return do_env_itemize(@_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 897 | |
| 898 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 899 | sub handle_classlike_descriptor{ |
| 900 | local($_, $what) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 901 | $THIS_CLASS = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 902 | my $arg_list = convert_args(next_argument()); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 903 | $idx = make_str_index_entry( |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 904 | "<tt class=\"$what\">$THIS_CLASS</tt> ($what in $THIS_MODULE)" ); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 905 | $idx =~ s/ \(.*\)//; |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 906 | return ("<dl><dt><b>$what $idx</b>(<var>$arg_list</var>)\n<dd>" |
Fred Drake | ab357ec | 2001-03-02 18:57:05 +0000 | [diff] [blame] | 907 | . $_ |
| 908 | . '</dl>'); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 909 | } |
| 910 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 911 | sub do_env_classdesc{ |
| 912 | return handle_classlike_descriptor(@_[0], "class"); |
| 913 | } |
| 914 | |
Fred Drake | 06a01e8 | 2001-05-11 01:00:30 +0000 | [diff] [blame] | 915 | sub do_env_classdescstar{ |
| 916 | local($_) = @_; |
| 917 | $THIS_CLASS = next_argument(); |
| 918 | $idx = make_str_index_entry( |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 919 | "<tt class=\"class\">$THIS_CLASS</tt> (class in $THIS_MODULE)"); |
Fred Drake | 06a01e8 | 2001-05-11 01:00:30 +0000 | [diff] [blame] | 920 | $idx =~ s/ \(.*\)//; |
| 921 | return ("<dl><dt><b>class $idx</b>\n<dd>" |
| 922 | . $_ |
| 923 | . '</dl>'); |
| 924 | } |
| 925 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 926 | sub do_env_excclassdesc{ |
| 927 | return handle_classlike_descriptor(@_[0], "exception"); |
| 928 | } |
| 929 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 930 | |
| 931 | sub do_env_methoddesc{ |
| 932 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 933 | my $class_name = next_optional_argument(); |
| 934 | $class_name = $THIS_CLASS |
| 935 | unless $class_name; |
Fred Drake | 5a0ca4e | 1999-01-12 04:16:51 +0000 | [diff] [blame] | 936 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 937 | my $arg_list = convert_args(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 938 | my $extra = ''; |
| 939 | if ($class_name) { |
| 940 | $extra = " ($class_name method)"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 941 | } |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 942 | my $idx = make_str_index_entry( |
| 943 | "<tt class=\"method\">$method()</tt>$extra"); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 944 | $idx =~ s/ \(.*\)//; |
| 945 | $idx =~ s/\(\)//; |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 946 | return "<dl><dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" . $_ . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 947 | } |
| 948 | |
| 949 | |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 950 | sub 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 Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 956 | my $arg_list = convert_args(next_argument()); |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 957 | my $extra = ''; |
| 958 | if ($class_name) { |
| 959 | $extra = " ($class_name method)"; |
| 960 | } |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 961 | my $idx = make_str_index_entry( |
| 962 | "<tt class=\"method\">$method()</tt>$extra"); |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 963 | $idx =~ s/ \(.*\)//; |
| 964 | $idx =~ s/\(\)//; |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 965 | return "<dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 966 | . $_; |
| 967 | } |
| 968 | |
| 969 | |
Fred Drake | d64a40d | 1998-09-10 18:59:13 +0000 | [diff] [blame] | 970 | sub do_cmd_methodlineni{ |
| 971 | local($_) = @_; |
| 972 | next_optional_argument(); |
| 973 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 974 | my $arg_list = convert_args(next_argument()); |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 975 | return "<dt><b>$method</b>(<var>$arg_list</var>)\n<dd>" |
Fred Drake | d64a40d | 1998-09-10 18:59:13 +0000 | [diff] [blame] | 976 | . $_; |
| 977 | } |
| 978 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 979 | sub do_env_methoddescni{ |
| 980 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 981 | next_optional_argument(); |
| 982 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 983 | my $arg_list = convert_args(next_argument()); |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 984 | return "<dl><dt><b>$method</b>(<var>$arg_list</var>)\n<dd>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 985 | . $_ |
| 986 | . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 987 | } |
| 988 | |
| 989 | |
| 990 | sub do_env_memberdesc{ |
| 991 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 992 | my $class = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 993 | my $member = next_argument(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 994 | $class = $THIS_CLASS |
| 995 | unless $class; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 996 | my $extra = ''; |
Fred Drake | 085b812 | 1999-04-21 14:00:29 +0000 | [diff] [blame] | 997 | $extra = " ($class attribute)" |
| 998 | if ($class ne ''); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 999 | my $idx = make_str_index_entry("<tt class=\"member\">$member</tt>$extra"); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1000 | $idx =~ s/ \(.*\)//; |
| 1001 | $idx =~ s/\(\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1002 | return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1003 | } |
| 1004 | |
| 1005 | |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1006 | sub do_cmd_memberline{ |
| 1007 | local($_) = @_; |
| 1008 | my $class = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1009 | my $member = next_argument(); |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1010 | $class = $THIS_CLASS |
| 1011 | unless $class; |
| 1012 | my $extra = ''; |
Fred Drake | 085b812 | 1999-04-21 14:00:29 +0000 | [diff] [blame] | 1013 | $extra = " ($class attribute)" |
| 1014 | if ($class ne ''); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 1015 | my $idx = make_str_index_entry("<tt class=\"member\">$member</tt>$extra"); |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1016 | $idx =~ s/ \(.*\)//; |
| 1017 | $idx =~ s/\(\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1018 | return "<dt><b>$idx</b><dd>" . $_; |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1019 | } |
| 1020 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1021 | sub do_env_memberdescni{ |
| 1022 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1023 | next_optional_argument(); |
| 1024 | my $member = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 1025 | return "<dl><dt><b><tt class=\"member\">$member</tt></b>\n<dd>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1026 | . $_ |
| 1027 | . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1028 | } |
| 1029 | |
| 1030 | |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1031 | sub do_cmd_memberlineni{ |
| 1032 | local($_) = @_; |
| 1033 | next_optional_argument(); |
| 1034 | my $member = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 1035 | return "<dt><b><tt class=\"member\">$member</tt></b><dd>" . $_; |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1036 | } |
| 1037 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1038 | @col_aligns = ('<td>', '<td>', '<td>', '<td>'); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1039 | |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1040 | sub 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 Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1048 | $font = 'tt class="file"'; |
| 1049 | } |
| 1050 | elsif ($font eq 'member') { |
| 1051 | $font = 'tt class="member"'; |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1052 | } |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1053 | elsif ($font eq 'class') { |
| 1054 | $font = 'tt class="class"'; |
| 1055 | } |
Fred Drake | 7388f73 | 2000-06-28 21:06:08 +0000 | [diff] [blame] | 1056 | elsif ($font eq 'constant') { |
| 1057 | $font = 'tt class="constant"'; |
| 1058 | } |
Fred Drake | cb0fc9c | 2000-08-09 13:45:04 +0000 | [diff] [blame] | 1059 | elsif ($font eq 'kbd') { |
| 1060 | $font = 'kbd'; |
| 1061 | } |
Fred Drake | d04592a | 2000-10-25 16:15:13 +0000 | [diff] [blame] | 1062 | elsif ($font eq 'programopt') { |
| 1063 | $font = 'b'; |
| 1064 | } |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 1065 | elsif ($font eq 'exception') { |
| 1066 | $font = 'tt class="exception"'; |
| 1067 | } |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1068 | return $font; |
| 1069 | } |
| 1070 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1071 | sub 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 Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1086 | sub setup_column_alignments{ |
| 1087 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1088 | 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 Drake | 79189b5 | 1999-04-28 13:54:30 +0000 | [diff] [blame] | 1097 | # return the aligned header start tags |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1098 | return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>"); |
| 1099 | } |
| 1100 | |
| 1101 | sub 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 Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1109 | return ($sfont, $efont); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1110 | } |
| 1111 | |
| 1112 | sub do_env_tableii{ |
| 1113 | local($_) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1114 | my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument()); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1115 | my $font = fix_font(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1116 | my $h1 = next_argument(); |
| 1117 | my $h2 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1118 | s/[\s\n]+//; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1119 | $globals{'lineifont'} = $font; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1120 | 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 Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1124 | . "\n <thead>" |
| 1125 | . "\n <tr class=\"tableheader\">" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1126 | . "\n $th1<b>$h1</b>\ </th>" |
| 1127 | . "\n $th2<b>$h2</b>\ </th>" |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1128 | . "\n </tr>" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1129 | . "\n </thead>" |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 1130 | . "\n <tbody valign=\"baseline\">" |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1131 | . $_ |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1132 | . "\n </tbody>" |
| 1133 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1134 | } |
| 1135 | |
Fred Drake | da72b93 | 2000-09-21 15:58:02 +0000 | [diff] [blame] | 1136 | sub do_env_longtableii{ |
| 1137 | return do_env_tableii(@_); |
| 1138 | } |
| 1139 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1140 | sub do_cmd_lineii{ |
| 1141 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1142 | my $aligns = next_optional_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1143 | my $c1 = next_argument(); |
| 1144 | my $c2 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1145 | s/[\s\n]+//; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1146 | my($sfont,$efont) = get_table_col1_fonts(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1147 | $c2 = ' ' if ($c2 eq ''); |
| 1148 | my($c1align,$c2align) = split('\|', $aligns); |
| 1149 | my $padding = ''; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1150 | if ($c1align =~ /align="right"/ || $c1 eq '') { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1151 | $padding = ' '; |
Fred Drake | 58b2bfd | 1998-04-02 20:14:04 +0000 | [diff] [blame] | 1152 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1153 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
| 1154 | . " $c2align$c2</td>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1155 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1156 | } |
| 1157 | |
| 1158 | sub do_env_tableiii{ |
| 1159 | local($_) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1160 | my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument()); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1161 | my $font = fix_font(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1162 | my $h1 = next_argument(); |
| 1163 | my $h2 = next_argument(); |
| 1164 | my $h3 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1165 | s/[\s\n]+//; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1166 | $globals{'lineifont'} = $font; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1167 | 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 Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1172 | . "\n <thead>" |
| 1173 | . "\n <tr class=\"tableheader\">" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1174 | . "\n $th1<b>$h1</b>\ </th>" |
| 1175 | . "\n $th2<b>$h2</b>\ </th>" |
| 1176 | . "\n $th3<b>$h3</b>\ </th>" |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1177 | . "\n </tr>" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1178 | . "\n </thead>" |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 1179 | . "\n <tbody valign=\"baseline\">" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1180 | . $_ |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1181 | . "\n </tbody>" |
| 1182 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1183 | } |
| 1184 | |
Fred Drake | da72b93 | 2000-09-21 15:58:02 +0000 | [diff] [blame] | 1185 | sub do_env_longtableiii{ |
| 1186 | return do_env_tableiii(@_); |
| 1187 | } |
| 1188 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1189 | sub do_cmd_lineiii{ |
| 1190 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1191 | my $aligns = next_optional_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1192 | my $c1 = next_argument(); |
| 1193 | my $c2 = next_argument(); |
| 1194 | my $c3 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1195 | s/[\s\n]+//; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1196 | my($sfont,$efont) = get_table_col1_fonts(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1197 | $c3 = ' ' if ($c3 eq ''); |
| 1198 | my($c1align,$c2align,$c3align) = split('\|', $aligns); |
| 1199 | my $padding = ''; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1200 | if ($c1align =~ /align="right"/ || $c1 eq '') { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1201 | $padding = ' '; |
Fred Drake | 58b2bfd | 1998-04-02 20:14:04 +0000 | [diff] [blame] | 1202 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1203 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1204 | . " $c2align$c2</td>\n" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1205 | . " $c3align$c3</td>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1206 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1207 | } |
| 1208 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1209 | sub do_env_tableiv{ |
| 1210 | local($_) = @_; |
| 1211 | my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument()); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1212 | my $font = fix_font(next_argument()); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1213 | my $h1 = next_argument(); |
| 1214 | my $h2 = next_argument(); |
| 1215 | my $h3 = next_argument(); |
| 1216 | my $h4 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1217 | s/[\s\n]+//; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1218 | $globals{'lineifont'} = $font; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1219 | 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 Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1225 | . "\n <thead>" |
| 1226 | . "\n <tr class=\"tableheader\">" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1227 | . "\n $th1<b>$h1</b>\ </th>" |
| 1228 | . "\n $th2<b>$h2</b>\ </th>" |
| 1229 | . "\n $th3<b>$h3</b>\ </th>" |
| 1230 | . "\n $th4<b>$h4</b>\ </th>" |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1231 | . "\n </tr>" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1232 | . "\n </thead>" |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 1233 | . "\n <tbody valign=\"baseline\">" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1234 | . $_ |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1235 | . "\n </tbody>" |
| 1236 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1237 | } |
| 1238 | |
Fred Drake | da72b93 | 2000-09-21 15:58:02 +0000 | [diff] [blame] | 1239 | sub do_env_longtableiv{ |
| 1240 | return do_env_tableiv(@_); |
| 1241 | } |
| 1242 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1243 | sub do_cmd_lineiv{ |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1244 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1245 | my $aligns = next_optional_argument(); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1246 | my $c1 = next_argument(); |
| 1247 | my $c2 = next_argument(); |
| 1248 | my $c3 = next_argument(); |
| 1249 | my $c4 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1250 | s/[\s\n]+//; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1251 | my($sfont,$efont) = get_table_col1_fonts(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1252 | $c4 = ' ' if ($c4 eq ''); |
| 1253 | my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns); |
| 1254 | my $padding = ''; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1255 | if ($c1align =~ /align="right"/ || $c1 eq '') { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1256 | $padding = ' '; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1257 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1258 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1259 | . " $c2align$c2</td>\n" |
| 1260 | . " $c3align$c3</td>\n" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1261 | . " $c4align$c4</td>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1262 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1263 | } |
| 1264 | |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1265 | |
| 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 | |
| 1284 | sub make_my_titlepage() { |
| 1285 | my $the_title = ""; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1286 | if ($t_title) { |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 1287 | $the_title .= "\n<h1>$t_title</h1>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1288 | } |
| 1289 | else { |
| 1290 | write_warnings("\nThis document has no title."); |
| 1291 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1292 | if ($t_author) { |
| 1293 | if ($t_authorURL) { |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1294 | my $href = translate_commands($t_authorURL); |
Fred Drake | 2d1f81e | 1999-02-09 16:03:31 +0000 | [diff] [blame] | 1295 | $href = make_named_href('author', $href, |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 1296 | "<b><font size=\"+2\">$t_author" |
| 1297 | . '</font></b>'); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1298 | $the_title .= "\n<p>$href</p>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1299 | } |
| 1300 | else { |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 1301 | $the_title .= ("\n<p><b><font size=\"+2\">$t_author" |
| 1302 | . '</font></b></p>'); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1303 | } |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1304 | } |
| 1305 | else { |
| 1306 | write_warnings("\nThere is no author for this document."); |
| 1307 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1308 | if ($t_institute) { |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1309 | $the_title .= "\n<p>$t_institute</p>"; |
| 1310 | } |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 1311 | if ($DEVELOPER_ADDRESS) { |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1312 | $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>"; |
| 1313 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1314 | if ($t_affil) { |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1315 | $the_title .= "\n<p><i>$t_affil</i></p>"; |
| 1316 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1317 | if ($t_date) { |
Fred Drake | de77bc5 | 2000-12-14 18:36:12 +0000 | [diff] [blame] | 1318 | $the_title .= "\n<p>"; |
Fred Drake | d04592a | 2000-10-25 16:15:13 +0000 | [diff] [blame] | 1319 | if ($PACKAGE_VERSION) { |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 1320 | $the_title .= ('<strong>Release ' |
| 1321 | . "$PACKAGE_VERSION$RELEASE_INFO</strong><br>\n"); |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1322 | } |
Fred Drake | de77bc5 | 2000-12-14 18:36:12 +0000 | [diff] [blame] | 1323 | $the_title .= "<strong>$t_date</strong></p>" |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1324 | } |
| 1325 | if ($t_address) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1326 | $the_title .= "\n<p>$t_address</p>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1327 | } |
| 1328 | else { |
| 1329 | $the_title .= "\n<p>"; |
| 1330 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1331 | if ($t_email) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1332 | $the_title .= "\n<p>$t_email</p>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1333 | } |
| 1334 | return $the_title; |
| 1335 | } |
| 1336 | |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1337 | sub make_my_titlegraphic() { |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1338 | my $filename = make_icon_filename($TITLE_PAGE_GRAPHIC); |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1339 | 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 Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 1347 | $graphic .= "\n src=\"$filename\"></td>\n"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1348 | return $graphic; |
| 1349 | } |
| 1350 | |
| 1351 | sub 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 Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 1378 | $the_title .= "\n</center></div>"; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1379 | return $the_title . $_ ; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1380 | } |
| 1381 | |
| 1382 | |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1383 | # |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1384 | # Module synopsis support |
| 1385 | # |
| 1386 | |
| 1387 | require SynopsisTable; |
| 1388 | |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1389 | sub get_chapter_id(){ |
| 1390 | my $id = do_cmd_thechapter(''); |
Fred Drake | 45f2601 | 1998-08-04 22:07:18 +0000 | [diff] [blame] | 1391 | $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/; |
| 1392 | $id =~ s/\.//; |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1393 | return $id; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1394 | } |
| 1395 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1396 | # 'chapter' => 'SynopsisTable instance' |
| 1397 | %ModuleSynopses = (); |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1398 | |
| 1399 | sub get_synopsis_table($){ |
| 1400 | my($chap) = @_; |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1401 | my $key; |
| 1402 | foreach $key (keys %ModuleSynopses) { |
| 1403 | if ($key eq $chap) { |
| 1404 | return $ModuleSynopses{$chap}; |
| 1405 | } |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1406 | } |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1407 | my $st = SynopsisTable->new(); |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1408 | $ModuleSynopses{$chap} = $st; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1409 | return $st; |
| 1410 | } |
| 1411 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1412 | sub do_cmd_moduleauthor{ |
| 1413 | local($_) = @_; |
| 1414 | next_argument(); |
| 1415 | next_argument(); |
| 1416 | return $_; |
| 1417 | } |
| 1418 | |
| 1419 | sub do_cmd_sectionauthor{ |
| 1420 | local($_) = @_; |
| 1421 | next_argument(); |
| 1422 | next_argument(); |
| 1423 | return $_; |
| 1424 | } |
| 1425 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1426 | sub 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 Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1437 | return anchor_label("module-$key",$CURRENT_FILE,$_) |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1438 | } |
| 1439 | |
| 1440 | sub do_cmd_modulesynopsis{ |
| 1441 | local($_) = @_; |
| 1442 | my $st = get_synopsis_table(get_chapter_id()); |
Fred Drake | 1cc5899 | 1999-04-13 22:08:59 +0000 | [diff] [blame] | 1443 | $st->set_synopsis($THIS_MODULE, translate_commands(next_argument())); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1444 | return $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1445 | } |
| 1446 | |
| 1447 | sub do_cmd_localmoduletable{ |
| 1448 | local($_) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1449 | my $chap = get_chapter_id(); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1450 | my $st = get_synopsis_table($chap); |
| 1451 | $st->set_file("$CURRENT_FILE"); |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1452 | return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1453 | } |
| 1454 | |
| 1455 | sub process_all_localmoduletables{ |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1456 | 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 | |
| 1470 | sub 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 Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1477 | while (/<tex2html-localmoduletable><(\d+)>/) { |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1478 | my $match = $&; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1479 | my $chap = $1; |
| 1480 | my $st = get_synopsis_table($chap); |
| 1481 | my $data = $st->tohtml(); |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1482 | s/$match/$data/; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1483 | } |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1484 | open(MYFILE,">$file"); |
| 1485 | print MYFILE $_; |
| 1486 | close(MYFILE); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1487 | } |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1488 | sub process_python_state{ |
| 1489 | process_all_localmoduletables(); |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1490 | } |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1491 | |
| 1492 | |
| 1493 | # |
| 1494 | # "See also:" -- references placed at the end of a \section |
| 1495 | # |
| 1496 | |
| 1497 | sub do_env_seealso{ |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 1498 | return ("<div class=\"seealso\">\n " |
| 1499 | . "<p class=\"heading\"><b>See Also:</b></p>\n" |
| 1500 | . @_[0] |
| 1501 | . '</div>'); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1502 | } |
| 1503 | |
| 1504 | sub 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 Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 1511 | my $period = '.'; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1512 | $key = $module |
| 1513 | unless $key; |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 1514 | if ($text =~ /\.$/) { |
| 1515 | $period = ''; |
| 1516 | } |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 1517 | 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 Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1522 | } |
| 1523 | |
Fred Drake | e0197bf | 2001-04-12 04:03:22 +0000 | [diff] [blame] | 1524 | sub 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 Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1532 | sub handle_rfclike_reference{ |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 1533 | local($_, $what, $format) = @_; |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 1534 | my $rfcnum = next_argument(); |
| 1535 | my $title = next_argument(); |
| 1536 | my $text = next_argument(); |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 1537 | my $url = get_rfc_url($rfcnum, $format); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1538 | my $icon = get_link_icon($url); |
Fred Drake | e0197bf | 2001-04-12 04:03:22 +0000 | [diff] [blame] | 1539 | my $attrtitle = strip_html_markup($title); |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 1540 | return '<dl compact class="seerfc">' |
| 1541 | . "\n <dt><a href=\"$url\"" |
Fred Drake | e0197bf | 2001-04-12 04:03:22 +0000 | [diff] [blame] | 1542 | . "\n title=\"$attrtitle\"" |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 1543 | . "\n >$what $rfcnum, <em>$title</em>$icon</a>" |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 1544 | . "\n <dd>$text\n </dl>" |
| 1545 | . $_; |
| 1546 | } |
| 1547 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1548 | sub do_cmd_seepep{ |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 1549 | return handle_rfclike_reference(@_[0], "PEP", $PEP_FORMAT); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1550 | } |
| 1551 | |
| 1552 | sub do_cmd_seerfc{ |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 1553 | return handle_rfclike_reference(@_[0], "RFC", $RFC_FORMAT); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1554 | } |
| 1555 | |
Fred Drake | 4844998 | 2000-09-12 17:52:33 +0000 | [diff] [blame] | 1556 | sub 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 Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 1562 | my $icon = get_link_icon($url); |
Fred Drake | 4844998 | 2000-09-12 17:52:33 +0000 | [diff] [blame] | 1563 | return '<dl compact class="seetitle">' |
| 1564 | . "\n <dt><em class=\"citetitle\"><a href=\"$url\"" |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1565 | . "\n >$title$icon</a></em>" |
Fred Drake | 4844998 | 2000-09-12 17:52:33 +0000 | [diff] [blame] | 1566 | . "\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 Drake | ef4d111 | 2000-05-09 16:17:51 +0000 | [diff] [blame] | 1576 | sub do_cmd_seeurl{ |
| 1577 | local($_) = @_; |
| 1578 | my $url = next_argument(); |
| 1579 | my $text = next_argument(); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1580 | my $icon = get_link_icon($url); |
Fred Drake | ef4d111 | 2000-05-09 16:17:51 +0000 | [diff] [blame] | 1581 | return '<dl compact class="seeurl">' |
| 1582 | . "\n <dt><a href=\"$url\"" |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1583 | . "\n class=\"url\">$url$icon</a>" |
Fred Drake | ef4d111 | 2000-05-09 16:17:51 +0000 | [diff] [blame] | 1584 | . "\n <dd>$text\n </dl>" |
| 1585 | . $_; |
| 1586 | } |
| 1587 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1588 | sub do_cmd_seetext{ |
Fred Drake | 79189b5 | 1999-04-28 13:54:30 +0000 | [diff] [blame] | 1589 | local($_) = @_; |
| 1590 | my $content = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1591 | return '<div class="seetext"><p>' . $content . '</div>' . $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1592 | } |
| 1593 | |
| 1594 | |
| 1595 | # |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1596 | # Definition list support. |
| 1597 | # |
| 1598 | |
| 1599 | sub do_env_definitions{ |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame^] | 1600 | return "<dl class=\"definitions\">" . @_[0] . "</dl>\n"; |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1601 | } |
| 1602 | |
| 1603 | sub do_cmd_term{ |
| 1604 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1605 | my $term = next_argument(); |
| 1606 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1607 | # could easily add an index entry here... |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1608 | return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_; |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1609 | } |
| 1610 | |
| 1611 | |
Fred Drake | 38178fd | 2000-09-22 17:05:04 +0000 | [diff] [blame] | 1612 | # 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 Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 1617 | process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_); |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 1618 | declaremodule # [] # {} # {} |
| 1619 | memberline # [] # {} |
| 1620 | methodline # [] # {} # {} |
| 1621 | modulesynopsis # {} |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1622 | platform # {} |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 1623 | samp # {} |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 1624 | setindexsubitem # {} |
Fred Drake | f32834c | 1999-02-12 22:06:32 +0000 | [diff] [blame] | 1625 | withsubitem # {} # {} |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 1626 | _RAW_ARG_DEFERRED_CMDS_ |
| 1627 | |
| 1628 | |
Fred Drake | 8633360 | 2001-04-10 17:13:39 +0000 | [diff] [blame] | 1629 | $alltt_start = '<dl><dd><pre class="verbatim">'; |
| 1630 | $alltt_end = '</pre></dl>'; |
| 1631 | |
| 1632 | sub 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 |
| 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 Drake | 57e52ef | 2001-06-15 21:31:57 +0000 | [diff] [blame] | 1674 | sub 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/\&/\&/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/<</\<\&\#60;/g; |
| 1703 | $text =~ s/>>/\>\&\#62;/g; |
| 1704 | # Just normal re-writes... |
| 1705 | $text =~ s/</\</g; |
| 1706 | $text =~ s/>/\>/g; |
| 1707 | # These last isn't needed for the HTML, but is needed to get |
| 1708 | # past LaTeX2HTML processing TeX macros. We use \ instead |
| 1709 | # of / 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 Drake | 8633360 | 2001-04-10 17:13:39 +0000 | [diff] [blame] | 1720 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1721 | 1; # This must be the last line |