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