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