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