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 | 899072a | 2004-04-08 15:30:12 +0000 | [diff] [blame^] | 582 | # XXX I don't remember why I added this to begin with. |
| 583 | # if (/^[ \t\r\n]/) { |
| 584 | # $_ = substr($_, 1); |
| 585 | # } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 586 | return "$aname$anchor_invisible_mark</a>" . $_; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 587 | } |
| 588 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 589 | define_indexing_macro('index'); |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 590 | sub idx_cmd_index($){ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 591 | my $str = next_argument(); |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 592 | add_index_entry("$str", $_[0]); |
Fred Drake | 2e7edb8 | 1998-05-11 18:31:17 +0000 | [diff] [blame] | 593 | } |
| 594 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 595 | define_indexing_macro('kwindex'); |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 596 | sub idx_cmd_kwindex($){ |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 597 | my $str = next_argument(); |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 598 | add_index_entry("<tt>$str</tt>!keyword", $_[0]); |
| 599 | add_index_entry("keyword!<tt>$str</tt>", $_[0]); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 600 | } |
| 601 | |
| 602 | define_indexing_macro('indexii'); |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 603 | sub idx_cmd_indexii($){ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 604 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 605 | my $str2 = next_argument(); |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 606 | add_index_entry("$str1!$str2", $_[0]); |
| 607 | add_index_entry("$str2!$str1", $_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 608 | } |
| 609 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 610 | define_indexing_macro('indexiii'); |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 611 | sub idx_cmd_indexiii($){ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 612 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 613 | my $str2 = next_argument(); |
| 614 | my $str3 = next_argument(); |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 615 | add_index_entry("$str1!$str2 $str3", $_[0]); |
| 616 | add_index_entry("$str2!$str3, $str1", $_[0]); |
| 617 | add_index_entry("$str3!$str1 $str2", $_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 618 | } |
| 619 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 620 | define_indexing_macro('indexiv'); |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 621 | sub idx_cmd_indexiv($){ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 622 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 623 | my $str2 = next_argument(); |
| 624 | my $str3 = next_argument(); |
| 625 | my $str4 = next_argument(); |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 626 | add_index_entry("$str1!$str2 $str3 $str4", $_[0]); |
| 627 | add_index_entry("$str2!$str3 $str4, $str1", $_[0]); |
| 628 | add_index_entry("$str3!$str4, $str1 $str2", $_[0]); |
| 629 | add_index_entry("$str4!$str1 $str2 $str3", $_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 630 | } |
| 631 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 632 | define_indexing_macro('ttindex'); |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 633 | sub idx_cmd_ttindex($){ |
Fred Drake | 345555d | 2003-12-30 16:19:28 +0000 | [diff] [blame] | 634 | my $str = codetext(next_argument()); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 635 | my $entry = $str . get_indexsubitem(); |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 636 | add_index_entry($entry, $_[0]); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 637 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 638 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 639 | sub my_typed_index_helper($$){ |
| 640 | my($word, $ahref) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 641 | my $str = next_argument(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 642 | add_index_entry("$str $word", $ahref); |
| 643 | add_index_entry("$word!$str", $ahref); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 644 | } |
| 645 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 646 | define_indexing_macro('stindex', 'opindex', 'exindex', 'obindex'); |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 647 | sub idx_cmd_stindex($){ my_typed_index_helper('statement', $_[0]); } |
| 648 | sub idx_cmd_opindex($){ my_typed_index_helper('operator', $_[0]); } |
| 649 | sub idx_cmd_exindex($){ my_typed_index_helper('exception', $_[0]); } |
| 650 | sub idx_cmd_obindex($){ my_typed_index_helper('object', $_[0]); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 651 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 652 | define_indexing_macro('bifuncindex'); |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 653 | sub idx_cmd_bifuncindex($){ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 654 | my $str = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 655 | add_index_entry("<tt class=\"function\">$str()</tt> (built-in function)", |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 656 | $_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 657 | } |
| 658 | |
| 659 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 660 | sub make_mod_index_entry($$){ |
| 661 | my($str, $define) = @_; |
| 662 | my($name, $aname, $ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 663 | # equivalent of add_index_entry() using $define instead of '' |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 664 | $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/ |
| 665 | if ($define eq 'DEF'); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 666 | $str = gen_index_id($str, $define); |
| 667 | $index{$str} .= $ahref; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 668 | write_idxfile($ahref, $str); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 669 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 670 | if ($define eq 'DEF') { |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 671 | # add to the module index |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 672 | $str =~ /(<tt.*<\/tt>)/; |
| 673 | my $nstr = $1; |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 674 | $Modules{$nstr} .= $ahref; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 675 | } |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 676 | return "$aname$anchor_invisible_mark2</a>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 677 | } |
| 678 | |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 679 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 680 | $THIS_MODULE = ''; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 681 | $THIS_CLASS = ''; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 682 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 683 | sub define_module($$){ |
| 684 | my($word, $name) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 685 | my $section_tag = join('', @curr_sec_id); |
Fred Drake | 3e4c614 | 1999-05-17 15:00:32 +0000 | [diff] [blame] | 686 | if ($word ne "built-in" && $word ne "extension" |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 687 | && $word ne "standard" && $word ne "") { |
| 688 | write_warnings("Bad module type '$word'" |
| 689 | . " for \\declaremodule (module $name)"); |
| 690 | $word = ""; |
Fred Drake | 3e4c614 | 1999-05-17 15:00:32 +0000 | [diff] [blame] | 691 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 692 | $word = "$word " if $word; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 693 | $THIS_MODULE = "$name"; |
Fred Drake | 5942b43 | 2000-10-30 06:24:56 +0000 | [diff] [blame] | 694 | $INDEX_SUBITEM = "(in module $name)"; |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 695 | print "[$name]"; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 696 | return make_mod_index_entry( |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 697 | "<tt class=\"module\">$name</tt> (${word}module)", 'DEF'); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 698 | } |
| 699 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 700 | sub my_module_index_helper($$){ |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 701 | local($word, $_) = @_; |
| 702 | my $name = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 703 | return define_module($word, $name) . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 704 | } |
| 705 | |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 706 | sub do_cmd_modindex{ return my_module_index_helper('', $_[0]); } |
| 707 | sub do_cmd_bimodindex{ return my_module_index_helper('built-in', $_[0]); } |
| 708 | sub do_cmd_exmodindex{ return my_module_index_helper('extension', $_[0]); } |
| 709 | sub do_cmd_stmodindex{ return my_module_index_helper('standard', $_[0]); } |
| 710 | # local($_) = @_; |
| 711 | # my $name = next_argument(); |
| 712 | # return define_module('standard', $name) . $_; |
| 713 | # } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 714 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 715 | sub ref_module_index_helper($$){ |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 716 | my($word, $ahref) = @_; |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 717 | my $str = next_argument(); |
| 718 | $word = "$word " if $word; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 719 | $str = "<tt class=\"module\">$str</tt> (${word}module)"; |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 720 | # can't use add_index_entry() since the 2nd arg to gen_index_id() is used; |
| 721 | # just inline it all here |
| 722 | $str = gen_index_id($str, 'REF'); |
| 723 | $index{$str} .= $ahref; |
| 724 | write_idxfile($ahref, $str); |
| 725 | } |
| 726 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 727 | # these should be adjusted a bit.... |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 728 | define_indexing_macro('refmodindex', 'refbimodindex', |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 729 | 'refexmodindex', 'refstmodindex'); |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 730 | sub idx_cmd_refmodindex($){ |
| 731 | return ref_module_index_helper('', $_[0]); } |
| 732 | sub idx_cmd_refbimodindex($){ |
| 733 | return ref_module_index_helper('built-in', $_[0]); } |
| 734 | sub idx_cmd_refexmodindex($){ |
| 735 | return ref_module_index_helper('extension', $_[0]);} |
| 736 | sub idx_cmd_refstmodindex($){ |
| 737 | return ref_module_index_helper('standard', $_[0]); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 738 | |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 739 | sub do_cmd_nodename{ return do_cmd_label($_[0]); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 740 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 741 | sub init_myformat(){ |
Fred Drake | 5d9c636f | 2003-08-05 05:00:23 +0000 | [diff] [blame] | 742 | # These markers must be non-empty or the main latex2html script |
| 743 | # may remove a surrounding element that has not other content as |
| 744 | # "extraneous"; this ensures these elements (usually hyperlink |
| 745 | # targets) are not removed improperly. We use comments since |
| 746 | # there's no meaningful actual content. |
| 747 | # Thanks to Dave Kuhlman for figuring why some named anchors were |
| 748 | # being lost. |
| 749 | $anchor_invisible_mark = '<!--x-->'; |
| 750 | $anchor_invisible_mark2 = '<!--y-->'; |
| 751 | $anchor_mark = '<!--z-->'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 752 | $icons{'anchor_mark'} = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 753 | } |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 754 | init_myformat(); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 755 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 756 | # Create an index entry, but include the string in the target anchor |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 757 | # instead of the dummy filler. |
| 758 | # |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 759 | sub make_str_index_entry($){ |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 760 | my $str = $_[0]; |
Fred Drake | 04bf724 | 2003-11-26 20:55:49 +0000 | [diff] [blame] | 761 | my($name, $ahref) = new_link_name_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 762 | add_index_entry($str, $ahref); |
Fred Drake | 04bf724 | 2003-11-26 20:55:49 +0000 | [diff] [blame] | 763 | if ($str =~ /^<[a-z]+\b/) { |
| 764 | my $s = "$str"; |
| 765 | $s =~ s/^<([a-z]+)\b/<$1 id='$name'/; |
| 766 | return $s; |
| 767 | } |
| 768 | else { |
| 769 | return "<a id='$name'>$str</a>"; |
| 770 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 771 | } |
| 772 | |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 773 | |
Fred Drake | dbb2b9d | 2002-10-30 21:38:32 +0000 | [diff] [blame] | 774 | %TokenToTargetMapping = (); # language:token -> link target |
| 775 | %DefinedGrammars = (); # language -> full grammar text |
| 776 | %BackpatchGrammarFiles = (); # file -> 1 (hash of files to fixup) |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 777 | |
| 778 | sub do_cmd_token{ |
| 779 | local($_) = @_; |
| 780 | my $token = next_argument(); |
| 781 | my $target = $TokenToTargetMapping{"$CURRENT_GRAMMAR:$token"}; |
| 782 | if ($token eq $CURRENT_TOKEN || $CURRENT_GRAMMAR eq '*') { |
| 783 | # recursive definition or display-only productionlist |
| 784 | return "$token"; |
| 785 | } |
| 786 | if ($target eq '') { |
| 787 | $target = "<pyGrammarToken><$CURRENT_GRAMMAR><$token>"; |
| 788 | if (! $BackpatchGrammarFiles{"$CURRENT_FILE"}) { |
| 789 | print "Adding '$CURRENT_FILE' to back-patch list.\n"; |
| 790 | } |
| 791 | $BackpatchGrammarFiles{"$CURRENT_FILE"} = 1; |
| 792 | } |
| 793 | return "<a href=\"$target\">$token</a>" . $_; |
| 794 | } |
| 795 | |
Fred Drake | 16bb419 | 2001-08-20 21:36:38 +0000 | [diff] [blame] | 796 | sub do_cmd_grammartoken{ |
| 797 | return do_cmd_token(@_); |
| 798 | } |
| 799 | |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 800 | sub do_env_productionlist{ |
| 801 | local($_) = @_; |
| 802 | my $lang = next_optional_argument(); |
| 803 | my $filename = "grammar-$lang.txt"; |
| 804 | if ($lang eq '') { |
| 805 | $filename = 'grammar.txt'; |
| 806 | } |
| 807 | local($CURRENT_GRAMMAR) = $lang; |
| 808 | $DefinedGrammars{$lang} .= $_; |
| 809 | return ("<dl><dd class=\"grammar\">\n" |
| 810 | . "<div class=\"productions\">\n" |
Fred Drake | e27f868 | 2001-12-14 16:54:53 +0000 | [diff] [blame] | 811 | . "<table cellpadding=\"2\">\n" |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 812 | . translate_commands(translate_environments($_)) |
| 813 | . "</table>\n" |
| 814 | . "</div>\n" |
| 815 | . (($lang eq '*') |
| 816 | ? '' |
| 817 | : ("<a class=\"grammar-footer\"\n" |
| 818 | . " href=\"$filename\" type=\"text/plain\"\n" |
| 819 | . " >Download entire grammar as text.</a>\n")) |
| 820 | . "</dd></dl>"); |
| 821 | } |
| 822 | |
| 823 | sub do_cmd_production{ |
| 824 | local($_) = @_; |
| 825 | my $token = next_argument(); |
| 826 | my $defn = next_argument(); |
| 827 | my $lang = $CURRENT_GRAMMAR; |
| 828 | local($CURRENT_TOKEN) = $token; |
| 829 | if ($lang eq '*') { |
Fred Drake | e27f868 | 2001-12-14 16:54:53 +0000 | [diff] [blame] | 830 | return ("<tr valign=\"baseline\">\n" |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 831 | . " <td><code>$token</code></td>\n" |
| 832 | . " <td> ::= </td>\n" |
| 833 | . " <td><code>" |
| 834 | . translate_commands($defn) |
| 835 | . "</code></td></tr>" |
| 836 | . $_); |
| 837 | } |
| 838 | my $target; |
| 839 | if ($lang eq '') { |
| 840 | $target = "$CURRENT_FILE\#tok-$token"; |
| 841 | } |
| 842 | else { |
| 843 | $target = "$CURRENT_FILE\#tok-$lang-$token"; |
| 844 | } |
| 845 | $TokenToTargetMapping{"$CURRENT_GRAMMAR:$token"} = $target; |
Fred Drake | e27f868 | 2001-12-14 16:54:53 +0000 | [diff] [blame] | 846 | return ("<tr valign=\"baseline\">\n" |
Fred Drake | 04bf724 | 2003-11-26 20:55:49 +0000 | [diff] [blame] | 847 | . " <td><code><a id='tok-$token'>" |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 848 | . "$token</a></code></td>\n" |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 849 | . " <td> ::= </td>\n" |
| 850 | . " <td><code>" |
| 851 | . translate_commands($defn) |
| 852 | . "</code></td></tr>" |
| 853 | . $_); |
| 854 | } |
| 855 | |
Fred Drake | 5381588 | 2002-03-15 23:21:37 +0000 | [diff] [blame] | 856 | sub do_cmd_productioncont{ |
| 857 | local($_) = @_; |
| 858 | my $defn = next_argument(); |
Fred Drake | 4837fa3 | 2002-06-18 18:30:28 +0000 | [diff] [blame] | 859 | $defn =~ s/^( +)/' ' x length $1/e; |
Fred Drake | 5381588 | 2002-03-15 23:21:37 +0000 | [diff] [blame] | 860 | return ("<tr valign=\"baseline\">\n" |
| 861 | . " <td> </td>\n" |
| 862 | . " <td> </td>\n" |
| 863 | . " <td><code>" |
| 864 | . translate_commands($defn) |
| 865 | . "</code></td></tr>" |
| 866 | . $_); |
| 867 | } |
| 868 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 869 | sub process_grammar_files(){ |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 870 | my $lang; |
| 871 | my $filename; |
| 872 | local($_); |
| 873 | print "process_grammar_files()\n"; |
| 874 | foreach $lang (keys %DefinedGrammars) { |
| 875 | $filename = "grammar-$lang.txt"; |
| 876 | if ($lang eq '*') { |
| 877 | next; |
| 878 | } |
| 879 | if ($lang eq '') { |
| 880 | $filename = 'grammar.txt'; |
| 881 | } |
| 882 | open(GRAMMAR, ">$filename") || die "\n$!\n"; |
| 883 | print GRAMMAR strip_grammar_markup($DefinedGrammars{$lang}); |
| 884 | close(GRAMMAR); |
| 885 | print "Wrote grammar file $filename\n"; |
| 886 | } |
| 887 | my $PATTERN = '<pyGrammarToken><([^>]*)><([^>]*)>'; |
| 888 | foreach $filename (keys %BackpatchGrammarFiles) { |
| 889 | print "\nBack-patching grammar links in $filename\n"; |
| 890 | my $buffer; |
| 891 | open(GRAMMAR, "<$filename") || die "\n$!\n"; |
| 892 | # read all of the file into the buffer |
| 893 | sysread(GRAMMAR, $buffer, 1024*1024); |
| 894 | close(GRAMMAR); |
| 895 | while ($buffer =~ /$PATTERN/) { |
| 896 | my($lang, $token) = ($1, $2); |
| 897 | my $target = $TokenToTargetMapping{"$lang:$token"}; |
| 898 | my $source = "<pyGrammarToken><$lang><$token>"; |
| 899 | $buffer =~ s/$source/$target/g; |
| 900 | } |
| 901 | open(GRAMMAR, ">$filename") || die "\n$!\n"; |
| 902 | print GRAMMAR $buffer; |
| 903 | close(GRAMMAR); |
| 904 | } |
| 905 | } |
| 906 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 907 | sub strip_grammar_markup($){ |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 908 | local($_) = @_; |
Fred Drake | 5381588 | 2002-03-15 23:21:37 +0000 | [diff] [blame] | 909 | s/\\productioncont/ /g; |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 910 | s/\\production(<<\d+>>)(.+)\1/\n$2 ::= /g; |
| 911 | s/\\token(<<\d+>>)(.+)\1/$2/g; |
| 912 | s/\\e([^a-zA-Z])/\\$1/g; |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 913 | s/<<\d+>>//g; |
| 914 | s/;SPMgt;/>/g; |
| 915 | s/;SPMlt;/</g; |
| 916 | s/;SPMquot;/\"/g; |
| 917 | return $_; |
| 918 | } |
| 919 | |
| 920 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 921 | $REFCOUNTS_LOADED = 0; |
| 922 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 923 | sub load_refcounts(){ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 924 | $REFCOUNTS_LOADED = 1; |
| 925 | |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 926 | my($myname, $mydir, $myext) = fileparse(__FILE__, '\..*'); |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 927 | chop $mydir; # remove trailing '/' |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 928 | ($myname, $mydir, $myext) = fileparse($mydir, '\..*'); |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 929 | chop $mydir; # remove trailing '/' |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 930 | $mydir = getcwd() . "$dd$mydir" |
| 931 | unless $mydir =~ s|^/|/|; |
| 932 | local $_; |
| 933 | my $filename = "$mydir${dd}api${dd}refcounts.dat"; |
| 934 | open(REFCOUNT_FILE, "<$filename") || die "\n$!\n"; |
| 935 | print "[loading API refcount data]"; |
| 936 | while (<REFCOUNT_FILE>) { |
Fred Drake | c2578c5 | 2000-04-10 18:26:45 +0000 | [diff] [blame] | 937 | 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] | 938 | my($func, $param, $count, $comment) = ($1, $2, $3, $4); |
| 939 | #print "\n$func($param) --> $count"; |
| 940 | $REFCOUNTS{"$func:$param"} = $count; |
| 941 | } |
| 942 | } |
| 943 | } |
| 944 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 945 | sub get_refcount($$){ |
| 946 | my($func, $param) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 947 | load_refcounts() |
| 948 | unless $REFCOUNTS_LOADED; |
| 949 | return $REFCOUNTS{"$func:$param"}; |
| 950 | } |
| 951 | |
Fred Drake | af07b2c | 2001-10-26 03:09:27 +0000 | [diff] [blame] | 952 | |
| 953 | $TLSTART = '<span class="typelabel">'; |
Fred Drake | f6e9027 | 2002-06-18 18:24:16 +0000 | [diff] [blame] | 954 | $TLEND = '</span> '; |
Fred Drake | af07b2c | 2001-10-26 03:09:27 +0000 | [diff] [blame] | 955 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 956 | sub cfuncline_helper($$$){ |
| 957 | my($type, $name, $args) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 958 | my $idx = make_str_index_entry( |
Fred Drake | 34adb8a | 2002-04-15 20:48:40 +0000 | [diff] [blame] | 959 | "<tt class=\"cfunction\">$name()</tt>" . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 960 | $idx =~ s/ \(.*\)//; |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 961 | $idx =~ s/\(\)//; # ???? - why both of these? |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 962 | $args =~ s/(\s|\*)([a-z_][a-z_0-9]*),/$1<var>$2<\/var>,/g; |
| 963 | $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] | 964 | return ('<table cellpadding="0" cellspacing="0"><tr valign="baseline">' |
| 965 | . "<td><nobr>$type\ <b>$idx</b>(</nobr></td>" |
| 966 | . "<td>$args)</td>" |
| 967 | . '</tr></table>'); |
Fred Drake | 34adb8a | 2002-04-15 20:48:40 +0000 | [diff] [blame] | 968 | } |
| 969 | sub do_cmd_cfuncline{ |
| 970 | local($_) = @_; |
| 971 | my $type = next_argument(); |
| 972 | my $name = next_argument(); |
| 973 | my $args = next_argument(); |
| 974 | my $siginfo = cfuncline_helper($type, $name, $args); |
| 975 | return "<dt>$siginfo\n<dd>" . $_; |
| 976 | } |
| 977 | sub do_env_cfuncdesc{ |
| 978 | local($_) = @_; |
| 979 | my $type = next_argument(); |
| 980 | my $name = next_argument(); |
| 981 | my $args = next_argument(); |
| 982 | my $siginfo = cfuncline_helper($type, $name, $args); |
| 983 | my $result_rc = get_refcount($name, ''); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 984 | my $rcinfo = ''; |
| 985 | if ($result_rc eq '+1') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 986 | $rcinfo = 'New reference'; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 987 | } |
| 988 | elsif ($result_rc eq '0') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 989 | $rcinfo = 'Borrowed reference'; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 990 | } |
Fred Drake | c2578c5 | 2000-04-10 18:26:45 +0000 | [diff] [blame] | 991 | elsif ($result_rc eq 'null') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 992 | $rcinfo = 'Always <tt class="constant">NULL</tt>'; |
Fred Drake | c2578c5 | 2000-04-10 18:26:45 +0000 | [diff] [blame] | 993 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 994 | if ($rcinfo ne '') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 995 | $rcinfo = ( "\n<div class=\"refcount-info\">" |
| 996 | . "\n <span class=\"label\">Return value:</span>" |
| 997 | . "\n <span class=\"value\">$rcinfo.</span>" |
| 998 | . "\n</div>"); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 999 | } |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1000 | return "<dl><dt>$siginfo</dt>\n<dd>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1001 | . $rcinfo |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1002 | . $_ |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1003 | . '</dd></dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1004 | } |
| 1005 | |
Fred Drake | eeb5ec4 | 2002-04-15 17:46:00 +0000 | [diff] [blame] | 1006 | sub do_cmd_cmemberline{ |
| 1007 | local($_) = @_; |
| 1008 | my $container = next_argument(); |
| 1009 | my $type = next_argument(); |
| 1010 | my $name = next_argument(); |
| 1011 | my $idx = make_str_index_entry("<tt class=\"cmember\">$name</tt>" |
Fred Drake | 0157276 | 2002-04-15 19:35:29 +0000 | [diff] [blame] | 1012 | . " ($container member)"); |
Fred Drake | eeb5ec4 | 2002-04-15 17:46:00 +0000 | [diff] [blame] | 1013 | $idx =~ s/ \(.*\)//; |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1014 | return "<dt>$type <b>$idx</b></dt>\n<dd>" |
Fred Drake | eeb5ec4 | 2002-04-15 17:46:00 +0000 | [diff] [blame] | 1015 | . $_; |
| 1016 | } |
| 1017 | sub do_env_cmemberdesc{ |
| 1018 | local($_) = @_; |
| 1019 | my $container = next_argument(); |
| 1020 | my $type = next_argument(); |
| 1021 | my $name = next_argument(); |
| 1022 | my $idx = make_str_index_entry("<tt class=\"cmember\">$name</tt>" |
Fred Drake | 0157276 | 2002-04-15 19:35:29 +0000 | [diff] [blame] | 1023 | . " ($container member)"); |
Fred Drake | eeb5ec4 | 2002-04-15 17:46:00 +0000 | [diff] [blame] | 1024 | $idx =~ s/ \(.*\)//; |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1025 | return "<dl><dt>$type <b>$idx</b></dt>\n<dd>" |
Fred Drake | eeb5ec4 | 2002-04-15 17:46:00 +0000 | [diff] [blame] | 1026 | . $_ |
| 1027 | . '</dl>'; |
| 1028 | } |
| 1029 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1030 | sub do_env_csimplemacrodesc{ |
| 1031 | local($_) = @_; |
| 1032 | my $name = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1033 | my $idx = make_str_index_entry("<tt class=\"macro\">$name</tt>"); |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1034 | return "<dl><dt><b>$idx</b></dt>\n<dd>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1035 | . $_ |
| 1036 | . '</dl>' |
| 1037 | } |
| 1038 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1039 | sub do_env_ctypedesc{ |
| 1040 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1041 | my $index_name = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1042 | my $type_name = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1043 | $index_name = $type_name |
| 1044 | unless $index_name; |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1045 | my($name, $aname, $ahref) = new_link_info(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1046 | add_index_entry("<tt class=\"ctype\">$index_name</tt> (C type)", $ahref); |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1047 | return "<dl><dt><b><tt class=\"ctype\">$aname$type_name</a></tt></b></dt>" |
| 1048 | . "\n<dd>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1049 | . $_ |
| 1050 | . '</dl>' |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1051 | } |
| 1052 | |
| 1053 | sub do_env_cvardesc{ |
| 1054 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1055 | my $var_type = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1056 | my $var_name = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1057 | my $idx = make_str_index_entry("<tt class=\"cdata\">$var_name</tt>" |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1058 | . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1059 | $idx =~ s/ \(.*\)//; |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1060 | return "<dl><dt>$var_type <b>$idx</b></dt>\n" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1061 | . '<dd>' |
| 1062 | . $_ |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1063 | . '</dd></dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1064 | } |
| 1065 | |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1066 | sub convert_args($){ |
| 1067 | local($IN_DESC_HANDLER) = 1; |
| 1068 | local($_) = @_; |
| 1069 | return translate_commands($_); |
| 1070 | } |
| 1071 | |
Fred Drake | f6e9027 | 2002-06-18 18:24:16 +0000 | [diff] [blame] | 1072 | sub funcline_helper($$$){ |
| 1073 | my($first, $idxitem, $arglist) = @_; |
| 1074 | return (($first ? '<dl>' : '') |
Fred Drake | b02f0df | 2002-11-13 19:16:37 +0000 | [diff] [blame] | 1075 | . '<dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">' |
| 1076 | . "\n <td><nobr><b>$idxitem</b>(</nobr></td>" |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1077 | . "\n <td><var>$arglist</var>)</td></tr></table></dt>\n<dd>"); |
Fred Drake | f6e9027 | 2002-06-18 18:24:16 +0000 | [diff] [blame] | 1078 | } |
| 1079 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1080 | sub do_env_funcdesc{ |
| 1081 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1082 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1083 | my $arg_list = convert_args(next_argument()); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1084 | my $idx = make_str_index_entry("<tt class=\"function\">$function_name()" |
| 1085 | . '</tt>' |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1086 | . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1087 | $idx =~ s/ \(.*\)//; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1088 | $idx =~ s/\(\)<\/tt>/<\/tt>/; |
Fred Drake | f6e9027 | 2002-06-18 18:24:16 +0000 | [diff] [blame] | 1089 | return funcline_helper(1, $idx, $arg_list) . $_ . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1090 | } |
| 1091 | |
| 1092 | sub do_env_funcdescni{ |
| 1093 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1094 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1095 | my $arg_list = convert_args(next_argument()); |
Fred Drake | f6e9027 | 2002-06-18 18:24:16 +0000 | [diff] [blame] | 1096 | my $prefix = "<tt class=\"function\">$function_name</tt>"; |
| 1097 | return funcline_helper(1, $prefix, $arg_list) . $_ . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1098 | } |
| 1099 | |
| 1100 | sub do_cmd_funcline{ |
| 1101 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1102 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1103 | my $arg_list = convert_args(next_argument()); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1104 | my $prefix = "<tt class=\"function\">$function_name()</tt>"; |
Fred Drake | ca675e4 | 1999-04-21 15:58:58 +0000 | [diff] [blame] | 1105 | my $idx = make_str_index_entry($prefix . get_indexsubitem()); |
| 1106 | $prefix =~ s/\(\)//; |
| 1107 | |
Fred Drake | f6e9027 | 2002-06-18 18:24:16 +0000 | [diff] [blame] | 1108 | return funcline_helper(0, $prefix, $arg_list) . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1109 | } |
| 1110 | |
Fred Drake | 6b3fb78 | 1999-07-12 16:50:09 +0000 | [diff] [blame] | 1111 | sub do_cmd_funclineni{ |
| 1112 | local($_) = @_; |
| 1113 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1114 | my $arg_list = convert_args(next_argument()); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1115 | my $prefix = "<tt class=\"function\">$function_name</tt>"; |
Fred Drake | 6b3fb78 | 1999-07-12 16:50:09 +0000 | [diff] [blame] | 1116 | |
Fred Drake | f6e9027 | 2002-06-18 18:24:16 +0000 | [diff] [blame] | 1117 | return funcline_helper(0, $prefix, $arg_list) . $_; |
Fred Drake | 6b3fb78 | 1999-07-12 16:50:09 +0000 | [diff] [blame] | 1118 | } |
| 1119 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1120 | # Change this flag to index the opcode entries. I don't think it's very |
| 1121 | # useful to index them, since they're only presented to describe the dis |
| 1122 | # module. |
| 1123 | # |
| 1124 | $INDEX_OPCODES = 0; |
| 1125 | |
| 1126 | sub do_env_opcodedesc{ |
| 1127 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1128 | my $opcode_name = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1129 | my $arg_list = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1130 | my $idx; |
| 1131 | if ($INDEX_OPCODES) { |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1132 | $idx = make_str_index_entry("<tt class=\"opcode\">$opcode_name</tt>" |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1133 | . ' (byte code instruction)'); |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1134 | $idx =~ s/ \(byte code instruction\)//; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1135 | } |
| 1136 | else { |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1137 | $idx = "<tt class=\"opcode\">$opcode_name</tt>"; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1138 | } |
| 1139 | my $stuff = "<dl><dt><b>$idx</b>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1140 | if ($arg_list) { |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1141 | $stuff .= " <var>$arg_list</var>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1142 | } |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1143 | return $stuff . "</dt>\n<dd>" . $_ . '</dt></dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1144 | } |
| 1145 | |
| 1146 | sub do_env_datadesc{ |
| 1147 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1148 | my $dataname = next_argument(); |
| 1149 | my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1150 | $idx =~ s/ \(.*\)//; |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1151 | return "<dl><dt><b>$idx</b></dt>\n<dd>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1152 | . $_ |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1153 | . '</dd></dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1154 | } |
| 1155 | |
| 1156 | sub do_env_datadescni{ |
| 1157 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1158 | my $idx = next_argument(); |
| 1159 | if (! $STRING_INDEX_TT) { |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1160 | $idx = "<tt>$idx</tt>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1161 | } |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1162 | return "<dl><dt><b>$idx</b></dt>\n<dd>" . $_ . '</dd></dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1163 | } |
| 1164 | |
| 1165 | sub do_cmd_dataline{ |
| 1166 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1167 | my $data_name = next_argument(); |
| 1168 | my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem()); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1169 | $idx =~ s/ \(.*\)//; |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1170 | return "<dt><b>$idx</b></dt><dd>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1171 | } |
| 1172 | |
Fred Drake | adb272c | 2000-04-10 17:47:14 +0000 | [diff] [blame] | 1173 | sub do_cmd_datalineni{ |
| 1174 | local($_) = @_; |
| 1175 | my $data_name = next_argument(); |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1176 | return "<dt><b><tt>$data_name</tt></b></dt><dd>" . $_; |
Fred Drake | adb272c | 2000-04-10 17:47:14 +0000 | [diff] [blame] | 1177 | } |
| 1178 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1179 | sub do_env_excdesc{ |
| 1180 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1181 | my $excname = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1182 | my $idx = make_str_index_entry("<tt class=\"exception\">$excname</tt>"); |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1183 | return ("<dl><dt><b>${TLSTART}exception$TLEND$idx</b></dt>" |
Fred Drake | af07b2c | 2001-10-26 03:09:27 +0000 | [diff] [blame] | 1184 | . "\n<dd>" |
| 1185 | . $_ |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1186 | . '</dd></dl>'); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1187 | } |
| 1188 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1189 | sub do_env_fulllineitems{ return do_env_itemize(@_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1190 | |
| 1191 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1192 | sub handle_classlike_descriptor($$){ |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1193 | local($_, $what) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1194 | $THIS_CLASS = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1195 | my $arg_list = convert_args(next_argument()); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1196 | $idx = make_str_index_entry( |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1197 | "<tt class=\"$what\">$THIS_CLASS</tt> ($what in $THIS_MODULE)" ); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1198 | $idx =~ s/ \(.*\)//; |
Fred Drake | f6e9027 | 2002-06-18 18:24:16 +0000 | [diff] [blame] | 1199 | my $prefix = "$TLSTART$what$TLEND$idx"; |
| 1200 | return funcline_helper(1, $prefix, $arg_list) . $_ . '</dl>'; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1201 | } |
| 1202 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1203 | sub do_env_classdesc{ |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 1204 | return handle_classlike_descriptor($_[0], "class"); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1205 | } |
| 1206 | |
Fred Drake | 06a01e8 | 2001-05-11 01:00:30 +0000 | [diff] [blame] | 1207 | sub do_env_classdescstar{ |
| 1208 | local($_) = @_; |
| 1209 | $THIS_CLASS = next_argument(); |
| 1210 | $idx = make_str_index_entry( |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1211 | "<tt class=\"class\">$THIS_CLASS</tt> (class in $THIS_MODULE)"); |
Fred Drake | 06a01e8 | 2001-05-11 01:00:30 +0000 | [diff] [blame] | 1212 | $idx =~ s/ \(.*\)//; |
Fred Drake | f6e9027 | 2002-06-18 18:24:16 +0000 | [diff] [blame] | 1213 | my $prefix = "${TLSTART}class$TLEND$idx"; |
| 1214 | # Can't use funcline_helper() since there is no args list. |
| 1215 | return "<dl><dt><b>$prefix</b>\n<dd>" . $_ . '</dl>'; |
Fred Drake | 06a01e8 | 2001-05-11 01:00:30 +0000 | [diff] [blame] | 1216 | } |
| 1217 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1218 | sub do_env_excclassdesc{ |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 1219 | return handle_classlike_descriptor($_[0], "exception"); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1220 | } |
| 1221 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1222 | |
| 1223 | sub do_env_methoddesc{ |
| 1224 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1225 | my $class_name = next_optional_argument(); |
| 1226 | $class_name = $THIS_CLASS |
| 1227 | unless $class_name; |
Fred Drake | 5a0ca4e | 1999-01-12 04:16:51 +0000 | [diff] [blame] | 1228 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1229 | my $arg_list = convert_args(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1230 | my $extra = ''; |
| 1231 | if ($class_name) { |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1232 | $extra = " ($class_name method)"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1233 | } |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1234 | my $idx = make_str_index_entry( |
| 1235 | "<tt class=\"method\">$method()</tt>$extra"); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1236 | $idx =~ s/ \(.*\)//; |
| 1237 | $idx =~ s/\(\)//; |
Fred Drake | f6e9027 | 2002-06-18 18:24:16 +0000 | [diff] [blame] | 1238 | return funcline_helper(1, $idx, $arg_list) . $_ . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1239 | } |
| 1240 | |
| 1241 | |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 1242 | sub do_cmd_methodline{ |
| 1243 | local($_) = @_; |
| 1244 | my $class_name = next_optional_argument(); |
| 1245 | $class_name = $THIS_CLASS |
| 1246 | unless $class_name; |
| 1247 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1248 | my $arg_list = convert_args(next_argument()); |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 1249 | my $extra = ''; |
| 1250 | if ($class_name) { |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1251 | $extra = " ($class_name method)"; |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 1252 | } |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1253 | my $idx = make_str_index_entry( |
| 1254 | "<tt class=\"method\">$method()</tt>$extra"); |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 1255 | $idx =~ s/ \(.*\)//; |
| 1256 | $idx =~ s/\(\)//; |
Fred Drake | f6e9027 | 2002-06-18 18:24:16 +0000 | [diff] [blame] | 1257 | return funcline_helper(0, $idx, $arg_list) . $_; |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 1258 | } |
| 1259 | |
| 1260 | |
Fred Drake | d64a40d | 1998-09-10 18:59:13 +0000 | [diff] [blame] | 1261 | sub do_cmd_methodlineni{ |
| 1262 | local($_) = @_; |
| 1263 | next_optional_argument(); |
| 1264 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1265 | my $arg_list = convert_args(next_argument()); |
Fred Drake | f6e9027 | 2002-06-18 18:24:16 +0000 | [diff] [blame] | 1266 | return funcline_helper(0, $method, $arg_list) . $_; |
Fred Drake | d64a40d | 1998-09-10 18:59:13 +0000 | [diff] [blame] | 1267 | } |
| 1268 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1269 | sub do_env_methoddescni{ |
| 1270 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1271 | next_optional_argument(); |
| 1272 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1273 | my $arg_list = convert_args(next_argument()); |
Fred Drake | f6e9027 | 2002-06-18 18:24:16 +0000 | [diff] [blame] | 1274 | return funcline_helper(1, $method, $arg_list) . $_ . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1275 | } |
| 1276 | |
| 1277 | |
| 1278 | sub do_env_memberdesc{ |
| 1279 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1280 | my $class = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1281 | my $member = next_argument(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1282 | $class = $THIS_CLASS |
| 1283 | unless $class; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1284 | my $extra = ''; |
Fred Drake | 085b812 | 1999-04-21 14:00:29 +0000 | [diff] [blame] | 1285 | $extra = " ($class attribute)" |
| 1286 | if ($class ne ''); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1287 | my $idx = make_str_index_entry("<tt class=\"member\">$member</tt>$extra"); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1288 | $idx =~ s/ \(.*\)//; |
| 1289 | $idx =~ s/\(\)//; |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1290 | return "<dl><dt><b>$idx</b></dt>\n<dd>" . $_ . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1291 | } |
| 1292 | |
| 1293 | |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1294 | sub do_cmd_memberline{ |
| 1295 | local($_) = @_; |
| 1296 | my $class = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1297 | my $member = next_argument(); |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1298 | $class = $THIS_CLASS |
| 1299 | unless $class; |
| 1300 | my $extra = ''; |
Fred Drake | 085b812 | 1999-04-21 14:00:29 +0000 | [diff] [blame] | 1301 | $extra = " ($class attribute)" |
| 1302 | if ($class ne ''); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1303 | my $idx = make_str_index_entry("<tt class=\"member\">$member</tt>$extra"); |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1304 | $idx =~ s/ \(.*\)//; |
| 1305 | $idx =~ s/\(\)//; |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1306 | return "<dt><b>$idx</b></dt><dd>" . $_; |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1307 | } |
| 1308 | |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1309 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1310 | sub do_env_memberdescni{ |
| 1311 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1312 | next_optional_argument(); |
| 1313 | my $member = next_argument(); |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1314 | 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] | 1315 | . $_ |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1316 | . '</dd></dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1317 | } |
| 1318 | |
| 1319 | |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1320 | sub do_cmd_memberlineni{ |
| 1321 | local($_) = @_; |
| 1322 | next_optional_argument(); |
| 1323 | my $member = next_argument(); |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1324 | return "<dt><b><tt class=\"member\">$member</tt></b></dt>\n<dd>" . $_; |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1325 | } |
| 1326 | |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1327 | |
| 1328 | @col_aligns = ('<td>', '<td>', '<td>', '<td>', '<td>'); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1329 | |
Fred Drake | cb19976 | 2001-08-16 21:56:24 +0000 | [diff] [blame] | 1330 | %FontConversions = ('cdata' => 'tt class="cdata"', |
| 1331 | 'character' => 'tt class="character"', |
| 1332 | 'class' => 'tt class="class"', |
| 1333 | 'command' => 'code', |
| 1334 | 'constant' => 'tt class="constant"', |
| 1335 | 'exception' => 'tt class="exception"', |
| 1336 | 'file' => 'tt class="file"', |
| 1337 | 'filenq' => 'tt class="file"', |
| 1338 | 'kbd' => 'kbd', |
| 1339 | 'member' => 'tt class="member"', |
| 1340 | 'programopt' => 'b', |
| 1341 | 'textrm' => '', |
| 1342 | ); |
| 1343 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1344 | sub fix_font($){ |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1345 | # do a little magic on a font name to get the right behavior in the first |
| 1346 | # column of the output table |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 1347 | my $font = $_[0]; |
Fred Drake | cb19976 | 2001-08-16 21:56:24 +0000 | [diff] [blame] | 1348 | if (defined $FontConversions{$font}) { |
| 1349 | $font = $FontConversions{$font}; |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 1350 | } |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1351 | return $font; |
| 1352 | } |
| 1353 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1354 | sub figure_column_alignment($){ |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 1355 | my $a = $_[0]; |
| 1356 | if (!defined $a) { |
| 1357 | return ''; |
| 1358 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1359 | my $mark = substr($a, 0, 1); |
| 1360 | my $r = ''; |
| 1361 | if ($mark eq 'c') |
| 1362 | { $r = ' align="center"'; } |
| 1363 | elsif ($mark eq 'r') |
| 1364 | { $r = ' align="right"'; } |
| 1365 | elsif ($mark eq 'l') |
| 1366 | { $r = ' align="left"'; } |
| 1367 | elsif ($mark eq 'p') |
| 1368 | { $r = ' align="left"'; } |
| 1369 | return $r; |
| 1370 | } |
| 1371 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1372 | sub setup_column_alignments($){ |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1373 | local($_) = @_; |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 1374 | my($s1, $s2, $s3, $s4, $s5) = split(/[|]/,$_); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1375 | my $a1 = figure_column_alignment($s1); |
| 1376 | my $a2 = figure_column_alignment($s2); |
| 1377 | my $a3 = figure_column_alignment($s3); |
| 1378 | my $a4 = figure_column_alignment($s4); |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1379 | my $a5 = figure_column_alignment($s5); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1380 | $col_aligns[0] = "<td$a1 valign=\"baseline\">"; |
| 1381 | $col_aligns[1] = "<td$a2>"; |
| 1382 | $col_aligns[2] = "<td$a3>"; |
| 1383 | $col_aligns[3] = "<td$a4>"; |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1384 | $col_aligns[4] = "<td$a5>"; |
Fred Drake | 79189b5 | 1999-04-28 13:54:30 +0000 | [diff] [blame] | 1385 | # return the aligned header start tags |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1386 | return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>", "<th$a5>"); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1387 | } |
| 1388 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1389 | sub get_table_col1_fonts(){ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1390 | my $font = $globals{'lineifont'}; |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1391 | my($sfont, $efont) = ('', ''); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1392 | if ($font) { |
| 1393 | $sfont = "<$font>"; |
| 1394 | $efont = "</$font>"; |
| 1395 | $efont =~ s/ .*>/>/; |
| 1396 | } |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1397 | return ($sfont, $efont); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1398 | } |
| 1399 | |
| 1400 | sub do_env_tableii{ |
| 1401 | local($_) = @_; |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1402 | my $arg = next_argument(); |
| 1403 | my($th1, $th2, $th3, $th4, $th5) = setup_column_alignments($arg); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1404 | my $font = fix_font(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1405 | my $h1 = next_argument(); |
| 1406 | my $h2 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1407 | s/[\s\n]+//; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1408 | $globals{'lineifont'} = $font; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1409 | my $a1 = $col_aligns[0]; |
| 1410 | my $a2 = $col_aligns[1]; |
| 1411 | s/\\lineii</\\lineii[$a1|$a2]</g; |
| 1412 | return '<table border align="center" style="border-collapse: collapse">' |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1413 | . "\n <thead>" |
| 1414 | . "\n <tr class=\"tableheader\">" |
| 1415 | . "\n $th1<b>$h1</b>\ </th>" |
| 1416 | . "\n $th2<b>$h2</b>\ </th>" |
| 1417 | . "\n </tr>" |
| 1418 | . "\n </thead>" |
| 1419 | . "\n <tbody valign=\"baseline\">" |
| 1420 | . $_ |
| 1421 | . "\n </tbody>" |
| 1422 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1423 | } |
| 1424 | |
Fred Drake | da72b93 | 2000-09-21 15:58:02 +0000 | [diff] [blame] | 1425 | sub do_env_longtableii{ |
| 1426 | return do_env_tableii(@_); |
| 1427 | } |
| 1428 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1429 | sub do_cmd_lineii{ |
| 1430 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1431 | my $aligns = next_optional_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1432 | my $c1 = next_argument(); |
| 1433 | my $c2 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1434 | s/[\s\n]+//; |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1435 | my($sfont, $efont) = get_table_col1_fonts(); |
Fred Drake | ecbfceb | 2003-09-04 21:25:03 +0000 | [diff] [blame] | 1436 | $c1 = ' ' if ($c1 eq ''); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1437 | $c2 = ' ' if ($c2 eq ''); |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1438 | my($c1align, $c2align) = split('\|', $aligns); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1439 | my $padding = ''; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1440 | if ($c1align =~ /align="right"/ || $c1 eq '') { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1441 | $padding = ' '; |
Fred Drake | 58b2bfd | 1998-04-02 20:14:04 +0000 | [diff] [blame] | 1442 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1443 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
| 1444 | . " $c2align$c2</td>" |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1445 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1446 | } |
| 1447 | |
| 1448 | sub do_env_tableiii{ |
| 1449 | local($_) = @_; |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1450 | my $arg = next_argument(); |
| 1451 | my($th1, $th2, $th3, $th4, $th5) = setup_column_alignments($arg); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1452 | my $font = fix_font(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1453 | my $h1 = next_argument(); |
| 1454 | my $h2 = next_argument(); |
| 1455 | my $h3 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1456 | s/[\s\n]+//; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1457 | $globals{'lineifont'} = $font; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1458 | my $a1 = $col_aligns[0]; |
| 1459 | my $a2 = $col_aligns[1]; |
| 1460 | my $a3 = $col_aligns[2]; |
| 1461 | s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g; |
| 1462 | return '<table border align="center" style="border-collapse: collapse">' |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1463 | . "\n <thead>" |
| 1464 | . "\n <tr class=\"tableheader\">" |
| 1465 | . "\n $th1<b>$h1</b>\ </th>" |
| 1466 | . "\n $th2<b>$h2</b>\ </th>" |
| 1467 | . "\n $th3<b>$h3</b>\ </th>" |
| 1468 | . "\n </tr>" |
| 1469 | . "\n </thead>" |
| 1470 | . "\n <tbody valign=\"baseline\">" |
| 1471 | . $_ |
| 1472 | . "\n </tbody>" |
| 1473 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1474 | } |
| 1475 | |
Fred Drake | da72b93 | 2000-09-21 15:58:02 +0000 | [diff] [blame] | 1476 | sub do_env_longtableiii{ |
| 1477 | return do_env_tableiii(@_); |
| 1478 | } |
| 1479 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1480 | sub do_cmd_lineiii{ |
| 1481 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1482 | my $aligns = next_optional_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1483 | my $c1 = next_argument(); |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1484 | my $c2 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1485 | my $c3 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1486 | s/[\s\n]+//; |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1487 | my($sfont, $efont) = get_table_col1_fonts(); |
Fred Drake | ecbfceb | 2003-09-04 21:25:03 +0000 | [diff] [blame] | 1488 | $c1 = ' ' if ($c1 eq ''); |
| 1489 | $c2 = ' ' if ($c2 eq ''); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1490 | $c3 = ' ' if ($c3 eq ''); |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1491 | my($c1align, $c2align, $c3align) = split('\|', $aligns); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1492 | my $padding = ''; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1493 | if ($c1align =~ /align="right"/ || $c1 eq '') { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1494 | $padding = ' '; |
Fred Drake | 58b2bfd | 1998-04-02 20:14:04 +0000 | [diff] [blame] | 1495 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1496 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1497 | . " $c2align$c2</td>\n" |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1498 | . " $c3align$c3</td>" |
| 1499 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1500 | } |
| 1501 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1502 | sub do_env_tableiv{ |
| 1503 | local($_) = @_; |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1504 | my $arg = next_argument(); |
| 1505 | my($th1, $th2, $th3, $th4, $th5) = setup_column_alignments($arg); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1506 | my $font = fix_font(next_argument()); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1507 | my $h1 = next_argument(); |
| 1508 | my $h2 = next_argument(); |
| 1509 | my $h3 = next_argument(); |
| 1510 | my $h4 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1511 | s/[\s\n]+//; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1512 | $globals{'lineifont'} = $font; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1513 | my $a1 = $col_aligns[0]; |
| 1514 | my $a2 = $col_aligns[1]; |
| 1515 | my $a3 = $col_aligns[2]; |
| 1516 | my $a4 = $col_aligns[3]; |
| 1517 | s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g; |
| 1518 | return '<table border align="center" style="border-collapse: collapse">' |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1519 | . "\n <thead>" |
| 1520 | . "\n <tr class=\"tableheader\">" |
| 1521 | . "\n $th1<b>$h1</b>\ </th>" |
| 1522 | . "\n $th2<b>$h2</b>\ </th>" |
| 1523 | . "\n $th3<b>$h3</b>\ </th>" |
| 1524 | . "\n $th4<b>$h4</b>\ </th>" |
| 1525 | . "\n </tr>" |
| 1526 | . "\n </thead>" |
| 1527 | . "\n <tbody valign=\"baseline\">" |
| 1528 | . $_ |
| 1529 | . "\n </tbody>" |
| 1530 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1531 | } |
| 1532 | |
Fred Drake | da72b93 | 2000-09-21 15:58:02 +0000 | [diff] [blame] | 1533 | sub do_env_longtableiv{ |
| 1534 | return do_env_tableiv(@_); |
| 1535 | } |
| 1536 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1537 | sub do_cmd_lineiv{ |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1538 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1539 | my $aligns = next_optional_argument(); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1540 | my $c1 = next_argument(); |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1541 | my $c2 = next_argument(); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1542 | my $c3 = next_argument(); |
| 1543 | my $c4 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1544 | s/[\s\n]+//; |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1545 | my($sfont, $efont) = get_table_col1_fonts(); |
Fred Drake | ecbfceb | 2003-09-04 21:25:03 +0000 | [diff] [blame] | 1546 | $c1 = ' ' if ($c1 eq ''); |
| 1547 | $c2 = ' ' if ($c2 eq ''); |
| 1548 | $c3 = ' ' if ($c3 eq ''); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1549 | $c4 = ' ' if ($c4 eq ''); |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1550 | my($c1align, $c2align, $c3align, $c4align) = split('\|', $aligns); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1551 | my $padding = ''; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1552 | if ($c1align =~ /align="right"/ || $c1 eq '') { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1553 | $padding = ' '; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1554 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1555 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1556 | . " $c2align$c2</td>\n" |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1557 | . " $c3align$c3</td>\n" |
| 1558 | . " $c4align$c4</td>" |
| 1559 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1560 | } |
| 1561 | |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1562 | sub do_env_tablev{ |
| 1563 | local($_) = @_; |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1564 | my $arg = next_argument(); |
| 1565 | my($th1, $th2, $th3, $th4, $th5) = setup_column_alignments($arg); |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1566 | my $font = fix_font(next_argument()); |
| 1567 | my $h1 = next_argument(); |
| 1568 | my $h2 = next_argument(); |
| 1569 | my $h3 = next_argument(); |
| 1570 | my $h4 = next_argument(); |
| 1571 | my $h5 = next_argument(); |
| 1572 | s/[\s\n]+//; |
| 1573 | $globals{'lineifont'} = $font; |
| 1574 | my $a1 = $col_aligns[0]; |
| 1575 | my $a2 = $col_aligns[1]; |
| 1576 | my $a3 = $col_aligns[2]; |
| 1577 | my $a4 = $col_aligns[3]; |
| 1578 | my $a5 = $col_aligns[4]; |
| 1579 | s/\\linev</\\linev[$a1|$a2|$a3|$a4|$a5]</g; |
| 1580 | return '<table border align="center" style="border-collapse: collapse">' |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1581 | . "\n <thead>" |
| 1582 | . "\n <tr class=\"tableheader\">" |
| 1583 | . "\n $th1<b>$h1</b>\ </th>" |
| 1584 | . "\n $th2<b>$h2</b>\ </th>" |
| 1585 | . "\n $th3<b>$h3</b>\ </th>" |
| 1586 | . "\n $th4<b>$h4</b>\ </th>" |
| 1587 | . "\n $th5<b>$h5</b>\ </th>" |
| 1588 | . "\n </tr>" |
| 1589 | . "\n </thead>" |
| 1590 | . "\n <tbody valign=\"baseline\">" |
| 1591 | . $_ |
| 1592 | . "\n </tbody>" |
| 1593 | . "\n</table>"; |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1594 | } |
| 1595 | |
| 1596 | sub do_env_longtablev{ |
| 1597 | return do_env_tablev(@_); |
| 1598 | } |
| 1599 | |
| 1600 | sub do_cmd_linev{ |
| 1601 | local($_) = @_; |
| 1602 | my $aligns = next_optional_argument(); |
| 1603 | my $c1 = next_argument(); |
| 1604 | my $c2 = next_argument(); |
| 1605 | my $c3 = next_argument(); |
| 1606 | my $c4 = next_argument(); |
| 1607 | my $c5 = next_argument(); |
| 1608 | s/[\s\n]+//; |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1609 | my($sfont, $efont) = get_table_col1_fonts(); |
Fred Drake | ecbfceb | 2003-09-04 21:25:03 +0000 | [diff] [blame] | 1610 | $c1 = ' ' if ($c1 eq ''); |
| 1611 | $c2 = ' ' if ($c2 eq ''); |
| 1612 | $c3 = ' ' if ($c3 eq ''); |
| 1613 | $c4 = ' ' if ($c4 eq ''); |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1614 | $c5 = ' ' if ($c5 eq ''); |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1615 | my($c1align, $c2align, $c3align, $c4align, $c5align) = split('\|',$aligns); |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1616 | my $padding = ''; |
| 1617 | if ($c1align =~ /align="right"/ || $c1 eq '') { |
| 1618 | $padding = ' '; |
| 1619 | } |
| 1620 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
| 1621 | . " $c2align$c2</td>\n" |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1622 | . " $c3align$c3</td>\n" |
| 1623 | . " $c4align$c4</td>\n" |
| 1624 | . " $c5align$c5</td>" |
| 1625 | . $_; |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1626 | } |
| 1627 | |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1628 | |
| 1629 | # These can be used to control the title page appearance; |
| 1630 | # they need a little bit of documentation. |
| 1631 | # |
| 1632 | # If $TITLE_PAGE_GRAPHIC is set, it should be the name of a file in the |
| 1633 | # $ICONSERVER directory, or include path information (other than "./"). The |
| 1634 | # default image type will be assumed if an extension is not provided. |
| 1635 | # |
| 1636 | # If specified, the "title page" will contain two colums: one containing the |
| 1637 | # title/author/etc., and the other containing the graphic. Use the other |
| 1638 | # four variables listed here to control specific details of the layout; all |
| 1639 | # are optional. |
| 1640 | # |
| 1641 | # $TITLE_PAGE_GRAPHIC = "my-company-logo"; |
| 1642 | # $TITLE_PAGE_GRAPHIC_COLWIDTH = "30%"; |
| 1643 | # $TITLE_PAGE_GRAPHIC_WIDTH = 150; |
| 1644 | # $TITLE_PAGE_GRAPHIC_HEIGHT = 150; |
| 1645 | # $TITLE_PAGE_GRAPHIC_ON_RIGHT = 0; |
| 1646 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1647 | sub make_my_titlepage(){ |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1648 | my $the_title = ""; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1649 | if ($t_title) { |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1650 | $the_title .= "\n<h1>$t_title</h1>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1651 | } |
| 1652 | else { |
| 1653 | write_warnings("\nThis document has no title."); |
| 1654 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1655 | if ($t_author) { |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1656 | if ($t_authorURL) { |
| 1657 | my $href = translate_commands($t_authorURL); |
| 1658 | $href = make_named_href('author', $href, |
| 1659 | "<b><font size=\"+2\">$t_author" |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1660 | . '</font></b>'); |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1661 | $the_title .= "\n<p>$href</p>"; |
| 1662 | } |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1663 | else { |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1664 | $the_title .= ("\n<p><b><font size=\"+2\">$t_author" |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1665 | . '</font></b></p>'); |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1666 | } |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1667 | } |
| 1668 | else { |
| 1669 | write_warnings("\nThere is no author for this document."); |
| 1670 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1671 | if ($t_institute) { |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1672 | $the_title .= "\n<p>$t_institute</p>"; |
| 1673 | } |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 1674 | if ($DEVELOPER_ADDRESS) { |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1675 | $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>"; |
| 1676 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1677 | if ($t_affil) { |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1678 | $the_title .= "\n<p><i>$t_affil</i></p>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1679 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1680 | if ($t_date) { |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1681 | $the_title .= "\n<p>"; |
| 1682 | if ($PACKAGE_VERSION) { |
| 1683 | $the_title .= ('<strong>Release ' |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1684 | . "$PACKAGE_VERSION$RELEASE_INFO</strong><br />\n"); |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1685 | } |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1686 | $the_title .= "<strong>$t_date</strong></p>" |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1687 | } |
| 1688 | if ($t_address) { |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1689 | $the_title .= "\n<p>$t_address</p>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1690 | } |
| 1691 | else { |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1692 | $the_title .= "\n<p></p>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1693 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1694 | if ($t_email) { |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1695 | $the_title .= "\n<p>$t_email</p>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1696 | } |
| 1697 | return $the_title; |
| 1698 | } |
| 1699 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1700 | sub make_my_titlegraphic(){ |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1701 | my $filename = make_icon_filename($TITLE_PAGE_GRAPHIC); |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1702 | my $graphic = "<td class=\"titlegraphic\""; |
| 1703 | $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_COLWIDTH\"" |
| 1704 | if ($TITLE_PAGE_GRAPHIC_COLWIDTH); |
| 1705 | $graphic .= "><img"; |
| 1706 | $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_WIDTH\"" |
| 1707 | if ($TITLE_PAGE_GRAPHIC_WIDTH); |
| 1708 | $graphic .= " height=\"$TITLE_PAGE_GRAPHIC_HEIGHT\"" |
| 1709 | if ($TITLE_PAGE_GRAPHIC_HEIGHT); |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1710 | $graphic .= "\n src=\"$filename\" /></td>\n"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1711 | return $graphic; |
| 1712 | } |
| 1713 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1714 | sub do_cmd_maketitle{ |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1715 | local($_) = @_; |
Fred Drake | dbb2b9d | 2002-10-30 21:38:32 +0000 | [diff] [blame] | 1716 | my $the_title = "\n"; |
| 1717 | if ($EXTERNAL_UP_LINK) { |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1718 | # This generates a <link> element in the wrong place (the |
Fred Drake | dbb2b9d | 2002-10-30 21:38:32 +0000 | [diff] [blame] | 1719 | # body), but I don't see any other way to get this generated |
| 1720 | # at all. Browsers like Mozilla, that support navigation |
| 1721 | # links, can make use of this. |
| 1722 | $the_title .= ("<link rel='up' href='$EXTERNAL_UP_LINK'" |
| 1723 | . ($EXTERNAL_UP_TITLE |
| 1724 | ? " title='$EXTERNAL_UP_TITLE'" : '') |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1725 | . " />\n"); |
Fred Drake | dbb2b9d | 2002-10-30 21:38:32 +0000 | [diff] [blame] | 1726 | } |
| 1727 | $the_title .= '<div class="titlepage">'; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1728 | if ($TITLE_PAGE_GRAPHIC) { |
| 1729 | if ($TITLE_PAGE_GRAPHIC_ON_RIGHT) { |
| 1730 | $the_title .= ("\n<table border=\"0\" width=\"100%\">" |
| 1731 | . "<tr align=\"right\">\n<td>" |
| 1732 | . make_my_titlepage() |
| 1733 | . "</td>\n" |
| 1734 | . make_my_titlegraphic() |
| 1735 | . "</tr>\n</table>"); |
| 1736 | } |
| 1737 | else { |
| 1738 | $the_title .= ("\n<table border=\"0\" width=\"100%\"><tr>\n" |
| 1739 | . make_my_titlegraphic() |
| 1740 | . "<td>" |
| 1741 | . make_my_titlepage() |
| 1742 | . "</td></tr>\n</table>"); |
| 1743 | } |
| 1744 | } |
| 1745 | else { |
| 1746 | $the_title .= ("\n<center>" |
| 1747 | . make_my_titlepage() |
| 1748 | . "\n</center>"); |
| 1749 | } |
| 1750 | $the_title .= "\n</div>"; |
| 1751 | return $the_title . $_; |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 1752 | $the_title .= "\n</center></div>"; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1753 | return $the_title . $_ ; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1754 | } |
| 1755 | |
| 1756 | |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1757 | # |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1758 | # Module synopsis support |
| 1759 | # |
| 1760 | |
| 1761 | require SynopsisTable; |
| 1762 | |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1763 | sub get_chapter_id(){ |
| 1764 | my $id = do_cmd_thechapter(''); |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 1765 | $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/$1/; |
Fred Drake | 45f2601 | 1998-08-04 22:07:18 +0000 | [diff] [blame] | 1766 | $id =~ s/\.//; |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1767 | return $id; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1768 | } |
| 1769 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1770 | # 'chapter' => 'SynopsisTable instance' |
| 1771 | %ModuleSynopses = (); |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1772 | |
| 1773 | sub get_synopsis_table($){ |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 1774 | my $chap = $_[0]; |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1775 | my $key; |
| 1776 | foreach $key (keys %ModuleSynopses) { |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1777 | if ($key eq $chap) { |
| 1778 | return $ModuleSynopses{$chap}; |
| 1779 | } |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1780 | } |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1781 | my $st = SynopsisTable->new(); |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1782 | $ModuleSynopses{$chap} = $st; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1783 | return $st; |
| 1784 | } |
| 1785 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1786 | sub do_cmd_moduleauthor{ |
| 1787 | local($_) = @_; |
| 1788 | next_argument(); |
| 1789 | next_argument(); |
| 1790 | return $_; |
| 1791 | } |
| 1792 | |
| 1793 | sub do_cmd_sectionauthor{ |
| 1794 | local($_) = @_; |
| 1795 | next_argument(); |
| 1796 | next_argument(); |
| 1797 | return $_; |
| 1798 | } |
| 1799 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1800 | sub do_cmd_declaremodule{ |
| 1801 | local($_) = @_; |
| 1802 | my $key = next_optional_argument(); |
| 1803 | my $type = next_argument(); |
| 1804 | my $name = next_argument(); |
| 1805 | my $st = get_synopsis_table(get_chapter_id()); |
| 1806 | # |
| 1807 | $key = $name unless $key; |
| 1808 | $type = 'built-in' if $type eq 'builtin'; |
| 1809 | $st->declare($name, $key, $type); |
| 1810 | define_module($type, $name); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1811 | return anchor_label("module-$key",$CURRENT_FILE,$_) |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1812 | } |
| 1813 | |
| 1814 | sub do_cmd_modulesynopsis{ |
| 1815 | local($_) = @_; |
| 1816 | my $st = get_synopsis_table(get_chapter_id()); |
Fred Drake | 1cc5899 | 1999-04-13 22:08:59 +0000 | [diff] [blame] | 1817 | $st->set_synopsis($THIS_MODULE, translate_commands(next_argument())); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1818 | return $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1819 | } |
| 1820 | |
| 1821 | sub do_cmd_localmoduletable{ |
| 1822 | local($_) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1823 | my $chap = get_chapter_id(); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1824 | my $st = get_synopsis_table($chap); |
| 1825 | $st->set_file("$CURRENT_FILE"); |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1826 | return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1827 | } |
| 1828 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1829 | sub process_all_localmoduletables(){ |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1830 | my $key; |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1831 | foreach $key (keys %ModuleSynopses) { |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 1832 | my $st = $ModuleSynopses{$key}; |
| 1833 | my $file = $st->get_file(); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1834 | if ($file) { |
| 1835 | process_localmoduletables_in_file($file); |
| 1836 | } |
| 1837 | else { |
Fred Drake | 6fe4660 | 2001-06-23 03:13:30 +0000 | [diff] [blame] | 1838 | print "\nsynopsis table $key has no file association\n"; |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1839 | } |
| 1840 | } |
| 1841 | } |
| 1842 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1843 | sub process_localmoduletables_in_file($){ |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 1844 | my $file = $_[0]; |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1845 | open(MYFILE, "<$file"); |
| 1846 | local($_); |
| 1847 | sysread(MYFILE, $_, 1024*1024); |
| 1848 | close(MYFILE); |
| 1849 | # need to get contents of file in $_ |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1850 | while (/<tex2html-localmoduletable><(\d+)>/) { |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1851 | my $match = $&; |
| 1852 | my $chap = $1; |
| 1853 | my $st = get_synopsis_table($chap); |
| 1854 | my $data = $st->tohtml(); |
| 1855 | s/$match/$data/; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1856 | } |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1857 | open(MYFILE,">$file"); |
| 1858 | print MYFILE $_; |
| 1859 | close(MYFILE); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1860 | } |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1861 | sub process_python_state(){ |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1862 | process_all_localmoduletables(); |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 1863 | process_grammar_files(); |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1864 | } |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1865 | |
| 1866 | |
| 1867 | # |
| 1868 | # "See also:" -- references placed at the end of a \section |
| 1869 | # |
| 1870 | |
| 1871 | sub do_env_seealso{ |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1872 | return ("<div class=\"seealso\">\n " |
| 1873 | . "<p class=\"heading\"><b>See Also:</b></p>\n" |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 1874 | . $_[0] |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1875 | . '</div>'); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1876 | } |
| 1877 | |
Fred Drake | 5ed35fd | 2001-11-30 18:09:54 +0000 | [diff] [blame] | 1878 | sub do_env_seealsostar{ |
| 1879 | return ("<div class=\"seealso-simple\">\n " |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 1880 | . $_[0] |
Fred Drake | 5ed35fd | 2001-11-30 18:09:54 +0000 | [diff] [blame] | 1881 | . '</div>'); |
| 1882 | } |
| 1883 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1884 | sub do_cmd_seemodule{ |
| 1885 | # Insert the right magic to jump to the module definition. This should |
| 1886 | # work most of the time, at least for repeat builds.... |
| 1887 | local($_) = @_; |
| 1888 | my $key = next_optional_argument(); |
| 1889 | my $module = next_argument(); |
| 1890 | my $text = next_argument(); |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 1891 | my $period = '.'; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1892 | $key = $module |
| 1893 | unless $key; |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 1894 | if ($text =~ /\.$/) { |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 1895 | $period = ''; |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 1896 | } |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1897 | return ('<dl compact class="seemodule">' |
| 1898 | . "\n <dt>Module <b><tt class=\"module\">" |
| 1899 | . "<a href=\"module-$key.html\">$module</a></tt>:</b>" |
| 1900 | . "\n <dd>$text$period\n </dl>" |
| 1901 | . $_); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1902 | } |
| 1903 | |
Fred Drake | e0197bf | 2001-04-12 04:03:22 +0000 | [diff] [blame] | 1904 | sub strip_html_markup($){ |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 1905 | my $str = $_[0]; |
Fred Drake | e0197bf | 2001-04-12 04:03:22 +0000 | [diff] [blame] | 1906 | my $s = "$str"; |
| 1907 | $s =~ s/<[a-zA-Z0-9]+(\s+[a-zA-Z0-9]+(\s*=\s*(\'[^\']*\'|\"[^\"]*\"|[a-zA-Z0-9]+))?)*\s*>//g; |
| 1908 | $s =~ s/<\/[a-zA-Z0-9]+>//g; |
| 1909 | return $s; |
| 1910 | } |
| 1911 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 1912 | sub handle_rfclike_reference($$$){ |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 1913 | local($_, $what, $format) = @_; |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 1914 | my $rfcnum = next_argument(); |
| 1915 | my $title = next_argument(); |
| 1916 | my $text = next_argument(); |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 1917 | my $url = get_rfc_url($rfcnum, $format); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1918 | my $icon = get_link_icon($url); |
Fred Drake | e0197bf | 2001-04-12 04:03:22 +0000 | [diff] [blame] | 1919 | my $attrtitle = strip_html_markup($title); |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 1920 | return '<dl compact class="seerfc">' |
| 1921 | . "\n <dt><a href=\"$url\"" |
Fred Drake | e0197bf | 2001-04-12 04:03:22 +0000 | [diff] [blame] | 1922 | . "\n title=\"$attrtitle\"" |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 1923 | . "\n >$what $rfcnum, <em>$title</em>$icon</a>" |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 1924 | . "\n <dd>$text\n </dl>" |
| 1925 | . $_; |
| 1926 | } |
| 1927 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1928 | sub do_cmd_seepep{ |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 1929 | return handle_rfclike_reference($_[0], "PEP", $PEP_FORMAT); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1930 | } |
| 1931 | |
| 1932 | sub do_cmd_seerfc{ |
Fred Drake | dbb2b9d | 2002-10-30 21:38:32 +0000 | [diff] [blame] | 1933 | # 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] | 1934 | return handle_rfclike_reference($_[0], "RFC", $RFC_FORMAT); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1935 | } |
| 1936 | |
Fred Drake | 4844998 | 2000-09-12 17:52:33 +0000 | [diff] [blame] | 1937 | sub do_cmd_seetitle{ |
| 1938 | local($_) = @_; |
| 1939 | my $url = next_optional_argument(); |
| 1940 | my $title = next_argument(); |
| 1941 | my $text = next_argument(); |
| 1942 | if ($url) { |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 1943 | my $icon = get_link_icon($url); |
Fred Drake | 4844998 | 2000-09-12 17:52:33 +0000 | [diff] [blame] | 1944 | return '<dl compact class="seetitle">' |
| 1945 | . "\n <dt><em class=\"citetitle\"><a href=\"$url\"" |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1946 | . "\n >$title$icon</a></em></dt>" |
| 1947 | . "\n <dd>$text</dd>\n </dl>" |
Fred Drake | 4844998 | 2000-09-12 17:52:33 +0000 | [diff] [blame] | 1948 | . $_; |
| 1949 | } |
| 1950 | return '<dl compact class="seetitle">' |
| 1951 | . "\n <dt><em class=\"citetitle\"" |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1952 | . "\n >$title</em></dt>" |
| 1953 | . "\n <dd>$text</dd>\n </dl>" |
Fred Drake | 4844998 | 2000-09-12 17:52:33 +0000 | [diff] [blame] | 1954 | . $_; |
| 1955 | } |
| 1956 | |
Fred Drake | 4f687b3 | 2004-01-08 14:57:27 +0000 | [diff] [blame] | 1957 | sub do_cmd_seelink{ |
| 1958 | local($_) = @_; |
| 1959 | my $url = next_argument(); |
| 1960 | my $linktext = next_argument(); |
| 1961 | my $text = next_argument(); |
| 1962 | my $icon = get_link_icon($url); |
| 1963 | return '<dl compact class="seeurl">' |
| 1964 | . "\n <dt><a href='$url'" |
| 1965 | . "\n >$linktext$icon</a></dt>" |
| 1966 | . "\n <dd>$text</dd>\n </dl>" |
| 1967 | . $_; |
| 1968 | } |
| 1969 | |
Fred Drake | ef4d111 | 2000-05-09 16:17:51 +0000 | [diff] [blame] | 1970 | sub do_cmd_seeurl{ |
| 1971 | local($_) = @_; |
| 1972 | my $url = next_argument(); |
| 1973 | my $text = next_argument(); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1974 | my $icon = get_link_icon($url); |
Fred Drake | ef4d111 | 2000-05-09 16:17:51 +0000 | [diff] [blame] | 1975 | return '<dl compact class="seeurl">' |
| 1976 | . "\n <dt><a href=\"$url\"" |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1977 | . "\n class=\"url\">$url$icon</a></dt>" |
| 1978 | . "\n <dd>$text</dd>\n </dl>" |
Fred Drake | ef4d111 | 2000-05-09 16:17:51 +0000 | [diff] [blame] | 1979 | . $_; |
| 1980 | } |
| 1981 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1982 | sub do_cmd_seetext{ |
Fred Drake | 79189b5 | 1999-04-28 13:54:30 +0000 | [diff] [blame] | 1983 | local($_) = @_; |
| 1984 | my $content = next_argument(); |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1985 | return '<div class="seetext"><p>' . $content . '</p></div>' . $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1986 | } |
| 1987 | |
| 1988 | |
| 1989 | # |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1990 | # Definition list support. |
| 1991 | # |
| 1992 | |
| 1993 | sub do_env_definitions{ |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 1994 | return '<dl class="definitions">' . $_[0] . "</dl>\n"; |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1995 | } |
| 1996 | |
| 1997 | sub do_cmd_term{ |
| 1998 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1999 | my $term = next_argument(); |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 2000 | my($name, $aname, $ahref) = new_link_info(); |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 2001 | # could easily add an index entry here... |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame] | 2002 | return "<dt><b>$aname" . $term . "</a></b></dt>\n<dd>" . $_; |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 2003 | } |
| 2004 | |
| 2005 | |
Fred Drake | 4e72e05 | 2003-07-15 22:00:36 +0000 | [diff] [blame] | 2006 | # Commands listed here have process-order dependencies; these often |
| 2007 | # are related to indexing operations. |
| 2008 | # XXX Not sure why funclineni, methodlineni, and samp are here. |
| 2009 | # |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 2010 | process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_); |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 2011 | declaremodule # [] # {} # {} |
Fred Drake | 4400509 | 2002-11-13 17:55:17 +0000 | [diff] [blame] | 2012 | funcline # {} # {} |
| 2013 | funclineni # {} # {} |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 2014 | memberline # [] # {} |
| 2015 | methodline # [] # {} # {} |
Fred Drake | 4400509 | 2002-11-13 17:55:17 +0000 | [diff] [blame] | 2016 | methodlineni # [] # {} # {} |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 2017 | modulesynopsis # {} |
Fred Drake | 4e72e05 | 2003-07-15 22:00:36 +0000 | [diff] [blame] | 2018 | bifuncindex # {} |
| 2019 | exindex # {} |
| 2020 | indexii # {} # {} |
| 2021 | indexiii # {} # {} # {} |
| 2022 | indexiv # {} # {} # {} # {} |
| 2023 | kwindex # {} |
| 2024 | obindex # {} |
| 2025 | opindex # {} |
| 2026 | stindex # {} |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 2027 | platform # {} |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 2028 | samp # {} |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 2029 | setindexsubitem # {} |
Fred Drake | f32834c | 1999-02-12 22:06:32 +0000 | [diff] [blame] | 2030 | withsubitem # {} # {} |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 2031 | _RAW_ARG_DEFERRED_CMDS_ |
| 2032 | |
| 2033 | |
Fred Drake | 8a5e679 | 2002-04-15 18:41:31 +0000 | [diff] [blame] | 2034 | $alltt_start = '<div class="verbatim"><pre>'; |
| 2035 | $alltt_end = '</pre></div>'; |
Fred Drake | 8633360 | 2001-04-10 17:13:39 +0000 | [diff] [blame] | 2036 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 2037 | sub do_env_alltt{ |
Fred Drake | 8633360 | 2001-04-10 17:13:39 +0000 | [diff] [blame] | 2038 | local ($_) = @_; |
| 2039 | local($closures,$reopens,@open_block_tags); |
| 2040 | |
| 2041 | # get the tag-strings for all open tags |
| 2042 | local(@keep_open_tags) = @$open_tags_R; |
| 2043 | ($closures,$reopens) = &preserve_open_tags() if (@$open_tags_R); |
| 2044 | |
| 2045 | # get the tags for text-level tags only |
| 2046 | $open_tags_R = [ @keep_open_tags ]; |
| 2047 | local($local_closures, $local_reopens); |
| 2048 | ($local_closures, $local_reopens,@open_block_tags) |
| 2049 | = &preserve_open_block_tags |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 2050 | if (@$open_tags_R); |
Fred Drake | 8633360 | 2001-04-10 17:13:39 +0000 | [diff] [blame] | 2051 | |
| 2052 | $open_tags_R = [ @open_block_tags ]; |
| 2053 | |
| 2054 | do { |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 2055 | local($open_tags_R) = [ @open_block_tags ]; |
| 2056 | local(@save_open_tags) = (); |
Fred Drake | 8633360 | 2001-04-10 17:13:39 +0000 | [diff] [blame] | 2057 | |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 2058 | local($cnt) = ++$global{'max_id'}; |
| 2059 | $_ = join('',"$O$cnt$C\\tt$O", ++$global{'max_id'}, $C |
| 2060 | , $_ , $O, $global{'max_id'}, "$C$O$cnt$C"); |
Fred Drake | 8633360 | 2001-04-10 17:13:39 +0000 | [diff] [blame] | 2061 | |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 2062 | $_ = &translate_environments($_); |
| 2063 | $_ = &translate_commands($_) if (/\\/); |
Fred Drake | 8633360 | 2001-04-10 17:13:39 +0000 | [diff] [blame] | 2064 | |
Fred Drake | 41aa018 | 2003-09-05 15:43:00 +0000 | [diff] [blame] | 2065 | # remove spurious <BR> someone sticks in; not sure where they |
| 2066 | # actually come from |
| 2067 | # XXX the replacement space is there to accomodate something |
| 2068 | # broken that inserts a space in front of the first line of |
| 2069 | # the environment |
| 2070 | s/<BR>/ /gi; |
Fred Drake | 8633360 | 2001-04-10 17:13:39 +0000 | [diff] [blame] | 2071 | |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 2072 | $_ = join('', $closures, $alltt_start, $local_reopens |
| 2073 | , $_ |
| 2074 | , &balance_tags() #, $local_closures |
| 2075 | , $alltt_end, $reopens); |
| 2076 | undef $open_tags_R; undef @save_open_tags; |
Fred Drake | 8633360 | 2001-04-10 17:13:39 +0000 | [diff] [blame] | 2077 | }; |
| 2078 | $open_tags_R = [ @keep_open_tags ]; |
Fred Drake | 345555d | 2003-12-30 16:19:28 +0000 | [diff] [blame] | 2079 | return codetext($_); |
Fred Drake | 8633360 | 2001-04-10 17:13:39 +0000 | [diff] [blame] | 2080 | } |
| 2081 | |
Fred Drake | 8effa01 | 2004-04-01 04:30:29 +0000 | [diff] [blame] | 2082 | # List of all filenames produced by do_cmd_verbatiminput() |
Fred Drake | 6fc22f6 | 2002-06-17 15:01:05 +0000 | [diff] [blame] | 2083 | %VerbatimFiles = (); |
| 2084 | @VerbatimOutputs = (); |
| 2085 | |
| 2086 | sub get_verbatim_output_name($){ |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 2087 | my $file = $_[0]; |
Fred Drake | 6fc22f6 | 2002-06-17 15:01:05 +0000 | [diff] [blame] | 2088 | # |
| 2089 | # Re-write the source filename to always use a .txt extension |
| 2090 | # so that Web servers will present it as text/plain. This is |
| 2091 | # needed since there is no other even moderately reliable way |
| 2092 | # to get the right Content-Type header on text files for |
| 2093 | # servers which we can't configure (like python.org mirrors). |
| 2094 | # |
| 2095 | if (defined $VerbatimFiles{$file}) { |
| 2096 | # We've seen this one before; re-use the same output file. |
| 2097 | return $VerbatimFiles{$file}; |
| 2098 | } |
Fred Drake | 49b33fa | 2002-11-15 19:04:10 +0000 | [diff] [blame] | 2099 | my($srcname, $srcdir, $srcext) = fileparse($file, '\..*'); |
Fred Drake | 6fc22f6 | 2002-06-17 15:01:05 +0000 | [diff] [blame] | 2100 | $filename = "$srcname.txt"; |
| 2101 | # |
| 2102 | # We need to determine if our default filename is already |
| 2103 | # being used, and find a new one it it is. If the name is in |
| 2104 | # used, this algorithm will first attempt to include the |
| 2105 | # source extension as part of the name, and if that is also in |
| 2106 | # use (if the same file is included multiple times, or if |
| 2107 | # another source file has that as the base name), a counter is |
| 2108 | # used instead. |
| 2109 | # |
| 2110 | my $found = 1; |
| 2111 | FIND: |
| 2112 | while ($found) { |
| 2113 | foreach $fn (@VerbatimOutputs) { |
| 2114 | if ($fn eq $filename) { |
| 2115 | if ($found == 1) { |
| 2116 | $srcext =~ s/^[.]//; # Remove '.' from extension |
| 2117 | $filename = "$srcname-$srcext.txt"; |
| 2118 | } |
| 2119 | else { |
| 2120 | $filename = "$srcname-$found.txt"; |
| 2121 | } |
| 2122 | ++$found; |
| 2123 | next FIND; |
| 2124 | } |
| 2125 | } |
| 2126 | $found = 0; |
| 2127 | } |
| 2128 | push @VerbatimOutputs, $filename; |
| 2129 | $VerbatimFiles{$file} = $filename; |
| 2130 | return $filename; |
| 2131 | } |
| 2132 | |
Fred Drake | 57e52ef | 2001-06-15 21:31:57 +0000 | [diff] [blame] | 2133 | sub do_cmd_verbatiminput{ |
| 2134 | local($_) = @_; |
| 2135 | my $fname = next_argument(); |
| 2136 | my $file; |
| 2137 | my $found = 0; |
| 2138 | my $texpath; |
| 2139 | # Search TEXINPUTS for the input file, the way we're supposed to: |
| 2140 | foreach $texpath (split /$envkey/, $TEXINPUTS) { |
| 2141 | $file = "$texpath$dd$fname"; |
| 2142 | last if ($found = (-f $file)); |
| 2143 | } |
Fred Drake | 6fc22f6 | 2002-06-17 15:01:05 +0000 | [diff] [blame] | 2144 | my $filename = ''; |
Fred Drake | 57e52ef | 2001-06-15 21:31:57 +0000 | [diff] [blame] | 2145 | my $text; |
| 2146 | if ($found) { |
| 2147 | open(MYFILE, "<$file") || die "\n$!\n"; |
| 2148 | read(MYFILE, $text, 1024*1024); |
| 2149 | close(MYFILE); |
Fred Drake | 6fc22f6 | 2002-06-17 15:01:05 +0000 | [diff] [blame] | 2150 | $filename = get_verbatim_output_name($file); |
| 2151 | # Now that we have a filename, write it out. |
| 2152 | open(MYFILE, ">$filename"); |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 2153 | print MYFILE $text; |
| 2154 | close(MYFILE); |
Fred Drake | 57e52ef | 2001-06-15 21:31:57 +0000 | [diff] [blame] | 2155 | # |
| 2156 | # These rewrites convert the raw text to something that will |
| 2157 | # be properly visible as HTML and also will pass through the |
| 2158 | # vagaries of conversion through LaTeX2HTML. The order in |
| 2159 | # which the specific rewrites are performed is significant. |
| 2160 | # |
| 2161 | $text =~ s/\&/\&/g; |
| 2162 | # These need to happen before the normal < and > re-writes, |
| 2163 | # since we need to avoid LaTeX2HTML's attempt to perform |
| 2164 | # ligature processing without regard to context (since it |
| 2165 | # doesn't have font information). |
| 2166 | $text =~ s/--/-&\#45;/g; |
| 2167 | $text =~ s/<</\<\&\#60;/g; |
| 2168 | $text =~ s/>>/\>\&\#62;/g; |
| 2169 | # Just normal re-writes... |
| 2170 | $text =~ s/</\</g; |
| 2171 | $text =~ s/>/\>/g; |
| 2172 | # These last isn't needed for the HTML, but is needed to get |
| 2173 | # past LaTeX2HTML processing TeX macros. We use \ instead |
| 2174 | # of / since many browsers don't support that. |
| 2175 | $text =~ s/\\/\&\#92;/g; |
| 2176 | } |
| 2177 | else { |
Fred Drake | 6fc22f6 | 2002-06-17 15:01:05 +0000 | [diff] [blame] | 2178 | return '<b>Could not locate requested file <i>$fname</i>!</b>\n'; |
| 2179 | } |
| 2180 | my $note = 'Download as text.'; |
| 2181 | if ($file ne $filename) { |
| 2182 | $note = ('Download as text (original file name: <span class="file">' |
| 2183 | . $fname |
| 2184 | . '</span>).'); |
Fred Drake | 57e52ef | 2001-06-15 21:31:57 +0000 | [diff] [blame] | 2185 | } |
Fred Drake | 8a5e679 | 2002-04-15 18:41:31 +0000 | [diff] [blame] | 2186 | return ("<div class=\"verbatim\">\n<pre>" |
Fred Drake | 57e52ef | 2001-06-15 21:31:57 +0000 | [diff] [blame] | 2187 | . $text |
Fred Drake | 8a5e679 | 2002-04-15 18:41:31 +0000 | [diff] [blame] | 2188 | . "</pre>\n<div class=\"footer\">\n" |
Fred Drake | 6fc22f6 | 2002-06-17 15:01:05 +0000 | [diff] [blame] | 2189 | . "<a href=\"$filename\" type=\"text/plain\"" |
| 2190 | . ">$note</a>" |
Fred Drake | 8a5e679 | 2002-04-15 18:41:31 +0000 | [diff] [blame] | 2191 | . "\n</div></div>" |
Fred Drake | 57e52ef | 2001-06-15 21:31:57 +0000 | [diff] [blame] | 2192 | . $_); |
| 2193 | } |
Fred Drake | 8633360 | 2001-04-10 17:13:39 +0000 | [diff] [blame] | 2194 | |
Fred Drake | 1b1ca0c | 2003-09-05 15:43:58 +0000 | [diff] [blame] | 2195 | 1; # This must be the last line |