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