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 | |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 26 | |
| 27 | # This is a fairly simple hack; it supports \let when it is used to create |
| 28 | # (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] | 29 | # 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] | 30 | # |
| 31 | sub do_cmd_let{ |
| 32 | local($_) = @_; |
| 33 | my $matched = 0; |
Fred Drake | 7a4ad0f | 1998-05-15 13:45:54 +0000 | [diff] [blame] | 34 | s/[\\]([a-zA-Z]+)\s*(=\s*)?[\\]([a-zA-Z]*)/$matched=1; ''/e; |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 35 | if ($matched) { |
| 36 | my($new, $old) = ($1, $3); |
| 37 | eval "sub do_cmd_$new { do_cmd_$old" . '(@_); }'; |
| 38 | print "\ndefining handler for \\$new using \\$old\n"; |
| 39 | } |
Fred Drake | 7a4ad0f | 1998-05-15 13:45:54 +0000 | [diff] [blame] | 40 | else { |
| 41 | s/[\\]([a-zA-Z]+)\s*(=\s*)?([^\\])/$matched=1; ''/es; |
| 42 | if ($matched) { |
| 43 | my($new, $char) = ($1, $3); |
| 44 | eval "sub do_cmd_$new { \"\\$char\" . \@_[0]; }"; |
| 45 | print "\ndefining handler for \\$new to insert '$char'\n"; |
| 46 | } |
| 47 | else { |
| 48 | write_warnings("Could not interpret \\let construct..."); |
| 49 | } |
| 50 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 51 | return $_; |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 55 | # words typeset in a special way (not in HTML though) |
| 56 | |
| 57 | sub do_cmd_ABC{ 'ABC' . @_[0]; } |
| 58 | sub do_cmd_UNIX{ 'Unix'. @_[0]; } |
| 59 | sub do_cmd_ASCII{ 'ASCII' . @_[0]; } |
| 60 | sub do_cmd_POSIX{ 'POSIX' . @_[0]; } |
| 61 | sub do_cmd_C{ 'C' . @_[0]; } |
| 62 | sub do_cmd_Cpp{ 'C++' . @_[0]; } |
| 63 | sub do_cmd_EOF{ 'EOF' . @_[0]; } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 64 | sub do_cmd_NULL{ '<tt class="constant">NULL</tt>' . @_[0]; } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 65 | |
| 66 | sub do_cmd_e{ '\' . @_[0]; } |
| 67 | |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 68 | $DEVELOPER_ADDRESS = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 69 | $PYTHON_VERSION = ''; |
| 70 | |
| 71 | sub do_cmd_version{ $PYTHON_VERSION . @_[0]; } |
| 72 | sub do_cmd_release{ |
| 73 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 74 | $PYTHON_VERSION = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 75 | return $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | sub do_cmd_authoraddress{ |
| 79 | local($_) = @_; |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 80 | $DEVELOPER_ADDRESS = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 81 | return $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 82 | } |
| 83 | |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 84 | #sub do_cmd_developer{ do_cmd_author(@_[0]); } |
| 85 | #sub do_cmd_developers{ do_cmd_author(@_[0]); } |
| 86 | #sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); } |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 87 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 88 | sub do_cmd_hackscore{ |
| 89 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 90 | next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 91 | return '_' . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 92 | } |
| 93 | |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 94 | sub use_wrappers{ |
| 95 | local($_,$before,$after) = @_; |
| 96 | my $stuff = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 97 | return $before . $stuff . $after . $_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 98 | } |
| 99 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 100 | sub use_sans_serif{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 101 | return use_wrappers(@_[0], '<font face="sans-serif">', '</font>'); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 102 | } |
| 103 | sub use_italics{ |
| 104 | return use_wrappers(@_[0], '<i>', '</i>'); |
| 105 | } |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 106 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 107 | sub do_cmd_optional{ |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 108 | return use_wrappers(@_[0], "</var><big>\[</big><var>", |
| 109 | "</var><big>\]</big><var>"); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 110 | } |
| 111 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 112 | # Logical formatting (some based on texinfo), needs to be converted to |
| 113 | # minimalist HTML. The "minimalist" is primarily to reduce the size of |
| 114 | # output files for users that read them over the network rather than |
| 115 | # from local repositories. |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 116 | |
Fred Drake | 2cafcbb | 1999-03-25 16:57:04 +0000 | [diff] [blame] | 117 | # \file and \samp are at the end of this file since they screw up fontlock. |
| 118 | |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 119 | sub do_cmd_pytype{ return @_[0]; } |
| 120 | sub do_cmd_makevar{ return @_[0]; } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 121 | sub do_cmd_code{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 122 | return use_wrappers(@_[0], '<code>', '</code>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 123 | sub do_cmd_module{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 124 | return use_wrappers(@_[0], '<tt class="module">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 125 | sub do_cmd_keyword{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 126 | return use_wrappers(@_[0], '<tt class="keyword">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 127 | sub do_cmd_exception{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 128 | return use_wrappers(@_[0], '<tt class="exception">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 129 | sub do_cmd_class{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 130 | return use_wrappers(@_[0], '<tt class="class">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 131 | sub do_cmd_function{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 132 | return use_wrappers(@_[0], '<tt class="function">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 133 | sub do_cmd_constant{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 134 | return use_wrappers(@_[0], '<tt class="constant">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 135 | sub do_cmd_member{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 136 | return use_wrappers(@_[0], '<tt class="member">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 137 | sub do_cmd_method{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 138 | return use_wrappers(@_[0], '<tt class="method">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 139 | sub do_cmd_cfunction{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 140 | return use_wrappers(@_[0], '<tt class="cfunction">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 141 | sub do_cmd_cdata{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 142 | return use_wrappers(@_[0], '<tt class="cdata">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 143 | sub do_cmd_ctype{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 144 | return use_wrappers(@_[0], '<tt class="ctype">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 145 | sub do_cmd_regexp{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 146 | return use_wrappers(@_[0], '<tt class="regexp">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 147 | sub do_cmd_character{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 148 | return use_wrappers(@_[0], '"<tt class="character">', '</tt>"'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 149 | sub do_cmd_program{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 150 | return use_wrappers(@_[0], '<b class="program">', '</b>'); } |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 151 | sub do_cmd_programopt{ |
| 152 | return use_wrappers(@_[0], '<b class="programopt">', '</b>'); } |
Fred Drake | 0cd6021 | 2000-04-11 18:46:59 +0000 | [diff] [blame^] | 153 | sub do_cmd_longprogramopt{ |
| 154 | # note that the --- will be later converted to -- by LaTeX2HTML |
| 155 | return use_wrappers(@_[0], '<b class="programopt">---', '</b>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 156 | sub do_cmd_email{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 157 | return use_wrappers(@_[0], '<span class="email">', '</span>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 158 | sub do_cmd_mimetype{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 159 | return use_wrappers(@_[0], '<span class="mimetype">', '</span>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 160 | sub do_cmd_var{ |
| 161 | return use_wrappers(@_[0], "<var>", "</var>"); } |
| 162 | sub do_cmd_dfn{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 163 | return use_wrappers(@_[0], '<i class="dfn">', '</i>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 164 | sub do_cmd_emph{ |
| 165 | return use_italics(@_); } |
| 166 | sub do_cmd_file{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 167 | return use_wrappers(@_[0], |
| 168 | '<font class="file" face="sans-serif">', |
| 169 | '</font>'); } |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 170 | sub do_cmd_filenq{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 171 | return do_cmd_file(@_[0]); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 172 | sub do_cmd_samp{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 173 | return use_wrappers(@_[0], '"<tt class="samp">', '</tt>"'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 174 | sub do_cmd_kbd{ |
| 175 | return use_wrappers(@_[0], '<kbd>', '</kbd>'); } |
| 176 | sub do_cmd_strong{ |
| 177 | return use_wrappers(@_[0], '<b>', '</b>'); } |
Fred Drake | 2cafcbb | 1999-03-25 16:57:04 +0000 | [diff] [blame] | 178 | sub do_cmd_textbf{ |
| 179 | return use_wrappers(@_[0], '<b>', '</b>'); } |
| 180 | sub do_cmd_textit{ |
| 181 | return use_wrappers(@_[0], '<i>', '</i>'); } |
| 182 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 183 | |
Fred Drake | 2581704 | 1999-01-13 17:06:34 +0000 | [diff] [blame] | 184 | sub do_cmd_refmodule{ |
| 185 | # Insert the right magic to jump to the module definition. |
| 186 | local($_) = @_; |
| 187 | my $key = next_optional_argument(); |
| 188 | my $module = next_argument(); |
| 189 | $key = $module |
| 190 | unless $key; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 191 | return "<tt class='module'><a href='module-$key.html'>$module</a></tt>" |
| 192 | . $_; |
Fred Drake | 2581704 | 1999-01-13 17:06:34 +0000 | [diff] [blame] | 193 | } |
| 194 | |
Fred Drake | 1a7af39 | 1998-04-01 22:44:56 +0000 | [diff] [blame] | 195 | sub do_cmd_newsgroup{ |
| 196 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 197 | my $newsgroup = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 198 | my $stuff = "<span class='newsgroup'><a href='news:$newsgroup'>" |
| 199 | . "$newsgroup</a></span>"; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 200 | return $stuff . $_; |
Fred Drake | 1a7af39 | 1998-04-01 22:44:56 +0000 | [diff] [blame] | 201 | } |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 202 | |
| 203 | sub do_cmd_envvar{ |
| 204 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 205 | my $envvar = next_argument(); |
| 206 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 207 | # The <tt> here is really to keep buildindex.py from making |
| 208 | # the variable name case-insensitive. |
| 209 | add_index_entry("environment variables!$envvar@<tt>\$$envvar</tt>", |
| 210 | $ahref); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 211 | add_index_entry("$envvar@\$$envvar", $ahref); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 212 | $aname =~ s/<a/<a class="envvar"/; |
Fred Drake | d37cecf | 1999-09-23 16:45:08 +0000 | [diff] [blame] | 213 | return "$aname\$$envvar</a>" . $_; |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 214 | } |
| 215 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 216 | sub do_cmd_url{ |
| 217 | # use the URL as both text and hyperlink |
| 218 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 219 | my $url = next_argument(); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 220 | $url =~ s/~/~/g; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 221 | return "<a class=\"url\" href=\"$url\">$url</a>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | sub do_cmd_manpage{ |
| 225 | # two parameters: \manpage{name}{section} |
| 226 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 227 | my $page = next_argument(); |
| 228 | my $section = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 229 | return "<span class='manpage'><i>$page</i>($section)</span>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | sub do_cmd_rfc{ |
| 233 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 234 | my $rfcnumber = next_argument(); |
| 235 | my $id = "rfcref-" . ++$global{'max_id'}; |
Fred Drake | 2eff3c5 | 1998-12-22 18:02:25 +0000 | [diff] [blame] | 236 | my $href = |
| 237 | "http://info.internet.isi.edu/in-notes/rfc/files/rfc$rfcnumber.txt"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 238 | # Save the reference |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 239 | my $nstr = gen_index_id("RFC!RFC $rfcnumber", ''); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 240 | $index{$nstr} .= make_half_href("$CURRENT_FILE#$id"); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 241 | return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">RFC $rfcnumber</a>" |
Fred Drake | d52879c | 1999-09-22 19:58:51 +0000 | [diff] [blame] | 242 | . $_); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 243 | } |
| 244 | |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 245 | sub do_cmd_citetitle{ |
| 246 | local($_) = @_; |
| 247 | my $url = next_optional_argument(); |
| 248 | my $title = next_argument(); |
| 249 | my $repl = ''; |
| 250 | if ($url) { |
| 251 | $repl = ("<em class='citetitle'><a\n" |
| 252 | . " href='$url'\n" |
| 253 | . " title='$title'\n" |
| 254 | . " >$title</a></em>"); |
| 255 | } |
| 256 | else { |
| 257 | $repl = "<em class='citetitle'\n >$title</em>"; |
| 258 | } |
| 259 | return $repl . $_; |
| 260 | } |
| 261 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 262 | sub do_cmd_deprecated{ |
| 263 | # two parameters: \deprecated{version}{whattodo} |
| 264 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 265 | my $release = next_argument(); |
| 266 | my $reason = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 267 | return "<b>Deprecated since release $release.</b>\n$reason<p>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 268 | } |
| 269 | |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 270 | sub do_cmd_versionadded{ |
| 271 | # one parameter: \versionadded{version} |
| 272 | local($_) = @_; |
| 273 | my $release = next_argument(); |
Fred Drake | 2116d98 | 1999-02-02 18:02:48 +0000 | [diff] [blame] | 274 | return "\nNew in version $release.\n" . $_; |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | sub do_cmd_versionchanged{ |
| 278 | # one parameter: \versionchanged{version} |
| 279 | local($_) = @_; |
| 280 | my $release = next_argument(); |
Fred Drake | 2116d98 | 1999-02-02 18:02:48 +0000 | [diff] [blame] | 281 | return "\nChanged in version $release.\n" . $_; |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 282 | } |
| 283 | |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 284 | # |
Fred Drake | 2cafcbb | 1999-03-25 16:57:04 +0000 | [diff] [blame] | 285 | # These function handle platform dependency tracking. |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 286 | # |
| 287 | sub do_cmd_platform{ |
| 288 | local($_) = @_; |
| 289 | my $platform = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 290 | $ModulePlatforms{"<tt class='module'>$THIS_MODULE</tt>"} = $platform; |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 291 | $platform = "Macintosh" |
Fred Drake | 085b812 | 1999-04-21 14:00:29 +0000 | [diff] [blame] | 292 | if $platform eq 'Mac'; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 293 | return "\n<p class='availability'>Availability: <span" |
| 294 | . "\n class='platform'>$platform</span>.</p>\n" . $_; |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 295 | } |
| 296 | |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 297 | $IGNORE_PLATFORM_ANNOTATION = ''; |
| 298 | sub do_cmd_ignorePlatformAnnotation{ |
| 299 | local($_) = @_; |
| 300 | $IGNORE_PLATFORM_ANNOTATION = next_argument(); |
| 301 | return $_; |
| 302 | } |
| 303 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 304 | |
| 305 | # index commands |
| 306 | |
| 307 | $INDEX_SUBITEM = ""; |
| 308 | |
| 309 | sub get_indexsubitem{ |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 310 | return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | sub do_cmd_setindexsubitem{ |
| 314 | local($_) = @_; |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 315 | $INDEX_SUBITEM = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 316 | return $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 317 | } |
| 318 | |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 319 | sub do_cmd_withsubitem{ |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 320 | # We can't really do the right thing, because LaTeX2HTML doesn't |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 321 | # do things in the right order, but we need to at least strip this stuff |
| 322 | # out, and leave anything that the second argument expanded out to. |
| 323 | # |
| 324 | local($_) = @_; |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 325 | my $oldsubitem = $INDEX_SUBITEM; |
| 326 | $INDEX_SUBITEM = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 327 | my $stuff = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 328 | my $br_id = ++$globals{'max_id'}; |
| 329 | my $marker = "$O$br_id$C"; |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 330 | return |
| 331 | $stuff |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 332 | . "\\setindexsubitem$marker$oldsubitem$marker" |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 333 | . $_; |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 334 | } |
| 335 | |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 336 | # This is the prologue macro which is required to start writing the |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 337 | # mod\jobname.idx file; we can just ignore it. (Defining this suppresses |
| 338 | # a warning that \makemodindex is unknown.) |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 339 | # |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 340 | sub do_cmd_makemodindex{ return @_[0]; } |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 341 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 342 | # We're in the document subdirectory when this happens! |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 343 | # |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 344 | open(IDXFILE, '>index.dat') || die "\n$!\n"; |
| 345 | open(INTLABELS, '>intlabels.pl') || die "\n$!\n"; |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 346 | print INTLABELS "%internal_labels = ();\n"; |
| 347 | print INTLABELS "1; # hack in case there are no entries\n\n"; |
| 348 | |
| 349 | # Using \0 for this is bad because we can't use common tools to work with the |
| 350 | # resulting files. Things like grep can be useful with this stuff! |
| 351 | # |
| 352 | $IDXFILE_FIELD_SEP = "\1"; |
| 353 | |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 354 | sub write_idxfile{ |
| 355 | my ($ahref, $str) = @_; |
| 356 | print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 357 | } |
| 358 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 359 | |
| 360 | sub gen_link{ |
| 361 | my($node,$target) = @_; |
| 362 | print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n"; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 363 | return "<a href='$node#$target'>"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 364 | } |
| 365 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 366 | sub add_index_entry{ |
| 367 | # add an entry to the index structures; ignore the return value |
| 368 | my($str,$ahref) = @_; |
| 369 | $str = gen_index_id($str, ''); |
| 370 | $index{$str} .= $ahref; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 371 | write_idxfile($ahref, $str); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 372 | } |
| 373 | |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 374 | sub new_link_info{ |
| 375 | my $name = "l2h-" . ++$globals{'max_id'}; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 376 | my $aname = "<a name='$name'>"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 377 | my $ahref = gen_link($CURRENT_FILE, $name); |
| 378 | return ($name, $aname, $ahref); |
| 379 | } |
| 380 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 381 | $IndexMacroPattern = ''; |
| 382 | sub define_indexing_macro{ |
| 383 | my $count = @_; |
| 384 | my $i = 0; |
| 385 | for (; $i < $count; ++$i) { |
| 386 | my $name = @_[$i]; |
| 387 | my $cmd = "idx_cmd_$name"; |
| 388 | die "\nNo function $cmd() defined!\n" |
| 389 | if (!defined &$cmd); |
| 390 | eval ("sub do_cmd_$name { return process_index_macros(" |
| 391 | . "\@_[0], '$name'); }"); |
| 392 | if (length($IndexMacroPattern) == 0) { |
| 393 | $IndexMacroPattern = "$name"; |
| 394 | } |
| 395 | else { |
| 396 | $IndexMacroPattern .= "|$name"; |
| 397 | } |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | $DEBUG_INDEXING = 0; |
| 402 | sub process_index_macros{ |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 403 | local($_) = @_; |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 404 | my $cmdname = @_[1]; # This is what triggered us in the first place; |
| 405 | # we know it's real, so just process it. |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 406 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 407 | my $cmd = "idx_cmd_$cmdname"; |
| 408 | print "\nIndexing: \\$cmdname" |
| 409 | if $DEBUG_INDEXING; |
| 410 | &$cmd($ahref); # modifies $_ and adds index entries |
| 411 | while (/^[\s\n]*\\($IndexMacroPattern)</) { |
| 412 | $cmdname = "$1"; |
| 413 | print " \\$cmdname" |
| 414 | if $DEBUG_INDEXING; |
| 415 | $cmd = "idx_cmd_$cmdname"; |
| 416 | if (!defined &$cmd) { |
| 417 | last; |
| 418 | } |
| 419 | else { |
| 420 | s/^[\s\n]*\\$cmdname//; |
| 421 | &$cmd($ahref); |
| 422 | } |
| 423 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 424 | return "$aname$anchor_invisible_mark</a>" . $_; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 425 | } |
| 426 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 427 | define_indexing_macro('index'); |
| 428 | sub idx_cmd_index{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 429 | my $str = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 430 | add_index_entry("$str", @_[0]); |
Fred Drake | 2e7edb8 | 1998-05-11 18:31:17 +0000 | [diff] [blame] | 431 | } |
| 432 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 433 | define_indexing_macro('kwindex'); |
| 434 | sub idx_cmd_kwindex{ |
| 435 | my $str = next_argument(); |
| 436 | add_index_entry("<tt>$str</tt>!keyword", @_[0]); |
| 437 | add_index_entry("keyword!<tt>$str</tt>", @_[0]); |
| 438 | } |
| 439 | |
| 440 | define_indexing_macro('indexii'); |
| 441 | sub idx_cmd_indexii{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 442 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 443 | my $str2 = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 444 | add_index_entry("$str1!$str2", @_[0]); |
| 445 | add_index_entry("$str2!$str1", @_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 446 | } |
| 447 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 448 | define_indexing_macro('indexiii'); |
| 449 | sub idx_cmd_indexiii{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 450 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 451 | my $str2 = next_argument(); |
| 452 | my $str3 = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 453 | add_index_entry("$str1!$str2 $str3", @_[0]); |
| 454 | add_index_entry("$str2!$str3, $str1", @_[0]); |
| 455 | add_index_entry("$str3!$str1 $str2", @_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 456 | } |
| 457 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 458 | define_indexing_macro('indexiv'); |
| 459 | sub idx_cmd_indexiv{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 460 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 461 | my $str2 = next_argument(); |
| 462 | my $str3 = next_argument(); |
| 463 | my $str4 = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 464 | add_index_entry("$str1!$str2 $str3 $str4", @_[0]); |
| 465 | add_index_entry("$str2!$str3 $str4, $str1", @_[0]); |
| 466 | add_index_entry("$str3!$str4, $str1 $str2", @_[0]); |
| 467 | add_index_entry("$str4!$$str1 $str2 $str3", @_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 468 | } |
| 469 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 470 | define_indexing_macro('ttindex'); |
| 471 | sub idx_cmd_ttindex{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 472 | my $str = next_argument(); |
| 473 | my $entry = $str . get_indexsubitem(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 474 | add_index_entry($entry, @_[0]); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 475 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 476 | |
| 477 | sub my_typed_index_helper{ |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 478 | my($word,$ahref) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 479 | my $str = next_argument(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 480 | add_index_entry("$str $word", $ahref); |
| 481 | add_index_entry("$word!$str", $ahref); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 482 | } |
| 483 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 484 | define_indexing_macro('stindex', 'opindex', 'exindex', 'obindex'); |
| 485 | sub idx_cmd_stindex{ my_typed_index_helper('statement', @_[0]); } |
| 486 | sub idx_cmd_opindex{ my_typed_index_helper('operator', @_[0]); } |
| 487 | sub idx_cmd_exindex{ my_typed_index_helper('exception', @_[0]); } |
| 488 | sub idx_cmd_obindex{ my_typed_index_helper('object', @_[0]); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 489 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 490 | define_indexing_macro('bifuncindex'); |
| 491 | sub idx_cmd_bifuncindex{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 492 | my $str = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 493 | add_index_entry("<tt class='function'>$str()</tt> (built-in function)", |
| 494 | @_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 495 | } |
| 496 | |
| 497 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 498 | sub make_mod_index_entry{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 499 | my($str,$define) = @_; |
| 500 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 501 | # equivalent of add_index_entry() using $define instead of '' |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 502 | $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/ |
| 503 | if ($define eq 'DEF'); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 504 | $str = gen_index_id($str, $define); |
| 505 | $index{$str} .= $ahref; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 506 | write_idxfile($ahref, $str); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 507 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 508 | if ($define eq 'DEF') { |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 509 | # add to the module index |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 510 | $str =~ /(<tt.*<\/tt>)/; |
| 511 | my $nstr = $1; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 512 | $Modules{$nstr} .= $ahref; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 513 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 514 | return "$aname$anchor_invisible_mark</a>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 515 | } |
| 516 | |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 517 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 518 | $THIS_MODULE = ''; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 519 | $THIS_CLASS = ''; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 520 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 521 | sub define_module{ |
| 522 | my($word,$name) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 523 | my $section_tag = join('', @curr_sec_id); |
Fred Drake | 3e4c614 | 1999-05-17 15:00:32 +0000 | [diff] [blame] | 524 | if ($word ne "built-in" && $word ne "extension" |
| 525 | && $word ne "standard" && $word ne "") { |
| 526 | write_warnings("Bad module type '$word'" |
| 527 | . " for \\declaremodule (module $name)"); |
| 528 | $word = ""; |
| 529 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 530 | $word = "$word " if $word; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 531 | $THIS_MODULE = "$name"; |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 532 | $INDEX_SUBITEM = "(in $name)"; |
| 533 | print "[$name]"; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 534 | return make_mod_index_entry( |
| 535 | "<tt class='module'>$name</tt> (${word}module)", 'DEF'); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | sub my_module_index_helper{ |
| 539 | local($word, $_) = @_; |
| 540 | my $name = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 541 | return define_module($word, $name) . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 542 | } |
| 543 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 544 | sub do_cmd_modindex{ return my_module_index_helper('', @_); } |
| 545 | sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); } |
| 546 | sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); } |
| 547 | sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 548 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 549 | sub ref_module_index_helper{ |
| 550 | local($word, $ahref) = @_; |
| 551 | my $str = next_argument(); |
| 552 | $word = "$word " if $word; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 553 | $str = "<tt class='module'>$str</tt> (${word}module)"; |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 554 | # can't use add_index_entry() since the 2nd arg to gen_index_id() is used; |
| 555 | # just inline it all here |
| 556 | $str = gen_index_id($str, 'REF'); |
| 557 | $index{$str} .= $ahref; |
| 558 | write_idxfile($ahref, $str); |
| 559 | } |
| 560 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 561 | # these should be adjusted a bit.... |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 562 | define_indexing_macro('refmodindex', 'refbimodindex', |
| 563 | 'refexmodindex', 'refstmodindex'); |
| 564 | sub idx_cmd_refmodindex{ return ref_module_index_helper('', @_); } |
| 565 | sub idx_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); } |
| 566 | sub idx_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); } |
| 567 | sub idx_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 568 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 569 | sub do_cmd_nodename{ return do_cmd_label(@_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 570 | |
| 571 | sub init_myformat{ |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 572 | # $anchor_invisible_mark = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 573 | $anchor_mark = ''; |
| 574 | $icons{'anchor_mark'} = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 575 | } |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 576 | init_myformat(); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 577 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 578 | # Create an index entry, but include the string in the target anchor |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 579 | # instead of the dummy filler. |
| 580 | # |
| 581 | sub make_str_index_entry{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 582 | my($str) = @_; |
| 583 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 584 | add_index_entry($str, $ahref); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 585 | return "$aname$str</a>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 586 | } |
| 587 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 588 | $REFCOUNTS_LOADED = 0; |
| 589 | |
| 590 | sub load_refcounts{ |
| 591 | $REFCOUNTS_LOADED = 1; |
| 592 | |
| 593 | use File::Basename; |
| 594 | my $myname, $mydir, $myext; |
| 595 | ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*'); |
| 596 | chop $mydir; # remove trailing '/' |
| 597 | ($myname, $mydir, $myext) = fileparse($mydir, '\..*'); |
| 598 | chop $mydir; # remove trailing '/' |
| 599 | $mydir = getcwd() . "$dd$mydir" |
| 600 | unless $mydir =~ s|^/|/|; |
| 601 | local $_; |
| 602 | my $filename = "$mydir${dd}api${dd}refcounts.dat"; |
| 603 | open(REFCOUNT_FILE, "<$filename") || die "\n$!\n"; |
| 604 | print "[loading API refcount data]"; |
| 605 | while (<REFCOUNT_FILE>) { |
Fred Drake | c2578c5 | 2000-04-10 18:26:45 +0000 | [diff] [blame] | 606 | if (/([a-zA-Z0-9_]+):PyObject\*:([a-zA-Z0-9_]*):(0|[-+]1|null):(.*)$/) { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 607 | my($func, $param, $count, $comment) = ($1, $2, $3, $4); |
| 608 | #print "\n$func($param) --> $count"; |
| 609 | $REFCOUNTS{"$func:$param"} = $count; |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | sub get_refcount{ |
| 615 | my ($func, $param) = @_; |
| 616 | load_refcounts() |
| 617 | unless $REFCOUNTS_LOADED; |
| 618 | return $REFCOUNTS{"$func:$param"}; |
| 619 | } |
| 620 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 621 | sub do_env_cfuncdesc{ |
| 622 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 623 | my $return_type = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 624 | my $function_name = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 625 | my $arg_list = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 626 | my $idx = make_str_index_entry( |
| 627 | "<tt class='cfunction'>$function_name()</tt>" . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 628 | $idx =~ s/ \(.*\)//; |
| 629 | $idx =~ s/\(\)//; # ???? |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 630 | my $result_rc = get_refcount($function_name, ''); |
| 631 | my $rcinfo = ''; |
| 632 | if ($result_rc eq '+1') { |
| 633 | $rcinfo = '<span class="label">Return value:</span>' |
| 634 | . "\n <span class=\"value\">New reference.</span>"; |
| 635 | } |
| 636 | elsif ($result_rc eq '0') { |
| 637 | $rcinfo = '<span class="label">Return value:</span>' |
| 638 | . "\n <span class=\"value\">Borrowed reference.</span>"; |
| 639 | } |
Fred Drake | c2578c5 | 2000-04-10 18:26:45 +0000 | [diff] [blame] | 640 | elsif ($result_rc eq 'null') { |
| 641 | $rcinfo = '<span class="label">Return value:</span>' |
| 642 | . "\n <span class=\"value\">Always NULL.</span>"; |
| 643 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 644 | if ($rcinfo ne '') { |
| 645 | $rcinfo = "\n<div class=\"refcount-info\">\n $rcinfo\n</div>"; |
| 646 | } |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 647 | return "<dl><dt>$return_type <b>$idx</b> (<var>$arg_list</var>)\n<dd>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 648 | . $rcinfo |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 649 | . $_ |
| 650 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 651 | } |
| 652 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 653 | sub do_env_csimplemacrodesc{ |
| 654 | local($_) = @_; |
| 655 | my $name = next_argument(); |
| 656 | my $idx = make_str_index_entry("<tt class='macro'>$name</tt>"); |
| 657 | return "<dl><dt><b>$idx</b>\n<dd>" |
| 658 | . $_ |
| 659 | . '</dl>' |
| 660 | } |
| 661 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 662 | sub do_env_ctypedesc{ |
| 663 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 664 | my $index_name = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 665 | my $type_name = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 666 | $index_name = $type_name |
| 667 | unless $index_name; |
| 668 | my($name,$aname,$ahref) = new_link_info(); |
| 669 | add_index_entry("<tt class='ctype'>$index_name</tt> (C type)", $ahref); |
| 670 | return "<dl><dt><b><tt class='ctype'>$aname$type_name</a></tt></b>\n<dd>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 671 | . $_ |
| 672 | . '</dl>' |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | sub do_env_cvardesc{ |
| 676 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 677 | my $var_type = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 678 | my $var_name = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 679 | my $idx = make_str_index_entry("<tt class='cdata'>$var_name</tt>" |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 680 | . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 681 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 682 | return "<dl><dt>$var_type <b>$idx</b>\n" |
| 683 | . '<dd>' |
| 684 | . $_ |
| 685 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 686 | } |
| 687 | |
| 688 | sub do_env_funcdesc{ |
| 689 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 690 | my $function_name = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 691 | my $arg_list = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 692 | my $idx = make_str_index_entry("<tt class='function'>$function_name()</tt>" |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 693 | . get_indexsubitem()); |
| 694 | $idx =~ s/ \(.*\)//; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 695 | $idx =~ s/\(\)<\/tt>/<\/tt>/; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 696 | 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] | 697 | } |
| 698 | |
| 699 | sub do_env_funcdescni{ |
| 700 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 701 | my $function_name = next_argument(); |
| 702 | my $arg_list = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 703 | return "<dl><dt><b><tt class='function'>$function_name</tt></b>" |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 704 | . " (<var>$arg_list</var>)\n" |
| 705 | . '<dd>' |
| 706 | . $_ |
| 707 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 708 | } |
| 709 | |
| 710 | sub do_cmd_funcline{ |
| 711 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 712 | my $function_name = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 713 | my $arg_list = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 714 | my $prefix = "<tt class='function'>$function_name()</tt>"; |
Fred Drake | ca675e4 | 1999-04-21 15:58:58 +0000 | [diff] [blame] | 715 | my $idx = make_str_index_entry($prefix . get_indexsubitem()); |
| 716 | $prefix =~ s/\(\)//; |
| 717 | |
| 718 | return "<dt><b>$prefix</b> (<var>$arg_list</var>)\n<dd>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 719 | } |
| 720 | |
Fred Drake | 6b3fb78 | 1999-07-12 16:50:09 +0000 | [diff] [blame] | 721 | sub do_cmd_funclineni{ |
| 722 | local($_) = @_; |
| 723 | my $function_name = next_argument(); |
| 724 | my $arg_list = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 725 | my $prefix = "<tt class='function'>$function_name</tt>"; |
Fred Drake | 6b3fb78 | 1999-07-12 16:50:09 +0000 | [diff] [blame] | 726 | |
| 727 | return "<dt><b>$prefix</b> (<var>$arg_list</var>)\n<dd>" . $_; |
| 728 | } |
| 729 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 730 | # Change this flag to index the opcode entries. I don't think it's very |
| 731 | # useful to index them, since they're only presented to describe the dis |
| 732 | # module. |
| 733 | # |
| 734 | $INDEX_OPCODES = 0; |
| 735 | |
| 736 | sub do_env_opcodedesc{ |
| 737 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 738 | my $opcode_name = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 739 | my $arg_list = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 740 | my $idx; |
| 741 | if ($INDEX_OPCODES) { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 742 | $idx = make_str_index_entry("<tt class='opcode'>$opcode_name</tt>" |
| 743 | . " (byte code instruction)"); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 744 | $idx =~ s/ \(byte code instruction\)//; |
| 745 | } |
| 746 | else { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 747 | $idx = "<tt class='opcode'>$opcode_name</tt>"; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 748 | } |
| 749 | my $stuff = "<dl><dt><b>$idx</b>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 750 | if ($arg_list) { |
| 751 | $stuff .= " <var>$arg_list</var>"; |
| 752 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 753 | return $stuff . "\n<dd>" . $_ . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 754 | } |
| 755 | |
| 756 | sub do_env_datadesc{ |
| 757 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 758 | my $dataname = next_argument(); |
| 759 | my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 760 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 761 | return "<dl><dt><b>$idx</b>\n<dd>" |
| 762 | . $_ |
| 763 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 764 | } |
| 765 | |
| 766 | sub do_env_datadescni{ |
| 767 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 768 | my $idx = next_argument(); |
| 769 | if (! $STRING_INDEX_TT) { |
| 770 | $idx = "<tt>$idx</tt>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 771 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 772 | return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 773 | } |
| 774 | |
| 775 | sub do_cmd_dataline{ |
| 776 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 777 | my $data_name = next_argument(); |
| 778 | my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem()); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 779 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 780 | return "<dt><b>$idx</b><dd>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 781 | } |
| 782 | |
Fred Drake | adb272c | 2000-04-10 17:47:14 +0000 | [diff] [blame] | 783 | sub do_cmd_datalineni{ |
| 784 | local($_) = @_; |
| 785 | my $data_name = next_argument(); |
| 786 | return "<dt><b><tt>$data_name</tt></b><dd>" . $_; |
| 787 | } |
| 788 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 789 | sub do_env_excdesc{ |
| 790 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 791 | my $excname = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 792 | my $idx = make_str_index_entry("<tt class='exception'>$excname</tt>"); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 793 | return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>' |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 794 | } |
| 795 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 796 | sub do_env_fulllineitems{ return do_env_itemize(@_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 797 | |
| 798 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 799 | sub do_env_classdesc{ |
| 800 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 801 | $THIS_CLASS = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 802 | my $arg_list = next_argument(); |
| 803 | $idx = make_str_index_entry( |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 804 | "<tt class='class'>$THIS_CLASS</tt> (class in $THIS_MODULE)" ); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 805 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 806 | 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] | 807 | } |
| 808 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 809 | |
| 810 | sub do_env_methoddesc{ |
| 811 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 812 | my $class_name = next_optional_argument(); |
| 813 | $class_name = $THIS_CLASS |
| 814 | unless $class_name; |
Fred Drake | 5a0ca4e | 1999-01-12 04:16:51 +0000 | [diff] [blame] | 815 | my $method = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 816 | my $arg_list = next_argument(); |
| 817 | my $extra = ''; |
| 818 | if ($class_name) { |
| 819 | $extra = " ($class_name method)"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 820 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 821 | my $idx = make_str_index_entry("<tt class='method'>$method()</tt>$extra"); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 822 | $idx =~ s/ \(.*\)//; |
| 823 | $idx =~ s/\(\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 824 | 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] | 825 | } |
| 826 | |
| 827 | |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 828 | sub do_cmd_methodline{ |
| 829 | local($_) = @_; |
| 830 | my $class_name = next_optional_argument(); |
| 831 | $class_name = $THIS_CLASS |
| 832 | unless $class_name; |
| 833 | my $method = next_argument(); |
| 834 | my $arg_list = next_argument(); |
| 835 | my $extra = ''; |
| 836 | if ($class_name) { |
| 837 | $extra = " ($class_name method)"; |
| 838 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 839 | my $idx = make_str_index_entry("<tt class='method'>$method()</tt>$extra"); |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 840 | $idx =~ s/ \(.*\)//; |
| 841 | $idx =~ s/\(\)//; |
| 842 | return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" |
| 843 | . $_; |
| 844 | } |
| 845 | |
| 846 | |
Fred Drake | d64a40d | 1998-09-10 18:59:13 +0000 | [diff] [blame] | 847 | sub do_cmd_methodlineni{ |
| 848 | local($_) = @_; |
| 849 | next_optional_argument(); |
| 850 | my $method = next_argument(); |
| 851 | my $arg_list = next_argument(); |
| 852 | return "<dt><b>$method</b> (<var>$arg_list</var>)\n<dd>" |
| 853 | . $_; |
| 854 | } |
| 855 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 856 | sub do_env_methoddescni{ |
| 857 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 858 | next_optional_argument(); |
| 859 | my $method = next_argument(); |
| 860 | my $arg_list = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 861 | return "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>" |
| 862 | . $_ |
| 863 | . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 864 | } |
| 865 | |
| 866 | |
| 867 | sub do_env_memberdesc{ |
| 868 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 869 | my $class = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 870 | my $member = next_argument(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 871 | $class = $THIS_CLASS |
| 872 | unless $class; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 873 | my $extra = ''; |
Fred Drake | 085b812 | 1999-04-21 14:00:29 +0000 | [diff] [blame] | 874 | $extra = " ($class attribute)" |
| 875 | if ($class ne ''); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 876 | my $idx = make_str_index_entry("<tt class='member'>$member</tt>$extra"); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 877 | $idx =~ s/ \(.*\)//; |
| 878 | $idx =~ s/\(\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 879 | return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 880 | } |
| 881 | |
| 882 | |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 883 | sub do_cmd_memberline{ |
| 884 | local($_) = @_; |
| 885 | my $class = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 886 | my $member = next_argument(); |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 887 | $class = $THIS_CLASS |
| 888 | unless $class; |
| 889 | my $extra = ''; |
Fred Drake | 085b812 | 1999-04-21 14:00:29 +0000 | [diff] [blame] | 890 | $extra = " ($class attribute)" |
| 891 | if ($class ne ''); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 892 | my $idx = make_str_index_entry("<tt class='member'>$member</tt>$extra"); |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 893 | $idx =~ s/ \(.*\)//; |
| 894 | $idx =~ s/\(\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 895 | return "<dt><b>$idx</b><dd>" . $_; |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 896 | } |
| 897 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 898 | sub do_env_memberdescni{ |
| 899 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 900 | next_optional_argument(); |
| 901 | my $member = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 902 | return "<dl><dt><b><tt class='member'>$member</tt></b>\n<dd>" |
| 903 | . $_ |
| 904 | . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 905 | } |
| 906 | |
| 907 | |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 908 | sub do_cmd_memberlineni{ |
| 909 | local($_) = @_; |
| 910 | next_optional_argument(); |
| 911 | my $member = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 912 | return "<dt><b><tt class='member'>$member</tt></b><dd>" . $_; |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 913 | } |
| 914 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 915 | @col_aligns = ('<td>', '<td>', '<td>', '<td>'); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 916 | |
Fred Drake | 15799ed | 1999-02-12 19:23:17 +0000 | [diff] [blame] | 917 | $TABLE_HEADER_BGCOLOR = $NAV_BGCOLOR; |
| 918 | |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 919 | sub fix_font{ |
| 920 | # do a little magic on a font name to get the right behavior in the first |
| 921 | # column of the output table |
| 922 | my $font = @_[0]; |
| 923 | if ($font eq 'textrm') { |
| 924 | $font = ''; |
| 925 | } |
| 926 | elsif ($font eq 'file' || $font eq 'filenq') { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 927 | $font = 'tt class="file"'; |
| 928 | } |
| 929 | elsif ($font eq 'member') { |
| 930 | $font = 'tt class="member"'; |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 931 | } |
| 932 | return $font; |
| 933 | } |
| 934 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 935 | sub figure_column_alignment{ |
| 936 | my $a = @_[0]; |
| 937 | my $mark = substr($a, 0, 1); |
| 938 | my $r = ''; |
| 939 | if ($mark eq 'c') |
| 940 | { $r = ' align="center"'; } |
| 941 | elsif ($mark eq 'r') |
| 942 | { $r = ' align="right"'; } |
| 943 | elsif ($mark eq 'l') |
| 944 | { $r = ' align="left"'; } |
| 945 | elsif ($mark eq 'p') |
| 946 | { $r = ' align="left"'; } |
| 947 | return $r; |
| 948 | } |
| 949 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 950 | sub setup_column_alignments{ |
| 951 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 952 | my($s1,$s2,$s3,$s4) = split(/[|]/,$_); |
| 953 | my $a1 = figure_column_alignment($s1); |
| 954 | my $a2 = figure_column_alignment($s2); |
| 955 | my $a3 = figure_column_alignment($s3); |
| 956 | my $a4 = figure_column_alignment($s4); |
| 957 | $col_aligns[0] = "<td$a1 valign=\"baseline\">"; |
| 958 | $col_aligns[1] = "<td$a2>"; |
| 959 | $col_aligns[2] = "<td$a3>"; |
| 960 | $col_aligns[3] = "<td$a4>"; |
Fred Drake | 79189b5 | 1999-04-28 13:54:30 +0000 | [diff] [blame] | 961 | # return the aligned header start tags |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 962 | return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>"); |
| 963 | } |
| 964 | |
| 965 | sub get_table_col1_fonts{ |
| 966 | my $font = $globals{'lineifont'}; |
| 967 | my ($sfont,$efont) = ('', ''); |
| 968 | if ($font) { |
| 969 | $sfont = "<$font>"; |
| 970 | $efont = "</$font>"; |
| 971 | $efont =~ s/ .*>/>/; |
| 972 | } |
| 973 | return ($font, $sfont, $efont); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 974 | } |
| 975 | |
| 976 | sub do_env_tableii{ |
| 977 | local($_) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 978 | my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument()); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 979 | my $font = fix_font(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 980 | my $h1 = next_argument(); |
| 981 | my $h2 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 982 | s/[\s\n]+//; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 983 | $globals{'lineifont'} = $font; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 984 | my $a1 = $col_aligns[0]; |
| 985 | my $a2 = $col_aligns[1]; |
| 986 | s/\\lineii</\\lineii[$a1|$a2]</g; |
| 987 | return '<table border align="center" style="border-collapse: collapse">' |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 988 | . "\n <thead>" |
| 989 | . "\n <tr$TABLE_HEADER_BGCOLOR>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 990 | . "\n $th1<b>$h1</b>\ </th>" |
| 991 | . "\n $th2<b>$h2</b>\ </th>" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 992 | . "\n </thead>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 993 | . "\n <tbody valign='baseline'>" |
| 994 | . $_ |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 995 | . "\n </tbody>" |
| 996 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 997 | } |
| 998 | |
| 999 | sub do_cmd_lineii{ |
| 1000 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1001 | my $aligns = next_optional_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1002 | my $c1 = next_argument(); |
| 1003 | my $c2 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1004 | s/[\s\n]+//; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1005 | my($font,$sfont,$efont) = get_table_col1_fonts(); |
| 1006 | $c2 = ' ' if ($c2 eq ''); |
| 1007 | my($c1align,$c2align) = split('\|', $aligns); |
| 1008 | my $padding = ''; |
| 1009 | if ($c1align =~ /align="right"/) { |
| 1010 | $padding = ' '; |
Fred Drake | 58b2bfd | 1998-04-02 20:14:04 +0000 | [diff] [blame] | 1011 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1012 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
| 1013 | . " $c2align$c2</td>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1014 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1015 | } |
| 1016 | |
| 1017 | sub do_env_tableiii{ |
| 1018 | local($_) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1019 | my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument()); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1020 | my $font = fix_font(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1021 | my $h1 = next_argument(); |
| 1022 | my $h2 = next_argument(); |
| 1023 | my $h3 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1024 | s/[\s\n]+//; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1025 | $globals{'lineifont'} = $font; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1026 | my $a1 = $col_aligns[0]; |
| 1027 | my $a2 = $col_aligns[1]; |
| 1028 | my $a3 = $col_aligns[2]; |
| 1029 | s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g; |
| 1030 | return '<table border align="center" style="border-collapse: collapse">' |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1031 | . "\n <thead>" |
| 1032 | . "\n <tr$TABLE_HEADER_BGCOLOR>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1033 | . "\n $th1<b>$h1</b>\ </th>" |
| 1034 | . "\n $th2<b>$h2</b>\ </th>" |
| 1035 | . "\n $th3<b>$h3</b>\ </th>" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1036 | . "\n </thead>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1037 | . "\n <tbody valign='baseline'>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1038 | . $_ |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1039 | . "\n </tbody>" |
| 1040 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1041 | } |
| 1042 | |
| 1043 | sub do_cmd_lineiii{ |
| 1044 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1045 | my $aligns = next_optional_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1046 | my $c1 = next_argument(); |
| 1047 | my $c2 = next_argument(); |
| 1048 | my $c3 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1049 | s/[\s\n]+//; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1050 | my($font,$sfont,$efont) = get_table_col1_fonts(); |
| 1051 | $c3 = ' ' if ($c3 eq ''); |
| 1052 | my($c1align,$c2align,$c3align) = split('\|', $aligns); |
| 1053 | my $padding = ''; |
| 1054 | if ($c1align =~ /align="right"/) { |
| 1055 | $padding = ' '; |
Fred Drake | 58b2bfd | 1998-04-02 20:14:04 +0000 | [diff] [blame] | 1056 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1057 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1058 | . " $c2align$c2</td>\n" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1059 | . " $c3align$c3</td>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1060 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1061 | } |
| 1062 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1063 | sub do_env_tableiv{ |
| 1064 | local($_) = @_; |
| 1065 | my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument()); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1066 | my $font = fix_font(next_argument()); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1067 | my $h1 = next_argument(); |
| 1068 | my $h2 = next_argument(); |
| 1069 | my $h3 = next_argument(); |
| 1070 | my $h4 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1071 | s/[\s\n]+//; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1072 | $globals{'lineifont'} = $font; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1073 | my $a1 = $col_aligns[0]; |
| 1074 | my $a2 = $col_aligns[1]; |
| 1075 | my $a3 = $col_aligns[2]; |
| 1076 | my $a4 = $col_aligns[3]; |
| 1077 | s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g; |
| 1078 | return '<table border align="center" style="border-collapse: collapse">' |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1079 | . "\n <thead>" |
| 1080 | . "\n <tr$TABLE_HEADER_BGCOLOR>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1081 | . "\n $th1<b>$h1</b>\ </th>" |
| 1082 | . "\n $th2<b>$h2</b>\ </th>" |
| 1083 | . "\n $th3<b>$h3</b>\ </th>" |
| 1084 | . "\n $th4<b>$h4</b>\ </th>" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1085 | . "\n </thead>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1086 | . "\n <tbody valign='baseline'>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1087 | . $_ |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1088 | . "\n </tbody>" |
| 1089 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1090 | } |
| 1091 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1092 | sub do_cmd_lineiv{ |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1093 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1094 | my $aligns = next_optional_argument(); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1095 | my $c1 = next_argument(); |
| 1096 | my $c2 = next_argument(); |
| 1097 | my $c3 = next_argument(); |
| 1098 | my $c4 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1099 | s/[\s\n]+//; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1100 | my($font,$sfont,$efont) = get_table_col1_fonts(); |
| 1101 | $c4 = ' ' if ($c4 eq ''); |
| 1102 | my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns); |
| 1103 | my $padding = ''; |
| 1104 | if ($c1align =~ /align="right"/) { |
| 1105 | $padding = ' '; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1106 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1107 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1108 | . " $c2align$c2</td>\n" |
| 1109 | . " $c3align$c3</td>\n" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1110 | . " $c4align$c4</td>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1111 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1112 | } |
| 1113 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1114 | sub do_cmd_maketitle { |
| 1115 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1116 | my $the_title = "\n<div class='titlepage'><center>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1117 | if ($t_title) { |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 1118 | $the_title .= "\n<h1>$t_title</h1>"; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1119 | } else { write_warnings("\nThis document has no title."); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1120 | if ($t_author) { |
| 1121 | if ($t_authorURL) { |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1122 | my $href = translate_commands($t_authorURL); |
Fred Drake | 2d1f81e | 1999-02-09 16:03:31 +0000 | [diff] [blame] | 1123 | $href = make_named_href('author', $href, |
| 1124 | "<b><font size='+2'>$t_author</font></b>"); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1125 | $the_title .= "\n<p>$href</p>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1126 | } else { |
Fred Drake | 2d1f81e | 1999-02-09 16:03:31 +0000 | [diff] [blame] | 1127 | $the_title .= ("\n<p><b><font size='+2'>$t_author</font></b></p>"); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1128 | } |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1129 | } else { write_warnings("\nThere is no author for this document."); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1130 | if ($t_institute) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1131 | $the_title .= "\n<p>$t_institute</p>";} |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 1132 | if ($DEVELOPER_ADDRESS) { |
| 1133 | $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1134 | if ($t_affil) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1135 | $the_title .= "\n<p><i>$t_affil</i></p>";} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1136 | if ($t_date) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1137 | $the_title .= "\n<p><strong>$t_date</strong>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1138 | if ($PYTHON_VERSION) { |
| 1139 | $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";} |
| 1140 | $the_title .= "</p>" |
| 1141 | } |
| 1142 | if ($t_address) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1143 | $the_title .= "\n<p>$t_address</p>"; |
| 1144 | } else { $the_title .= "\n<p>"} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1145 | if ($t_email) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1146 | $the_title .= "\n<p>$t_email</p>"; |
| 1147 | }# else { $the_title .= "</p>" } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 1148 | $the_title .= "\n</center></div>"; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1149 | return $the_title . $_ ; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1150 | } |
| 1151 | |
| 1152 | |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1153 | # |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1154 | # Module synopsis support |
| 1155 | # |
| 1156 | |
| 1157 | require SynopsisTable; |
| 1158 | |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1159 | sub get_chapter_id(){ |
| 1160 | my $id = do_cmd_thechapter(''); |
Fred Drake | 45f2601 | 1998-08-04 22:07:18 +0000 | [diff] [blame] | 1161 | $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/; |
| 1162 | $id =~ s/\.//; |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1163 | return $id; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1164 | } |
| 1165 | |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1166 | %ModuleSynopses = ('chapter' => 'SynopsisTable instance'); |
| 1167 | |
| 1168 | sub get_synopsis_table($){ |
| 1169 | my($chap) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1170 | my $st = $ModuleSynopses{$chap}; |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1171 | my $key; |
| 1172 | foreach $key (keys %ModuleSynopses) { |
| 1173 | if ($key eq $chap) { |
| 1174 | return $ModuleSynopses{$chap}; |
| 1175 | } |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1176 | } |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1177 | $st = SynopsisTable->new(); |
| 1178 | $ModuleSynopses{$chap} = $st; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1179 | return $st; |
| 1180 | } |
| 1181 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1182 | sub do_cmd_moduleauthor{ |
| 1183 | local($_) = @_; |
| 1184 | next_argument(); |
| 1185 | next_argument(); |
| 1186 | return $_; |
| 1187 | } |
| 1188 | |
| 1189 | sub do_cmd_sectionauthor{ |
| 1190 | local($_) = @_; |
| 1191 | next_argument(); |
| 1192 | next_argument(); |
| 1193 | return $_; |
| 1194 | } |
| 1195 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1196 | sub do_cmd_declaremodule{ |
| 1197 | local($_) = @_; |
| 1198 | my $key = next_optional_argument(); |
| 1199 | my $type = next_argument(); |
| 1200 | my $name = next_argument(); |
| 1201 | my $st = get_synopsis_table(get_chapter_id()); |
| 1202 | # |
| 1203 | $key = $name unless $key; |
| 1204 | $type = 'built-in' if $type eq 'builtin'; |
| 1205 | $st->declare($name, $key, $type); |
| 1206 | define_module($type, $name); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1207 | return anchor_label("module-$key",$CURRENT_FILE,$_) |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1208 | } |
| 1209 | |
| 1210 | sub do_cmd_modulesynopsis{ |
| 1211 | local($_) = @_; |
| 1212 | my $st = get_synopsis_table(get_chapter_id()); |
Fred Drake | 1cc5899 | 1999-04-13 22:08:59 +0000 | [diff] [blame] | 1213 | $st->set_synopsis($THIS_MODULE, translate_commands(next_argument())); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1214 | return $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1215 | } |
| 1216 | |
| 1217 | sub do_cmd_localmoduletable{ |
| 1218 | local($_) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1219 | my $chap = get_chapter_id(); |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1220 | return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1221 | } |
| 1222 | |
| 1223 | sub process_all_localmoduletables{ |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1224 | while (/<tex2html-localmoduletable><(\d+)>/) { |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1225 | my $match = $&; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1226 | my $chap = $1; |
| 1227 | my $st = get_synopsis_table($chap); |
| 1228 | my $data = $st->tohtml(); |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1229 | s/$match/$data/; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1230 | } |
| 1231 | } |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1232 | sub process_python_state{ |
| 1233 | process_all_localmoduletables(); |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1234 | } |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1235 | |
| 1236 | |
| 1237 | # |
| 1238 | # "See also:" -- references placed at the end of a \section |
| 1239 | # |
| 1240 | |
| 1241 | sub do_env_seealso{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1242 | return "<div class='seealso'>\n " |
| 1243 | . "<p class='heading'><b>See Also:</b></p>\n" |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 1244 | . @_[0] |
| 1245 | . '</div>'; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1246 | } |
| 1247 | |
| 1248 | sub do_cmd_seemodule{ |
| 1249 | # Insert the right magic to jump to the module definition. This should |
| 1250 | # work most of the time, at least for repeat builds.... |
| 1251 | local($_) = @_; |
| 1252 | my $key = next_optional_argument(); |
| 1253 | my $module = next_argument(); |
| 1254 | my $text = next_argument(); |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 1255 | my $period = '.'; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1256 | $key = $module |
| 1257 | unless $key; |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 1258 | if ($text =~ /\.$/) { |
| 1259 | $period = ''; |
| 1260 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1261 | return '<dl compact class="seemodule">' |
| 1262 | . "\n <dt>Module <b><tt class='module'><a href='module-$key.html'>" |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 1263 | . "$module</a></tt>:</b>" |
| 1264 | . "\n <dd>$text$period\n </dl>" |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 1265 | . $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1266 | } |
| 1267 | |
| 1268 | sub do_cmd_seetext{ |
Fred Drake | 79189b5 | 1999-04-28 13:54:30 +0000 | [diff] [blame] | 1269 | local($_) = @_; |
| 1270 | my $content = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1271 | return '<div class="seetext"><p>' . $content . '</div>' . $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1272 | } |
| 1273 | |
| 1274 | |
| 1275 | # |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1276 | # Definition list support. |
| 1277 | # |
| 1278 | |
| 1279 | sub do_env_definitions{ |
| 1280 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1281 | return "<dl class='definitions'>$_</dl>\n"; |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1282 | } |
| 1283 | |
| 1284 | sub do_cmd_term{ |
| 1285 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1286 | my $term = next_argument(); |
| 1287 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1288 | # could easily add an index entry here... |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1289 | return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_; |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1290 | } |
| 1291 | |
| 1292 | |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 1293 | process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_); |
| 1294 | code # {} |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 1295 | declaremodule # [] # {} # {} |
| 1296 | memberline # [] # {} |
| 1297 | methodline # [] # {} # {} |
| 1298 | modulesynopsis # {} |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1299 | platform # {} |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 1300 | samp # {} |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 1301 | setindexsubitem # {} |
Fred Drake | f32834c | 1999-02-12 22:06:32 +0000 | [diff] [blame] | 1302 | withsubitem # {} # {} |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 1303 | _RAW_ARG_DEFERRED_CMDS_ |
| 1304 | |
| 1305 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1306 | 1; # This must be the last line |