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); |
| 44 | return (" <img src='$icon'\n" |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 45 | . " border='0' class='offsitelink'" |
| 46 | . ($OFF_SITE_LINK_ICON_HEIGHT |
| 47 | ? " height='$OFF_SITE_LINK_ICON_HEIGHT'" |
| 48 | : '') |
| 49 | . ($OFF_SITE_LINK_ICON_WIDTH |
| 50 | ? " width='$OFF_SITE_LINK_ICON_WIDTH'" |
| 51 | : '') |
| 52 | . " alt='[off-site link]'\n" |
Fred 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]; } |
| 89 | |
| 90 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 91 | # words typeset in a special way (not in HTML though) |
| 92 | |
| 93 | sub do_cmd_ABC{ 'ABC' . @_[0]; } |
| 94 | sub do_cmd_UNIX{ 'Unix'. @_[0]; } |
| 95 | sub do_cmd_ASCII{ 'ASCII' . @_[0]; } |
| 96 | sub do_cmd_POSIX{ 'POSIX' . @_[0]; } |
| 97 | sub do_cmd_C{ 'C' . @_[0]; } |
| 98 | sub do_cmd_Cpp{ 'C++' . @_[0]; } |
| 99 | sub do_cmd_EOF{ 'EOF' . @_[0]; } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 100 | sub do_cmd_NULL{ '<tt class="constant">NULL</tt>' . @_[0]; } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 101 | |
| 102 | sub do_cmd_e{ '\' . @_[0]; } |
| 103 | |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 104 | $DEVELOPER_ADDRESS = ''; |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 105 | $SHORT_VERSION = ''; |
Fred Drake | d04592a | 2000-10-25 16:15:13 +0000 | [diff] [blame] | 106 | $PACKAGE_VERSION = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 107 | |
Fred Drake | d04592a | 2000-10-25 16:15:13 +0000 | [diff] [blame] | 108 | sub do_cmd_version{ $PACKAGE_VERSION . @_[0]; } |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 109 | sub do_cmd_shortversion{ $SHORT_VERSION . @_[0]; } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 110 | sub do_cmd_release{ |
| 111 | local($_) = @_; |
Fred Drake | d04592a | 2000-10-25 16:15:13 +0000 | [diff] [blame] | 112 | $PACKAGE_VERSION = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 113 | return $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 114 | } |
| 115 | |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 116 | sub do_cmd_setshortversion{ |
| 117 | local($_) = @_; |
| 118 | $SHORT_VERSION = next_argument(); |
| 119 | return $_; |
| 120 | } |
| 121 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 122 | sub do_cmd_authoraddress{ |
| 123 | local($_) = @_; |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 124 | $DEVELOPER_ADDRESS = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 125 | return $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 126 | } |
| 127 | |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 128 | #sub do_cmd_developer{ do_cmd_author(@_[0]); } |
| 129 | #sub do_cmd_developers{ do_cmd_author(@_[0]); } |
| 130 | #sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); } |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 131 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 132 | sub do_cmd_hackscore{ |
| 133 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 134 | next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 135 | return '_' . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 136 | } |
| 137 | |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 138 | sub use_wrappers{ |
| 139 | local($_,$before,$after) = @_; |
| 140 | my $stuff = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 141 | return $before . $stuff . $after . $_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 142 | } |
| 143 | |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 144 | $IN_DESC_HANDLER = 0; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 145 | sub do_cmd_optional{ |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 146 | if ($IN_DESC_HANDLER) { |
| 147 | return use_wrappers(@_[0], "</var><big>\[</big><var>", |
| 148 | "</var><big>\]</big><var>"); |
| 149 | } |
| 150 | else { |
| 151 | return use_wrappers(@_[0], "<big>\[</big>", "<big>\]</big>"); |
| 152 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 153 | } |
| 154 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 155 | # Logical formatting (some based on texinfo), needs to be converted to |
| 156 | # minimalist HTML. The "minimalist" is primarily to reduce the size of |
| 157 | # output files for users that read them over the network rather than |
| 158 | # from local repositories. |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 159 | |
Fred Drake | 2cafcbb | 1999-03-25 16:57:04 +0000 | [diff] [blame] | 160 | # \file and \samp are at the end of this file since they screw up fontlock. |
| 161 | |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 162 | sub do_cmd_pytype{ return @_[0]; } |
Fred Drake | 3d5a04a | 2000-08-03 17:25:44 +0000 | [diff] [blame] | 163 | sub do_cmd_makevar{ |
| 164 | return use_wrappers(@_[0], '<span class="makevar">', '</span>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 165 | sub do_cmd_code{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 166 | return use_wrappers(@_[0], '<code>', '</code>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 167 | sub do_cmd_module{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 168 | return use_wrappers(@_[0], '<tt class="module">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 169 | sub do_cmd_keyword{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 170 | return use_wrappers(@_[0], '<tt class="keyword">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 171 | sub do_cmd_exception{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 172 | return use_wrappers(@_[0], '<tt class="exception">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 173 | sub do_cmd_class{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 174 | return use_wrappers(@_[0], '<tt class="class">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 175 | sub do_cmd_function{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 176 | return use_wrappers(@_[0], '<tt class="function">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 177 | sub do_cmd_constant{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 178 | return use_wrappers(@_[0], '<tt class="constant">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 179 | sub do_cmd_member{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 180 | return use_wrappers(@_[0], '<tt class="member">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 181 | sub do_cmd_method{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 182 | return use_wrappers(@_[0], '<tt class="method">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 183 | sub do_cmd_cfunction{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 184 | return use_wrappers(@_[0], '<tt class="cfunction">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 185 | sub do_cmd_cdata{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 186 | return use_wrappers(@_[0], '<tt class="cdata">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 187 | sub do_cmd_ctype{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 188 | return use_wrappers(@_[0], '<tt class="ctype">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 189 | sub do_cmd_regexp{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 190 | return use_wrappers(@_[0], '<tt class="regexp">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 191 | sub do_cmd_character{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 192 | return use_wrappers(@_[0], '"<tt class="character">', '</tt>"'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 193 | sub do_cmd_program{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 194 | return use_wrappers(@_[0], '<b class="program">', '</b>'); } |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 195 | sub do_cmd_programopt{ |
| 196 | return use_wrappers(@_[0], '<b class="programopt">', '</b>'); } |
Fred Drake | 0cd6021 | 2000-04-11 18:46:59 +0000 | [diff] [blame] | 197 | sub do_cmd_longprogramopt{ |
| 198 | # note that the --- will be later converted to -- by LaTeX2HTML |
| 199 | return use_wrappers(@_[0], '<b class="programopt">---', '</b>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 200 | sub do_cmd_email{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 201 | return use_wrappers(@_[0], '<span class="email">', '</span>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 202 | sub do_cmd_mimetype{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 203 | return use_wrappers(@_[0], '<span class="mimetype">', '</span>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 204 | sub do_cmd_var{ |
| 205 | return use_wrappers(@_[0], "<var>", "</var>"); } |
| 206 | sub do_cmd_dfn{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 207 | return use_wrappers(@_[0], '<i class="dfn">', '</i>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 208 | sub do_cmd_emph{ |
Fred Drake | 38178fd | 2000-09-22 17:05:04 +0000 | [diff] [blame] | 209 | return use_wrappers(@_[0], '<i>', '</i>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 210 | sub do_cmd_file{ |
Fred Drake | 3d5a04a | 2000-08-03 17:25:44 +0000 | [diff] [blame] | 211 | return use_wrappers(@_[0], '<span class="file">', '</span>'); } |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 212 | sub do_cmd_filenq{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 213 | return do_cmd_file(@_[0]); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 214 | sub do_cmd_samp{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 215 | return use_wrappers(@_[0], '"<tt class="samp">', '</tt>"'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 216 | sub do_cmd_kbd{ |
| 217 | return use_wrappers(@_[0], '<kbd>', '</kbd>'); } |
| 218 | sub do_cmd_strong{ |
| 219 | return use_wrappers(@_[0], '<b>', '</b>'); } |
Fred Drake | 2cafcbb | 1999-03-25 16:57:04 +0000 | [diff] [blame] | 220 | sub do_cmd_textbf{ |
| 221 | return use_wrappers(@_[0], '<b>', '</b>'); } |
| 222 | sub do_cmd_textit{ |
| 223 | return use_wrappers(@_[0], '<i>', '</i>'); } |
| 224 | |
Fred Drake | 3d5a04a | 2000-08-03 17:25:44 +0000 | [diff] [blame] | 225 | sub do_cmd_moreargs{ |
| 226 | return '...' . @_[0]; } |
| 227 | sub do_cmd_unspecified{ |
| 228 | return '...' . @_[0]; } |
| 229 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 230 | |
Fred Drake | 2581704 | 1999-01-13 17:06:34 +0000 | [diff] [blame] | 231 | sub do_cmd_refmodule{ |
| 232 | # Insert the right magic to jump to the module definition. |
| 233 | local($_) = @_; |
| 234 | my $key = next_optional_argument(); |
| 235 | my $module = next_argument(); |
| 236 | $key = $module |
| 237 | unless $key; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 238 | return "<tt class='module'><a href='module-$key.html'>$module</a></tt>" |
| 239 | . $_; |
Fred Drake | 2581704 | 1999-01-13 17:06:34 +0000 | [diff] [blame] | 240 | } |
| 241 | |
Fred Drake | 1a7af39 | 1998-04-01 22:44:56 +0000 | [diff] [blame] | 242 | sub do_cmd_newsgroup{ |
| 243 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 244 | my $newsgroup = next_argument(); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 245 | my $icon = get_link_icon("news:$newsgroup"); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 246 | my $stuff = "<span class='newsgroup'><a href='news:$newsgroup'>" |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 247 | . "$newsgroup$icon</a></span>"; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 248 | return $stuff . $_; |
Fred Drake | 1a7af39 | 1998-04-01 22:44:56 +0000 | [diff] [blame] | 249 | } |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 250 | |
| 251 | sub do_cmd_envvar{ |
| 252 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 253 | my $envvar = next_argument(); |
| 254 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 255 | # The <tt> here is really to keep buildindex.py from making |
| 256 | # the variable name case-insensitive. |
| 257 | add_index_entry("environment variables!$envvar@<tt>\$$envvar</tt>", |
| 258 | $ahref); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 259 | add_index_entry("$envvar@\$$envvar", $ahref); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 260 | $aname =~ s/<a/<a class="envvar"/; |
Fred Drake | d37cecf | 1999-09-23 16:45:08 +0000 | [diff] [blame] | 261 | return "$aname\$$envvar</a>" . $_; |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 262 | } |
| 263 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 264 | sub do_cmd_url{ |
| 265 | # use the URL as both text and hyperlink |
| 266 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 267 | my $url = next_argument(); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 268 | my $icon = get_link_icon($url); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 269 | $url =~ s/~/~/g; |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 270 | return "<a class=\"url\" href=\"$url\">$url$icon</a>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | sub do_cmd_manpage{ |
| 274 | # two parameters: \manpage{name}{section} |
| 275 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 276 | my $page = next_argument(); |
| 277 | my $section = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 278 | return "<span class='manpage'><i>$page</i>($section)</span>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 279 | } |
| 280 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 281 | sub get_pep_url{ |
| 282 | my $rfcnum = sprintf("%04d", @_[0]); |
| 283 | return "http://python.sourceforge.net/peps/pep-$rfcnum.html"; |
| 284 | } |
| 285 | |
| 286 | sub do_cmd_pep{ |
| 287 | local($_) = @_; |
| 288 | my $rfcnumber = next_argument(); |
| 289 | my $id = "rfcref-" . ++$global{'max_id'}; |
| 290 | my $href = get_pep_url($rfcnumber); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 291 | my $icon = get_link_icon($href); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 292 | # Save the reference |
| 293 | my $nstr = gen_index_id("Python Enhancement Proposals!PEP $rfcnumber", ''); |
| 294 | $index{$nstr} .= make_half_href("$CURRENT_FILE#$id"); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 295 | return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">PEP $rfcnumber" |
| 296 | . "$icon</a>" . $_); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 297 | } |
| 298 | |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 299 | sub get_rfc_url{ |
| 300 | my $rfcnum = sprintf("%04d", @_[0]); |
| 301 | return "http://www.ietf.org/rfc/rfc$rfcnum.txt"; |
| 302 | } |
| 303 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 304 | sub do_cmd_rfc{ |
| 305 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 306 | my $rfcnumber = next_argument(); |
| 307 | my $id = "rfcref-" . ++$global{'max_id'}; |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 308 | my $href = get_rfc_url($rfcnumber); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 309 | my $icon = get_link_icon($href); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 310 | # Save the reference |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 311 | my $nstr = gen_index_id("RFC!RFC $rfcnumber", ''); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 312 | $index{$nstr} .= make_half_href("$CURRENT_FILE#$id"); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 313 | return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">RFC $rfcnumber" |
| 314 | . "$icon</a>" . $_); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 315 | } |
| 316 | |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 317 | sub do_cmd_citetitle{ |
| 318 | local($_) = @_; |
| 319 | my $url = next_optional_argument(); |
| 320 | my $title = next_argument(); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 321 | my $icon = get_link_icon($url); |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 322 | my $repl = ''; |
| 323 | if ($url) { |
| 324 | $repl = ("<em class='citetitle'><a\n" |
| 325 | . " href='$url'\n" |
| 326 | . " title='$title'\n" |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 327 | . " >$title$icon</a></em>"); |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 328 | } |
| 329 | else { |
| 330 | $repl = "<em class='citetitle'\n >$title</em>"; |
| 331 | } |
| 332 | return $repl . $_; |
| 333 | } |
| 334 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 335 | sub do_cmd_deprecated{ |
| 336 | # two parameters: \deprecated{version}{whattodo} |
| 337 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 338 | my $release = next_argument(); |
| 339 | my $reason = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 340 | return "<b>Deprecated since release $release.</b>\n$reason<p>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 341 | } |
| 342 | |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 343 | sub do_cmd_versionadded{ |
| 344 | # one parameter: \versionadded{version} |
| 345 | local($_) = @_; |
| 346 | my $release = next_argument(); |
Fred Drake | 2116d98 | 1999-02-02 18:02:48 +0000 | [diff] [blame] | 347 | return "\nNew in version $release.\n" . $_; |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | sub do_cmd_versionchanged{ |
| 351 | # one parameter: \versionchanged{version} |
| 352 | local($_) = @_; |
Fred Drake | 52e7684 | 2000-05-02 17:37:42 +0000 | [diff] [blame] | 353 | my $explanation = next_optional_argument(); |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 354 | my $release = next_argument(); |
Fred Drake | 52e7684 | 2000-05-02 17:37:42 +0000 | [diff] [blame] | 355 | my $text = "\nChanged in version $release.\n"; |
| 356 | if ($release) { |
| 357 | $text = "\nChanged in version $release:\n$explanation.\n"; |
| 358 | } |
| 359 | return $text . $_; |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 360 | } |
| 361 | |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 362 | # |
Fred Drake | 2cafcbb | 1999-03-25 16:57:04 +0000 | [diff] [blame] | 363 | # These function handle platform dependency tracking. |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 364 | # |
| 365 | sub do_cmd_platform{ |
| 366 | local($_) = @_; |
| 367 | my $platform = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 368 | $ModulePlatforms{"<tt class='module'>$THIS_MODULE</tt>"} = $platform; |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 369 | $platform = "Macintosh" |
Fred Drake | 085b812 | 1999-04-21 14:00:29 +0000 | [diff] [blame] | 370 | if $platform eq 'Mac'; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 371 | return "\n<p class='availability'>Availability: <span" |
| 372 | . "\n class='platform'>$platform</span>.</p>\n" . $_; |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 373 | } |
| 374 | |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 375 | $IGNORE_PLATFORM_ANNOTATION = ''; |
| 376 | sub do_cmd_ignorePlatformAnnotation{ |
| 377 | local($_) = @_; |
| 378 | $IGNORE_PLATFORM_ANNOTATION = next_argument(); |
| 379 | return $_; |
| 380 | } |
| 381 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 382 | |
| 383 | # index commands |
| 384 | |
| 385 | $INDEX_SUBITEM = ""; |
| 386 | |
| 387 | sub get_indexsubitem{ |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 388 | return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | sub do_cmd_setindexsubitem{ |
| 392 | local($_) = @_; |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 393 | $INDEX_SUBITEM = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 394 | return $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 395 | } |
| 396 | |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 397 | sub do_cmd_withsubitem{ |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 398 | # We can't really do the right thing, because LaTeX2HTML doesn't |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 399 | # do things in the right order, but we need to at least strip this stuff |
| 400 | # out, and leave anything that the second argument expanded out to. |
| 401 | # |
| 402 | local($_) = @_; |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 403 | my $oldsubitem = $INDEX_SUBITEM; |
| 404 | $INDEX_SUBITEM = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 405 | my $stuff = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 406 | my $br_id = ++$globals{'max_id'}; |
| 407 | my $marker = "$O$br_id$C"; |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 408 | return |
| 409 | $stuff |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 410 | . "\\setindexsubitem$marker$oldsubitem$marker" |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 411 | . $_; |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 412 | } |
| 413 | |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 414 | # This is the prologue macro which is required to start writing the |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 415 | # mod\jobname.idx file; we can just ignore it. (Defining this suppresses |
| 416 | # a warning that \makemodindex is unknown.) |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 417 | # |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 418 | sub do_cmd_makemodindex{ return @_[0]; } |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 419 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 420 | # We're in the document subdirectory when this happens! |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 421 | # |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 422 | open(IDXFILE, '>index.dat') || die "\n$!\n"; |
| 423 | open(INTLABELS, '>intlabels.pl') || die "\n$!\n"; |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 424 | print INTLABELS "%internal_labels = ();\n"; |
| 425 | print INTLABELS "1; # hack in case there are no entries\n\n"; |
| 426 | |
| 427 | # Using \0 for this is bad because we can't use common tools to work with the |
| 428 | # resulting files. Things like grep can be useful with this stuff! |
| 429 | # |
| 430 | $IDXFILE_FIELD_SEP = "\1"; |
| 431 | |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 432 | sub write_idxfile{ |
| 433 | my ($ahref, $str) = @_; |
| 434 | print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 435 | } |
| 436 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 437 | |
| 438 | sub gen_link{ |
| 439 | my($node,$target) = @_; |
| 440 | print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n"; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 441 | return "<a href='$node#$target'>"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 442 | } |
| 443 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 444 | sub add_index_entry{ |
| 445 | # add an entry to the index structures; ignore the return value |
| 446 | my($str,$ahref) = @_; |
| 447 | $str = gen_index_id($str, ''); |
| 448 | $index{$str} .= $ahref; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 449 | write_idxfile($ahref, $str); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 450 | } |
| 451 | |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 452 | sub new_link_info{ |
| 453 | my $name = "l2h-" . ++$globals{'max_id'}; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 454 | my $aname = "<a name='$name'>"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 455 | my $ahref = gen_link($CURRENT_FILE, $name); |
| 456 | return ($name, $aname, $ahref); |
| 457 | } |
| 458 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 459 | $IndexMacroPattern = ''; |
| 460 | sub define_indexing_macro{ |
| 461 | my $count = @_; |
| 462 | my $i = 0; |
| 463 | for (; $i < $count; ++$i) { |
| 464 | my $name = @_[$i]; |
| 465 | my $cmd = "idx_cmd_$name"; |
| 466 | die "\nNo function $cmd() defined!\n" |
| 467 | if (!defined &$cmd); |
| 468 | eval ("sub do_cmd_$name { return process_index_macros(" |
| 469 | . "\@_[0], '$name'); }"); |
| 470 | if (length($IndexMacroPattern) == 0) { |
| 471 | $IndexMacroPattern = "$name"; |
| 472 | } |
| 473 | else { |
| 474 | $IndexMacroPattern .= "|$name"; |
| 475 | } |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | $DEBUG_INDEXING = 0; |
| 480 | sub process_index_macros{ |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 481 | local($_) = @_; |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 482 | my $cmdname = @_[1]; # This is what triggered us in the first place; |
| 483 | # we know it's real, so just process it. |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 484 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 485 | my $cmd = "idx_cmd_$cmdname"; |
| 486 | print "\nIndexing: \\$cmdname" |
| 487 | if $DEBUG_INDEXING; |
| 488 | &$cmd($ahref); # modifies $_ and adds index entries |
| 489 | while (/^[\s\n]*\\($IndexMacroPattern)</) { |
| 490 | $cmdname = "$1"; |
| 491 | print " \\$cmdname" |
| 492 | if $DEBUG_INDEXING; |
| 493 | $cmd = "idx_cmd_$cmdname"; |
| 494 | if (!defined &$cmd) { |
| 495 | last; |
| 496 | } |
| 497 | else { |
| 498 | s/^[\s\n]*\\$cmdname//; |
| 499 | &$cmd($ahref); |
| 500 | } |
| 501 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 502 | return "$aname$anchor_invisible_mark</a>" . $_; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 503 | } |
| 504 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 505 | define_indexing_macro('index'); |
| 506 | sub idx_cmd_index{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 507 | my $str = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 508 | add_index_entry("$str", @_[0]); |
Fred Drake | 2e7edb8 | 1998-05-11 18:31:17 +0000 | [diff] [blame] | 509 | } |
| 510 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 511 | define_indexing_macro('kwindex'); |
| 512 | sub idx_cmd_kwindex{ |
| 513 | my $str = next_argument(); |
| 514 | add_index_entry("<tt>$str</tt>!keyword", @_[0]); |
| 515 | add_index_entry("keyword!<tt>$str</tt>", @_[0]); |
| 516 | } |
| 517 | |
| 518 | define_indexing_macro('indexii'); |
| 519 | sub idx_cmd_indexii{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 520 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 521 | my $str2 = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 522 | add_index_entry("$str1!$str2", @_[0]); |
| 523 | add_index_entry("$str2!$str1", @_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 524 | } |
| 525 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 526 | define_indexing_macro('indexiii'); |
| 527 | sub idx_cmd_indexiii{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 528 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 529 | my $str2 = next_argument(); |
| 530 | my $str3 = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 531 | add_index_entry("$str1!$str2 $str3", @_[0]); |
| 532 | add_index_entry("$str2!$str3, $str1", @_[0]); |
| 533 | add_index_entry("$str3!$str1 $str2", @_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 534 | } |
| 535 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 536 | define_indexing_macro('indexiv'); |
| 537 | sub idx_cmd_indexiv{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 538 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 539 | my $str2 = next_argument(); |
| 540 | my $str3 = next_argument(); |
| 541 | my $str4 = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 542 | add_index_entry("$str1!$str2 $str3 $str4", @_[0]); |
| 543 | add_index_entry("$str2!$str3 $str4, $str1", @_[0]); |
| 544 | add_index_entry("$str3!$str4, $str1 $str2", @_[0]); |
| 545 | add_index_entry("$str4!$$str1 $str2 $str3", @_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 546 | } |
| 547 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 548 | define_indexing_macro('ttindex'); |
| 549 | sub idx_cmd_ttindex{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 550 | my $str = next_argument(); |
| 551 | my $entry = $str . get_indexsubitem(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 552 | add_index_entry($entry, @_[0]); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 553 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 554 | |
| 555 | sub my_typed_index_helper{ |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 556 | my($word,$ahref) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 557 | my $str = next_argument(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 558 | add_index_entry("$str $word", $ahref); |
| 559 | add_index_entry("$word!$str", $ahref); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 560 | } |
| 561 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 562 | define_indexing_macro('stindex', 'opindex', 'exindex', 'obindex'); |
| 563 | sub idx_cmd_stindex{ my_typed_index_helper('statement', @_[0]); } |
| 564 | sub idx_cmd_opindex{ my_typed_index_helper('operator', @_[0]); } |
| 565 | sub idx_cmd_exindex{ my_typed_index_helper('exception', @_[0]); } |
| 566 | sub idx_cmd_obindex{ my_typed_index_helper('object', @_[0]); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 567 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 568 | define_indexing_macro('bifuncindex'); |
| 569 | sub idx_cmd_bifuncindex{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 570 | my $str = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 571 | add_index_entry("<tt class='function'>$str()</tt> (built-in function)", |
| 572 | @_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 573 | } |
| 574 | |
| 575 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 576 | sub make_mod_index_entry{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 577 | my($str,$define) = @_; |
| 578 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 579 | # equivalent of add_index_entry() using $define instead of '' |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 580 | $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/ |
| 581 | if ($define eq 'DEF'); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 582 | $str = gen_index_id($str, $define); |
| 583 | $index{$str} .= $ahref; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 584 | write_idxfile($ahref, $str); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 585 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 586 | if ($define eq 'DEF') { |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 587 | # add to the module index |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 588 | $str =~ /(<tt.*<\/tt>)/; |
| 589 | my $nstr = $1; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 590 | $Modules{$nstr} .= $ahref; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 591 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 592 | return "$aname$anchor_invisible_mark</a>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 593 | } |
| 594 | |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 595 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 596 | $THIS_MODULE = ''; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 597 | $THIS_CLASS = ''; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 598 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 599 | sub define_module{ |
| 600 | my($word,$name) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 601 | my $section_tag = join('', @curr_sec_id); |
Fred Drake | 3e4c614 | 1999-05-17 15:00:32 +0000 | [diff] [blame] | 602 | if ($word ne "built-in" && $word ne "extension" |
| 603 | && $word ne "standard" && $word ne "") { |
| 604 | write_warnings("Bad module type '$word'" |
| 605 | . " for \\declaremodule (module $name)"); |
| 606 | $word = ""; |
| 607 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 608 | $word = "$word " if $word; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 609 | $THIS_MODULE = "$name"; |
Fred Drake | 5942b43 | 2000-10-30 06:24:56 +0000 | [diff] [blame^] | 610 | $INDEX_SUBITEM = "(in module $name)"; |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 611 | print "[$name]"; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 612 | return make_mod_index_entry( |
| 613 | "<tt class='module'>$name</tt> (${word}module)", 'DEF'); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | sub my_module_index_helper{ |
| 617 | local($word, $_) = @_; |
| 618 | my $name = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 619 | return define_module($word, $name) . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 620 | } |
| 621 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 622 | sub do_cmd_modindex{ return my_module_index_helper('', @_); } |
| 623 | sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); } |
| 624 | sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); } |
| 625 | sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 626 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 627 | sub ref_module_index_helper{ |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 628 | my($word, $ahref) = @_; |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 629 | my $str = next_argument(); |
| 630 | $word = "$word " if $word; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 631 | $str = "<tt class='module'>$str</tt> (${word}module)"; |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 632 | # can't use add_index_entry() since the 2nd arg to gen_index_id() is used; |
| 633 | # just inline it all here |
| 634 | $str = gen_index_id($str, 'REF'); |
| 635 | $index{$str} .= $ahref; |
| 636 | write_idxfile($ahref, $str); |
| 637 | } |
| 638 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 639 | # these should be adjusted a bit.... |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 640 | define_indexing_macro('refmodindex', 'refbimodindex', |
| 641 | 'refexmodindex', 'refstmodindex'); |
| 642 | sub idx_cmd_refmodindex{ return ref_module_index_helper('', @_); } |
| 643 | sub idx_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); } |
| 644 | sub idx_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); } |
| 645 | sub idx_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 646 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 647 | sub do_cmd_nodename{ return do_cmd_label(@_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 648 | |
| 649 | sub init_myformat{ |
Fred Drake | 38178fd | 2000-09-22 17:05:04 +0000 | [diff] [blame] | 650 | $anchor_invisible_mark = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 651 | $anchor_mark = ''; |
| 652 | $icons{'anchor_mark'} = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 653 | } |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 654 | init_myformat(); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 655 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 656 | # Create an index entry, but include the string in the target anchor |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 657 | # instead of the dummy filler. |
| 658 | # |
| 659 | sub make_str_index_entry{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 660 | my($str) = @_; |
| 661 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 662 | add_index_entry($str, $ahref); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 663 | return "$aname$str</a>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 664 | } |
| 665 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 666 | $REFCOUNTS_LOADED = 0; |
| 667 | |
| 668 | sub load_refcounts{ |
| 669 | $REFCOUNTS_LOADED = 1; |
| 670 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 671 | my $myname, $mydir, $myext; |
| 672 | ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*'); |
| 673 | chop $mydir; # remove trailing '/' |
| 674 | ($myname, $mydir, $myext) = fileparse($mydir, '\..*'); |
| 675 | chop $mydir; # remove trailing '/' |
| 676 | $mydir = getcwd() . "$dd$mydir" |
| 677 | unless $mydir =~ s|^/|/|; |
| 678 | local $_; |
| 679 | my $filename = "$mydir${dd}api${dd}refcounts.dat"; |
| 680 | open(REFCOUNT_FILE, "<$filename") || die "\n$!\n"; |
| 681 | print "[loading API refcount data]"; |
| 682 | while (<REFCOUNT_FILE>) { |
Fred Drake | c2578c5 | 2000-04-10 18:26:45 +0000 | [diff] [blame] | 683 | 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] | 684 | my($func, $param, $count, $comment) = ($1, $2, $3, $4); |
| 685 | #print "\n$func($param) --> $count"; |
| 686 | $REFCOUNTS{"$func:$param"} = $count; |
| 687 | } |
| 688 | } |
| 689 | } |
| 690 | |
| 691 | sub get_refcount{ |
| 692 | my ($func, $param) = @_; |
| 693 | load_refcounts() |
| 694 | unless $REFCOUNTS_LOADED; |
| 695 | return $REFCOUNTS{"$func:$param"}; |
| 696 | } |
| 697 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 698 | sub do_env_cfuncdesc{ |
| 699 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 700 | my $return_type = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 701 | my $function_name = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 702 | my $arg_list = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 703 | my $idx = make_str_index_entry( |
| 704 | "<tt class='cfunction'>$function_name()</tt>" . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 705 | $idx =~ s/ \(.*\)//; |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 706 | $idx =~ s/\(\)//; # ???? - why both of these? |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 707 | my $result_rc = get_refcount($function_name, ''); |
| 708 | my $rcinfo = ''; |
| 709 | if ($result_rc eq '+1') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 710 | $rcinfo = 'New reference'; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 711 | } |
| 712 | elsif ($result_rc eq '0') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 713 | $rcinfo = 'Borrowed reference'; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 714 | } |
Fred Drake | c2578c5 | 2000-04-10 18:26:45 +0000 | [diff] [blame] | 715 | elsif ($result_rc eq 'null') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 716 | $rcinfo = 'Always <tt class="constant">NULL</tt>'; |
Fred Drake | c2578c5 | 2000-04-10 18:26:45 +0000 | [diff] [blame] | 717 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 718 | if ($rcinfo ne '') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 719 | $rcinfo = ( "\n<div class=\"refcount-info\">" |
| 720 | . "\n <span class=\"label\">Return value:</span>" |
| 721 | . "\n <span class=\"value\">$rcinfo.</span>" |
| 722 | . "\n</div>"); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 723 | } |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 724 | 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] | 725 | . $rcinfo |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 726 | . $_ |
| 727 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 728 | } |
| 729 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 730 | sub do_env_csimplemacrodesc{ |
| 731 | local($_) = @_; |
| 732 | my $name = next_argument(); |
| 733 | my $idx = make_str_index_entry("<tt class='macro'>$name</tt>"); |
| 734 | return "<dl><dt><b>$idx</b>\n<dd>" |
| 735 | . $_ |
| 736 | . '</dl>' |
| 737 | } |
| 738 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 739 | sub do_env_ctypedesc{ |
| 740 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 741 | my $index_name = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 742 | my $type_name = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 743 | $index_name = $type_name |
| 744 | unless $index_name; |
| 745 | my($name,$aname,$ahref) = new_link_info(); |
| 746 | add_index_entry("<tt class='ctype'>$index_name</tt> (C type)", $ahref); |
| 747 | 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] | 748 | . $_ |
| 749 | . '</dl>' |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 750 | } |
| 751 | |
| 752 | sub do_env_cvardesc{ |
| 753 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 754 | my $var_type = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 755 | my $var_name = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 756 | my $idx = make_str_index_entry("<tt class='cdata'>$var_name</tt>" |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 757 | . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 758 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 759 | return "<dl><dt>$var_type <b>$idx</b>\n" |
| 760 | . '<dd>' |
| 761 | . $_ |
| 762 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 763 | } |
| 764 | |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 765 | sub convert_args($){ |
| 766 | local($IN_DESC_HANDLER) = 1; |
| 767 | local($_) = @_; |
| 768 | return translate_commands($_); |
| 769 | } |
| 770 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 771 | sub do_env_funcdesc{ |
| 772 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 773 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 774 | my $arg_list = convert_args(next_argument()); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 775 | my $idx = make_str_index_entry("<tt class='function'>$function_name()</tt>" |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 776 | . get_indexsubitem()); |
| 777 | $idx =~ s/ \(.*\)//; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 778 | $idx =~ s/\(\)<\/tt>/<\/tt>/; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 779 | 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] | 780 | } |
| 781 | |
| 782 | sub do_env_funcdescni{ |
| 783 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 784 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 785 | my $arg_list = convert_args(next_argument()); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 786 | return "<dl><dt><b><tt class='function'>$function_name</tt></b>" |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 787 | . " (<var>$arg_list</var>)\n" |
| 788 | . '<dd>' |
| 789 | . $_ |
| 790 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 791 | } |
| 792 | |
| 793 | sub do_cmd_funcline{ |
| 794 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 795 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 796 | my $arg_list = convert_args(next_argument()); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 797 | my $prefix = "<tt class='function'>$function_name()</tt>"; |
Fred Drake | ca675e4 | 1999-04-21 15:58:58 +0000 | [diff] [blame] | 798 | my $idx = make_str_index_entry($prefix . get_indexsubitem()); |
| 799 | $prefix =~ s/\(\)//; |
| 800 | |
| 801 | return "<dt><b>$prefix</b> (<var>$arg_list</var>)\n<dd>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 802 | } |
| 803 | |
Fred Drake | 6b3fb78 | 1999-07-12 16:50:09 +0000 | [diff] [blame] | 804 | sub do_cmd_funclineni{ |
| 805 | local($_) = @_; |
| 806 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 807 | my $arg_list = convert_args(next_argument()); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 808 | my $prefix = "<tt class='function'>$function_name</tt>"; |
Fred Drake | 6b3fb78 | 1999-07-12 16:50:09 +0000 | [diff] [blame] | 809 | |
| 810 | return "<dt><b>$prefix</b> (<var>$arg_list</var>)\n<dd>" . $_; |
| 811 | } |
| 812 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 813 | # Change this flag to index the opcode entries. I don't think it's very |
| 814 | # useful to index them, since they're only presented to describe the dis |
| 815 | # module. |
| 816 | # |
| 817 | $INDEX_OPCODES = 0; |
| 818 | |
| 819 | sub do_env_opcodedesc{ |
| 820 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 821 | my $opcode_name = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 822 | my $arg_list = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 823 | my $idx; |
| 824 | if ($INDEX_OPCODES) { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 825 | $idx = make_str_index_entry("<tt class='opcode'>$opcode_name</tt>" |
| 826 | . " (byte code instruction)"); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 827 | $idx =~ s/ \(byte code instruction\)//; |
| 828 | } |
| 829 | else { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 830 | $idx = "<tt class='opcode'>$opcode_name</tt>"; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 831 | } |
| 832 | my $stuff = "<dl><dt><b>$idx</b>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 833 | if ($arg_list) { |
| 834 | $stuff .= " <var>$arg_list</var>"; |
| 835 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 836 | return $stuff . "\n<dd>" . $_ . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 837 | } |
| 838 | |
| 839 | sub do_env_datadesc{ |
| 840 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 841 | my $dataname = next_argument(); |
| 842 | my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 843 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 844 | return "<dl><dt><b>$idx</b>\n<dd>" |
| 845 | . $_ |
| 846 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 847 | } |
| 848 | |
| 849 | sub do_env_datadescni{ |
| 850 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 851 | my $idx = next_argument(); |
| 852 | if (! $STRING_INDEX_TT) { |
| 853 | $idx = "<tt>$idx</tt>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 854 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 855 | return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 856 | } |
| 857 | |
| 858 | sub do_cmd_dataline{ |
| 859 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 860 | my $data_name = next_argument(); |
| 861 | my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem()); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 862 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 863 | return "<dt><b>$idx</b><dd>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 864 | } |
| 865 | |
Fred Drake | adb272c | 2000-04-10 17:47:14 +0000 | [diff] [blame] | 866 | sub do_cmd_datalineni{ |
| 867 | local($_) = @_; |
| 868 | my $data_name = next_argument(); |
| 869 | return "<dt><b><tt>$data_name</tt></b><dd>" . $_; |
| 870 | } |
| 871 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 872 | sub do_env_excdesc{ |
| 873 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 874 | my $excname = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 875 | my $idx = make_str_index_entry("<tt class='exception'>$excname</tt>"); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 876 | return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>' |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 877 | } |
| 878 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 879 | sub do_env_fulllineitems{ return do_env_itemize(@_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 880 | |
| 881 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 882 | sub handle_classlike_descriptor{ |
| 883 | local($_, $what) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 884 | $THIS_CLASS = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 885 | my $arg_list = convert_args(next_argument()); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 886 | $idx = make_str_index_entry( |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 887 | "<tt class='$what'>$THIS_CLASS</tt> ($what in $THIS_MODULE)" ); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 888 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 889 | return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>'; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 890 | } |
| 891 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 892 | sub do_env_classdesc{ |
| 893 | return handle_classlike_descriptor(@_[0], "class"); |
| 894 | } |
| 895 | |
| 896 | sub do_env_excclassdesc{ |
| 897 | return handle_classlike_descriptor(@_[0], "exception"); |
| 898 | } |
| 899 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 900 | |
| 901 | sub do_env_methoddesc{ |
| 902 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 903 | my $class_name = next_optional_argument(); |
| 904 | $class_name = $THIS_CLASS |
| 905 | unless $class_name; |
Fred Drake | 5a0ca4e | 1999-01-12 04:16:51 +0000 | [diff] [blame] | 906 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 907 | my $arg_list = convert_args(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 908 | my $extra = ''; |
| 909 | if ($class_name) { |
| 910 | $extra = " ($class_name method)"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 911 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 912 | my $idx = make_str_index_entry("<tt class='method'>$method()</tt>$extra"); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 913 | $idx =~ s/ \(.*\)//; |
| 914 | $idx =~ s/\(\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 915 | 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] | 916 | } |
| 917 | |
| 918 | |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 919 | sub do_cmd_methodline{ |
| 920 | local($_) = @_; |
| 921 | my $class_name = next_optional_argument(); |
| 922 | $class_name = $THIS_CLASS |
| 923 | unless $class_name; |
| 924 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 925 | my $arg_list = convert_args(next_argument()); |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 926 | my $extra = ''; |
| 927 | if ($class_name) { |
| 928 | $extra = " ($class_name method)"; |
| 929 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 930 | my $idx = make_str_index_entry("<tt class='method'>$method()</tt>$extra"); |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 931 | $idx =~ s/ \(.*\)//; |
| 932 | $idx =~ s/\(\)//; |
| 933 | return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" |
| 934 | . $_; |
| 935 | } |
| 936 | |
| 937 | |
Fred Drake | d64a40d | 1998-09-10 18:59:13 +0000 | [diff] [blame] | 938 | sub do_cmd_methodlineni{ |
| 939 | local($_) = @_; |
| 940 | next_optional_argument(); |
| 941 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 942 | my $arg_list = convert_args(next_argument()); |
Fred Drake | d64a40d | 1998-09-10 18:59:13 +0000 | [diff] [blame] | 943 | return "<dt><b>$method</b> (<var>$arg_list</var>)\n<dd>" |
| 944 | . $_; |
| 945 | } |
| 946 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 947 | sub do_env_methoddescni{ |
| 948 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 949 | next_optional_argument(); |
| 950 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 951 | my $arg_list = convert_args(next_argument()); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 952 | return "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>" |
| 953 | . $_ |
| 954 | . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 955 | } |
| 956 | |
| 957 | |
| 958 | sub do_env_memberdesc{ |
| 959 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 960 | my $class = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 961 | my $member = next_argument(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 962 | $class = $THIS_CLASS |
| 963 | unless $class; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 964 | my $extra = ''; |
Fred Drake | 085b812 | 1999-04-21 14:00:29 +0000 | [diff] [blame] | 965 | $extra = " ($class attribute)" |
| 966 | if ($class ne ''); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 967 | my $idx = make_str_index_entry("<tt class='member'>$member</tt>$extra"); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 968 | $idx =~ s/ \(.*\)//; |
| 969 | $idx =~ s/\(\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 970 | return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 971 | } |
| 972 | |
| 973 | |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 974 | sub do_cmd_memberline{ |
| 975 | local($_) = @_; |
| 976 | my $class = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 977 | my $member = next_argument(); |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 978 | $class = $THIS_CLASS |
| 979 | unless $class; |
| 980 | my $extra = ''; |
Fred Drake | 085b812 | 1999-04-21 14:00:29 +0000 | [diff] [blame] | 981 | $extra = " ($class attribute)" |
| 982 | if ($class ne ''); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 983 | my $idx = make_str_index_entry("<tt class='member'>$member</tt>$extra"); |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 984 | $idx =~ s/ \(.*\)//; |
| 985 | $idx =~ s/\(\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 986 | return "<dt><b>$idx</b><dd>" . $_; |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 987 | } |
| 988 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 989 | sub do_env_memberdescni{ |
| 990 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 991 | next_optional_argument(); |
| 992 | my $member = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 993 | return "<dl><dt><b><tt class='member'>$member</tt></b>\n<dd>" |
| 994 | . $_ |
| 995 | . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 996 | } |
| 997 | |
| 998 | |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 999 | sub do_cmd_memberlineni{ |
| 1000 | local($_) = @_; |
| 1001 | next_optional_argument(); |
| 1002 | my $member = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1003 | return "<dt><b><tt class='member'>$member</tt></b><dd>" . $_; |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1004 | } |
| 1005 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1006 | @col_aligns = ('<td>', '<td>', '<td>', '<td>'); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1007 | |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1008 | sub fix_font{ |
| 1009 | # do a little magic on a font name to get the right behavior in the first |
| 1010 | # column of the output table |
| 1011 | my $font = @_[0]; |
| 1012 | if ($font eq 'textrm') { |
| 1013 | $font = ''; |
| 1014 | } |
| 1015 | elsif ($font eq 'file' || $font eq 'filenq') { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1016 | $font = 'tt class="file"'; |
| 1017 | } |
| 1018 | elsif ($font eq 'member') { |
| 1019 | $font = 'tt class="member"'; |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1020 | } |
Fred Drake | 7388f73 | 2000-06-28 21:06:08 +0000 | [diff] [blame] | 1021 | elsif ($font eq 'constant') { |
| 1022 | $font = 'tt class="constant"'; |
| 1023 | } |
Fred Drake | cb0fc9c | 2000-08-09 13:45:04 +0000 | [diff] [blame] | 1024 | elsif ($font eq 'kbd') { |
| 1025 | $font = 'kbd'; |
| 1026 | } |
Fred Drake | d04592a | 2000-10-25 16:15:13 +0000 | [diff] [blame] | 1027 | elsif ($font eq 'programopt') { |
| 1028 | $font = 'b'; |
| 1029 | } |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1030 | return $font; |
| 1031 | } |
| 1032 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1033 | sub figure_column_alignment{ |
| 1034 | my $a = @_[0]; |
| 1035 | my $mark = substr($a, 0, 1); |
| 1036 | my $r = ''; |
| 1037 | if ($mark eq 'c') |
| 1038 | { $r = ' align="center"'; } |
| 1039 | elsif ($mark eq 'r') |
| 1040 | { $r = ' align="right"'; } |
| 1041 | elsif ($mark eq 'l') |
| 1042 | { $r = ' align="left"'; } |
| 1043 | elsif ($mark eq 'p') |
| 1044 | { $r = ' align="left"'; } |
| 1045 | return $r; |
| 1046 | } |
| 1047 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1048 | sub setup_column_alignments{ |
| 1049 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1050 | my($s1,$s2,$s3,$s4) = split(/[|]/,$_); |
| 1051 | my $a1 = figure_column_alignment($s1); |
| 1052 | my $a2 = figure_column_alignment($s2); |
| 1053 | my $a3 = figure_column_alignment($s3); |
| 1054 | my $a4 = figure_column_alignment($s4); |
| 1055 | $col_aligns[0] = "<td$a1 valign=\"baseline\">"; |
| 1056 | $col_aligns[1] = "<td$a2>"; |
| 1057 | $col_aligns[2] = "<td$a3>"; |
| 1058 | $col_aligns[3] = "<td$a4>"; |
Fred Drake | 79189b5 | 1999-04-28 13:54:30 +0000 | [diff] [blame] | 1059 | # return the aligned header start tags |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1060 | return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>"); |
| 1061 | } |
| 1062 | |
| 1063 | sub get_table_col1_fonts{ |
| 1064 | my $font = $globals{'lineifont'}; |
| 1065 | my ($sfont,$efont) = ('', ''); |
| 1066 | if ($font) { |
| 1067 | $sfont = "<$font>"; |
| 1068 | $efont = "</$font>"; |
| 1069 | $efont =~ s/ .*>/>/; |
| 1070 | } |
| 1071 | return ($font, $sfont, $efont); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1072 | } |
| 1073 | |
| 1074 | sub do_env_tableii{ |
| 1075 | local($_) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1076 | my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument()); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1077 | my $font = fix_font(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1078 | my $h1 = next_argument(); |
| 1079 | my $h2 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1080 | s/[\s\n]+//; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1081 | $globals{'lineifont'} = $font; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1082 | my $a1 = $col_aligns[0]; |
| 1083 | my $a2 = $col_aligns[1]; |
| 1084 | s/\\lineii</\\lineii[$a1|$a2]</g; |
| 1085 | return '<table border align="center" style="border-collapse: collapse">' |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1086 | . "\n <thead>" |
| 1087 | . "\n <tr class=\"tableheader\">" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1088 | . "\n $th1<b>$h1</b>\ </th>" |
| 1089 | . "\n $th2<b>$h2</b>\ </th>" |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1090 | . "\n </tr>" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1091 | . "\n </thead>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1092 | . "\n <tbody valign='baseline'>" |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1093 | . $_ |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1094 | . "\n </tbody>" |
| 1095 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1096 | } |
| 1097 | |
Fred Drake | da72b93 | 2000-09-21 15:58:02 +0000 | [diff] [blame] | 1098 | sub do_env_longtableii{ |
| 1099 | return do_env_tableii(@_); |
| 1100 | } |
| 1101 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1102 | sub do_cmd_lineii{ |
| 1103 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1104 | my $aligns = next_optional_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1105 | my $c1 = next_argument(); |
| 1106 | my $c2 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1107 | s/[\s\n]+//; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1108 | my($font,$sfont,$efont) = get_table_col1_fonts(); |
| 1109 | $c2 = ' ' if ($c2 eq ''); |
| 1110 | my($c1align,$c2align) = split('\|', $aligns); |
| 1111 | my $padding = ''; |
| 1112 | if ($c1align =~ /align="right"/) { |
| 1113 | $padding = ' '; |
Fred Drake | 58b2bfd | 1998-04-02 20:14:04 +0000 | [diff] [blame] | 1114 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1115 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
| 1116 | . " $c2align$c2</td>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1117 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1118 | } |
| 1119 | |
| 1120 | sub do_env_tableiii{ |
| 1121 | local($_) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1122 | my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument()); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1123 | my $font = fix_font(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1124 | my $h1 = next_argument(); |
| 1125 | my $h2 = next_argument(); |
| 1126 | my $h3 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1127 | s/[\s\n]+//; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1128 | $globals{'lineifont'} = $font; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1129 | my $a1 = $col_aligns[0]; |
| 1130 | my $a2 = $col_aligns[1]; |
| 1131 | my $a3 = $col_aligns[2]; |
| 1132 | s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g; |
| 1133 | return '<table border align="center" style="border-collapse: collapse">' |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1134 | . "\n <thead>" |
| 1135 | . "\n <tr class=\"tableheader\">" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1136 | . "\n $th1<b>$h1</b>\ </th>" |
| 1137 | . "\n $th2<b>$h2</b>\ </th>" |
| 1138 | . "\n $th3<b>$h3</b>\ </th>" |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1139 | . "\n </tr>" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1140 | . "\n </thead>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1141 | . "\n <tbody valign='baseline'>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1142 | . $_ |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1143 | . "\n </tbody>" |
| 1144 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1145 | } |
| 1146 | |
Fred Drake | da72b93 | 2000-09-21 15:58:02 +0000 | [diff] [blame] | 1147 | sub do_env_longtableiii{ |
| 1148 | return do_env_tableiii(@_); |
| 1149 | } |
| 1150 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1151 | sub do_cmd_lineiii{ |
| 1152 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1153 | my $aligns = next_optional_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1154 | my $c1 = next_argument(); |
| 1155 | my $c2 = next_argument(); |
| 1156 | my $c3 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1157 | s/[\s\n]+//; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1158 | my($font,$sfont,$efont) = get_table_col1_fonts(); |
| 1159 | $c3 = ' ' if ($c3 eq ''); |
| 1160 | my($c1align,$c2align,$c3align) = split('\|', $aligns); |
| 1161 | my $padding = ''; |
| 1162 | if ($c1align =~ /align="right"/) { |
| 1163 | $padding = ' '; |
Fred Drake | 58b2bfd | 1998-04-02 20:14:04 +0000 | [diff] [blame] | 1164 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1165 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1166 | . " $c2align$c2</td>\n" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1167 | . " $c3align$c3</td>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1168 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1169 | } |
| 1170 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1171 | sub do_env_tableiv{ |
| 1172 | local($_) = @_; |
| 1173 | my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument()); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1174 | my $font = fix_font(next_argument()); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1175 | my $h1 = next_argument(); |
| 1176 | my $h2 = next_argument(); |
| 1177 | my $h3 = next_argument(); |
| 1178 | my $h4 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1179 | s/[\s\n]+//; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1180 | $globals{'lineifont'} = $font; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1181 | my $a1 = $col_aligns[0]; |
| 1182 | my $a2 = $col_aligns[1]; |
| 1183 | my $a3 = $col_aligns[2]; |
| 1184 | my $a4 = $col_aligns[3]; |
| 1185 | s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g; |
| 1186 | return '<table border align="center" style="border-collapse: collapse">' |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1187 | . "\n <thead>" |
| 1188 | . "\n <tr class=\"tableheader\">" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1189 | . "\n $th1<b>$h1</b>\ </th>" |
| 1190 | . "\n $th2<b>$h2</b>\ </th>" |
| 1191 | . "\n $th3<b>$h3</b>\ </th>" |
| 1192 | . "\n $th4<b>$h4</b>\ </th>" |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1193 | . "\n </tr>" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1194 | . "\n </thead>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1195 | . "\n <tbody valign='baseline'>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1196 | . $_ |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1197 | . "\n </tbody>" |
| 1198 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1199 | } |
| 1200 | |
Fred Drake | da72b93 | 2000-09-21 15:58:02 +0000 | [diff] [blame] | 1201 | sub do_env_longtableiv{ |
| 1202 | return do_env_tableiv(@_); |
| 1203 | } |
| 1204 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1205 | sub do_cmd_lineiv{ |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1206 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1207 | my $aligns = next_optional_argument(); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1208 | my $c1 = next_argument(); |
| 1209 | my $c2 = next_argument(); |
| 1210 | my $c3 = next_argument(); |
| 1211 | my $c4 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1212 | s/[\s\n]+//; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1213 | my($font,$sfont,$efont) = get_table_col1_fonts(); |
| 1214 | $c4 = ' ' if ($c4 eq ''); |
| 1215 | my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns); |
| 1216 | my $padding = ''; |
| 1217 | if ($c1align =~ /align="right"/) { |
| 1218 | $padding = ' '; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1219 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1220 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1221 | . " $c2align$c2</td>\n" |
| 1222 | . " $c3align$c3</td>\n" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1223 | . " $c4align$c4</td>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1224 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1225 | } |
| 1226 | |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1227 | |
| 1228 | # These can be used to control the title page appearance; |
| 1229 | # they need a little bit of documentation. |
| 1230 | # |
| 1231 | # If $TITLE_PAGE_GRAPHIC is set, it should be the name of a file in the |
| 1232 | # $ICONSERVER directory, or include path information (other than "./"). The |
| 1233 | # default image type will be assumed if an extension is not provided. |
| 1234 | # |
| 1235 | # If specified, the "title page" will contain two colums: one containing the |
| 1236 | # title/author/etc., and the other containing the graphic. Use the other |
| 1237 | # four variables listed here to control specific details of the layout; all |
| 1238 | # are optional. |
| 1239 | # |
| 1240 | # $TITLE_PAGE_GRAPHIC = "my-company-logo"; |
| 1241 | # $TITLE_PAGE_GRAPHIC_COLWIDTH = "30%"; |
| 1242 | # $TITLE_PAGE_GRAPHIC_WIDTH = 150; |
| 1243 | # $TITLE_PAGE_GRAPHIC_HEIGHT = 150; |
| 1244 | # $TITLE_PAGE_GRAPHIC_ON_RIGHT = 0; |
| 1245 | |
| 1246 | sub make_my_titlepage() { |
| 1247 | my $the_title = ""; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1248 | if ($t_title) { |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 1249 | $the_title .= "\n<h1>$t_title</h1>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1250 | } |
| 1251 | else { |
| 1252 | write_warnings("\nThis document has no title."); |
| 1253 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1254 | if ($t_author) { |
| 1255 | if ($t_authorURL) { |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1256 | my $href = translate_commands($t_authorURL); |
Fred Drake | 2d1f81e | 1999-02-09 16:03:31 +0000 | [diff] [blame] | 1257 | $href = make_named_href('author', $href, |
| 1258 | "<b><font size='+2'>$t_author</font></b>"); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1259 | $the_title .= "\n<p>$href</p>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1260 | } |
| 1261 | else { |
Fred Drake | 2d1f81e | 1999-02-09 16:03:31 +0000 | [diff] [blame] | 1262 | $the_title .= ("\n<p><b><font size='+2'>$t_author</font></b></p>"); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1263 | } |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1264 | } |
| 1265 | else { |
| 1266 | write_warnings("\nThere is no author for this document."); |
| 1267 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1268 | if ($t_institute) { |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1269 | $the_title .= "\n<p>$t_institute</p>"; |
| 1270 | } |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 1271 | if ($DEVELOPER_ADDRESS) { |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1272 | $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>"; |
| 1273 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1274 | if ($t_affil) { |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1275 | $the_title .= "\n<p><i>$t_affil</i></p>"; |
| 1276 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1277 | if ($t_date) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1278 | $the_title .= "\n<p><strong>$t_date</strong>"; |
Fred Drake | d04592a | 2000-10-25 16:15:13 +0000 | [diff] [blame] | 1279 | if ($PACKAGE_VERSION) { |
| 1280 | $the_title .= "<br><strong>Release $PACKAGE_VERSION</strong>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1281 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1282 | $the_title .= "</p>" |
| 1283 | } |
| 1284 | if ($t_address) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1285 | $the_title .= "\n<p>$t_address</p>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1286 | } |
| 1287 | else { |
| 1288 | $the_title .= "\n<p>"; |
| 1289 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1290 | if ($t_email) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1291 | $the_title .= "\n<p>$t_email</p>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1292 | } |
| 1293 | return $the_title; |
| 1294 | } |
| 1295 | |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1296 | sub make_my_titlegraphic() { |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1297 | my $filename = make_icon_filename($TITLE_PAGE_GRAPHIC); |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1298 | my $graphic = "<td class=\"titlegraphic\""; |
| 1299 | $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_COLWIDTH\"" |
| 1300 | if ($TITLE_PAGE_GRAPHIC_COLWIDTH); |
| 1301 | $graphic .= "><img"; |
| 1302 | $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_WIDTH\"" |
| 1303 | if ($TITLE_PAGE_GRAPHIC_WIDTH); |
| 1304 | $graphic .= " height=\"$TITLE_PAGE_GRAPHIC_HEIGHT\"" |
| 1305 | if ($TITLE_PAGE_GRAPHIC_HEIGHT); |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 1306 | $graphic .= "\n src=\"$filename\"></td>\n"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1307 | return $graphic; |
| 1308 | } |
| 1309 | |
| 1310 | sub do_cmd_maketitle { |
| 1311 | local($_) = @_; |
| 1312 | my $the_title = "\n<div class=\"titlepage\">"; |
| 1313 | if ($TITLE_PAGE_GRAPHIC) { |
| 1314 | if ($TITLE_PAGE_GRAPHIC_ON_RIGHT) { |
| 1315 | $the_title .= ("\n<table border=\"0\" width=\"100%\">" |
| 1316 | . "<tr align=\"right\">\n<td>" |
| 1317 | . make_my_titlepage() |
| 1318 | . "</td>\n" |
| 1319 | . make_my_titlegraphic() |
| 1320 | . "</tr>\n</table>"); |
| 1321 | } |
| 1322 | else { |
| 1323 | $the_title .= ("\n<table border=\"0\" width=\"100%\"><tr>\n" |
| 1324 | . make_my_titlegraphic() |
| 1325 | . "<td>" |
| 1326 | . make_my_titlepage() |
| 1327 | . "</td></tr>\n</table>"); |
| 1328 | } |
| 1329 | } |
| 1330 | else { |
| 1331 | $the_title .= ("\n<center>" |
| 1332 | . make_my_titlepage() |
| 1333 | . "\n</center>"); |
| 1334 | } |
| 1335 | $the_title .= "\n</div>"; |
| 1336 | return $the_title . $_; |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 1337 | $the_title .= "\n</center></div>"; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1338 | return $the_title . $_ ; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1339 | } |
| 1340 | |
| 1341 | |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1342 | # |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1343 | # Module synopsis support |
| 1344 | # |
| 1345 | |
| 1346 | require SynopsisTable; |
| 1347 | |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1348 | sub get_chapter_id(){ |
| 1349 | my $id = do_cmd_thechapter(''); |
Fred Drake | 45f2601 | 1998-08-04 22:07:18 +0000 | [diff] [blame] | 1350 | $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/; |
| 1351 | $id =~ s/\.//; |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1352 | return $id; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1353 | } |
| 1354 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1355 | # 'chapter' => 'SynopsisTable instance' |
| 1356 | %ModuleSynopses = (); |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1357 | |
| 1358 | sub get_synopsis_table($){ |
| 1359 | my($chap) = @_; |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1360 | my $key; |
| 1361 | foreach $key (keys %ModuleSynopses) { |
| 1362 | if ($key eq $chap) { |
| 1363 | return $ModuleSynopses{$chap}; |
| 1364 | } |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1365 | } |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1366 | my $st = SynopsisTable->new(); |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1367 | $ModuleSynopses{$chap} = $st; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1368 | return $st; |
| 1369 | } |
| 1370 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1371 | sub do_cmd_moduleauthor{ |
| 1372 | local($_) = @_; |
| 1373 | next_argument(); |
| 1374 | next_argument(); |
| 1375 | return $_; |
| 1376 | } |
| 1377 | |
| 1378 | sub do_cmd_sectionauthor{ |
| 1379 | local($_) = @_; |
| 1380 | next_argument(); |
| 1381 | next_argument(); |
| 1382 | return $_; |
| 1383 | } |
| 1384 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1385 | sub do_cmd_declaremodule{ |
| 1386 | local($_) = @_; |
| 1387 | my $key = next_optional_argument(); |
| 1388 | my $type = next_argument(); |
| 1389 | my $name = next_argument(); |
| 1390 | my $st = get_synopsis_table(get_chapter_id()); |
| 1391 | # |
| 1392 | $key = $name unless $key; |
| 1393 | $type = 'built-in' if $type eq 'builtin'; |
| 1394 | $st->declare($name, $key, $type); |
| 1395 | define_module($type, $name); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1396 | return anchor_label("module-$key",$CURRENT_FILE,$_) |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1397 | } |
| 1398 | |
| 1399 | sub do_cmd_modulesynopsis{ |
| 1400 | local($_) = @_; |
| 1401 | my $st = get_synopsis_table(get_chapter_id()); |
Fred Drake | 1cc5899 | 1999-04-13 22:08:59 +0000 | [diff] [blame] | 1402 | $st->set_synopsis($THIS_MODULE, translate_commands(next_argument())); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1403 | return $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1404 | } |
| 1405 | |
| 1406 | sub do_cmd_localmoduletable{ |
| 1407 | local($_) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1408 | my $chap = get_chapter_id(); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1409 | my $st = get_synopsis_table($chap); |
| 1410 | $st->set_file("$CURRENT_FILE"); |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1411 | return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1412 | } |
| 1413 | |
| 1414 | sub process_all_localmoduletables{ |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1415 | my $key; |
| 1416 | my $st, $file; |
| 1417 | foreach $key (keys %ModuleSynopses) { |
| 1418 | $st = $ModuleSynopses{$key}; |
| 1419 | $file = $st->get_file(); |
| 1420 | if ($file) { |
| 1421 | process_localmoduletables_in_file($file); |
| 1422 | } |
| 1423 | else { |
| 1424 | print "\nsynopsis table $key has no file association"; |
| 1425 | } |
| 1426 | } |
| 1427 | } |
| 1428 | |
| 1429 | sub process_localmoduletables_in_file{ |
| 1430 | my $file = @_[0]; |
| 1431 | open(MYFILE, "<$file"); |
| 1432 | local($_); |
| 1433 | sysread(MYFILE, $_, 1024*1024); |
| 1434 | close(MYFILE); |
| 1435 | # need to get contents of file in $_ |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1436 | while (/<tex2html-localmoduletable><(\d+)>/) { |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1437 | my $match = $&; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1438 | my $chap = $1; |
| 1439 | my $st = get_synopsis_table($chap); |
| 1440 | my $data = $st->tohtml(); |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1441 | s/$match/$data/; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1442 | } |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1443 | open(MYFILE,">$file"); |
| 1444 | print MYFILE $_; |
| 1445 | close(MYFILE); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1446 | } |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1447 | sub process_python_state{ |
| 1448 | process_all_localmoduletables(); |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1449 | } |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1450 | |
| 1451 | |
| 1452 | # |
| 1453 | # "See also:" -- references placed at the end of a \section |
| 1454 | # |
| 1455 | |
| 1456 | sub do_env_seealso{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1457 | return "<div class='seealso'>\n " |
| 1458 | . "<p class='heading'><b>See Also:</b></p>\n" |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 1459 | . @_[0] |
| 1460 | . '</div>'; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1461 | } |
| 1462 | |
| 1463 | sub do_cmd_seemodule{ |
| 1464 | # Insert the right magic to jump to the module definition. This should |
| 1465 | # work most of the time, at least for repeat builds.... |
| 1466 | local($_) = @_; |
| 1467 | my $key = next_optional_argument(); |
| 1468 | my $module = next_argument(); |
| 1469 | my $text = next_argument(); |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 1470 | my $period = '.'; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1471 | $key = $module |
| 1472 | unless $key; |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 1473 | if ($text =~ /\.$/) { |
| 1474 | $period = ''; |
| 1475 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1476 | return '<dl compact class="seemodule">' |
| 1477 | . "\n <dt>Module <b><tt class='module'><a href='module-$key.html'>" |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 1478 | . "$module</a></tt>:</b>" |
| 1479 | . "\n <dd>$text$period\n </dl>" |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 1480 | . $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1481 | } |
| 1482 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1483 | sub handle_rfclike_reference{ |
| 1484 | local($_, $what) = @_; |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 1485 | my $rfcnum = next_argument(); |
| 1486 | my $title = next_argument(); |
| 1487 | my $text = next_argument(); |
| 1488 | my $url = get_rfc_url($rfcnum); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1489 | my $icon = get_link_icon($url); |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 1490 | return '<dl compact class="seerfc">' |
| 1491 | . "\n <dt><a href=\"$url\"" |
| 1492 | . "\n title=\"$title\"" |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 1493 | . "\n >$what $rfcnum, <em>$title</em>$icon</a>" |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 1494 | . "\n <dd>$text\n </dl>" |
| 1495 | . $_; |
| 1496 | } |
| 1497 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1498 | sub do_cmd_seepep{ |
| 1499 | return handle_rfclike_reference(@_[0], "PEP"); |
| 1500 | } |
| 1501 | |
| 1502 | sub do_cmd_seerfc{ |
| 1503 | return handle_rfclike_reference(@_[0], "RFC"); |
| 1504 | } |
| 1505 | |
Fred Drake | 4844998 | 2000-09-12 17:52:33 +0000 | [diff] [blame] | 1506 | sub do_cmd_seetitle{ |
| 1507 | local($_) = @_; |
| 1508 | my $url = next_optional_argument(); |
| 1509 | my $title = next_argument(); |
| 1510 | my $text = next_argument(); |
| 1511 | if ($url) { |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 1512 | my $icon = get_link_icon($url); |
Fred Drake | 4844998 | 2000-09-12 17:52:33 +0000 | [diff] [blame] | 1513 | return '<dl compact class="seetitle">' |
| 1514 | . "\n <dt><em class=\"citetitle\"><a href=\"$url\"" |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1515 | . "\n >$title$icon</a></em>" |
Fred Drake | 4844998 | 2000-09-12 17:52:33 +0000 | [diff] [blame] | 1516 | . "\n <dd>$text\n </dl>" |
| 1517 | . $_; |
| 1518 | } |
| 1519 | return '<dl compact class="seetitle">' |
| 1520 | . "\n <dt><em class=\"citetitle\"" |
| 1521 | . "\n >$title</em>" |
| 1522 | . "\n <dd>$text\n </dl>" |
| 1523 | . $_; |
| 1524 | } |
| 1525 | |
Fred Drake | ef4d111 | 2000-05-09 16:17:51 +0000 | [diff] [blame] | 1526 | sub do_cmd_seeurl{ |
| 1527 | local($_) = @_; |
| 1528 | my $url = next_argument(); |
| 1529 | my $text = next_argument(); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1530 | my $icon = get_link_icon($url); |
Fred Drake | ef4d111 | 2000-05-09 16:17:51 +0000 | [diff] [blame] | 1531 | return '<dl compact class="seeurl">' |
| 1532 | . "\n <dt><a href=\"$url\"" |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1533 | . "\n class=\"url\">$url$icon</a>" |
Fred Drake | ef4d111 | 2000-05-09 16:17:51 +0000 | [diff] [blame] | 1534 | . "\n <dd>$text\n </dl>" |
| 1535 | . $_; |
| 1536 | } |
| 1537 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1538 | sub do_cmd_seetext{ |
Fred Drake | 79189b5 | 1999-04-28 13:54:30 +0000 | [diff] [blame] | 1539 | local($_) = @_; |
| 1540 | my $content = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1541 | return '<div class="seetext"><p>' . $content . '</div>' . $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1542 | } |
| 1543 | |
| 1544 | |
| 1545 | # |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1546 | # Definition list support. |
| 1547 | # |
| 1548 | |
| 1549 | sub do_env_definitions{ |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 1550 | return "<dl class='definitions'>" . @_[0] . "</dl>\n"; |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1551 | } |
| 1552 | |
| 1553 | sub do_cmd_term{ |
| 1554 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1555 | my $term = next_argument(); |
| 1556 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1557 | # could easily add an index entry here... |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1558 | return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_; |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1559 | } |
| 1560 | |
| 1561 | |
Fred Drake | 38178fd | 2000-09-22 17:05:04 +0000 | [diff] [blame] | 1562 | # I don't recall exactly why this was needed, but it was very much needed. |
| 1563 | # We'll see if anything breaks when I move the "code" line out -- some |
| 1564 | # things broke with it in. |
| 1565 | |
| 1566 | #code # {} |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 1567 | process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_); |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 1568 | declaremodule # [] # {} # {} |
| 1569 | memberline # [] # {} |
| 1570 | methodline # [] # {} # {} |
| 1571 | modulesynopsis # {} |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1572 | platform # {} |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 1573 | samp # {} |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 1574 | setindexsubitem # {} |
Fred Drake | f32834c | 1999-02-12 22:06:32 +0000 | [diff] [blame] | 1575 | withsubitem # {} # {} |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 1576 | _RAW_ARG_DEFERRED_CMDS_ |
| 1577 | |
| 1578 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1579 | 1; # This must be the last line |