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