Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1 | # python.perl by Fred L. Drake, Jr. <fdrake@acm.org> -*- perl -*- |
| 2 | # |
| 3 | # Heavily based on Guido van Rossum's myformat.perl (now obsolete). |
| 4 | # |
| 5 | # Extension to LaTeX2HTML for documents using myformat.sty. |
| 6 | # Subroutines of the form do_cmd_<name> here define translations |
| 7 | # for LaTeX commands \<name> defined in the corresponding .sty file. |
| 8 | |
| 9 | package main; |
| 10 | |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 11 | use File::Basename; |
| 12 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 13 | |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 14 | sub next_argument{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 15 | my $param; |
| 16 | $param = missing_braces() |
| 17 | unless ((s/$next_pair_pr_rx/$param=$2;''/eo) |
| 18 | ||(s/$next_pair_rx/$param=$2;''/eo)); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 19 | return $param; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | sub next_optional_argument{ |
| 23 | my($param,$rx) = ('', "^\\s*(\\[([^]]*)\\])?"); |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 24 | s/$rx/$param=$2;''/eo; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 25 | return $param; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 26 | } |
| 27 | |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 28 | sub make_icon_filename($){ |
| 29 | my($myname, $mydir, $myext) = fileparse(@_[0], '\..*'); |
| 30 | chop $mydir; |
| 31 | if ($mydir eq '.') { |
| 32 | $mydir = $ICONSERVER; |
| 33 | } |
| 34 | $myext = ".$IMAGE_TYPE" |
| 35 | unless $myext; |
| 36 | return "$mydir$dd$myname$myext"; |
| 37 | } |
| 38 | |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 39 | sub get_link_icon($){ |
| 40 | my $url = @_[0]; |
| 41 | if ($OFF_SITE_LINK_ICON && ($url =~ /^[-a-zA-Z0-9.]+:/)) { |
| 42 | # absolute URL; assume it points off-site |
| 43 | my $icon = make_icon_filename($OFF_SITE_LINK_ICON); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 44 | return (" <img src=\"$icon\"\n" |
| 45 | . ' border="0" class="offsitelink"' |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 46 | . ($OFF_SITE_LINK_ICON_HEIGHT |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 47 | ? " height=\"$OFF_SITE_LINK_ICON_HEIGHT\"" |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 48 | : '') |
| 49 | . ($OFF_SITE_LINK_ICON_WIDTH |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 50 | ? " width=\"$OFF_SITE_LINK_ICON_WIDTH\"" |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 51 | : '') |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 52 | . " alt=\"[off-site link]\"\n" |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 53 | . " >"); |
| 54 | } |
| 55 | return ''; |
| 56 | } |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 57 | |
| 58 | # This is a fairly simple hack; it supports \let when it is used to create |
| 59 | # (or redefine) a macro to exactly be some other macro: \let\newname=\oldname. |
Fred Drake | 5b73cdf | 1998-05-15 16:59:38 +0000 | [diff] [blame] | 60 | # Many possible uses of \let aren't supported or aren't supported correctly. |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 61 | # |
| 62 | sub do_cmd_let{ |
| 63 | local($_) = @_; |
| 64 | my $matched = 0; |
Fred Drake | 7a4ad0f | 1998-05-15 13:45:54 +0000 | [diff] [blame] | 65 | s/[\\]([a-zA-Z]+)\s*(=\s*)?[\\]([a-zA-Z]*)/$matched=1; ''/e; |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 66 | if ($matched) { |
| 67 | my($new, $old) = ($1, $3); |
| 68 | eval "sub do_cmd_$new { do_cmd_$old" . '(@_); }'; |
| 69 | print "\ndefining handler for \\$new using \\$old\n"; |
| 70 | } |
Fred Drake | 7a4ad0f | 1998-05-15 13:45:54 +0000 | [diff] [blame] | 71 | else { |
| 72 | s/[\\]([a-zA-Z]+)\s*(=\s*)?([^\\])/$matched=1; ''/es; |
| 73 | if ($matched) { |
| 74 | my($new, $char) = ($1, $3); |
| 75 | eval "sub do_cmd_$new { \"\\$char\" . \@_[0]; }"; |
| 76 | print "\ndefining handler for \\$new to insert '$char'\n"; |
| 77 | } |
| 78 | else { |
| 79 | write_warnings("Could not interpret \\let construct..."); |
| 80 | } |
| 81 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 82 | return $_; |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | |
Fred Drake | c3fd45f | 2000-06-15 22:41:48 +0000 | [diff] [blame] | 86 | # the older version of LaTeX2HTML we use doesn't support this, but we use it: |
| 87 | |
| 88 | sub do_cmd_textasciitilde{ '~' . @_[0]; } |
Fred Drake | 056a71d | 2001-04-21 05:48:07 +0000 | [diff] [blame] | 89 | sub do_cmd_textasciicircum{ '^' . @_[0]; } |
Fred Drake | 6fe4660 | 2001-06-23 03:13:30 +0000 | [diff] [blame] | 90 | sub do_cmd_textbar{ '|' . @_[0]; } |
| 91 | sub do_cmd_infinity{ '∞' . @_[0]; } |
| 92 | sub do_cmd_plusminus{ '±' . @_[0]; } |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 93 | sub do_cmd_menuselection{ @_[0]; } |
| 94 | sub do_cmd_sub{ ' > ' . @_[0]; } |
Fred Drake | c3fd45f | 2000-06-15 22:41:48 +0000 | [diff] [blame] | 95 | |
| 96 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 97 | # words typeset in a special way (not in HTML though) |
| 98 | |
| 99 | sub do_cmd_ABC{ 'ABC' . @_[0]; } |
| 100 | sub do_cmd_UNIX{ 'Unix'. @_[0]; } |
| 101 | sub do_cmd_ASCII{ 'ASCII' . @_[0]; } |
| 102 | sub do_cmd_POSIX{ 'POSIX' . @_[0]; } |
| 103 | sub do_cmd_C{ 'C' . @_[0]; } |
| 104 | sub do_cmd_Cpp{ 'C++' . @_[0]; } |
| 105 | sub do_cmd_EOF{ 'EOF' . @_[0]; } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 106 | sub do_cmd_NULL{ '<tt class="constant">NULL</tt>' . @_[0]; } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 107 | |
| 108 | sub do_cmd_e{ '\' . @_[0]; } |
| 109 | |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 110 | $DEVELOPER_ADDRESS = ''; |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 111 | $SHORT_VERSION = ''; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 112 | $RELEASE_INFO = ''; |
Fred Drake | d04592a | 2000-10-25 16:15:13 +0000 | [diff] [blame] | 113 | $PACKAGE_VERSION = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 114 | |
Fred Drake | d04592a | 2000-10-25 16:15:13 +0000 | [diff] [blame] | 115 | sub do_cmd_version{ $PACKAGE_VERSION . @_[0]; } |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 116 | sub do_cmd_shortversion{ $SHORT_VERSION . @_[0]; } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 117 | sub do_cmd_release{ |
| 118 | local($_) = @_; |
Fred Drake | d04592a | 2000-10-25 16:15:13 +0000 | [diff] [blame] | 119 | $PACKAGE_VERSION = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 120 | return $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 121 | } |
| 122 | |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 123 | sub do_cmd_setreleaseinfo{ |
| 124 | local($_) = @_; |
| 125 | $RELEASE_INFO = next_argument(); |
| 126 | return $_; |
| 127 | } |
| 128 | |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 129 | sub do_cmd_setshortversion{ |
| 130 | local($_) = @_; |
| 131 | $SHORT_VERSION = next_argument(); |
| 132 | return $_; |
| 133 | } |
| 134 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 135 | sub do_cmd_authoraddress{ |
| 136 | local($_) = @_; |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 137 | $DEVELOPER_ADDRESS = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 138 | return $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 139 | } |
| 140 | |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 141 | #sub do_cmd_developer{ do_cmd_author(@_[0]); } |
| 142 | #sub do_cmd_developers{ do_cmd_author(@_[0]); } |
| 143 | #sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); } |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 144 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 145 | sub do_cmd_hackscore{ |
| 146 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 147 | next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 148 | return '_' . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 149 | } |
| 150 | |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 151 | sub use_wrappers{ |
| 152 | local($_,$before,$after) = @_; |
| 153 | my $stuff = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 154 | return $before . $stuff . $after . $_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 155 | } |
| 156 | |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 157 | $IN_DESC_HANDLER = 0; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 158 | sub do_cmd_optional{ |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 159 | if ($IN_DESC_HANDLER) { |
| 160 | return use_wrappers(@_[0], "</var><big>\[</big><var>", |
| 161 | "</var><big>\]</big><var>"); |
| 162 | } |
| 163 | else { |
| 164 | return use_wrappers(@_[0], "<big>\[</big>", "<big>\]</big>"); |
| 165 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 166 | } |
| 167 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 168 | # Logical formatting (some based on texinfo), needs to be converted to |
| 169 | # minimalist HTML. The "minimalist" is primarily to reduce the size of |
| 170 | # output files for users that read them over the network rather than |
| 171 | # from local repositories. |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 172 | |
Fred Drake | 2cafcbb | 1999-03-25 16:57:04 +0000 | [diff] [blame] | 173 | # \file and \samp are at the end of this file since they screw up fontlock. |
| 174 | |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 175 | sub do_cmd_pytype{ return @_[0]; } |
Fred Drake | 3d5a04a | 2000-08-03 17:25:44 +0000 | [diff] [blame] | 176 | sub do_cmd_makevar{ |
| 177 | return use_wrappers(@_[0], '<span class="makevar">', '</span>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 178 | sub do_cmd_code{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 179 | return use_wrappers(@_[0], '<code>', '</code>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 180 | sub do_cmd_module{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 181 | return use_wrappers(@_[0], '<tt class="module">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 182 | sub do_cmd_keyword{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 183 | return use_wrappers(@_[0], '<tt class="keyword">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 184 | sub do_cmd_exception{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 185 | return use_wrappers(@_[0], '<tt class="exception">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 186 | sub do_cmd_class{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 187 | return use_wrappers(@_[0], '<tt class="class">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 188 | sub do_cmd_function{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 189 | return use_wrappers(@_[0], '<tt class="function">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 190 | sub do_cmd_constant{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 191 | return use_wrappers(@_[0], '<tt class="constant">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 192 | sub do_cmd_member{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 193 | return use_wrappers(@_[0], '<tt class="member">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 194 | sub do_cmd_method{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 195 | return use_wrappers(@_[0], '<tt class="method">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 196 | sub do_cmd_cfunction{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 197 | return use_wrappers(@_[0], '<tt class="cfunction">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 198 | sub do_cmd_cdata{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 199 | return use_wrappers(@_[0], '<tt class="cdata">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 200 | sub do_cmd_ctype{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 201 | return use_wrappers(@_[0], '<tt class="ctype">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 202 | sub do_cmd_regexp{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 203 | return use_wrappers(@_[0], '<tt class="regexp">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 204 | sub do_cmd_character{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 205 | return use_wrappers(@_[0], '"<tt class="character">', '</tt>"'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 206 | sub do_cmd_program{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 207 | return use_wrappers(@_[0], '<b class="program">', '</b>'); } |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 208 | sub do_cmd_programopt{ |
| 209 | return use_wrappers(@_[0], '<b class="programopt">', '</b>'); } |
Fred Drake | 0cd6021 | 2000-04-11 18:46:59 +0000 | [diff] [blame] | 210 | sub do_cmd_longprogramopt{ |
| 211 | # note that the --- will be later converted to -- by LaTeX2HTML |
| 212 | return use_wrappers(@_[0], '<b class="programopt">---', '</b>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 213 | sub do_cmd_email{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 214 | return use_wrappers(@_[0], '<span class="email">', '</span>'); } |
Fred Drake | 7eac0cb | 2001-08-03 18:36:17 +0000 | [diff] [blame] | 215 | sub do_cmd_mailheader{ |
| 216 | return use_wrappers(@_[0], '<tt class="mimeheader">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 217 | sub do_cmd_mimetype{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 218 | return use_wrappers(@_[0], '<span class="mimetype">', '</span>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 219 | sub do_cmd_var{ |
| 220 | return use_wrappers(@_[0], "<var>", "</var>"); } |
| 221 | sub do_cmd_dfn{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 222 | return use_wrappers(@_[0], '<i class="dfn">', '</i>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 223 | sub do_cmd_emph{ |
Fred Drake | 38178fd | 2000-09-22 17:05:04 +0000 | [diff] [blame] | 224 | return use_wrappers(@_[0], '<i>', '</i>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 225 | sub do_cmd_file{ |
Fred Drake | 3d5a04a | 2000-08-03 17:25:44 +0000 | [diff] [blame] | 226 | return use_wrappers(@_[0], '<span class="file">', '</span>'); } |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 227 | sub do_cmd_filenq{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 228 | return do_cmd_file(@_[0]); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 229 | sub do_cmd_samp{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 230 | return use_wrappers(@_[0], '"<tt class="samp">', '</tt>"'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 231 | sub do_cmd_kbd{ |
| 232 | return use_wrappers(@_[0], '<kbd>', '</kbd>'); } |
| 233 | sub do_cmd_strong{ |
| 234 | return use_wrappers(@_[0], '<b>', '</b>'); } |
Fred Drake | 2cafcbb | 1999-03-25 16:57:04 +0000 | [diff] [blame] | 235 | sub do_cmd_textbf{ |
| 236 | return use_wrappers(@_[0], '<b>', '</b>'); } |
| 237 | sub do_cmd_textit{ |
| 238 | return use_wrappers(@_[0], '<i>', '</i>'); } |
| 239 | |
Fred Drake | 3d5a04a | 2000-08-03 17:25:44 +0000 | [diff] [blame] | 240 | sub do_cmd_moreargs{ |
| 241 | return '...' . @_[0]; } |
| 242 | sub do_cmd_unspecified{ |
| 243 | return '...' . @_[0]; } |
| 244 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 245 | |
Fred Drake | 2581704 | 1999-01-13 17:06:34 +0000 | [diff] [blame] | 246 | sub do_cmd_refmodule{ |
| 247 | # Insert the right magic to jump to the module definition. |
| 248 | local($_) = @_; |
| 249 | my $key = next_optional_argument(); |
| 250 | my $module = next_argument(); |
| 251 | $key = $module |
| 252 | unless $key; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 253 | return "<tt class=\"module\"><a href=\"module-$key.html\">$module</a></tt>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 254 | . $_; |
Fred Drake | 2581704 | 1999-01-13 17:06:34 +0000 | [diff] [blame] | 255 | } |
| 256 | |
Fred Drake | 1a7af39 | 1998-04-01 22:44:56 +0000 | [diff] [blame] | 257 | sub do_cmd_newsgroup{ |
| 258 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 259 | my $newsgroup = next_argument(); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 260 | my $icon = get_link_icon("news:$newsgroup"); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 261 | my $stuff = ("<a class=\"newsgroup\" href=\"news:$newsgroup\">" |
| 262 | . "$newsgroup$icon</a>"); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 263 | return $stuff . $_; |
Fred Drake | 1a7af39 | 1998-04-01 22:44:56 +0000 | [diff] [blame] | 264 | } |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 265 | |
| 266 | sub do_cmd_envvar{ |
| 267 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 268 | my $envvar = next_argument(); |
| 269 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 270 | # The <tt> here is really to keep buildindex.py from making |
| 271 | # the variable name case-insensitive. |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 272 | add_index_entry("environment variables!$envvar@<tt>$envvar</tt>", |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 273 | $ahref); |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 274 | add_index_entry("$envvar (environment variable)", $ahref); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 275 | $aname =~ s/<a/<a class="envvar"/; |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 276 | return "$aname$envvar</a>" . $_; |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 277 | } |
| 278 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 279 | sub do_cmd_url{ |
| 280 | # use the URL as both text and hyperlink |
| 281 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 282 | my $url = next_argument(); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 283 | my $icon = get_link_icon($url); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 284 | $url =~ s/~/~/g; |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 285 | return "<a class=\"url\" href=\"$url\">$url$icon</a>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | sub do_cmd_manpage{ |
| 289 | # two parameters: \manpage{name}{section} |
| 290 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 291 | my $page = next_argument(); |
| 292 | my $section = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 293 | return "<span class=\"manpage\"><i>$page</i>($section)</span>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 294 | } |
| 295 | |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 296 | $PEP_FORMAT = "http://python.sourceforge.net/peps/pep-%04d.html"; |
| 297 | #$RFC_FORMAT = "http://www.ietf.org/rfc/rfc%04d.txt"; |
| 298 | $RFC_FORMAT = "http://www.faqs.org/rfcs/rfc%d.html"; |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 299 | |
| 300 | sub get_rfc_url($$){ |
| 301 | my($rfcnum, $format) = @_; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 302 | return sprintf($format, $rfcnum); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | sub do_cmd_pep{ |
| 306 | local($_) = @_; |
| 307 | my $rfcnumber = next_argument(); |
| 308 | my $id = "rfcref-" . ++$global{'max_id'}; |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 309 | my $href = get_rfc_url($rfcnumber, $PEP_FORMAT); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 310 | my $icon = get_link_icon($href); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 311 | # Save the reference |
| 312 | my $nstr = gen_index_id("Python Enhancement Proposals!PEP $rfcnumber", ''); |
| 313 | $index{$nstr} .= make_half_href("$CURRENT_FILE#$id"); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 314 | return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">PEP $rfcnumber" |
| 315 | . "$icon</a>" . $_); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 316 | } |
| 317 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 318 | sub do_cmd_rfc{ |
| 319 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 320 | my $rfcnumber = next_argument(); |
| 321 | my $id = "rfcref-" . ++$global{'max_id'}; |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 322 | my $href = get_rfc_url($rfcnumber, $RFC_FORMAT); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 323 | my $icon = get_link_icon($href); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 324 | # Save the reference |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 325 | my $nstr = gen_index_id("RFC!RFC $rfcnumber", ''); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 326 | $index{$nstr} .= make_half_href("$CURRENT_FILE#$id"); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 327 | return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">RFC $rfcnumber" |
| 328 | . "$icon</a>" . $_); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 329 | } |
| 330 | |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 331 | sub do_cmd_ulink{ |
| 332 | local($_) = @_; |
| 333 | my $text = next_argument(); |
| 334 | my $url = next_argument(); |
| 335 | return "<a class=\"ulink\" href=\"$url\"\n >$text</a>" . $_; |
| 336 | } |
| 337 | |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 338 | sub do_cmd_citetitle{ |
| 339 | local($_) = @_; |
| 340 | my $url = next_optional_argument(); |
| 341 | my $title = next_argument(); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 342 | my $icon = get_link_icon($url); |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 343 | my $repl = ''; |
| 344 | if ($url) { |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 345 | $repl = ("<em class=\"citetitle\"><a\n" |
| 346 | . " href=\"$url\"\n" |
| 347 | . " title=\"$title\"\n" |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 348 | . " >$title$icon</a></em>"); |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 349 | } |
| 350 | else { |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 351 | $repl = "<em class=\"citetitle\"\n >$title</em>"; |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 352 | } |
| 353 | return $repl . $_; |
| 354 | } |
| 355 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 356 | sub do_cmd_deprecated{ |
| 357 | # two parameters: \deprecated{version}{whattodo} |
| 358 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 359 | my $release = next_argument(); |
| 360 | my $reason = next_argument(); |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 361 | return ('<div class="versionnote">' |
| 362 | . "<b>Deprecated since release $release.</b>" |
| 363 | . "\n$reason</div><p>" |
| 364 | . $_); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 365 | } |
| 366 | |
Fred Drake | c2b29d0 | 2001-04-18 03:11:04 +0000 | [diff] [blame] | 367 | sub versionnote{ |
| 368 | # one or two parameters: \versionnote[explanation]{version} |
| 369 | my $type = @_[0]; |
| 370 | local $_ = @_[1]; |
| 371 | my $explanation = next_optional_argument(); |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 372 | my $release = next_argument(); |
Fred Drake | c2b29d0 | 2001-04-18 03:11:04 +0000 | [diff] [blame] | 373 | my $text = "$type in version $release."; |
| 374 | if ($explanation) { |
| 375 | $text = "$type in version $release:\n$explanation."; |
| 376 | } |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 377 | return "\n<span class=\"versionnote\">$text</span>\n" . $_; |
Fred Drake | c2b29d0 | 2001-04-18 03:11:04 +0000 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | sub do_cmd_versionadded{ |
| 381 | return versionnote('New', @_); |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | sub do_cmd_versionchanged{ |
Fred Drake | c2b29d0 | 2001-04-18 03:11:04 +0000 | [diff] [blame] | 385 | return versionnote('Changed', @_); |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 386 | } |
| 387 | |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 388 | # |
Fred Drake | 2cafcbb | 1999-03-25 16:57:04 +0000 | [diff] [blame] | 389 | # These function handle platform dependency tracking. |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 390 | # |
| 391 | sub do_cmd_platform{ |
| 392 | local($_) = @_; |
| 393 | my $platform = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 394 | $ModulePlatforms{"<tt class=\"module\">$THIS_MODULE</tt>"} = $platform; |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 395 | $platform = "Macintosh" |
Fred Drake | 085b812 | 1999-04-21 14:00:29 +0000 | [diff] [blame] | 396 | if $platform eq 'Mac'; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 397 | return "\n<p class=\"availability\">Availability: <span" |
| 398 | . "\n class=\"platform\">$platform</span>.</p>\n" . $_; |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 399 | } |
| 400 | |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 401 | $IGNORE_PLATFORM_ANNOTATION = ''; |
| 402 | sub do_cmd_ignorePlatformAnnotation{ |
| 403 | local($_) = @_; |
| 404 | $IGNORE_PLATFORM_ANNOTATION = next_argument(); |
| 405 | return $_; |
| 406 | } |
| 407 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 408 | |
| 409 | # index commands |
| 410 | |
| 411 | $INDEX_SUBITEM = ""; |
| 412 | |
| 413 | sub get_indexsubitem{ |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 414 | return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | sub do_cmd_setindexsubitem{ |
| 418 | local($_) = @_; |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 419 | $INDEX_SUBITEM = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 420 | return $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 421 | } |
| 422 | |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 423 | sub do_cmd_withsubitem{ |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 424 | # We can't really do the right thing, because LaTeX2HTML doesn't |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 425 | # do things in the right order, but we need to at least strip this stuff |
| 426 | # out, and leave anything that the second argument expanded out to. |
| 427 | # |
| 428 | local($_) = @_; |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 429 | my $oldsubitem = $INDEX_SUBITEM; |
| 430 | $INDEX_SUBITEM = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 431 | my $stuff = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 432 | my $br_id = ++$globals{'max_id'}; |
| 433 | my $marker = "$O$br_id$C"; |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 434 | return |
| 435 | $stuff |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 436 | . "\\setindexsubitem$marker$oldsubitem$marker" |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 437 | . $_; |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 438 | } |
| 439 | |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 440 | # This is the prologue macro which is required to start writing the |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 441 | # mod\jobname.idx file; we can just ignore it. (Defining this suppresses |
| 442 | # a warning that \makemodindex is unknown.) |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 443 | # |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 444 | sub do_cmd_makemodindex{ return @_[0]; } |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 445 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 446 | # We're in the document subdirectory when this happens! |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 447 | # |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 448 | open(IDXFILE, '>index.dat') || die "\n$!\n"; |
| 449 | open(INTLABELS, '>intlabels.pl') || die "\n$!\n"; |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 450 | print INTLABELS "%internal_labels = ();\n"; |
| 451 | print INTLABELS "1; # hack in case there are no entries\n\n"; |
| 452 | |
| 453 | # Using \0 for this is bad because we can't use common tools to work with the |
| 454 | # resulting files. Things like grep can be useful with this stuff! |
| 455 | # |
| 456 | $IDXFILE_FIELD_SEP = "\1"; |
| 457 | |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 458 | sub write_idxfile{ |
| 459 | my ($ahref, $str) = @_; |
| 460 | print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 461 | } |
| 462 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 463 | |
| 464 | sub gen_link{ |
| 465 | my($node,$target) = @_; |
| 466 | print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n"; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 467 | return "<a href=\"$node#$target\">"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 468 | } |
| 469 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 470 | sub add_index_entry{ |
| 471 | # add an entry to the index structures; ignore the return value |
| 472 | my($str,$ahref) = @_; |
| 473 | $str = gen_index_id($str, ''); |
| 474 | $index{$str} .= $ahref; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 475 | write_idxfile($ahref, $str); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 476 | } |
| 477 | |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 478 | sub new_link_info{ |
| 479 | my $name = "l2h-" . ++$globals{'max_id'}; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 480 | my $aname = "<a name=\"$name\">"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 481 | my $ahref = gen_link($CURRENT_FILE, $name); |
| 482 | return ($name, $aname, $ahref); |
| 483 | } |
| 484 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 485 | $IndexMacroPattern = ''; |
| 486 | sub define_indexing_macro{ |
| 487 | my $count = @_; |
| 488 | my $i = 0; |
| 489 | for (; $i < $count; ++$i) { |
| 490 | my $name = @_[$i]; |
| 491 | my $cmd = "idx_cmd_$name"; |
| 492 | die "\nNo function $cmd() defined!\n" |
| 493 | if (!defined &$cmd); |
| 494 | eval ("sub do_cmd_$name { return process_index_macros(" |
| 495 | . "\@_[0], '$name'); }"); |
| 496 | if (length($IndexMacroPattern) == 0) { |
| 497 | $IndexMacroPattern = "$name"; |
| 498 | } |
| 499 | else { |
| 500 | $IndexMacroPattern .= "|$name"; |
| 501 | } |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | $DEBUG_INDEXING = 0; |
| 506 | sub process_index_macros{ |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 507 | local($_) = @_; |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 508 | my $cmdname = @_[1]; # This is what triggered us in the first place; |
| 509 | # we know it's real, so just process it. |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 510 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 511 | my $cmd = "idx_cmd_$cmdname"; |
| 512 | print "\nIndexing: \\$cmdname" |
| 513 | if $DEBUG_INDEXING; |
| 514 | &$cmd($ahref); # modifies $_ and adds index entries |
| 515 | while (/^[\s\n]*\\($IndexMacroPattern)</) { |
| 516 | $cmdname = "$1"; |
| 517 | print " \\$cmdname" |
| 518 | if $DEBUG_INDEXING; |
| 519 | $cmd = "idx_cmd_$cmdname"; |
| 520 | if (!defined &$cmd) { |
| 521 | last; |
| 522 | } |
| 523 | else { |
| 524 | s/^[\s\n]*\\$cmdname//; |
| 525 | &$cmd($ahref); |
| 526 | } |
| 527 | } |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 528 | if (/^[ \t\r\n]/) { |
| 529 | $_ = substr($_, 1); |
| 530 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 531 | return "$aname$anchor_invisible_mark</a>" . $_; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 532 | } |
| 533 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 534 | define_indexing_macro('index'); |
| 535 | sub idx_cmd_index{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 536 | my $str = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 537 | add_index_entry("$str", @_[0]); |
Fred Drake | 2e7edb8 | 1998-05-11 18:31:17 +0000 | [diff] [blame] | 538 | } |
| 539 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 540 | define_indexing_macro('kwindex'); |
| 541 | sub idx_cmd_kwindex{ |
| 542 | my $str = next_argument(); |
| 543 | add_index_entry("<tt>$str</tt>!keyword", @_[0]); |
| 544 | add_index_entry("keyword!<tt>$str</tt>", @_[0]); |
| 545 | } |
| 546 | |
| 547 | define_indexing_macro('indexii'); |
| 548 | sub idx_cmd_indexii{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 549 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 550 | my $str2 = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 551 | add_index_entry("$str1!$str2", @_[0]); |
| 552 | add_index_entry("$str2!$str1", @_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 553 | } |
| 554 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 555 | define_indexing_macro('indexiii'); |
| 556 | sub idx_cmd_indexiii{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 557 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 558 | my $str2 = next_argument(); |
| 559 | my $str3 = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 560 | add_index_entry("$str1!$str2 $str3", @_[0]); |
| 561 | add_index_entry("$str2!$str3, $str1", @_[0]); |
| 562 | add_index_entry("$str3!$str1 $str2", @_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 563 | } |
| 564 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 565 | define_indexing_macro('indexiv'); |
| 566 | sub idx_cmd_indexiv{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 567 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 568 | my $str2 = next_argument(); |
| 569 | my $str3 = next_argument(); |
| 570 | my $str4 = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 571 | add_index_entry("$str1!$str2 $str3 $str4", @_[0]); |
| 572 | add_index_entry("$str2!$str3 $str4, $str1", @_[0]); |
| 573 | add_index_entry("$str3!$str4, $str1 $str2", @_[0]); |
| 574 | add_index_entry("$str4!$$str1 $str2 $str3", @_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 575 | } |
| 576 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 577 | define_indexing_macro('ttindex'); |
| 578 | sub idx_cmd_ttindex{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 579 | my $str = next_argument(); |
| 580 | my $entry = $str . get_indexsubitem(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 581 | add_index_entry($entry, @_[0]); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 582 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 583 | |
| 584 | sub my_typed_index_helper{ |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 585 | my($word,$ahref) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 586 | my $str = next_argument(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 587 | add_index_entry("$str $word", $ahref); |
| 588 | add_index_entry("$word!$str", $ahref); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 589 | } |
| 590 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 591 | define_indexing_macro('stindex', 'opindex', 'exindex', 'obindex'); |
| 592 | sub idx_cmd_stindex{ my_typed_index_helper('statement', @_[0]); } |
| 593 | sub idx_cmd_opindex{ my_typed_index_helper('operator', @_[0]); } |
| 594 | sub idx_cmd_exindex{ my_typed_index_helper('exception', @_[0]); } |
| 595 | sub idx_cmd_obindex{ my_typed_index_helper('object', @_[0]); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 596 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 597 | define_indexing_macro('bifuncindex'); |
| 598 | sub idx_cmd_bifuncindex{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 599 | my $str = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 600 | add_index_entry("<tt class=\"function\">$str()</tt> (built-in function)", |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 601 | @_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 605 | sub make_mod_index_entry{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 606 | my($str,$define) = @_; |
| 607 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 608 | # equivalent of add_index_entry() using $define instead of '' |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 609 | $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/ |
| 610 | if ($define eq 'DEF'); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 611 | $str = gen_index_id($str, $define); |
| 612 | $index{$str} .= $ahref; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 613 | write_idxfile($ahref, $str); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 614 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 615 | if ($define eq 'DEF') { |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 616 | # add to the module index |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 617 | $str =~ /(<tt.*<\/tt>)/; |
| 618 | my $nstr = $1; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 619 | $Modules{$nstr} .= $ahref; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 620 | } |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 621 | return "$aname$anchor_invisible_mark2</a>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 622 | } |
| 623 | |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 624 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 625 | $THIS_MODULE = ''; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 626 | $THIS_CLASS = ''; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 627 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 628 | sub define_module{ |
| 629 | my($word,$name) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 630 | my $section_tag = join('', @curr_sec_id); |
Fred Drake | 3e4c614 | 1999-05-17 15:00:32 +0000 | [diff] [blame] | 631 | if ($word ne "built-in" && $word ne "extension" |
| 632 | && $word ne "standard" && $word ne "") { |
| 633 | write_warnings("Bad module type '$word'" |
| 634 | . " for \\declaremodule (module $name)"); |
| 635 | $word = ""; |
| 636 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 637 | $word = "$word " if $word; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 638 | $THIS_MODULE = "$name"; |
Fred Drake | 5942b43 | 2000-10-30 06:24:56 +0000 | [diff] [blame] | 639 | $INDEX_SUBITEM = "(in module $name)"; |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 640 | print "[$name]"; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 641 | return make_mod_index_entry( |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 642 | "<tt class=\"module\">$name</tt> (${word}module)", 'DEF'); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 643 | } |
| 644 | |
| 645 | sub my_module_index_helper{ |
| 646 | local($word, $_) = @_; |
| 647 | my $name = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 648 | return define_module($word, $name) . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 649 | } |
| 650 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 651 | sub do_cmd_modindex{ return my_module_index_helper('', @_); } |
| 652 | sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); } |
| 653 | sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); } |
| 654 | sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); } |
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 | sub ref_module_index_helper{ |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 657 | my($word, $ahref) = @_; |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 658 | my $str = next_argument(); |
| 659 | $word = "$word " if $word; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 660 | $str = "<tt class=\"module\">$str</tt> (${word}module)"; |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 661 | # can't use add_index_entry() since the 2nd arg to gen_index_id() is used; |
| 662 | # just inline it all here |
| 663 | $str = gen_index_id($str, 'REF'); |
| 664 | $index{$str} .= $ahref; |
| 665 | write_idxfile($ahref, $str); |
| 666 | } |
| 667 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 668 | # these should be adjusted a bit.... |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 669 | define_indexing_macro('refmodindex', 'refbimodindex', |
| 670 | 'refexmodindex', 'refstmodindex'); |
| 671 | sub idx_cmd_refmodindex{ return ref_module_index_helper('', @_); } |
| 672 | sub idx_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); } |
| 673 | sub idx_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); } |
| 674 | sub idx_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 675 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 676 | sub do_cmd_nodename{ return do_cmd_label(@_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 677 | |
| 678 | sub init_myformat{ |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 679 | $anchor_invisible_mark = ' '; |
| 680 | $anchor_invisible_mark2 = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 681 | $anchor_mark = ''; |
| 682 | $icons{'anchor_mark'} = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 683 | } |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 684 | init_myformat(); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 685 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 686 | # Create an index entry, but include the string in the target anchor |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 687 | # instead of the dummy filler. |
| 688 | # |
| 689 | sub make_str_index_entry{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 690 | my($str) = @_; |
| 691 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 692 | add_index_entry($str, $ahref); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 693 | return "$aname$str</a>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 694 | } |
| 695 | |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 696 | |
| 697 | %TokenToTargetMapping = (); |
| 698 | %DefinedGrammars = (); |
| 699 | %BackpatchGrammarFiles = (); |
| 700 | |
| 701 | sub do_cmd_token{ |
| 702 | local($_) = @_; |
| 703 | my $token = next_argument(); |
| 704 | my $target = $TokenToTargetMapping{"$CURRENT_GRAMMAR:$token"}; |
| 705 | if ($token eq $CURRENT_TOKEN || $CURRENT_GRAMMAR eq '*') { |
| 706 | # recursive definition or display-only productionlist |
| 707 | return "$token"; |
| 708 | } |
| 709 | if ($target eq '') { |
| 710 | $target = "<pyGrammarToken><$CURRENT_GRAMMAR><$token>"; |
| 711 | if (! $BackpatchGrammarFiles{"$CURRENT_FILE"}) { |
| 712 | print "Adding '$CURRENT_FILE' to back-patch list.\n"; |
| 713 | } |
| 714 | $BackpatchGrammarFiles{"$CURRENT_FILE"} = 1; |
| 715 | } |
| 716 | return "<a href=\"$target\">$token</a>" . $_; |
| 717 | } |
| 718 | |
Fred Drake | 16bb419 | 2001-08-20 21:36:38 +0000 | [diff] [blame^] | 719 | sub do_cmd_grammartoken{ |
| 720 | return do_cmd_token(@_); |
| 721 | } |
| 722 | |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 723 | sub do_env_productionlist{ |
| 724 | local($_) = @_; |
| 725 | my $lang = next_optional_argument(); |
| 726 | my $filename = "grammar-$lang.txt"; |
| 727 | if ($lang eq '') { |
| 728 | $filename = 'grammar.txt'; |
| 729 | } |
| 730 | local($CURRENT_GRAMMAR) = $lang; |
| 731 | $DefinedGrammars{$lang} .= $_; |
| 732 | return ("<dl><dd class=\"grammar\">\n" |
| 733 | . "<div class=\"productions\">\n" |
| 734 | . "<table cellpadding=\"2\" valign=\"baseline\">\n" |
| 735 | . translate_commands(translate_environments($_)) |
| 736 | . "</table>\n" |
| 737 | . "</div>\n" |
| 738 | . (($lang eq '*') |
| 739 | ? '' |
| 740 | : ("<a class=\"grammar-footer\"\n" |
| 741 | . " href=\"$filename\" type=\"text/plain\"\n" |
| 742 | . " >Download entire grammar as text.</a>\n")) |
| 743 | . "</dd></dl>"); |
| 744 | } |
| 745 | |
| 746 | sub do_cmd_production{ |
| 747 | local($_) = @_; |
| 748 | my $token = next_argument(); |
| 749 | my $defn = next_argument(); |
| 750 | my $lang = $CURRENT_GRAMMAR; |
| 751 | local($CURRENT_TOKEN) = $token; |
| 752 | if ($lang eq '*') { |
| 753 | return ("<tr>\n" |
| 754 | . " <td><code>$token</code></td>\n" |
| 755 | . " <td> ::= </td>\n" |
| 756 | . " <td><code>" |
| 757 | . translate_commands($defn) |
| 758 | . "</code></td></tr>" |
| 759 | . $_); |
| 760 | } |
| 761 | my $target; |
| 762 | if ($lang eq '') { |
| 763 | $target = "$CURRENT_FILE\#tok-$token"; |
| 764 | } |
| 765 | else { |
| 766 | $target = "$CURRENT_FILE\#tok-$lang-$token"; |
| 767 | } |
| 768 | $TokenToTargetMapping{"$CURRENT_GRAMMAR:$token"} = $target; |
| 769 | return ("<tr>\n" |
| 770 | . " <td><code><a name=\"tok-$token\">$token</a></code></td>\n" |
| 771 | . " <td> ::= </td>\n" |
| 772 | . " <td><code>" |
| 773 | . translate_commands($defn) |
| 774 | . "</code></td></tr>" |
| 775 | . $_); |
| 776 | } |
| 777 | |
| 778 | sub process_grammar_files{ |
| 779 | my $lang; |
| 780 | my $filename; |
| 781 | local($_); |
| 782 | print "process_grammar_files()\n"; |
| 783 | foreach $lang (keys %DefinedGrammars) { |
| 784 | $filename = "grammar-$lang.txt"; |
| 785 | if ($lang eq '*') { |
| 786 | next; |
| 787 | } |
| 788 | if ($lang eq '') { |
| 789 | $filename = 'grammar.txt'; |
| 790 | } |
| 791 | open(GRAMMAR, ">$filename") || die "\n$!\n"; |
| 792 | print GRAMMAR strip_grammar_markup($DefinedGrammars{$lang}); |
| 793 | close(GRAMMAR); |
| 794 | print "Wrote grammar file $filename\n"; |
| 795 | } |
| 796 | my $PATTERN = '<pyGrammarToken><([^>]*)><([^>]*)>'; |
| 797 | foreach $filename (keys %BackpatchGrammarFiles) { |
| 798 | print "\nBack-patching grammar links in $filename\n"; |
| 799 | my $buffer; |
| 800 | open(GRAMMAR, "<$filename") || die "\n$!\n"; |
| 801 | # read all of the file into the buffer |
| 802 | sysread(GRAMMAR, $buffer, 1024*1024); |
| 803 | close(GRAMMAR); |
| 804 | while ($buffer =~ /$PATTERN/) { |
| 805 | my($lang, $token) = ($1, $2); |
| 806 | my $target = $TokenToTargetMapping{"$lang:$token"}; |
| 807 | my $source = "<pyGrammarToken><$lang><$token>"; |
| 808 | $buffer =~ s/$source/$target/g; |
| 809 | } |
| 810 | open(GRAMMAR, ">$filename") || die "\n$!\n"; |
| 811 | print GRAMMAR $buffer; |
| 812 | close(GRAMMAR); |
| 813 | } |
| 814 | } |
| 815 | |
| 816 | sub strip_grammar_markup{ |
| 817 | local($_) = @_; |
| 818 | s/\\production(<<\d+>>)(.+)\1/\n\2 ::= /g; |
| 819 | s/\\token(<<\d+>>)(.+)\1/\2/g; |
| 820 | s/\\e([^a-zA-Z])/\\\1/g; |
| 821 | s/<<\d+>>//g; |
| 822 | s/;SPMgt;/>/g; |
| 823 | s/;SPMlt;/</g; |
| 824 | s/;SPMquot;/\"/g; |
| 825 | return $_; |
| 826 | } |
| 827 | |
| 828 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 829 | $REFCOUNTS_LOADED = 0; |
| 830 | |
| 831 | sub load_refcounts{ |
| 832 | $REFCOUNTS_LOADED = 1; |
| 833 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 834 | my $myname, $mydir, $myext; |
| 835 | ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*'); |
| 836 | chop $mydir; # remove trailing '/' |
| 837 | ($myname, $mydir, $myext) = fileparse($mydir, '\..*'); |
| 838 | chop $mydir; # remove trailing '/' |
| 839 | $mydir = getcwd() . "$dd$mydir" |
| 840 | unless $mydir =~ s|^/|/|; |
| 841 | local $_; |
| 842 | my $filename = "$mydir${dd}api${dd}refcounts.dat"; |
| 843 | open(REFCOUNT_FILE, "<$filename") || die "\n$!\n"; |
| 844 | print "[loading API refcount data]"; |
| 845 | while (<REFCOUNT_FILE>) { |
Fred Drake | c2578c5 | 2000-04-10 18:26:45 +0000 | [diff] [blame] | 846 | 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] | 847 | my($func, $param, $count, $comment) = ($1, $2, $3, $4); |
| 848 | #print "\n$func($param) --> $count"; |
| 849 | $REFCOUNTS{"$func:$param"} = $count; |
| 850 | } |
| 851 | } |
| 852 | } |
| 853 | |
| 854 | sub get_refcount{ |
| 855 | my ($func, $param) = @_; |
| 856 | load_refcounts() |
| 857 | unless $REFCOUNTS_LOADED; |
| 858 | return $REFCOUNTS{"$func:$param"}; |
| 859 | } |
| 860 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 861 | sub do_env_cfuncdesc{ |
| 862 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 863 | my $return_type = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 864 | my $function_name = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 865 | my $arg_list = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 866 | my $idx = make_str_index_entry( |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 867 | "<tt class=\"cfunction\">$function_name()</tt>" . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 868 | $idx =~ s/ \(.*\)//; |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 869 | $idx =~ s/\(\)//; # ???? - why both of these? |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 870 | my $result_rc = get_refcount($function_name, ''); |
| 871 | my $rcinfo = ''; |
| 872 | if ($result_rc eq '+1') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 873 | $rcinfo = 'New reference'; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 874 | } |
| 875 | elsif ($result_rc eq '0') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 876 | $rcinfo = 'Borrowed reference'; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 877 | } |
Fred Drake | c2578c5 | 2000-04-10 18:26:45 +0000 | [diff] [blame] | 878 | elsif ($result_rc eq 'null') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 879 | $rcinfo = 'Always <tt class="constant">NULL</tt>'; |
Fred Drake | c2578c5 | 2000-04-10 18:26:45 +0000 | [diff] [blame] | 880 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 881 | if ($rcinfo ne '') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 882 | $rcinfo = ( "\n<div class=\"refcount-info\">" |
| 883 | . "\n <span class=\"label\">Return value:</span>" |
| 884 | . "\n <span class=\"value\">$rcinfo.</span>" |
| 885 | . "\n</div>"); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 886 | } |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 887 | 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] | 888 | . $rcinfo |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 889 | . $_ |
| 890 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 891 | } |
| 892 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 893 | sub do_env_csimplemacrodesc{ |
| 894 | local($_) = @_; |
| 895 | my $name = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 896 | my $idx = make_str_index_entry("<tt class=\"macro\">$name</tt>"); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 897 | return "<dl><dt><b>$idx</b>\n<dd>" |
| 898 | . $_ |
| 899 | . '</dl>' |
| 900 | } |
| 901 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 902 | sub do_env_ctypedesc{ |
| 903 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 904 | my $index_name = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 905 | my $type_name = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 906 | $index_name = $type_name |
| 907 | unless $index_name; |
| 908 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 909 | add_index_entry("<tt class=\"ctype\">$index_name</tt> (C type)", $ahref); |
| 910 | 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] | 911 | . $_ |
| 912 | . '</dl>' |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 913 | } |
| 914 | |
| 915 | sub do_env_cvardesc{ |
| 916 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 917 | my $var_type = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 918 | my $var_name = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 919 | my $idx = make_str_index_entry("<tt class=\"cdata\">$var_name</tt>" |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 920 | . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 921 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 922 | return "<dl><dt>$var_type <b>$idx</b>\n" |
| 923 | . '<dd>' |
| 924 | . $_ |
| 925 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 926 | } |
| 927 | |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 928 | sub convert_args($){ |
| 929 | local($IN_DESC_HANDLER) = 1; |
| 930 | local($_) = @_; |
| 931 | return translate_commands($_); |
| 932 | } |
| 933 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 934 | sub do_env_funcdesc{ |
| 935 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 936 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 937 | my $arg_list = convert_args(next_argument()); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 938 | my $idx = make_str_index_entry("<tt class=\"function\">$function_name()" |
| 939 | . '</tt>' |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 940 | . get_indexsubitem()); |
| 941 | $idx =~ s/ \(.*\)//; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 942 | $idx =~ s/\(\)<\/tt>/<\/tt>/; |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 943 | 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] | 944 | } |
| 945 | |
| 946 | sub do_env_funcdescni{ |
| 947 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 948 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 949 | my $arg_list = convert_args(next_argument()); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 950 | return "<dl><dt><b><tt class=\"function\">$function_name</tt></b>" |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 951 | . "(<var>$arg_list</var>)\n" |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 952 | . '<dd>' |
| 953 | . $_ |
| 954 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 955 | } |
| 956 | |
| 957 | sub do_cmd_funcline{ |
| 958 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 959 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 960 | my $arg_list = convert_args(next_argument()); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 961 | my $prefix = "<tt class=\"function\">$function_name()</tt>"; |
Fred Drake | ca675e4 | 1999-04-21 15:58:58 +0000 | [diff] [blame] | 962 | my $idx = make_str_index_entry($prefix . get_indexsubitem()); |
| 963 | $prefix =~ s/\(\)//; |
| 964 | |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 965 | return "<dt><b>$prefix</b>(<var>$arg_list</var>)\n<dd>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 966 | } |
| 967 | |
Fred Drake | 6b3fb78 | 1999-07-12 16:50:09 +0000 | [diff] [blame] | 968 | sub do_cmd_funclineni{ |
| 969 | local($_) = @_; |
| 970 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 971 | my $arg_list = convert_args(next_argument()); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 972 | my $prefix = "<tt class=\"function\">$function_name</tt>"; |
Fred Drake | 6b3fb78 | 1999-07-12 16:50:09 +0000 | [diff] [blame] | 973 | |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 974 | return "<dt><b>$prefix</b>(<var>$arg_list</var>)\n<dd>" . $_; |
Fred Drake | 6b3fb78 | 1999-07-12 16:50:09 +0000 | [diff] [blame] | 975 | } |
| 976 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 977 | # Change this flag to index the opcode entries. I don't think it's very |
| 978 | # useful to index them, since they're only presented to describe the dis |
| 979 | # module. |
| 980 | # |
| 981 | $INDEX_OPCODES = 0; |
| 982 | |
| 983 | sub do_env_opcodedesc{ |
| 984 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 985 | my $opcode_name = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 986 | my $arg_list = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 987 | my $idx; |
| 988 | if ($INDEX_OPCODES) { |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 989 | $idx = make_str_index_entry("<tt class=\"opcode\">$opcode_name</tt>" |
| 990 | . ' (byte code instruction)'); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 991 | $idx =~ s/ \(byte code instruction\)//; |
| 992 | } |
| 993 | else { |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 994 | $idx = "<tt class=\"opcode\">$opcode_name</tt>"; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 995 | } |
| 996 | my $stuff = "<dl><dt><b>$idx</b>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 997 | if ($arg_list) { |
| 998 | $stuff .= " <var>$arg_list</var>"; |
| 999 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1000 | return $stuff . "\n<dd>" . $_ . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1001 | } |
| 1002 | |
| 1003 | sub do_env_datadesc{ |
| 1004 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1005 | my $dataname = next_argument(); |
| 1006 | my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1007 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1008 | return "<dl><dt><b>$idx</b>\n<dd>" |
| 1009 | . $_ |
| 1010 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1011 | } |
| 1012 | |
| 1013 | sub do_env_datadescni{ |
| 1014 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1015 | my $idx = next_argument(); |
| 1016 | if (! $STRING_INDEX_TT) { |
| 1017 | $idx = "<tt>$idx</tt>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1018 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1019 | return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1020 | } |
| 1021 | |
| 1022 | sub do_cmd_dataline{ |
| 1023 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1024 | my $data_name = next_argument(); |
| 1025 | my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem()); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1026 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1027 | return "<dt><b>$idx</b><dd>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1028 | } |
| 1029 | |
Fred Drake | adb272c | 2000-04-10 17:47:14 +0000 | [diff] [blame] | 1030 | sub do_cmd_datalineni{ |
| 1031 | local($_) = @_; |
| 1032 | my $data_name = next_argument(); |
| 1033 | return "<dt><b><tt>$data_name</tt></b><dd>" . $_; |
| 1034 | } |
| 1035 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1036 | sub do_env_excdesc{ |
| 1037 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1038 | my $excname = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1039 | my $idx = make_str_index_entry("<tt class=\"exception\">$excname</tt>"); |
Fred Drake | ab357ec | 2001-03-02 18:57:05 +0000 | [diff] [blame] | 1040 | return "<dl><dt><b>exception $idx</b>\n<dd>" . $_ . '</dl>' |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1041 | } |
| 1042 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1043 | sub do_env_fulllineitems{ return do_env_itemize(@_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1044 | |
| 1045 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1046 | sub handle_classlike_descriptor{ |
| 1047 | local($_, $what) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1048 | $THIS_CLASS = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1049 | my $arg_list = convert_args(next_argument()); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1050 | $idx = make_str_index_entry( |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1051 | "<tt class=\"$what\">$THIS_CLASS</tt> ($what in $THIS_MODULE)" ); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1052 | $idx =~ s/ \(.*\)//; |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 1053 | return ("<dl><dt><b>$what $idx</b>(<var>$arg_list</var>)\n<dd>" |
Fred Drake | ab357ec | 2001-03-02 18:57:05 +0000 | [diff] [blame] | 1054 | . $_ |
| 1055 | . '</dl>'); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1056 | } |
| 1057 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1058 | sub do_env_classdesc{ |
| 1059 | return handle_classlike_descriptor(@_[0], "class"); |
| 1060 | } |
| 1061 | |
Fred Drake | 06a01e8 | 2001-05-11 01:00:30 +0000 | [diff] [blame] | 1062 | sub do_env_classdescstar{ |
| 1063 | local($_) = @_; |
| 1064 | $THIS_CLASS = next_argument(); |
| 1065 | $idx = make_str_index_entry( |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1066 | "<tt class=\"class\">$THIS_CLASS</tt> (class in $THIS_MODULE)"); |
Fred Drake | 06a01e8 | 2001-05-11 01:00:30 +0000 | [diff] [blame] | 1067 | $idx =~ s/ \(.*\)//; |
| 1068 | return ("<dl><dt><b>class $idx</b>\n<dd>" |
| 1069 | . $_ |
| 1070 | . '</dl>'); |
| 1071 | } |
| 1072 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1073 | sub do_env_excclassdesc{ |
| 1074 | return handle_classlike_descriptor(@_[0], "exception"); |
| 1075 | } |
| 1076 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1077 | |
| 1078 | sub do_env_methoddesc{ |
| 1079 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1080 | my $class_name = next_optional_argument(); |
| 1081 | $class_name = $THIS_CLASS |
| 1082 | unless $class_name; |
Fred Drake | 5a0ca4e | 1999-01-12 04:16:51 +0000 | [diff] [blame] | 1083 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1084 | my $arg_list = convert_args(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1085 | my $extra = ''; |
| 1086 | if ($class_name) { |
| 1087 | $extra = " ($class_name method)"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1088 | } |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1089 | my $idx = make_str_index_entry( |
| 1090 | "<tt class=\"method\">$method()</tt>$extra"); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1091 | $idx =~ s/ \(.*\)//; |
| 1092 | $idx =~ s/\(\)//; |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 1093 | 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] | 1094 | } |
| 1095 | |
| 1096 | |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 1097 | sub do_cmd_methodline{ |
| 1098 | local($_) = @_; |
| 1099 | my $class_name = next_optional_argument(); |
| 1100 | $class_name = $THIS_CLASS |
| 1101 | unless $class_name; |
| 1102 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1103 | my $arg_list = convert_args(next_argument()); |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 1104 | my $extra = ''; |
| 1105 | if ($class_name) { |
| 1106 | $extra = " ($class_name method)"; |
| 1107 | } |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1108 | my $idx = make_str_index_entry( |
| 1109 | "<tt class=\"method\">$method()</tt>$extra"); |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 1110 | $idx =~ s/ \(.*\)//; |
| 1111 | $idx =~ s/\(\)//; |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 1112 | return "<dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 1113 | . $_; |
| 1114 | } |
| 1115 | |
| 1116 | |
Fred Drake | d64a40d | 1998-09-10 18:59:13 +0000 | [diff] [blame] | 1117 | sub do_cmd_methodlineni{ |
| 1118 | local($_) = @_; |
| 1119 | next_optional_argument(); |
| 1120 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1121 | my $arg_list = convert_args(next_argument()); |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 1122 | return "<dt><b>$method</b>(<var>$arg_list</var>)\n<dd>" |
Fred Drake | d64a40d | 1998-09-10 18:59:13 +0000 | [diff] [blame] | 1123 | . $_; |
| 1124 | } |
| 1125 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1126 | sub do_env_methoddescni{ |
| 1127 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1128 | next_optional_argument(); |
| 1129 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1130 | my $arg_list = convert_args(next_argument()); |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 1131 | return "<dl><dt><b>$method</b>(<var>$arg_list</var>)\n<dd>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1132 | . $_ |
| 1133 | . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1134 | } |
| 1135 | |
| 1136 | |
| 1137 | sub do_env_memberdesc{ |
| 1138 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1139 | my $class = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1140 | my $member = next_argument(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1141 | $class = $THIS_CLASS |
| 1142 | unless $class; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1143 | my $extra = ''; |
Fred Drake | 085b812 | 1999-04-21 14:00:29 +0000 | [diff] [blame] | 1144 | $extra = " ($class attribute)" |
| 1145 | if ($class ne ''); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1146 | my $idx = make_str_index_entry("<tt class=\"member\">$member</tt>$extra"); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1147 | $idx =~ s/ \(.*\)//; |
| 1148 | $idx =~ s/\(\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1149 | return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1150 | } |
| 1151 | |
| 1152 | |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1153 | sub do_cmd_memberline{ |
| 1154 | local($_) = @_; |
| 1155 | my $class = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1156 | my $member = next_argument(); |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1157 | $class = $THIS_CLASS |
| 1158 | unless $class; |
| 1159 | my $extra = ''; |
Fred Drake | 085b812 | 1999-04-21 14:00:29 +0000 | [diff] [blame] | 1160 | $extra = " ($class attribute)" |
| 1161 | if ($class ne ''); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1162 | my $idx = make_str_index_entry("<tt class=\"member\">$member</tt>$extra"); |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1163 | $idx =~ s/ \(.*\)//; |
| 1164 | $idx =~ s/\(\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1165 | return "<dt><b>$idx</b><dd>" . $_; |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1166 | } |
| 1167 | |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1168 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1169 | sub do_env_memberdescni{ |
| 1170 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1171 | next_optional_argument(); |
| 1172 | my $member = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1173 | return "<dl><dt><b><tt class=\"member\">$member</tt></b>\n<dd>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1174 | . $_ |
| 1175 | . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1176 | } |
| 1177 | |
| 1178 | |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1179 | sub do_cmd_memberlineni{ |
| 1180 | local($_) = @_; |
| 1181 | next_optional_argument(); |
| 1182 | my $member = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1183 | return "<dt><b><tt class=\"member\">$member</tt></b><dd>" . $_; |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1184 | } |
| 1185 | |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1186 | |
| 1187 | @col_aligns = ('<td>', '<td>', '<td>', '<td>', '<td>'); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1188 | |
Fred Drake | cb19976 | 2001-08-16 21:56:24 +0000 | [diff] [blame] | 1189 | %FontConversions = ('cdata' => 'tt class="cdata"', |
| 1190 | 'character' => 'tt class="character"', |
| 1191 | 'class' => 'tt class="class"', |
| 1192 | 'command' => 'code', |
| 1193 | 'constant' => 'tt class="constant"', |
| 1194 | 'exception' => 'tt class="exception"', |
| 1195 | 'file' => 'tt class="file"', |
| 1196 | 'filenq' => 'tt class="file"', |
| 1197 | 'kbd' => 'kbd', |
| 1198 | 'member' => 'tt class="member"', |
| 1199 | 'programopt' => 'b', |
| 1200 | 'textrm' => '', |
| 1201 | ); |
| 1202 | |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1203 | sub fix_font{ |
| 1204 | # do a little magic on a font name to get the right behavior in the first |
| 1205 | # column of the output table |
| 1206 | my $font = @_[0]; |
Fred Drake | cb19976 | 2001-08-16 21:56:24 +0000 | [diff] [blame] | 1207 | if (defined $FontConversions{$font}) { |
| 1208 | $font = $FontConversions{$font}; |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 1209 | } |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1210 | return $font; |
| 1211 | } |
| 1212 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1213 | sub figure_column_alignment{ |
| 1214 | my $a = @_[0]; |
| 1215 | my $mark = substr($a, 0, 1); |
| 1216 | my $r = ''; |
| 1217 | if ($mark eq 'c') |
| 1218 | { $r = ' align="center"'; } |
| 1219 | elsif ($mark eq 'r') |
| 1220 | { $r = ' align="right"'; } |
| 1221 | elsif ($mark eq 'l') |
| 1222 | { $r = ' align="left"'; } |
| 1223 | elsif ($mark eq 'p') |
| 1224 | { $r = ' align="left"'; } |
| 1225 | return $r; |
| 1226 | } |
| 1227 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1228 | sub setup_column_alignments{ |
| 1229 | local($_) = @_; |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1230 | my($s1,$s2,$s3,$s4,$a5) = split(/[|]/,$_); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1231 | my $a1 = figure_column_alignment($s1); |
| 1232 | my $a2 = figure_column_alignment($s2); |
| 1233 | my $a3 = figure_column_alignment($s3); |
| 1234 | my $a4 = figure_column_alignment($s4); |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1235 | my $a5 = figure_column_alignment($s5); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1236 | $col_aligns[0] = "<td$a1 valign=\"baseline\">"; |
| 1237 | $col_aligns[1] = "<td$a2>"; |
| 1238 | $col_aligns[2] = "<td$a3>"; |
| 1239 | $col_aligns[3] = "<td$a4>"; |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1240 | $col_aligns[4] = "<td$a5>"; |
Fred Drake | 79189b5 | 1999-04-28 13:54:30 +0000 | [diff] [blame] | 1241 | # return the aligned header start tags |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1242 | return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>", "<th$a5>"); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1243 | } |
| 1244 | |
| 1245 | sub get_table_col1_fonts{ |
| 1246 | my $font = $globals{'lineifont'}; |
| 1247 | my ($sfont,$efont) = ('', ''); |
| 1248 | if ($font) { |
| 1249 | $sfont = "<$font>"; |
| 1250 | $efont = "</$font>"; |
| 1251 | $efont =~ s/ .*>/>/; |
| 1252 | } |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1253 | return ($sfont, $efont); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1254 | } |
| 1255 | |
| 1256 | sub do_env_tableii{ |
| 1257 | local($_) = @_; |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1258 | my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument()); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1259 | my $font = fix_font(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1260 | my $h1 = next_argument(); |
| 1261 | my $h2 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1262 | s/[\s\n]+//; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1263 | $globals{'lineifont'} = $font; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1264 | my $a1 = $col_aligns[0]; |
| 1265 | my $a2 = $col_aligns[1]; |
| 1266 | s/\\lineii</\\lineii[$a1|$a2]</g; |
| 1267 | return '<table border align="center" style="border-collapse: collapse">' |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1268 | . "\n <thead>" |
| 1269 | . "\n <tr class=\"tableheader\">" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1270 | . "\n $th1<b>$h1</b>\ </th>" |
| 1271 | . "\n $th2<b>$h2</b>\ </th>" |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1272 | . "\n </tr>" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1273 | . "\n </thead>" |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1274 | . "\n <tbody valign=\"baseline\">" |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1275 | . $_ |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1276 | . "\n </tbody>" |
| 1277 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1278 | } |
| 1279 | |
Fred Drake | da72b93 | 2000-09-21 15:58:02 +0000 | [diff] [blame] | 1280 | sub do_env_longtableii{ |
| 1281 | return do_env_tableii(@_); |
| 1282 | } |
| 1283 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1284 | sub do_cmd_lineii{ |
| 1285 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1286 | my $aligns = next_optional_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1287 | my $c1 = next_argument(); |
| 1288 | my $c2 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1289 | s/[\s\n]+//; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1290 | my($sfont,$efont) = get_table_col1_fonts(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1291 | $c2 = ' ' if ($c2 eq ''); |
| 1292 | my($c1align,$c2align) = split('\|', $aligns); |
| 1293 | my $padding = ''; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1294 | if ($c1align =~ /align="right"/ || $c1 eq '') { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1295 | $padding = ' '; |
Fred Drake | 58b2bfd | 1998-04-02 20:14:04 +0000 | [diff] [blame] | 1296 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1297 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
| 1298 | . " $c2align$c2</td>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1299 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1300 | } |
| 1301 | |
| 1302 | sub do_env_tableiii{ |
| 1303 | local($_) = @_; |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1304 | my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument()); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1305 | my $font = fix_font(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1306 | my $h1 = next_argument(); |
| 1307 | my $h2 = next_argument(); |
| 1308 | my $h3 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1309 | s/[\s\n]+//; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1310 | $globals{'lineifont'} = $font; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1311 | my $a1 = $col_aligns[0]; |
| 1312 | my $a2 = $col_aligns[1]; |
| 1313 | my $a3 = $col_aligns[2]; |
| 1314 | s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g; |
| 1315 | return '<table border align="center" style="border-collapse: collapse">' |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1316 | . "\n <thead>" |
| 1317 | . "\n <tr class=\"tableheader\">" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1318 | . "\n $th1<b>$h1</b>\ </th>" |
| 1319 | . "\n $th2<b>$h2</b>\ </th>" |
| 1320 | . "\n $th3<b>$h3</b>\ </th>" |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1321 | . "\n </tr>" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1322 | . "\n </thead>" |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1323 | . "\n <tbody valign=\"baseline\">" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1324 | . $_ |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1325 | . "\n </tbody>" |
| 1326 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1327 | } |
| 1328 | |
Fred Drake | da72b93 | 2000-09-21 15:58:02 +0000 | [diff] [blame] | 1329 | sub do_env_longtableiii{ |
| 1330 | return do_env_tableiii(@_); |
| 1331 | } |
| 1332 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1333 | sub do_cmd_lineiii{ |
| 1334 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1335 | my $aligns = next_optional_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1336 | my $c1 = next_argument(); |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1337 | my $c2 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1338 | my $c3 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1339 | s/[\s\n]+//; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1340 | my($sfont,$efont) = get_table_col1_fonts(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1341 | $c3 = ' ' if ($c3 eq ''); |
| 1342 | my($c1align,$c2align,$c3align) = split('\|', $aligns); |
| 1343 | my $padding = ''; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1344 | if ($c1align =~ /align="right"/ || $c1 eq '') { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1345 | $padding = ' '; |
Fred Drake | 58b2bfd | 1998-04-02 20:14:04 +0000 | [diff] [blame] | 1346 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1347 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1348 | . " $c2align$c2</td>\n" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1349 | . " $c3align$c3</td>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1350 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1351 | } |
| 1352 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1353 | sub do_env_tableiv{ |
| 1354 | local($_) = @_; |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1355 | my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument()); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1356 | my $font = fix_font(next_argument()); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1357 | my $h1 = next_argument(); |
| 1358 | my $h2 = next_argument(); |
| 1359 | my $h3 = next_argument(); |
| 1360 | my $h4 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1361 | s/[\s\n]+//; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1362 | $globals{'lineifont'} = $font; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1363 | my $a1 = $col_aligns[0]; |
| 1364 | my $a2 = $col_aligns[1]; |
| 1365 | my $a3 = $col_aligns[2]; |
| 1366 | my $a4 = $col_aligns[3]; |
| 1367 | s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g; |
| 1368 | return '<table border align="center" style="border-collapse: collapse">' |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1369 | . "\n <thead>" |
| 1370 | . "\n <tr class=\"tableheader\">" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1371 | . "\n $th1<b>$h1</b>\ </th>" |
| 1372 | . "\n $th2<b>$h2</b>\ </th>" |
| 1373 | . "\n $th3<b>$h3</b>\ </th>" |
| 1374 | . "\n $th4<b>$h4</b>\ </th>" |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1375 | . "\n </tr>" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1376 | . "\n </thead>" |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1377 | . "\n <tbody valign=\"baseline\">" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1378 | . $_ |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1379 | . "\n </tbody>" |
| 1380 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1381 | } |
| 1382 | |
Fred Drake | da72b93 | 2000-09-21 15:58:02 +0000 | [diff] [blame] | 1383 | sub do_env_longtableiv{ |
| 1384 | return do_env_tableiv(@_); |
| 1385 | } |
| 1386 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1387 | sub do_cmd_lineiv{ |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1388 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1389 | my $aligns = next_optional_argument(); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1390 | my $c1 = next_argument(); |
| 1391 | my $c2 = next_argument(); |
| 1392 | my $c3 = next_argument(); |
| 1393 | my $c4 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1394 | s/[\s\n]+//; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1395 | my($sfont,$efont) = get_table_col1_fonts(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1396 | $c4 = ' ' if ($c4 eq ''); |
| 1397 | my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns); |
| 1398 | my $padding = ''; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1399 | if ($c1align =~ /align="right"/ || $c1 eq '') { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1400 | $padding = ' '; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1401 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1402 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1403 | . " $c2align$c2</td>\n" |
| 1404 | . " $c3align$c3</td>\n" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1405 | . " $c4align$c4</td>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1406 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1407 | } |
| 1408 | |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1409 | sub do_env_tablev{ |
| 1410 | local($_) = @_; |
| 1411 | my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument()); |
| 1412 | my $font = fix_font(next_argument()); |
| 1413 | my $h1 = next_argument(); |
| 1414 | my $h2 = next_argument(); |
| 1415 | my $h3 = next_argument(); |
| 1416 | my $h4 = next_argument(); |
| 1417 | my $h5 = next_argument(); |
| 1418 | s/[\s\n]+//; |
| 1419 | $globals{'lineifont'} = $font; |
| 1420 | my $a1 = $col_aligns[0]; |
| 1421 | my $a2 = $col_aligns[1]; |
| 1422 | my $a3 = $col_aligns[2]; |
| 1423 | my $a4 = $col_aligns[3]; |
| 1424 | my $a5 = $col_aligns[4]; |
| 1425 | s/\\linev</\\linev[$a1|$a2|$a3|$a4|$a5]</g; |
| 1426 | return '<table border align="center" style="border-collapse: collapse">' |
| 1427 | . "\n <thead>" |
| 1428 | . "\n <tr class=\"tableheader\">" |
| 1429 | . "\n $th1<b>$h1</b>\ </th>" |
| 1430 | . "\n $th2<b>$h2</b>\ </th>" |
| 1431 | . "\n $th3<b>$h3</b>\ </th>" |
| 1432 | . "\n $th4<b>$h4</b>\ </th>" |
| 1433 | . "\n $th5<b>$h5</b>\ </th>" |
| 1434 | . "\n </tr>" |
| 1435 | . "\n </thead>" |
| 1436 | . "\n <tbody valign=\"baseline\">" |
| 1437 | . $_ |
| 1438 | . "\n </tbody>" |
| 1439 | . "\n</table>"; |
| 1440 | } |
| 1441 | |
| 1442 | sub do_env_longtablev{ |
| 1443 | return do_env_tablev(@_); |
| 1444 | } |
| 1445 | |
| 1446 | sub do_cmd_linev{ |
| 1447 | local($_) = @_; |
| 1448 | my $aligns = next_optional_argument(); |
| 1449 | my $c1 = next_argument(); |
| 1450 | my $c2 = next_argument(); |
| 1451 | my $c3 = next_argument(); |
| 1452 | my $c4 = next_argument(); |
| 1453 | my $c5 = next_argument(); |
| 1454 | s/[\s\n]+//; |
| 1455 | my($sfont,$efont) = get_table_col1_fonts(); |
| 1456 | $c5 = ' ' if ($c5 eq ''); |
| 1457 | my($c1align,$c2align,$c3align,$c4align,$c5align) = split('\|', $aligns); |
| 1458 | my $padding = ''; |
| 1459 | if ($c1align =~ /align="right"/ || $c1 eq '') { |
| 1460 | $padding = ' '; |
| 1461 | } |
| 1462 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
| 1463 | . " $c2align$c2</td>\n" |
| 1464 | . " $c3align$c3</td>\n" |
| 1465 | . " $c4align$c4</td>\n" |
| 1466 | . " $c5align$c5</td>" |
| 1467 | . $_; |
| 1468 | } |
| 1469 | |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1470 | |
| 1471 | # These can be used to control the title page appearance; |
| 1472 | # they need a little bit of documentation. |
| 1473 | # |
| 1474 | # If $TITLE_PAGE_GRAPHIC is set, it should be the name of a file in the |
| 1475 | # $ICONSERVER directory, or include path information (other than "./"). The |
| 1476 | # default image type will be assumed if an extension is not provided. |
| 1477 | # |
| 1478 | # If specified, the "title page" will contain two colums: one containing the |
| 1479 | # title/author/etc., and the other containing the graphic. Use the other |
| 1480 | # four variables listed here to control specific details of the layout; all |
| 1481 | # are optional. |
| 1482 | # |
| 1483 | # $TITLE_PAGE_GRAPHIC = "my-company-logo"; |
| 1484 | # $TITLE_PAGE_GRAPHIC_COLWIDTH = "30%"; |
| 1485 | # $TITLE_PAGE_GRAPHIC_WIDTH = 150; |
| 1486 | # $TITLE_PAGE_GRAPHIC_HEIGHT = 150; |
| 1487 | # $TITLE_PAGE_GRAPHIC_ON_RIGHT = 0; |
| 1488 | |
| 1489 | sub make_my_titlepage() { |
| 1490 | my $the_title = ""; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1491 | if ($t_title) { |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 1492 | $the_title .= "\n<h1>$t_title</h1>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1493 | } |
| 1494 | else { |
| 1495 | write_warnings("\nThis document has no title."); |
| 1496 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1497 | if ($t_author) { |
| 1498 | if ($t_authorURL) { |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1499 | my $href = translate_commands($t_authorURL); |
Fred Drake | 2d1f81e | 1999-02-09 16:03:31 +0000 | [diff] [blame] | 1500 | $href = make_named_href('author', $href, |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1501 | "<b><font size=\"+2\">$t_author" |
| 1502 | . '</font></b>'); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1503 | $the_title .= "\n<p>$href</p>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1504 | } |
| 1505 | else { |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1506 | $the_title .= ("\n<p><b><font size=\"+2\">$t_author" |
| 1507 | . '</font></b></p>'); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1508 | } |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1509 | } |
| 1510 | else { |
| 1511 | write_warnings("\nThere is no author for this document."); |
| 1512 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1513 | if ($t_institute) { |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1514 | $the_title .= "\n<p>$t_institute</p>"; |
| 1515 | } |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 1516 | if ($DEVELOPER_ADDRESS) { |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1517 | $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>"; |
| 1518 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1519 | if ($t_affil) { |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1520 | $the_title .= "\n<p><i>$t_affil</i></p>"; |
| 1521 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1522 | if ($t_date) { |
Fred Drake | de77bc5 | 2000-12-14 18:36:12 +0000 | [diff] [blame] | 1523 | $the_title .= "\n<p>"; |
Fred Drake | d04592a | 2000-10-25 16:15:13 +0000 | [diff] [blame] | 1524 | if ($PACKAGE_VERSION) { |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1525 | $the_title .= ('<strong>Release ' |
| 1526 | . "$PACKAGE_VERSION$RELEASE_INFO</strong><br>\n"); |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1527 | } |
Fred Drake | de77bc5 | 2000-12-14 18:36:12 +0000 | [diff] [blame] | 1528 | $the_title .= "<strong>$t_date</strong></p>" |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1529 | } |
| 1530 | if ($t_address) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1531 | $the_title .= "\n<p>$t_address</p>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1532 | } |
| 1533 | else { |
| 1534 | $the_title .= "\n<p>"; |
| 1535 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1536 | if ($t_email) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1537 | $the_title .= "\n<p>$t_email</p>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1538 | } |
| 1539 | return $the_title; |
| 1540 | } |
| 1541 | |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1542 | sub make_my_titlegraphic() { |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1543 | my $filename = make_icon_filename($TITLE_PAGE_GRAPHIC); |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1544 | my $graphic = "<td class=\"titlegraphic\""; |
| 1545 | $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_COLWIDTH\"" |
| 1546 | if ($TITLE_PAGE_GRAPHIC_COLWIDTH); |
| 1547 | $graphic .= "><img"; |
| 1548 | $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_WIDTH\"" |
| 1549 | if ($TITLE_PAGE_GRAPHIC_WIDTH); |
| 1550 | $graphic .= " height=\"$TITLE_PAGE_GRAPHIC_HEIGHT\"" |
| 1551 | if ($TITLE_PAGE_GRAPHIC_HEIGHT); |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 1552 | $graphic .= "\n src=\"$filename\"></td>\n"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1553 | return $graphic; |
| 1554 | } |
| 1555 | |
| 1556 | sub do_cmd_maketitle { |
| 1557 | local($_) = @_; |
| 1558 | my $the_title = "\n<div class=\"titlepage\">"; |
| 1559 | if ($TITLE_PAGE_GRAPHIC) { |
| 1560 | if ($TITLE_PAGE_GRAPHIC_ON_RIGHT) { |
| 1561 | $the_title .= ("\n<table border=\"0\" width=\"100%\">" |
| 1562 | . "<tr align=\"right\">\n<td>" |
| 1563 | . make_my_titlepage() |
| 1564 | . "</td>\n" |
| 1565 | . make_my_titlegraphic() |
| 1566 | . "</tr>\n</table>"); |
| 1567 | } |
| 1568 | else { |
| 1569 | $the_title .= ("\n<table border=\"0\" width=\"100%\"><tr>\n" |
| 1570 | . make_my_titlegraphic() |
| 1571 | . "<td>" |
| 1572 | . make_my_titlepage() |
| 1573 | . "</td></tr>\n</table>"); |
| 1574 | } |
| 1575 | } |
| 1576 | else { |
| 1577 | $the_title .= ("\n<center>" |
| 1578 | . make_my_titlepage() |
| 1579 | . "\n</center>"); |
| 1580 | } |
| 1581 | $the_title .= "\n</div>"; |
| 1582 | return $the_title . $_; |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 1583 | $the_title .= "\n</center></div>"; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1584 | return $the_title . $_ ; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1585 | } |
| 1586 | |
| 1587 | |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1588 | # |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1589 | # Module synopsis support |
| 1590 | # |
| 1591 | |
| 1592 | require SynopsisTable; |
| 1593 | |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1594 | sub get_chapter_id(){ |
| 1595 | my $id = do_cmd_thechapter(''); |
Fred Drake | 45f2601 | 1998-08-04 22:07:18 +0000 | [diff] [blame] | 1596 | $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/; |
| 1597 | $id =~ s/\.//; |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1598 | return $id; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1599 | } |
| 1600 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1601 | # 'chapter' => 'SynopsisTable instance' |
| 1602 | %ModuleSynopses = (); |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1603 | |
| 1604 | sub get_synopsis_table($){ |
| 1605 | my($chap) = @_; |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1606 | my $key; |
| 1607 | foreach $key (keys %ModuleSynopses) { |
| 1608 | if ($key eq $chap) { |
| 1609 | return $ModuleSynopses{$chap}; |
| 1610 | } |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1611 | } |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1612 | my $st = SynopsisTable->new(); |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1613 | $ModuleSynopses{$chap} = $st; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1614 | return $st; |
| 1615 | } |
| 1616 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1617 | sub do_cmd_moduleauthor{ |
| 1618 | local($_) = @_; |
| 1619 | next_argument(); |
| 1620 | next_argument(); |
| 1621 | return $_; |
| 1622 | } |
| 1623 | |
| 1624 | sub do_cmd_sectionauthor{ |
| 1625 | local($_) = @_; |
| 1626 | next_argument(); |
| 1627 | next_argument(); |
| 1628 | return $_; |
| 1629 | } |
| 1630 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1631 | sub do_cmd_declaremodule{ |
| 1632 | local($_) = @_; |
| 1633 | my $key = next_optional_argument(); |
| 1634 | my $type = next_argument(); |
| 1635 | my $name = next_argument(); |
| 1636 | my $st = get_synopsis_table(get_chapter_id()); |
| 1637 | # |
| 1638 | $key = $name unless $key; |
| 1639 | $type = 'built-in' if $type eq 'builtin'; |
| 1640 | $st->declare($name, $key, $type); |
| 1641 | define_module($type, $name); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1642 | return anchor_label("module-$key",$CURRENT_FILE,$_) |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1643 | } |
| 1644 | |
| 1645 | sub do_cmd_modulesynopsis{ |
| 1646 | local($_) = @_; |
| 1647 | my $st = get_synopsis_table(get_chapter_id()); |
Fred Drake | 1cc5899 | 1999-04-13 22:08:59 +0000 | [diff] [blame] | 1648 | $st->set_synopsis($THIS_MODULE, translate_commands(next_argument())); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1649 | return $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1650 | } |
| 1651 | |
| 1652 | sub do_cmd_localmoduletable{ |
| 1653 | local($_) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1654 | my $chap = get_chapter_id(); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1655 | my $st = get_synopsis_table($chap); |
| 1656 | $st->set_file("$CURRENT_FILE"); |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1657 | return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1658 | } |
| 1659 | |
| 1660 | sub process_all_localmoduletables{ |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1661 | my $key; |
| 1662 | my $st, $file; |
| 1663 | foreach $key (keys %ModuleSynopses) { |
| 1664 | $st = $ModuleSynopses{$key}; |
| 1665 | $file = $st->get_file(); |
| 1666 | if ($file) { |
| 1667 | process_localmoduletables_in_file($file); |
| 1668 | } |
| 1669 | else { |
Fred Drake | 6fe4660 | 2001-06-23 03:13:30 +0000 | [diff] [blame] | 1670 | print "\nsynopsis table $key has no file association\n"; |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1671 | } |
| 1672 | } |
| 1673 | } |
| 1674 | |
| 1675 | sub process_localmoduletables_in_file{ |
| 1676 | my $file = @_[0]; |
| 1677 | open(MYFILE, "<$file"); |
| 1678 | local($_); |
| 1679 | sysread(MYFILE, $_, 1024*1024); |
| 1680 | close(MYFILE); |
| 1681 | # need to get contents of file in $_ |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1682 | while (/<tex2html-localmoduletable><(\d+)>/) { |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1683 | my $match = $&; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1684 | my $chap = $1; |
| 1685 | my $st = get_synopsis_table($chap); |
| 1686 | my $data = $st->tohtml(); |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1687 | s/$match/$data/; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1688 | } |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1689 | open(MYFILE,">$file"); |
| 1690 | print MYFILE $_; |
| 1691 | close(MYFILE); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1692 | } |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1693 | sub process_python_state{ |
| 1694 | process_all_localmoduletables(); |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 1695 | process_grammar_files(); |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1696 | } |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1697 | |
| 1698 | |
| 1699 | # |
| 1700 | # "See also:" -- references placed at the end of a \section |
| 1701 | # |
| 1702 | |
| 1703 | sub do_env_seealso{ |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1704 | return ("<div class=\"seealso\">\n " |
| 1705 | . "<p class=\"heading\"><b>See Also:</b></p>\n" |
| 1706 | . @_[0] |
| 1707 | . '</div>'); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1708 | } |
| 1709 | |
| 1710 | sub do_cmd_seemodule{ |
| 1711 | # Insert the right magic to jump to the module definition. This should |
| 1712 | # work most of the time, at least for repeat builds.... |
| 1713 | local($_) = @_; |
| 1714 | my $key = next_optional_argument(); |
| 1715 | my $module = next_argument(); |
| 1716 | my $text = next_argument(); |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 1717 | my $period = '.'; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1718 | $key = $module |
| 1719 | unless $key; |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 1720 | if ($text =~ /\.$/) { |
| 1721 | $period = ''; |
| 1722 | } |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1723 | return ('<dl compact class="seemodule">' |
| 1724 | . "\n <dt>Module <b><tt class=\"module\">" |
| 1725 | . "<a href=\"module-$key.html\">$module</a></tt>:</b>" |
| 1726 | . "\n <dd>$text$period\n </dl>" |
| 1727 | . $_); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1728 | } |
| 1729 | |
Fred Drake | e0197bf | 2001-04-12 04:03:22 +0000 | [diff] [blame] | 1730 | sub strip_html_markup($){ |
| 1731 | my $str = @_[0]; |
| 1732 | my $s = "$str"; |
| 1733 | $s =~ s/<[a-zA-Z0-9]+(\s+[a-zA-Z0-9]+(\s*=\s*(\'[^\']*\'|\"[^\"]*\"|[a-zA-Z0-9]+))?)*\s*>//g; |
| 1734 | $s =~ s/<\/[a-zA-Z0-9]+>//g; |
| 1735 | return $s; |
| 1736 | } |
| 1737 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1738 | sub handle_rfclike_reference{ |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 1739 | local($_, $what, $format) = @_; |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 1740 | my $rfcnum = next_argument(); |
| 1741 | my $title = next_argument(); |
| 1742 | my $text = next_argument(); |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 1743 | my $url = get_rfc_url($rfcnum, $format); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1744 | my $icon = get_link_icon($url); |
Fred Drake | e0197bf | 2001-04-12 04:03:22 +0000 | [diff] [blame] | 1745 | my $attrtitle = strip_html_markup($title); |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 1746 | return '<dl compact class="seerfc">' |
| 1747 | . "\n <dt><a href=\"$url\"" |
Fred Drake | e0197bf | 2001-04-12 04:03:22 +0000 | [diff] [blame] | 1748 | . "\n title=\"$attrtitle\"" |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 1749 | . "\n >$what $rfcnum, <em>$title</em>$icon</a>" |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 1750 | . "\n <dd>$text\n </dl>" |
| 1751 | . $_; |
| 1752 | } |
| 1753 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1754 | sub do_cmd_seepep{ |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 1755 | return handle_rfclike_reference(@_[0], "PEP", $PEP_FORMAT); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1756 | } |
| 1757 | |
| 1758 | sub do_cmd_seerfc{ |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 1759 | return handle_rfclike_reference(@_[0], "RFC", $RFC_FORMAT); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1760 | } |
| 1761 | |
Fred Drake | 4844998 | 2000-09-12 17:52:33 +0000 | [diff] [blame] | 1762 | sub do_cmd_seetitle{ |
| 1763 | local($_) = @_; |
| 1764 | my $url = next_optional_argument(); |
| 1765 | my $title = next_argument(); |
| 1766 | my $text = next_argument(); |
| 1767 | if ($url) { |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 1768 | my $icon = get_link_icon($url); |
Fred Drake | 4844998 | 2000-09-12 17:52:33 +0000 | [diff] [blame] | 1769 | return '<dl compact class="seetitle">' |
| 1770 | . "\n <dt><em class=\"citetitle\"><a href=\"$url\"" |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1771 | . "\n >$title$icon</a></em>" |
Fred Drake | 4844998 | 2000-09-12 17:52:33 +0000 | [diff] [blame] | 1772 | . "\n <dd>$text\n </dl>" |
| 1773 | . $_; |
| 1774 | } |
| 1775 | return '<dl compact class="seetitle">' |
| 1776 | . "\n <dt><em class=\"citetitle\"" |
| 1777 | . "\n >$title</em>" |
| 1778 | . "\n <dd>$text\n </dl>" |
| 1779 | . $_; |
| 1780 | } |
| 1781 | |
Fred Drake | ef4d111 | 2000-05-09 16:17:51 +0000 | [diff] [blame] | 1782 | sub do_cmd_seeurl{ |
| 1783 | local($_) = @_; |
| 1784 | my $url = next_argument(); |
| 1785 | my $text = next_argument(); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1786 | my $icon = get_link_icon($url); |
Fred Drake | ef4d111 | 2000-05-09 16:17:51 +0000 | [diff] [blame] | 1787 | return '<dl compact class="seeurl">' |
| 1788 | . "\n <dt><a href=\"$url\"" |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1789 | . "\n class=\"url\">$url$icon</a>" |
Fred Drake | ef4d111 | 2000-05-09 16:17:51 +0000 | [diff] [blame] | 1790 | . "\n <dd>$text\n </dl>" |
| 1791 | . $_; |
| 1792 | } |
| 1793 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1794 | sub do_cmd_seetext{ |
Fred Drake | 79189b5 | 1999-04-28 13:54:30 +0000 | [diff] [blame] | 1795 | local($_) = @_; |
| 1796 | my $content = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1797 | return '<div class="seetext"><p>' . $content . '</div>' . $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1798 | } |
| 1799 | |
| 1800 | |
| 1801 | # |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1802 | # Definition list support. |
| 1803 | # |
| 1804 | |
| 1805 | sub do_env_definitions{ |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1806 | return "<dl class=\"definitions\">" . @_[0] . "</dl>\n"; |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1807 | } |
| 1808 | |
| 1809 | sub do_cmd_term{ |
| 1810 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1811 | my $term = next_argument(); |
| 1812 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1813 | # could easily add an index entry here... |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1814 | return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_; |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1815 | } |
| 1816 | |
| 1817 | |
Fred Drake | 38178fd | 2000-09-22 17:05:04 +0000 | [diff] [blame] | 1818 | # I don't recall exactly why this was needed, but it was very much needed. |
| 1819 | # We'll see if anything breaks when I move the "code" line out -- some |
| 1820 | # things broke with it in. |
| 1821 | |
| 1822 | #code # {} |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 1823 | process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_); |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 1824 | declaremodule # [] # {} # {} |
| 1825 | memberline # [] # {} |
| 1826 | methodline # [] # {} # {} |
| 1827 | modulesynopsis # {} |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1828 | platform # {} |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 1829 | samp # {} |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 1830 | setindexsubitem # {} |
Fred Drake | f32834c | 1999-02-12 22:06:32 +0000 | [diff] [blame] | 1831 | withsubitem # {} # {} |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 1832 | _RAW_ARG_DEFERRED_CMDS_ |
| 1833 | |
| 1834 | |
Fred Drake | 8633360 | 2001-04-10 17:13:39 +0000 | [diff] [blame] | 1835 | $alltt_start = '<dl><dd><pre class="verbatim">'; |
| 1836 | $alltt_end = '</pre></dl>'; |
| 1837 | |
| 1838 | sub do_env_alltt { |
| 1839 | local ($_) = @_; |
| 1840 | local($closures,$reopens,@open_block_tags); |
| 1841 | |
| 1842 | # get the tag-strings for all open tags |
| 1843 | local(@keep_open_tags) = @$open_tags_R; |
| 1844 | ($closures,$reopens) = &preserve_open_tags() if (@$open_tags_R); |
| 1845 | |
| 1846 | # get the tags for text-level tags only |
| 1847 | $open_tags_R = [ @keep_open_tags ]; |
| 1848 | local($local_closures, $local_reopens); |
| 1849 | ($local_closures, $local_reopens,@open_block_tags) |
| 1850 | = &preserve_open_block_tags |
| 1851 | if (@$open_tags_R); |
| 1852 | |
| 1853 | $open_tags_R = [ @open_block_tags ]; |
| 1854 | |
| 1855 | do { |
| 1856 | local($open_tags_R) = [ @open_block_tags ]; |
| 1857 | local(@save_open_tags) = (); |
| 1858 | |
| 1859 | local($cnt) = ++$global{'max_id'}; |
| 1860 | $_ = join('',"$O$cnt$C\\tt$O", ++$global{'max_id'}, $C |
| 1861 | , $_ , $O, $global{'max_id'}, "$C$O$cnt$C"); |
| 1862 | |
| 1863 | $_ = &translate_environments($_); |
| 1864 | $_ = &translate_commands($_) if (/\\/); |
| 1865 | |
| 1866 | # preserve space-runs, using |
| 1867 | while (s/(\S) ( +)/$1$2;SPMnbsp;/g){}; |
| 1868 | s/(<BR>) /$1;SPMnbsp;/g; |
| 1869 | |
| 1870 | $_ = join('', $closures, $alltt_start, $local_reopens |
| 1871 | , $_ |
| 1872 | , &balance_tags() #, $local_closures |
| 1873 | , $alltt_end, $reopens); |
| 1874 | undef $open_tags_R; undef @save_open_tags; |
| 1875 | }; |
| 1876 | $open_tags_R = [ @keep_open_tags ]; |
| 1877 | $_; |
| 1878 | } |
| 1879 | |
Fred Drake | 57e52ef | 2001-06-15 21:31:57 +0000 | [diff] [blame] | 1880 | sub do_cmd_verbatiminput{ |
| 1881 | local($_) = @_; |
| 1882 | my $fname = next_argument(); |
| 1883 | my $file; |
| 1884 | my $found = 0; |
| 1885 | my $texpath; |
| 1886 | # Search TEXINPUTS for the input file, the way we're supposed to: |
| 1887 | foreach $texpath (split /$envkey/, $TEXINPUTS) { |
| 1888 | $file = "$texpath$dd$fname"; |
| 1889 | last if ($found = (-f $file)); |
| 1890 | } |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 1891 | my $srcname; |
Fred Drake | 57e52ef | 2001-06-15 21:31:57 +0000 | [diff] [blame] | 1892 | my $text; |
| 1893 | if ($found) { |
| 1894 | open(MYFILE, "<$file") || die "\n$!\n"; |
| 1895 | read(MYFILE, $text, 1024*1024); |
| 1896 | close(MYFILE); |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 1897 | use File::Basename; |
| 1898 | my $srcdir, $srcext; |
| 1899 | ($srcname, $srcdir, $srcext) = fileparse($file, '\..*'); |
| 1900 | open(MYFILE, ">$srcname.txt"); |
| 1901 | print MYFILE $text; |
| 1902 | close(MYFILE); |
Fred Drake | 57e52ef | 2001-06-15 21:31:57 +0000 | [diff] [blame] | 1903 | # |
| 1904 | # These rewrites convert the raw text to something that will |
| 1905 | # be properly visible as HTML and also will pass through the |
| 1906 | # vagaries of conversion through LaTeX2HTML. The order in |
| 1907 | # which the specific rewrites are performed is significant. |
| 1908 | # |
| 1909 | $text =~ s/\&/\&/g; |
| 1910 | # These need to happen before the normal < and > re-writes, |
| 1911 | # since we need to avoid LaTeX2HTML's attempt to perform |
| 1912 | # ligature processing without regard to context (since it |
| 1913 | # doesn't have font information). |
| 1914 | $text =~ s/--/-&\#45;/g; |
| 1915 | $text =~ s/<</\<\&\#60;/g; |
| 1916 | $text =~ s/>>/\>\&\#62;/g; |
| 1917 | # Just normal re-writes... |
| 1918 | $text =~ s/</\</g; |
| 1919 | $text =~ s/>/\>/g; |
| 1920 | # These last isn't needed for the HTML, but is needed to get |
| 1921 | # past LaTeX2HTML processing TeX macros. We use \ instead |
| 1922 | # of / since many browsers don't support that. |
| 1923 | $text =~ s/\\/\&\#92;/g; |
| 1924 | } |
| 1925 | else { |
| 1926 | $text = '<b>Could not locate requested file <i>$fname</i>!</b>\n'; |
| 1927 | } |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 1928 | return ('<dl><dd><pre class="verbatim">' |
Fred Drake | 57e52ef | 2001-06-15 21:31:57 +0000 | [diff] [blame] | 1929 | . $text |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 1930 | . "</pre>\n<div class=\"verbatiminput-footer\">\n" |
| 1931 | . "<a href=\"$srcname.txt\" type=\"text/plain\"" |
| 1932 | . ">Download as text.</a>" |
| 1933 | . "\n</div>\n</dd></dl>" |
Fred Drake | 57e52ef | 2001-06-15 21:31:57 +0000 | [diff] [blame] | 1934 | . $_); |
| 1935 | } |
Fred Drake | 8633360 | 2001-04-10 17:13:39 +0000 | [diff] [blame] | 1936 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1937 | 1; # This must be the last line |