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