Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1 | # python.perl by Fred L. Drake, Jr. <fdrake@acm.org> -*- perl -*- |
| 2 | # |
| 3 | # Heavily based on Guido van Rossum's myformat.perl (now obsolete). |
| 4 | # |
| 5 | # Extension to LaTeX2HTML for documents using myformat.sty. |
| 6 | # Subroutines of the form do_cmd_<name> here define translations |
| 7 | # for LaTeX commands \<name> defined in the corresponding .sty file. |
| 8 | |
| 9 | package main; |
| 10 | |
| 11 | |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 12 | sub next_argument{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 13 | my $param; |
| 14 | $param = missing_braces() |
| 15 | unless ((s/$next_pair_pr_rx/$param=$2;''/eo) |
| 16 | ||(s/$next_pair_rx/$param=$2;''/eo)); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 17 | return $param; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | sub next_optional_argument{ |
| 21 | my($param,$rx) = ('', "^\\s*(\\[([^]]*)\\])?"); |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 22 | s/$rx/$param=$2;''/eo; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 23 | return $param; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | sub swallow_newline{ |
| 27 | s/[\n]?//o; |
| 28 | } |
| 29 | |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 30 | |
| 31 | # This is a fairly simple hack; it supports \let when it is used to create |
| 32 | # (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] | 33 | # 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] | 34 | # |
| 35 | sub do_cmd_let{ |
| 36 | local($_) = @_; |
| 37 | my $matched = 0; |
Fred Drake | 7a4ad0f | 1998-05-15 13:45:54 +0000 | [diff] [blame] | 38 | s/[\\]([a-zA-Z]+)\s*(=\s*)?[\\]([a-zA-Z]*)/$matched=1; ''/e; |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 39 | if ($matched) { |
| 40 | my($new, $old) = ($1, $3); |
| 41 | eval "sub do_cmd_$new { do_cmd_$old" . '(@_); }'; |
| 42 | print "\ndefining handler for \\$new using \\$old\n"; |
| 43 | } |
Fred Drake | 7a4ad0f | 1998-05-15 13:45:54 +0000 | [diff] [blame] | 44 | else { |
| 45 | s/[\\]([a-zA-Z]+)\s*(=\s*)?([^\\])/$matched=1; ''/es; |
| 46 | if ($matched) { |
| 47 | my($new, $char) = ($1, $3); |
| 48 | eval "sub do_cmd_$new { \"\\$char\" . \@_[0]; }"; |
| 49 | print "\ndefining handler for \\$new to insert '$char'\n"; |
| 50 | } |
| 51 | else { |
| 52 | write_warnings("Could not interpret \\let construct..."); |
| 53 | } |
| 54 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 55 | return $_; |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 59 | # words typeset in a special way (not in HTML though) |
| 60 | |
| 61 | sub do_cmd_ABC{ 'ABC' . @_[0]; } |
| 62 | sub do_cmd_UNIX{ 'Unix'. @_[0]; } |
| 63 | sub do_cmd_ASCII{ 'ASCII' . @_[0]; } |
| 64 | sub do_cmd_POSIX{ 'POSIX' . @_[0]; } |
| 65 | sub do_cmd_C{ 'C' . @_[0]; } |
| 66 | sub do_cmd_Cpp{ 'C++' . @_[0]; } |
| 67 | sub do_cmd_EOF{ 'EOF' . @_[0]; } |
| 68 | sub do_cmd_NULL{ '<tt>NULL</tt>' . @_[0]; } |
| 69 | |
| 70 | sub do_cmd_e{ '\' . @_[0]; } |
| 71 | |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 72 | $DEVELOPER_ADDRESS = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 73 | $PYTHON_VERSION = ''; |
| 74 | |
| 75 | sub do_cmd_version{ $PYTHON_VERSION . @_[0]; } |
| 76 | sub do_cmd_release{ |
| 77 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 78 | $PYTHON_VERSION = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 79 | return $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | sub do_cmd_authoraddress{ |
| 83 | local($_) = @_; |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 84 | $DEVELOPER_ADDRESS = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 85 | return $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 86 | } |
| 87 | |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 88 | #sub do_cmd_developer{ do_cmd_author(@_[0]); } |
| 89 | #sub do_cmd_developers{ do_cmd_author(@_[0]); } |
| 90 | #sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); } |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 91 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 92 | sub do_cmd_hackscore{ |
| 93 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 94 | next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 95 | return '_' . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 96 | } |
| 97 | |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 98 | sub use_wrappers{ |
| 99 | local($_,$before,$after) = @_; |
| 100 | my $stuff = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 101 | return $before . $stuff . $after . $_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 102 | } |
| 103 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 104 | sub use_sans_serif{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 105 | return use_wrappers(@_[0], '<font face="sans-serif">', '</font>'); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 106 | } |
| 107 | sub use_italics{ |
| 108 | return use_wrappers(@_[0], '<i>', '</i>'); |
| 109 | } |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 110 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 111 | sub do_cmd_optional{ |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 112 | return use_wrappers(@_[0], "</var><big>\[</big><var>", |
| 113 | "</var><big>\]</big><var>"); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 114 | } |
| 115 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 116 | # Logical formatting (some based on texinfo), needs to be converted to |
| 117 | # minimalist HTML. The "minimalist" is primarily to reduce the size of |
| 118 | # output files for users that read them over the network rather than |
| 119 | # from local repositories. |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 120 | |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 121 | sub do_cmd_pytype{ return @_[0]; } |
| 122 | sub do_cmd_makevar{ return @_[0]; } |
Fred Drake | 1a4c539 | 1999-02-09 15:31:52 +0000 | [diff] [blame] | 123 | sub do_cmd_code{ return use_wrappers(@_[0], '<tt>', '</tt>'); } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 124 | sub do_cmd_module{ return do_cmd_code(@_); } |
| 125 | sub do_cmd_keyword{ return do_cmd_code(@_); } |
| 126 | sub do_cmd_exception{ return do_cmd_code(@_); } |
| 127 | sub do_cmd_class{ return do_cmd_code(@_); } |
| 128 | sub do_cmd_function{ return do_cmd_code(@_); } |
| 129 | sub do_cmd_constant{ return do_cmd_code(@_); } |
| 130 | sub do_cmd_member{ return do_cmd_code(@_); } |
| 131 | sub do_cmd_method{ return do_cmd_code(@_); } |
| 132 | sub do_cmd_cfunction{ return do_cmd_code(@_); } |
| 133 | sub do_cmd_cdata{ return do_cmd_code(@_); } |
| 134 | sub do_cmd_ctype{ return do_cmd_code(@_); } |
| 135 | sub do_cmd_regexp{ return do_cmd_code(@_); } |
| 136 | sub do_cmd_character{ return do_cmd_samp(@_); } |
| 137 | sub do_cmd_program{ return do_cmd_strong(@_); } |
| 138 | sub do_cmd_email{ return use_sans_serif(@_); } |
| 139 | sub do_cmd_mimetype{ return use_sans_serif(@_); } |
Fred Drake | 1a4c539 | 1999-02-09 15:31:52 +0000 | [diff] [blame] | 140 | sub do_cmd_var{ return use_wrappers(@_[0], "<i>", "</i>"); } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 141 | sub do_cmd_dfn{ return use_italics(@_); } # make an index entry? |
| 142 | sub do_cmd_emph{ return use_italics(@_); } |
| 143 | sub do_cmd_file{ return use_wrappers(@_[0], '"<tt>', '</tt>"'); } |
Fred Drake | 1a4c539 | 1999-02-09 15:31:52 +0000 | [diff] [blame] | 144 | sub do_cmd_samp{ return use_wrappers(@_[0], '"<tt>', '</tt>"'); } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 145 | sub do_cmd_kbd{ return use_wrappers(@_[0], '<kbd>', '</kbd>'); } |
| 146 | sub do_cmd_strong{ return use_wrappers(@_[0], '<b>', '</b>'); } |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 147 | |
Fred Drake | 2581704 | 1999-01-13 17:06:34 +0000 | [diff] [blame] | 148 | sub do_cmd_refmodule{ |
| 149 | # Insert the right magic to jump to the module definition. |
| 150 | local($_) = @_; |
| 151 | my $key = next_optional_argument(); |
| 152 | my $module = next_argument(); |
| 153 | $key = $module |
| 154 | unless $key; |
| 155 | return "<tt><a href=\"module-$key.html\">$module</a></tt>" . $_; |
| 156 | } |
| 157 | |
Fred Drake | 1a7af39 | 1998-04-01 22:44:56 +0000 | [diff] [blame] | 158 | sub do_cmd_newsgroup{ |
| 159 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 160 | my $newsgroup = next_argument(); |
Fred Drake | 1a7af39 | 1998-04-01 22:44:56 +0000 | [diff] [blame] | 161 | my $stuff = "<a href=\"news:$newsgroup\"><font face=sans-serif>" |
| 162 | . "$newsgroup</font></a>"; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 163 | return $stuff . $_; |
Fred Drake | 1a7af39 | 1998-04-01 22:44:56 +0000 | [diff] [blame] | 164 | } |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 165 | |
| 166 | sub do_cmd_envvar{ |
| 167 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 168 | my $envvar = next_argument(); |
| 169 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 170 | # The <tt> here is really to keep buildindex.py from making |
| 171 | # the variable name case-insensitive. |
| 172 | add_index_entry("environment variables!$envvar@<tt>\$$envvar</tt>", |
| 173 | $ahref); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 174 | add_index_entry("$envvar@\$$envvar", $ahref); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 175 | return "$aname\$$envvar</a>" . $_; |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 176 | } |
| 177 | |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 178 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 179 | sub do_cmd_url{ |
| 180 | # use the URL as both text and hyperlink |
| 181 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 182 | my $url = next_argument(); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 183 | $url =~ s/~/~/g; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 184 | return "<a href=\"$url\"><font face=sans-serif>$url</font></a>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | sub do_cmd_manpage{ |
| 188 | # two parameters: \manpage{name}{section} |
| 189 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 190 | my $page = next_argument(); |
| 191 | my $section = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 192 | return "<i>$page</i>($section)" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | sub do_cmd_rfc{ |
| 196 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 197 | my $rfcnumber = next_argument(); |
| 198 | my $id = "rfcref-" . ++$global{'max_id'}; |
Fred Drake | 2eff3c5 | 1998-12-22 18:02:25 +0000 | [diff] [blame] | 199 | my $href = |
| 200 | "http://info.internet.isi.edu/in-notes/rfc/files/rfc$rfcnumber.txt"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 201 | # Save the reference |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 202 | my $nstr = gen_index_id("RFC!RFC $rfcnumber", ''); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 203 | $index{$nstr} .= make_half_href("$CURRENT_FILE#$id"); |
| 204 | return "<a name=\"$id\"\nhref=\"$href\">RFC $rfcnumber</a>" .$_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 205 | } |
| 206 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 207 | sub do_cmd_deprecated{ |
| 208 | # two parameters: \deprecated{version}{whattodo} |
| 209 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 210 | my $release = next_argument(); |
| 211 | my $reason = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 212 | return "<b>Deprecated since release $release.</b>\n$reason<p>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 213 | } |
| 214 | |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 215 | sub do_cmd_versionadded{ |
| 216 | # one parameter: \versionadded{version} |
| 217 | local($_) = @_; |
| 218 | my $release = next_argument(); |
Fred Drake | 2116d98 | 1999-02-02 18:02:48 +0000 | [diff] [blame] | 219 | return "\nNew in version $release.\n" . $_; |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | sub do_cmd_versionchanged{ |
| 223 | # one parameter: \versionchanged{version} |
| 224 | local($_) = @_; |
| 225 | my $release = next_argument(); |
Fred Drake | 2116d98 | 1999-02-02 18:02:48 +0000 | [diff] [blame] | 226 | return "\nChanged in version $release.\n" . $_; |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 227 | } |
| 228 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 229 | # file and samp are at the end of this file since they screw up fontlock. |
| 230 | |
| 231 | # index commands |
| 232 | |
| 233 | $INDEX_SUBITEM = ""; |
| 234 | |
| 235 | sub get_indexsubitem{ |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 236 | return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | sub do_cmd_setindexsubitem{ |
| 240 | local($_) = @_; |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 241 | my $subitem = next_argument(); |
| 242 | $INDEX_SUBITEM = $subitem; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 243 | return $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 244 | } |
| 245 | |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 246 | sub do_cmd_withsubitem{ |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 247 | # We can't really do the right thing, because LaTeX2HTML doesn't |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 248 | # do things in the right order, but we need to at least strip this stuff |
| 249 | # out, and leave anything that the second argument expanded out to. |
| 250 | # |
| 251 | local($_) = @_; |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 252 | my $oldsubitem = $INDEX_SUBITEM; |
| 253 | $INDEX_SUBITEM = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 254 | my $stuff = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 255 | my $br_id = ++$globals{'max_id'}; |
| 256 | my $marker = "$O$br_id$C"; |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 257 | return |
| 258 | $stuff |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 259 | . "\\setindexsubitem$marker$oldsubitem$marker" |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 260 | . $_; |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 261 | } |
| 262 | |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 263 | # This is the prologue macro which is required to start writing the |
| 264 | # mod\jobname.idx file; we can just ignore it. |
| 265 | # |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 266 | sub do_cmd_makemodindex{ return @_[0]; } |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 267 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 268 | # We're in the document subdirectory when this happens! |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 269 | # |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 270 | open(IDXFILE, '>index.dat') || die "\n$!\n"; |
| 271 | open(INTLABELS, '>intlabels.pl') || die "\n$!\n"; |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 272 | print INTLABELS "%internal_labels = ();\n"; |
| 273 | print INTLABELS "1; # hack in case there are no entries\n\n"; |
| 274 | |
| 275 | # Using \0 for this is bad because we can't use common tools to work with the |
| 276 | # resulting files. Things like grep can be useful with this stuff! |
| 277 | # |
| 278 | $IDXFILE_FIELD_SEP = "\1"; |
| 279 | |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 280 | sub write_idxfile{ |
| 281 | my ($ahref, $str) = @_; |
| 282 | print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 283 | } |
| 284 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 285 | |
| 286 | sub gen_link{ |
| 287 | my($node,$target) = @_; |
| 288 | print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n"; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 289 | return "<a href=\"$node#$target\">"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | sub make_index_entry{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 293 | my($str) = @_; |
| 294 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 295 | add_index_entry($str, $ahref); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 296 | return "$aname$anchor_invisible_mark</a>"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | sub add_index_entry{ |
| 300 | # add an entry to the index structures; ignore the return value |
| 301 | my($str,$ahref) = @_; |
| 302 | $str = gen_index_id($str, ''); |
| 303 | $index{$str} .= $ahref; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 304 | write_idxfile($ahref, $str); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 305 | } |
| 306 | |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 307 | sub new_link_info{ |
| 308 | my $name = "l2h-" . ++$globals{'max_id'}; |
| 309 | my $aname = '<a name="' . $name . '">'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 310 | my $ahref = gen_link($CURRENT_FILE, $name); |
| 311 | return ($name, $aname, $ahref); |
| 312 | } |
| 313 | |
| 314 | sub do_cmd_index{ |
| 315 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 316 | my $str = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 317 | swallow_newline(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 318 | # |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 319 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 320 | add_index_entry("$str", $ahref); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 321 | return "$aname$anchor_invisible_mark</a>" . $_; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 322 | } |
| 323 | |
Fred Drake | 2e7edb8 | 1998-05-11 18:31:17 +0000 | [diff] [blame] | 324 | sub do_cmd_kwindex{ |
| 325 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 326 | my $str = next_argument(); |
Fred Drake | 2e7edb8 | 1998-05-11 18:31:17 +0000 | [diff] [blame] | 327 | # |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 328 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 2e7edb8 | 1998-05-11 18:31:17 +0000 | [diff] [blame] | 329 | add_index_entry("<tt>$str</tt>!keyword", $ahref); |
| 330 | add_index_entry("keyword!<tt>$str</tt>", $ahref); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 331 | return "$aname$anchor_invisible_mark</a>" . $_; |
Fred Drake | 2e7edb8 | 1998-05-11 18:31:17 +0000 | [diff] [blame] | 332 | } |
| 333 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 334 | sub do_cmd_indexii{ |
| 335 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 336 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 337 | my $str2 = next_argument(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 338 | # |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 339 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 340 | add_index_entry("$str1!$str2", $ahref); |
| 341 | add_index_entry("$str2!$str1", $ahref); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 342 | return "$aname$anchor_invisible_mark</a>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | sub do_cmd_indexiii{ |
| 346 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 347 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 348 | my $str2 = next_argument(); |
| 349 | my $str3 = next_argument(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 350 | # |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 351 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 352 | add_index_entry("$str1!$str2 $str3", $ahref); |
| 353 | add_index_entry("$str2!$str3, $str1", $ahref); |
| 354 | add_index_entry("$str3!$str1 $str2", $ahref); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 355 | return "$aname$anchor_invisible_mark</a>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 356 | } |
| 357 | |
| 358 | sub do_cmd_indexiv{ |
| 359 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 360 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 361 | my $str2 = next_argument(); |
| 362 | my $str3 = next_argument(); |
| 363 | my $str4 = next_argument(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 364 | # |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 365 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 366 | add_index_entry("$str1!$str2 $str3 $str4", $ahref); |
| 367 | add_index_entry("$str2!$str3 $str4, $str1", $ahref); |
| 368 | add_index_entry("$str3!$str4, $str1 $str2", $ahref); |
| 369 | add_index_entry("$str4!$$str1 $str2 $str3", $ahref); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 370 | return "$aname$anchor_invisible_mark</a>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 371 | } |
| 372 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 373 | sub do_cmd_ttindex{ |
| 374 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 375 | my $str = next_argument(); |
| 376 | my $entry = $str . get_indexsubitem(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 377 | swallow_newline(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 378 | return make_index_entry($entry) . $_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 379 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 380 | |
| 381 | sub my_typed_index_helper{ |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 382 | local($word,$_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 383 | my $str = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 384 | swallow_newline(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 385 | # |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 386 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 387 | add_index_entry("$str $word", $ahref); |
| 388 | add_index_entry("$word!$str", $ahref); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 389 | return "$aname$anchor_invisible_mark</a>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 390 | } |
| 391 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 392 | sub do_cmd_stindex{ return my_typed_index_helper('statement', @_); } |
| 393 | sub do_cmd_opindex{ return my_typed_index_helper('operator', @_); } |
| 394 | sub do_cmd_exindex{ return my_typed_index_helper('exception', @_); } |
| 395 | sub do_cmd_obindex{ return my_typed_index_helper('object', @_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 396 | |
| 397 | sub my_parword_index_helper{ |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 398 | local($word,$_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 399 | my $str = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 400 | swallow_newline(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 401 | return make_index_entry("$str ($word)") . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 405 | sub make_mod_index_entry{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 406 | my($str,$define) = @_; |
| 407 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 408 | # equivalent of add_index_entry() using $define instead of '' |
| 409 | $str = gen_index_id($str, $define); |
| 410 | $index{$str} .= $ahref; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 411 | write_idxfile($ahref, $str); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 412 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 413 | if ($define eq 'DEF') { |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 414 | # add to the module index |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 415 | my($nstr,$garbage) = split / /, $str, 2; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 416 | $Modules{$nstr} .= $ahref; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 417 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 418 | return "$aname$anchor_invisible_mark</a>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 419 | } |
| 420 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 421 | $THIS_MODULE = ''; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 422 | $THIS_CLASS = ''; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 423 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 424 | sub define_module{ |
| 425 | my($word,$name) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 426 | my $section_tag = join('', @curr_sec_id); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 427 | $word = "$word " if $word; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 428 | $THIS_MODULE = "$name"; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 429 | return make_mod_index_entry("<tt>$name</tt> (${word}module)", 'DEF'); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | sub my_module_index_helper{ |
| 433 | local($word, $_) = @_; |
| 434 | my $name = next_argument(); |
| 435 | swallow_newline(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 436 | return define_module($word, $name) . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | sub ref_module_index_helper{ |
| 440 | local($word, $_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 441 | my $str = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 442 | swallow_newline(); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 443 | $word = "$word " if $word; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 444 | return make_mod_index_entry("<tt>$str</tt> (${word}module)", 'REF') . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 445 | } |
| 446 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 447 | sub do_cmd_bifuncindex{ |
| 448 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 449 | my $str = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 450 | my $fname = "<tt>$str()</tt>"; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 451 | swallow_newline(); |
| 452 | return make_index_entry("$fname (built-in function)") . $_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 453 | } |
| 454 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 455 | sub do_cmd_modindex{ return my_module_index_helper('', @_); } |
| 456 | sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); } |
| 457 | sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); } |
| 458 | sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 459 | |
| 460 | # these should be adjusted a bit.... |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 461 | sub do_cmd_refmodindex{ return ref_module_index_helper('', @_); } |
| 462 | sub do_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); } |
| 463 | sub do_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); } |
| 464 | sub do_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 465 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 466 | sub do_cmd_nodename{ return do_cmd_label(@_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 467 | |
| 468 | sub init_myformat{ |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 469 | # $anchor_invisible_mark = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 470 | $anchor_mark = ''; |
| 471 | $icons{'anchor_mark'} = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 472 | } |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 473 | init_myformat(); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 474 | |
| 475 | # similar to make_index_entry(), but includes the string in the result |
| 476 | # instead of the dummy filler. |
| 477 | # |
| 478 | sub make_str_index_entry{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 479 | my($str) = @_; |
| 480 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 481 | add_index_entry($str, $ahref); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 482 | return "$aname$str</a>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 483 | } |
| 484 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 485 | sub do_env_cfuncdesc{ |
| 486 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 487 | my $return_type = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 488 | my $function_name = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 489 | my $arg_list = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 490 | my $idx = make_str_index_entry("<tt>$function_name()</tt>" |
| 491 | . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 492 | $idx =~ s/ \(.*\)//; |
| 493 | $idx =~ s/\(\)//; # ???? |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 494 | return "<dl><dt>$return_type <b>$idx</b>" |
| 495 | . "(<var>$arg_list</var>)\n<dd>" |
| 496 | . $_ |
| 497 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | sub do_env_ctypedesc{ |
| 501 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 502 | my $type_name = next_argument(); |
| 503 | my $idx = make_str_index_entry("<tt>$type_name</tt>" . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 504 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 505 | return "<dl><dt><b>$idx</b>\n<dd>" |
| 506 | . $_ |
| 507 | . '</dl>' |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | sub do_env_cvardesc{ |
| 511 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 512 | my $var_type = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 513 | my $var_name = next_argument(); |
| 514 | my $idx = make_str_index_entry("<tt>$var_name</tt>" . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 515 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 516 | return "<dl><dt>$var_type <b>$idx</b>\n" |
| 517 | . '<dd>' |
| 518 | . $_ |
| 519 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | sub do_env_funcdesc{ |
| 523 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 524 | my $function_name = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 525 | my $arg_list = next_argument(); |
| 526 | my $idx = make_str_index_entry("<tt>$function_name()</tt>" |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 527 | . get_indexsubitem()); |
| 528 | $idx =~ s/ \(.*\)//; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 529 | $idx =~ s/\(\)<\/tt>/<\/tt>/; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 530 | return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 531 | } |
| 532 | |
| 533 | sub do_env_funcdescni{ |
| 534 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 535 | my $function_name = next_argument(); |
| 536 | my $arg_list = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 537 | return "<dl><dt><b><tt>$function_name</tt></b> (<var>$arg_list</var>)\n" |
| 538 | . "<dd>" |
| 539 | . $_ . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 540 | } |
| 541 | |
| 542 | sub do_cmd_funcline{ |
| 543 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 544 | my $function_name = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 545 | my $arg_list = next_argument(); |
| 546 | my $idx = make_str_index_entry("<tt>$function_name()</tt>" |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 547 | . get_indexsubitem()); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 548 | $idx =~ s/\(\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 549 | return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | # Change this flag to index the opcode entries. I don't think it's very |
| 553 | # useful to index them, since they're only presented to describe the dis |
| 554 | # module. |
| 555 | # |
| 556 | $INDEX_OPCODES = 0; |
| 557 | |
| 558 | sub do_env_opcodedesc{ |
| 559 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 560 | my $opcode_name = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 561 | my $arg_list = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 562 | my $idx; |
| 563 | if ($INDEX_OPCODES) { |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 564 | $idx = make_str_index_entry( |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 565 | "<tt>$opcode_name</tt> (byte code instruction)"); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 566 | $idx =~ s/ \(byte code instruction\)//; |
| 567 | } |
| 568 | else { |
| 569 | $idx = "<tt>$opcode_name</tt>"; |
| 570 | } |
| 571 | my $stuff = "<dl><dt><b>$idx</b>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 572 | if ($arg_list) { |
| 573 | $stuff .= " <var>$arg_list</var>"; |
| 574 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 575 | return $stuff . "\n<dd>" . $_ . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 576 | } |
| 577 | |
| 578 | sub do_env_datadesc{ |
| 579 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 580 | my $dataname = next_argument(); |
| 581 | my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 582 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 583 | return "<dl><dt><b>$idx</b>\n<dd>" |
| 584 | . $_ |
| 585 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 586 | } |
| 587 | |
| 588 | sub do_env_datadescni{ |
| 589 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 590 | my $idx = next_argument(); |
| 591 | if (! $STRING_INDEX_TT) { |
| 592 | $idx = "<tt>$idx</tt>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 593 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 594 | return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | sub do_cmd_dataline{ |
| 598 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 599 | my $data_name = next_argument(); |
| 600 | my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem()); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 601 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 602 | return "<dt><b>$idx</b><dd>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 603 | } |
| 604 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 605 | sub do_env_excdesc{ |
| 606 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 607 | my $excname = next_argument(); |
| 608 | my $idx = make_str_index_entry("<tt>$excname</tt>"); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 609 | return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>' |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 610 | } |
| 611 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 612 | sub do_env_fulllineitems{ return do_env_itemize(@_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 613 | |
| 614 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 615 | sub do_env_classdesc{ |
| 616 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 617 | $THIS_CLASS = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 618 | my $arg_list = next_argument(); |
| 619 | $idx = make_str_index_entry( |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 620 | "<tt>$THIS_CLASS</tt> (class in $THIS_MODULE)" ); |
| 621 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 622 | return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>'; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 623 | } |
| 624 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 625 | |
| 626 | sub do_env_methoddesc{ |
| 627 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 628 | my $class_name = next_optional_argument(); |
| 629 | $class_name = $THIS_CLASS |
| 630 | unless $class_name; |
Fred Drake | 5a0ca4e | 1999-01-12 04:16:51 +0000 | [diff] [blame] | 631 | my $method = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 632 | my $arg_list = next_argument(); |
| 633 | my $extra = ''; |
| 634 | if ($class_name) { |
| 635 | $extra = " ($class_name method)"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 636 | } |
Fred Drake | 5a0ca4e | 1999-01-12 04:16:51 +0000 | [diff] [blame] | 637 | my $idx = make_str_index_entry("<tt>$method()</tt>$extra"); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 638 | $idx =~ s/ \(.*\)//; |
| 639 | $idx =~ s/\(\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 640 | return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 641 | } |
| 642 | |
| 643 | |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 644 | sub do_cmd_methodline{ |
| 645 | local($_) = @_; |
| 646 | my $class_name = next_optional_argument(); |
| 647 | $class_name = $THIS_CLASS |
| 648 | unless $class_name; |
| 649 | my $method = next_argument(); |
| 650 | my $arg_list = next_argument(); |
| 651 | my $extra = ''; |
| 652 | if ($class_name) { |
| 653 | $extra = " ($class_name method)"; |
| 654 | } |
Fred Drake | 5a0ca4e | 1999-01-12 04:16:51 +0000 | [diff] [blame] | 655 | my $idx = make_str_index_entry("<tt>$method()</tt>$extra"); |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 656 | $idx =~ s/ \(.*\)//; |
| 657 | $idx =~ s/\(\)//; |
| 658 | return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" |
| 659 | . $_; |
| 660 | } |
| 661 | |
| 662 | |
Fred Drake | d64a40d | 1998-09-10 18:59:13 +0000 | [diff] [blame] | 663 | sub do_cmd_methodlineni{ |
| 664 | local($_) = @_; |
| 665 | next_optional_argument(); |
| 666 | my $method = next_argument(); |
| 667 | my $arg_list = next_argument(); |
| 668 | return "<dt><b>$method</b> (<var>$arg_list</var>)\n<dd>" |
| 669 | . $_; |
| 670 | } |
| 671 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 672 | sub do_env_methoddescni{ |
| 673 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 674 | next_optional_argument(); |
| 675 | my $method = next_argument(); |
| 676 | my $arg_list = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 677 | return "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>" |
| 678 | . $_ |
| 679 | . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 680 | } |
| 681 | |
| 682 | |
| 683 | sub do_env_memberdesc{ |
| 684 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 685 | my $class = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 686 | my $member = next_argument(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 687 | $class = $THIS_CLASS |
| 688 | unless $class; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 689 | my $extra = ''; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 690 | $extra = " ($class_name attribute)" |
Fred Drake | a608feb | 1998-04-12 03:58:13 +0000 | [diff] [blame] | 691 | if (!($class eq '')); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 692 | my $idx = make_str_index_entry("<tt>$member</tt>$extra"); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 693 | $idx =~ s/ \(.*\)//; |
| 694 | $idx =~ s/\(\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 695 | return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 696 | } |
| 697 | |
| 698 | |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 699 | sub do_cmd_memberline{ |
| 700 | local($_) = @_; |
| 701 | my $class = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 702 | my $member = next_argument(); |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 703 | $class = $THIS_CLASS |
| 704 | unless $class; |
| 705 | my $extra = ''; |
| 706 | $extra = " ($class_name attribute)" |
| 707 | if (!($class eq '')); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 708 | my $idx = make_str_index_entry("<tt>$member</tt>$extra"); |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 709 | $idx =~ s/ \(.*\)//; |
| 710 | $idx =~ s/\(\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 711 | return "<dt><b>$idx</b><dd>" . $_; |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 712 | } |
| 713 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 714 | sub do_env_memberdescni{ |
| 715 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 716 | next_optional_argument(); |
| 717 | my $member = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 718 | return "<dl><dt><b>$member</b>\n<dd>" . $_ . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 722 | sub do_cmd_memberlineni{ |
| 723 | local($_) = @_; |
| 724 | next_optional_argument(); |
| 725 | my $member = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 726 | return "<dt><b>$member</b><dd>" . $_; |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 727 | } |
| 728 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 729 | @col_aligns = ("<td>", "<td>", "<td>", "<td>"); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 730 | |
| 731 | sub setup_column_alignments{ |
| 732 | local($_) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 733 | my($a1,$a2,$a3,$a4) = split(/[|]/,$_); |
| 734 | my($th1,$th2,$th3,$th4) = ('<th>', '<th>', '<th>', '<th>'); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 735 | $col_aligns[0] = (($a1 eq 'c') ? '<td align=center>' : '<td>'); |
| 736 | $col_aligns[1] = (($a2 eq 'c') ? '<td align=center>' : '<td>'); |
| 737 | $col_aligns[2] = (($a3 eq 'c') ? '<td align=center>' : '<td>'); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 738 | $col_aligns[3] = (($a4 eq 'c') ? '<td align=center>' : '<td>'); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 739 | # return the aligned header start tags; only used for \begin{tableiii?} |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 740 | $th1 = (($a1 eq 'l') ? '<th align=left>' |
| 741 | : ($a1 eq 'r' ? '<th align=right>' : '<th>')); |
| 742 | $th2 = (($a2 eq 'l') ? '<th align=left>' |
| 743 | : ($a2 eq 'r' ? '<th align=right>' : '<th>')); |
| 744 | $th3 = (($a3 eq 'l') ? '<th align=left>' |
| 745 | : ($a3 eq 'r' ? '<th align=right>' : '<th>')); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 746 | $th4 = (($a4 eq 'l') ? '<th align=left>' |
| 747 | : ($a4 eq 'r' ? '<th align=right>' : '<th>')); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 748 | return ($th1, $th2, $th3, $th4); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 749 | } |
| 750 | |
| 751 | sub do_env_tableii{ |
| 752 | local($_) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 753 | my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 754 | my $font = next_argument(); |
| 755 | my $h1 = next_argument(); |
| 756 | my $h2 = next_argument(); |
| 757 | $font = '' |
| 758 | if ($font eq 'textrm'); |
| 759 | $globals{'lineifont'} = $font; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 760 | return '<table border align=center>' |
| 761 | . "\n <tr>$th1<b>$h1</b></th>" |
| 762 | . "\n $th2<b>$h2</b></th>" |
| 763 | . $_ |
| 764 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 765 | } |
| 766 | |
| 767 | sub do_cmd_lineii{ |
| 768 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 769 | my $c1 = next_argument(); |
| 770 | my $c2 = next_argument(); |
| 771 | my($font,$sfont,$efont) = ($globals{'lineifont'}, '', ''); |
Fred Drake | 58b2bfd | 1998-04-02 20:14:04 +0000 | [diff] [blame] | 772 | if ($font) { |
Fred Drake | 5cca42e | 1998-04-09 17:59:11 +0000 | [diff] [blame] | 773 | $sfont = "<$font>"; |
Fred Drake | 58b2bfd | 1998-04-02 20:14:04 +0000 | [diff] [blame] | 774 | $efont = "</$font>"; |
| 775 | } |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 776 | my($c1align,$c2align) = @col_aligns[0,1]; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 777 | return "<tr>$c1align$sfont$c1$efont</td>\n" |
| 778 | . " $c2align$c2</td>" |
| 779 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 780 | } |
| 781 | |
| 782 | sub do_env_tableiii{ |
| 783 | local($_) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 784 | my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 785 | my $font = next_argument(); |
| 786 | my $h1 = next_argument(); |
| 787 | my $h2 = next_argument(); |
| 788 | my $h3 = next_argument(); |
| 789 | $font = '' |
| 790 | if ($font eq 'textrm'); |
| 791 | $globals{'lineifont'} = $font; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 792 | return '<table border align=center>' |
| 793 | . "\n <tr>$th1<b>$h1</b></th>" |
| 794 | . "\n $th2<b>$h2</b></th>" |
| 795 | . "\n $th3<b>$h3</b></th>" |
| 796 | . $_ |
| 797 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 798 | } |
| 799 | |
| 800 | sub do_cmd_lineiii{ |
| 801 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 802 | my $c1 = next_argument(); |
| 803 | my $c2 = next_argument(); |
| 804 | my $c3 = next_argument(); |
| 805 | my($font,$sfont,$efont) = ($globals{'lineifont'}, '', ''); |
Fred Drake | 58b2bfd | 1998-04-02 20:14:04 +0000 | [diff] [blame] | 806 | if ($font) { |
Fred Drake | 5cca42e | 1998-04-09 17:59:11 +0000 | [diff] [blame] | 807 | $sfont = "<$font>"; |
Fred Drake | 58b2bfd | 1998-04-02 20:14:04 +0000 | [diff] [blame] | 808 | $efont = "</$font>"; |
| 809 | } |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 810 | my($c1align,$c2align,$c3align) = @col_aligns[0,1,2]; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 811 | return "<tr>$c1align$sfont$c1$efont</td>\n" |
| 812 | . " $c2align$c2</td>\n" |
| 813 | . " $c3align$c3</td>" |
| 814 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 815 | } |
| 816 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 817 | sub do_env_tableiv{ |
| 818 | local($_) = @_; |
| 819 | my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument()); |
| 820 | my $font = next_argument(); |
| 821 | my $h1 = next_argument(); |
| 822 | my $h2 = next_argument(); |
| 823 | my $h3 = next_argument(); |
| 824 | my $h4 = next_argument(); |
| 825 | $font = '' |
| 826 | if ($font eq 'textrm'); |
| 827 | $globals{'lineifont'} = $font; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 828 | return '<table border align=center>' |
| 829 | . "\n <tr>$th1<b>$h1</b></th>" |
| 830 | . "\n $th2<b>$h2</b></th>" |
| 831 | . "\n $th3<b>$h3</b></th>" |
| 832 | . "\n $th4<b>$h4</b></th>" |
| 833 | . $_ |
| 834 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 835 | } |
| 836 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 837 | sub do_cmd_lineiv{ |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 838 | local($_) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 839 | my $c1 = next_argument(); |
| 840 | my $c2 = next_argument(); |
| 841 | my $c3 = next_argument(); |
| 842 | my $c4 = next_argument(); |
| 843 | my($font,$sfont,$efont) = ($globals{'lineifont'}, '', ''); |
| 844 | if ($font) { |
| 845 | $sfont = "<$font>"; |
| 846 | $efont = "</$font>"; |
| 847 | } |
| 848 | my($c1align,$c2align,$c3align,$c4align) = @col_aligns; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 849 | return "<tr>$c1align$sfont$c1$efont</td>\n" |
| 850 | . " $c2align$c2</td>\n" |
| 851 | . " $c3align$c3</td>\n" |
| 852 | . " $c4align$c4</td>" |
| 853 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 854 | } |
| 855 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 856 | sub do_cmd_maketitle { |
| 857 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 858 | my $the_title = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 859 | if ($t_title) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 860 | $the_title .= "<h1 align=center>$t_title</h1>"; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 861 | } else { write_warnings("\nThis document has no title."); } |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 862 | $the_title .= "\n<center>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 863 | if ($t_author) { |
| 864 | if ($t_authorURL) { |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 865 | my $href = translate_commands($t_authorURL); |
Fred Drake | 2d1f81e | 1999-02-09 16:03:31 +0000 | [diff] [blame^] | 866 | $href = make_named_href('author', $href, |
| 867 | "<b><font size='+2'>$t_author</font></b>"); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 868 | $the_title .= "\n<p>$href</p>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 869 | } else { |
Fred Drake | 2d1f81e | 1999-02-09 16:03:31 +0000 | [diff] [blame^] | 870 | $the_title .= ("\n<p><b><font size='+2'>$t_author</font></b></p>"); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 871 | } |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 872 | } else { write_warnings("\nThere is no author for this document."); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 873 | if ($t_institute) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 874 | $the_title .= "\n<p>$t_institute</p>";} |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 875 | if ($DEVELOPER_ADDRESS) { |
| 876 | $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 877 | if ($t_affil) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 878 | $the_title .= "\n<p><i>$t_affil</i></p>";} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 879 | if ($t_date) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 880 | $the_title .= "\n<p><strong>$t_date</strong>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 881 | if ($PYTHON_VERSION) { |
| 882 | $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";} |
| 883 | $the_title .= "</p>" |
| 884 | } |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 885 | $the_title .= "\n</center>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 886 | if ($t_address) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 887 | $the_title .= "\n<p>$t_address</p>"; |
| 888 | } else { $the_title .= "\n<p>"} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 889 | if ($t_email) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 890 | $the_title .= "\n<p>$t_email</p>"; |
| 891 | }# else { $the_title .= "</p>" } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 892 | return $the_title . $_ ; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 893 | } |
| 894 | |
| 895 | |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 896 | # |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 897 | # Module synopsis support |
| 898 | # |
| 899 | |
| 900 | require SynopsisTable; |
| 901 | |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 902 | sub get_chapter_id(){ |
| 903 | my $id = do_cmd_thechapter(''); |
Fred Drake | 45f2601 | 1998-08-04 22:07:18 +0000 | [diff] [blame] | 904 | $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/; |
| 905 | $id =~ s/\.//; |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 906 | return $id; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 907 | } |
| 908 | |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 909 | %ModuleSynopses = ('chapter' => 'SynopsisTable instance'); |
| 910 | |
| 911 | sub get_synopsis_table($){ |
| 912 | my($chap) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 913 | my $st = $ModuleSynopses{$chap}; |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 914 | my $key; |
| 915 | foreach $key (keys %ModuleSynopses) { |
| 916 | if ($key eq $chap) { |
| 917 | return $ModuleSynopses{$chap}; |
| 918 | } |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 919 | } |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 920 | $st = SynopsisTable->new(); |
| 921 | $ModuleSynopses{$chap} = $st; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 922 | return $st; |
| 923 | } |
| 924 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 925 | sub do_cmd_moduleauthor{ |
| 926 | local($_) = @_; |
| 927 | next_argument(); |
| 928 | next_argument(); |
| 929 | return $_; |
| 930 | } |
| 931 | |
| 932 | sub do_cmd_sectionauthor{ |
| 933 | local($_) = @_; |
| 934 | next_argument(); |
| 935 | next_argument(); |
| 936 | return $_; |
| 937 | } |
| 938 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 939 | sub do_cmd_declaremodule{ |
| 940 | local($_) = @_; |
| 941 | my $key = next_optional_argument(); |
| 942 | my $type = next_argument(); |
| 943 | my $name = next_argument(); |
| 944 | my $st = get_synopsis_table(get_chapter_id()); |
| 945 | # |
| 946 | $key = $name unless $key; |
| 947 | $type = 'built-in' if $type eq 'builtin'; |
| 948 | $st->declare($name, $key, $type); |
| 949 | define_module($type, $name); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 950 | return anchor_label("module-$key",$CURRENT_FILE,$_) |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 951 | } |
| 952 | |
| 953 | sub do_cmd_modulesynopsis{ |
| 954 | local($_) = @_; |
| 955 | my $st = get_synopsis_table(get_chapter_id()); |
| 956 | $st->set_synopsis($THIS_MODULE, next_argument()); |
| 957 | swallow_newline(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 958 | return $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 959 | } |
| 960 | |
| 961 | sub do_cmd_localmoduletable{ |
| 962 | local($_) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 963 | my $chap = get_chapter_id(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 964 | return "<tex2htmllocalmoduletable><$chap>\\tableofchildlinks[off]" . $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 965 | } |
| 966 | |
| 967 | sub process_all_localmoduletables{ |
| 968 | while (/<tex2htmllocalmoduletable><(\d+)>/) { |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 969 | my $match = $&; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 970 | my $chap = $1; |
| 971 | my $st = get_synopsis_table($chap); |
| 972 | my $data = $st->tohtml(); |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 973 | s/$match/$data/; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 974 | } |
| 975 | } |
| 976 | |
| 977 | |
| 978 | # |
| 979 | # "See also:" -- references placed at the end of a \section |
| 980 | # |
| 981 | |
| 982 | sub do_env_seealso{ |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 983 | return "<p><b>See Also:</b></p>\n" . @_[0]; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 984 | } |
| 985 | |
| 986 | sub do_cmd_seemodule{ |
| 987 | # Insert the right magic to jump to the module definition. This should |
| 988 | # work most of the time, at least for repeat builds.... |
| 989 | local($_) = @_; |
| 990 | my $key = next_optional_argument(); |
| 991 | my $module = next_argument(); |
| 992 | my $text = next_argument(); |
| 993 | $key = $module |
| 994 | unless $key; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 995 | return "<p>Module <tt><b><a href=\"module-$key.html\">$module</a></b></tt>" |
| 996 | . " ($text)</p>" |
| 997 | . $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 998 | } |
| 999 | |
| 1000 | sub do_cmd_seetext{ |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1001 | return '<p>' . @_[0]; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1002 | } |
| 1003 | |
| 1004 | |
| 1005 | # |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1006 | # Definition list support. |
| 1007 | # |
| 1008 | |
| 1009 | sub do_env_definitions{ |
| 1010 | local($_) = @_; |
| 1011 | swallow_newline(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1012 | return "<dl>$_</dl>\n"; |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1013 | } |
| 1014 | |
| 1015 | sub do_cmd_term{ |
| 1016 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1017 | my $term = next_argument(); |
| 1018 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1019 | swallow_newline(); |
| 1020 | # could easily add an index entry here... |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1021 | return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_; |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1022 | } |
| 1023 | |
| 1024 | |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 1025 | process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_); |
| 1026 | code # {} |
| 1027 | samp # {} |
| 1028 | _RAW_ARG_DEFERRED_CMDS_ |
| 1029 | |
| 1030 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1031 | 1; # This must be the last line |