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