Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1 | % |
Fred Drake | 6663b22 | 1998-03-06 22:33:06 +0000 | [diff] [blame] | 2 | % python.sty for the Python docummentation [works only with with Latex2e] |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 3 | % |
| 4 | |
| 5 | \NeedsTeXFormat{LaTeX2e}[1995/12/01] |
| 6 | \ProvidesPackage{python} |
Fred Drake | c0b2e45 | 1998-03-25 14:53:43 +0000 | [diff] [blame] | 7 | [1998/01/11 LaTeX package (Python markup)] |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 8 | |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 9 | % Uncomment these two lines to ignore the paper size and make the page |
| 10 | % size more like a typical published manual. |
| 11 | %\renewcommand{\paperheight}{9in} |
| 12 | %\renewcommand{\paperwidth}{8.5in} % typical squarish manual |
| 13 | %\renewcommand{\paperwidth}{7in} % O'Reilly ``Programmming Python'' |
| 14 | |
Fred Drake | 454a4fb | 1998-04-01 22:20:14 +0000 | [diff] [blame] | 15 | % These packages can be used to add marginal annotations which indicate |
| 16 | % index entries and labels; useful for reviewing this messy documentation! |
| 17 | % |
| 18 | %\RequirePackage{showkeys} |
| 19 | %\RequirePackage{showidx} |
| 20 | |
Fred Drake | c0b2e45 | 1998-03-25 14:53:43 +0000 | [diff] [blame] | 21 | % for PDF output, use maximal compression & a lot of other stuff |
| 22 | % (test for PDF recommended by Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov>) |
| 23 | % |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 24 | \newif\ifpy@doing@page@targets |
| 25 | \py@doing@page@targetsfalse |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 26 | |
Fred Drake | c0b2e45 | 1998-03-25 14:53:43 +0000 | [diff] [blame] | 27 | \ifx\pdfoutput\undefined\else\ifcase\pdfoutput |
Fred Drake | c0b2e45 | 1998-03-25 14:53:43 +0000 | [diff] [blame] | 28 | \else |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 29 | \input{pdfcolor} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 30 | \let\py@LinkColor=\NavyBlue |
| 31 | \let\py@NormalColor=\Black |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 32 | \pdfcompresslevel=9 |
Fred Drake | ba1700c | 1998-05-11 20:42:54 +0000 | [diff] [blame] | 33 | \pdfpagewidth=\paperwidth % page width of PDF output |
| 34 | \pdfpageheight=\paperheight % page height of PDF output |
Fred Drake | ebcb658 | 1998-03-06 21:25:17 +0000 | [diff] [blame] | 35 | % |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 36 | % Pad the number with '0' to 3 digits wide so no page name is a prefix |
| 37 | % of any other. |
| 38 | % |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 39 | \newcommand{\py@targetno}[1]{\ifnum#1<100 0\fi\ifnum#1<10 0\fi#1} |
| 40 | \newcommand{\py@pageno}{\py@targetno\thepage} |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 41 | % |
Fred Drake | ebcb658 | 1998-03-06 21:25:17 +0000 | [diff] [blame] | 42 | % This definition allows the entries in the page-view of the ToC to be |
| 43 | % active links. Some work, some don't. |
| 44 | % |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 45 | \let\py@OldContentsline=\contentsline |
Fred Drake | aa2aea0 | 1999-01-27 17:37:36 +0000 | [diff] [blame] | 46 | % |
| 47 | % Macro that takes two args: the name to link to and the content of |
| 48 | % the link. This takes care of the PDF magic, getting the colors |
| 49 | % the same for each link, and avoids having lots of garbage all over |
| 50 | % this style file. |
| 51 | \newcommand{\py@linkToName}[2]{% |
| 52 | \pdfannotlink attr{/Border [0 0 0]} goto name{#1}% |
| 53 | \py@LinkColor#2\py@NormalColor% |
| 54 | \pdfendlink% |
| 55 | } |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 56 | % Compute the padded page number separately since we end up with a pair of |
| 57 | % \relax tokens; this gets the right string computed and works. |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 58 | \renewcommand{\contentsline}[3]{% |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 59 | \def\my@pageno{\py@targetno{#3}}% |
Fred Drake | aa2aea0 | 1999-01-27 17:37:36 +0000 | [diff] [blame] | 60 | \py@OldContentsline{#1}{\py@linkToName{page\my@pageno}{#2}}{#3}% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 61 | } |
Fred Drake | ebcb658 | 1998-03-06 21:25:17 +0000 | [diff] [blame] | 62 | \AtEndDocument{ |
Fred Drake | c0b2e45 | 1998-03-25 14:53:43 +0000 | [diff] [blame] | 63 | \InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{} |
Fred Drake | ebcb658 | 1998-03-06 21:25:17 +0000 | [diff] [blame] | 64 | } |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 65 | \newcommand{\py@target}[1]{% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 66 | \ifpy@doing@page@targets% |
Fred Drake | 9b8afde | 1999-03-24 14:16:17 +0000 | [diff] [blame] | 67 | {\pdfdest name{#1} xyz}% |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 68 | \fi% |
| 69 | } |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 70 | \let\py@OldLabel=\label |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 71 | \renewcommand{\label}[1]{% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 72 | \py@OldLabel{#1}% |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 73 | \py@target{label-#1}% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 74 | } |
Fred Drake | ba1700c | 1998-05-11 20:42:54 +0000 | [diff] [blame] | 75 | % This stuff adds a page# destination to every PDF page, where # is three |
| 76 | % digits wide, padded with leading zeros. This doesn't really help with |
| 77 | % the frontmatter, but does fine with the body. |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 78 | % |
| 79 | % This is *heavily* based on the hyperref package. |
| 80 | % |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 81 | \def\@begindvi{% |
| 82 | \unvbox \@begindvibox |
| 83 | \@hyperfixhead |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 84 | } |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 85 | \def\@hyperfixhead{% |
| 86 | \let\H@old@thehead\@thehead |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 87 | \global\def\@foo{\py@target{page\py@pageno}}% |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 88 | \expandafter\ifx\expandafter\@empty\H@old@thehead |
| 89 | \def\H@old@thehead{\hfil}\fi |
| 90 | \def\@thehead{\@foo\relax\H@old@thehead}% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 91 | } |
Fred Drake | c0b2e45 | 1998-03-25 14:53:43 +0000 | [diff] [blame] | 92 | \fi\fi |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 93 | |
| 94 | % Increase printable page size (copied from fullpage.sty) |
| 95 | \topmargin 0pt |
| 96 | \advance \topmargin by -\headheight |
| 97 | \advance \topmargin by -\headsep |
| 98 | |
| 99 | % attempt to work a little better for A4 users |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 100 | \textheight \paperheight |
| 101 | \advance\textheight by -2in |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 102 | |
| 103 | \oddsidemargin 0pt |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 104 | \evensidemargin 0pt |
| 105 | %\evensidemargin -.25in % for ``manual size'' documents |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 106 | \marginparwidth 0.5in |
| 107 | |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 108 | \textwidth \paperwidth |
| 109 | \advance\textwidth by -2in |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 110 | |
| 111 | |
| 112 | % Style parameters and macros used by most documents here |
| 113 | \raggedbottom |
| 114 | \sloppy |
| 115 | \parindent = 0mm |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 116 | \parskip = 2mm |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 117 | \hbadness = 5000 % don't print trivial gripes |
| 118 | |
| 119 | \pagestyle{empty} % start this way; change for |
| 120 | \pagenumbering{roman} % ToC & chapters |
| 121 | \setcounter{secnumdepth}{1} |
| 122 | |
| 123 | % Use this to set the font family for headers and other decor: |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 124 | \newcommand{\py@HeaderFamily}{\sffamily} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 125 | |
| 126 | % Redefine the 'normal' header/footer style when using "fancyhdr" package: |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 127 | \@ifundefined{fancyhf}{}{ |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 128 | % Use \pagestyle{normal} as the primary pagestyle for text. |
| 129 | \fancypagestyle{normal}{ |
| 130 | \fancyhf{} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 131 | \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}} |
| 132 | \fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}} |
| 133 | \fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 134 | \renewcommand{\headrulewidth}{0pt} |
| 135 | \renewcommand{\footrulewidth}{0.4pt} |
| 136 | } |
| 137 | % Update the plain style so we get the page number & footer line, |
| 138 | % but not a chapter or section title. This is to keep the first |
| 139 | % page of a chapter and the blank page between chapters `clean.' |
| 140 | \fancypagestyle{plain}{ |
| 141 | \fancyhf{} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 142 | \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 143 | \renewcommand{\headrulewidth}{0pt} |
| 144 | \renewcommand{\footrulewidth}{0.4pt} |
| 145 | } |
| 146 | % Redefine \cleardoublepage so that the blank page between chapters |
| 147 | % gets the plain style and not the fancy style. This is described |
| 148 | % in the documentation for the fancyhdr package by Piet von Oostrum. |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 149 | \@ifundefined{chapter}{}{ |
Fred Drake | 28f1391 | 1998-03-04 21:47:59 +0000 | [diff] [blame] | 150 | \renewcommand{\cleardoublepage}{ |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 151 | \clearpage\if@openright \ifodd\c@page\else |
Fred Drake | 28f1391 | 1998-03-04 21:47:59 +0000 | [diff] [blame] | 152 | \hbox{} |
| 153 | \thispagestyle{plain} |
| 154 | \newpage |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 155 | \if@twocolumn\hbox{}\newpage\fi\fi\fi |
Fred Drake | 28f1391 | 1998-03-04 21:47:59 +0000 | [diff] [blame] | 156 | } |
| 157 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 158 | } |
| 159 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 160 | % This sets up the {verbatim} environment to be indented and a minipage, |
| 161 | % and to have all the other mostly nice properties that we want for |
| 162 | % code samples. |
| 163 | |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 164 | \let\py@OldVerbatim=\verbatim |
| 165 | \let\py@OldEndVerbatim=\endverbatim |
| 166 | \RequirePackage{verbatim} |
| 167 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 168 | % Variable used by begin code command |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 169 | \newlength{\py@codewidth} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 170 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 171 | \renewcommand{\verbatim}{% |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 172 | \setlength{\parindent}{1cm}% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 173 | % Calculate the text width for the minipage: |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 174 | \setlength{\py@codewidth}{\linewidth}% |
| 175 | \addtolength{\py@codewidth}{-\parindent}% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 176 | % |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 177 | \par\indent% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 178 | \begin{minipage}[t]{\py@codewidth}% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 179 | \small% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 180 | \py@OldVerbatim% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 181 | } |
| 182 | \renewcommand{\endverbatim}{% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 183 | \py@OldEndVerbatim% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 184 | \end{minipage}% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 185 | } |
| 186 | |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 187 | |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 188 | \newcommand{\py@modulebadkey}{{--just-some-junk--}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 189 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 190 | |
| 191 | %% Lots of index-entry generation support. |
| 192 | |
| 193 | % Command to wrap around stuff that refers to function / module / |
| 194 | % attribute names in the index. Default behavior: like \code{}. To |
| 195 | % just keep the index entries in the roman font, uncomment the second |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 196 | % definition; it matches O'Reilly style more. |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 197 | % |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 198 | \newcommand{\py@idxcode}[1]{\texttt{#1}} |
| 199 | %\renewcommand{\py@idxcode}[1]{#1} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 200 | |
| 201 | % Command to generate two index entries (using subentries) |
| 202 | \newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}} |
| 203 | |
| 204 | % And three entries (using only one level of subentries) |
| 205 | \newcommand{\indexiii}[3]{\index{#1!#2 #3}\index{#2!#3, #1}\index{#3!#1 #2}} |
| 206 | |
| 207 | % And four (again, using only one level of subentries) |
| 208 | \newcommand{\indexiv}[4]{ |
| 209 | \index{#1!#2 #3 #4} |
| 210 | \index{#2!#3 #4, #1} |
| 211 | \index{#3!#4, #1 #2} |
| 212 | \index{#4!#1 #2 #3} |
| 213 | } |
| 214 | |
| 215 | % Command to generate a reference to a function, statement, keyword, |
| 216 | % operator. |
Fred Drake | 0cabff9 | 1998-05-06 19:36:01 +0000 | [diff] [blame] | 217 | \newcommand{\kwindex}[1]{\indexii{keyword}{#1@{\py@idxcode{#1}}}} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 218 | \newcommand{\stindex}[1]{\indexii{statement}{#1@{\py@idxcode{#1}}}} |
| 219 | \newcommand{\opindex}[1]{\indexii{operator}{#1@{\py@idxcode{#1}}}} |
| 220 | \newcommand{\exindex}[1]{\indexii{exception}{#1@{\py@idxcode{#1}}}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 221 | \newcommand{\obindex}[1]{\indexii{object}{#1}} |
Fred Drake | 2351c80 | 1998-04-02 18:48:32 +0000 | [diff] [blame] | 222 | \newcommand{\bifuncindex}[1]{\withsubitem{(built-in function)}{\ttindex{#1()}}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 223 | |
| 224 | % Add an index entry for a module |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 225 | \newcommand{\py@refmodule}[2]{\index{#1@{\py@idxcode{#1}} (#2module)}} |
| 226 | \newcommand{\refmodindex}[1]{\py@refmodule{#1}{}} |
| 227 | \newcommand{\refbimodindex}[1]{\py@refmodule{#1}{built-in }} |
| 228 | \newcommand{\refexmodindex}[1]{\py@refmodule{#1}{extension }} |
| 229 | \newcommand{\refstmodindex}[1]{\py@refmodule{#1}{standard }} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 230 | |
Fred Drake | da94374 | 1999-01-13 17:09:06 +0000 | [diff] [blame] | 231 | % Refer to a module's documentation using a hyperlink of the module's |
| 232 | % name, at least if we're building PDF: |
| 233 | \@ifundefined{pdfannotlink}{% |
| 234 | \newcommand{\refmodule}[2][\py@modulebadkey]{\module{#2}} |
Fred Drake | aa2aea0 | 1999-01-27 17:37:36 +0000 | [diff] [blame] | 235 | }{% |
| 236 | \newcommand{\refmodule}[2][\py@modulebadkey]{% |
Fred Drake | da94374 | 1999-01-13 17:09:06 +0000 | [diff] [blame] | 237 | \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi% |
Fred Drake | aa2aea0 | 1999-01-27 17:37:36 +0000 | [diff] [blame] | 238 | \py@linkToName{label-module-\py@modulekey}{\module{#2}}% |
Fred Drake | da94374 | 1999-01-13 17:09:06 +0000 | [diff] [blame] | 239 | } |
| 240 | } |
| 241 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 242 | % support for the module index |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 243 | \newif\ifpy@UseModuleIndex |
| 244 | \py@UseModuleIndexfalse |
Fred Drake | b390daf | 1998-03-09 16:35:36 +0000 | [diff] [blame] | 245 | |
Fred Drake | b390daf | 1998-03-09 16:35:36 +0000 | [diff] [blame] | 246 | \newcommand{\makemodindex}{ |
| 247 | \newwrite\modindexfile |
| 248 | \openout\modindexfile=mod\jobname.idx |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 249 | \py@UseModuleIndextrue |
Fred Drake | b390daf | 1998-03-09 16:35:36 +0000 | [diff] [blame] | 250 | } |
| 251 | |
Fred Drake | 0ee9f72 | 1998-03-12 06:41:40 +0000 | [diff] [blame] | 252 | % Add the defining entry for a module |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 253 | \newcommand{\py@modindex}[2]{% |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 254 | \renewcommand{\py@thismodule}{#1} |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 255 | \setindexsubitem{(in module #1)}% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 256 | \index{#1@{\py@idxcode{#1}} (#2module)|textbf}% |
| 257 | \ifpy@UseModuleIndex% |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 258 | \@ifundefined{py@modplat@\py@thismodulekey}{ |
| 259 | \write\modindexfile{\protect\indexentry{#1@{\texttt{#1}}}{\thepage}}% |
| 260 | }{\write\modindexfile{\protect\indexentry{#1@{\texttt{#1} % |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 261 | \emph{(\py@platformof[\py@thismodulekey]{})}}}{\thepage}}% |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 262 | } |
Fred Drake | 0ee9f72 | 1998-03-12 06:41:40 +0000 | [diff] [blame] | 263 | \fi% |
| 264 | } |
| 265 | |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 266 | % *** XXX *** THE NEXT FOUR MACROS ARE NOW OBSOLETE !!! *** |
| 267 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 268 | % built-in & Python modules in the main distribution |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 269 | \newcommand{\bimodindex}[1]{\py@modindex{#1}{built-in }% |
| 270 | \typeout{*** MACRO bimodindex IS OBSOLETE -- USE declaremodule INSTEAD!}} |
| 271 | \newcommand{\stmodindex}[1]{\py@modindex{#1}{standard }% |
| 272 | \typeout{*** MACRO stmodindex IS OBSOLETE -- USE declaremodule INSTEAD!}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 273 | |
| 274 | % Python & extension modules outside the main distribution |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 275 | \newcommand{\modindex}[1]{\py@modindex{#1}{}% |
| 276 | \typeout{*** MACRO modindex IS OBSOLETE -- USE declaremodule INSTEAD!}} |
| 277 | \newcommand{\exmodindex}[1]{\py@modindex{#1}{extension }% |
| 278 | \typeout{*** MACRO exmodindex IS OBSOLETE -- USE declaremodule INSTEAD!}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 279 | |
| 280 | % Additional string for an index entry |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 281 | \newcommand{\index@subitem}{} |
| 282 | \newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 283 | \newcommand{\ttindex}[1]{\index{#1@{\py@idxcode{#1}} \index@subitem}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 284 | |
Fred Drake | 0ee9f72 | 1998-03-12 06:41:40 +0000 | [diff] [blame] | 285 | \newcommand{\withsubitem}[2]{% |
| 286 | \begingroup% |
| 287 | \def\index@subitem{#1}#2% |
| 288 | \endgroup% |
| 289 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 290 | |
Fred Drake | 5371497 | 1998-04-02 22:33:16 +0000 | [diff] [blame] | 291 | |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 292 | % Module synopsis processing ----------------------------------------------- |
| 293 | % |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 294 | \newcommand{\py@thisclass}{} |
| 295 | \newcommand{\py@thismodule}{} |
| 296 | \newcommand{\py@thismodulekey}{} |
| 297 | \newcommand{\py@thismoduletype}{} |
| 298 | |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 299 | \newcommand{\py@standardIndexModule}[1]{\py@modindex{#1}{standard }} |
| 300 | \newcommand{\py@builtinIndexModule}[1]{\py@modindex{#1}{built-in }} |
| 301 | \newcommand{\py@extensionIndexModule}[1]{\py@modindex{#1}{extension }} |
| 302 | \newcommand{\py@IndexModule}[1]{\py@modindex{#1}{}} |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 303 | |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 304 | \newif\ifpy@HaveModSynopsis \py@HaveModSynopsisfalse |
| 305 | \newif\ifpy@ModSynopsisFileIsOpen \py@ModSynopsisFileIsOpenfalse |
| 306 | \newif\ifpy@HaveModPlatform \py@HaveModPlatformfalse |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 307 | |
| 308 | % \declaremodule[key]{type}{name} |
| 309 | \newcommand{\declaremodule}[3][\py@modulebadkey]{ |
| 310 | \py@openModSynopsisFile |
| 311 | \renewcommand{\py@thismoduletype}{#2} |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 312 | \ifx\py@modulebadkey#1 |
| 313 | \renewcommand{\py@thismodulekey}{#3} |
| 314 | \else |
| 315 | \renewcommand{\py@thismodulekey}{#1} |
| 316 | \fi |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 317 | \csname py@#2IndexModule\endcsname{#3} |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 318 | \label{module-\py@thismodulekey} |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 319 | } |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 320 | \newif\ifpy@ModPlatformFileIsOpen \py@ModPlatformFileIsOpenfalse |
| 321 | \newcommand{\py@ModPlatformFilename}{\jobname.pla} |
| 322 | \newcommand{\platform}[1]{ |
| 323 | \ifpy@ModPlatformFileIsOpen\else |
| 324 | \newwrite\py@ModPlatformFile |
| 325 | \openout\py@ModPlatformFile=\py@ModPlatformFilename |
| 326 | \py@ModPlatformFileIsOpentrue |
| 327 | \fi |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 328 | } |
| 329 | \InputIfFileExists{\jobname.pla}{}{} |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 330 | \newcommand{\py@platformof}[2][\py@modulebadkey]{% |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 331 | \ifx\py@modulebadkey#1 \def\py@key{#2}% |
| 332 | \else \def\py@key{#1}% |
| 333 | \fi% |
| 334 | \csname py@modplat@\py@key\endcsname% |
| 335 | } |
| 336 | \newcommand{\ignorePlatformAnnotation}[1]{} |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 337 | |
Fred Drake | b75c615 | 1998-08-10 18:41:43 +0000 | [diff] [blame] | 338 | % \moduleauthor{name}{email} |
| 339 | \newcommand{\moduleauthor}[2]{} |
| 340 | |
| 341 | % \sectionauthor{name}{email} |
| 342 | \newcommand{\sectionauthor}[2]{} |
| 343 | |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 344 | |
| 345 | \newcommand{\py@defsynopsis}{Module has no synopsis.} |
| 346 | \newcommand{\py@modulesynopsis}{\py@defsynopsis} |
| 347 | \newcommand{\modulesynopsis}[1]{ |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 348 | \py@HaveModSynopsistrue |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 349 | \renewcommand{\py@modulesynopsis}{#1} |
| 350 | } |
| 351 | |
| 352 | % define the file |
| 353 | \newwrite\py@ModSynopsisFile |
| 354 | |
| 355 | % hacked from \addtocontents from latex.ltx: |
| 356 | \long\def\py@writeModSynopsisFile#1{% |
| 357 | \protected@write\py@ModSynopsisFile% |
| 358 | {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}% |
| 359 | {\string#1}% |
| 360 | } |
| 361 | \newcommand{\py@closeModSynopsisFile}{ |
| 362 | \ifpy@ModSynopsisFileIsOpen |
| 363 | \closeout\py@ModSynopsisFile |
| 364 | \py@ModSynopsisFileIsOpenfalse |
| 365 | \fi |
| 366 | } |
| 367 | \newcommand{\py@openModSynopsisFile}{ |
| 368 | \ifpy@ModSynopsisFileIsOpen\else |
| 369 | \openout\py@ModSynopsisFile=\py@ModSynopsisFilename |
| 370 | \py@ModSynopsisFileIsOpentrue |
| 371 | \fi |
| 372 | } |
| 373 | |
| 374 | \newcommand{\py@ProcessModSynopsis}{ |
| 375 | \ifpy@HaveModSynopsis |
| 376 | \py@writeModSynopsisFile{\modulesynopsis% |
| 377 | {\py@thismodulekey}{\py@thismodule}% |
| 378 | {\py@thismoduletype}{\py@modulesynopsis}}% |
| 379 | \py@HaveModSynopsisfalse |
| 380 | \fi |
| 381 | \renewcommand{\py@modulesynopsis}{\py@defsynopsis} |
| 382 | } |
| 383 | \AtEndDocument{\py@ProcessModSynopsis\py@closeModSynopsisFile} |
| 384 | |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 385 | |
| 386 | \long\def\py@writeModPlatformFile#1{% |
| 387 | \protected@write\py@ModPlatformFile% |
| 388 | {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}% |
| 389 | {\string#1}% |
| 390 | } |
| 391 | |
| 392 | |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 393 | \newcommand{\localmoduletable}{ |
| 394 | \IfFileExists{\py@ModSynopsisFilename}{ |
| 395 | \begin{synopsistable} |
| 396 | \input{\py@ModSynopsisFilename} |
| 397 | \end{synopsistable} |
| 398 | }{} |
| 399 | } |
| 400 | |
| 401 | \@ifundefined{pdfoutput}{ |
| 402 | \newcommand{\py@ModSynopsisSummary}[4]{\bfcode{#2} & #4\\} |
| 403 | }{ |
Fred Drake | aa2aea0 | 1999-01-27 17:37:36 +0000 | [diff] [blame] | 404 | \newcommand{\py@ModSynopsisSummary}[4]{% |
| 405 | \py@linkToName{label-module-#1}{\bfcode{#2}} & #4\\ |
| 406 | } |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 407 | } |
| 408 | \newenvironment{synopsistable}{ |
| 409 | % key, name, type, synopsis |
| 410 | \let\modulesynopsis=\py@ModSynopsisSummary |
| 411 | \begin{tabular}{ll} |
| 412 | }{ |
| 413 | \end{tabular} |
| 414 | } |
| 415 | % |
| 416 | % -------------------------------------------------------------------------- |
| 417 | |
| 418 | |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 419 | \newcommand{\py@reset}{ |
| 420 | \py@ProcessModSynopsis |
| 421 | \renewcommand{\py@thisclass}{} |
| 422 | \renewcommand{\py@thismodule}{} |
| 423 | \renewcommand{\py@thismodulekey}{} |
| 424 | \renewcommand{\py@thismoduletype}{} |
| 425 | } |
| 426 | |
| 427 | % Augment the sectioning commands used to get our own font family in place, |
| 428 | % and reset some internal data items: |
| 429 | \renewcommand{\section}{\py@reset% |
| 430 | \@startsection{section}{1}{\z@}% |
| 431 | {-3.5ex \@plus -1ex \@minus -.2ex}% |
| 432 | {2.3ex \@plus.2ex}% |
| 433 | {\reset@font\Large\py@HeaderFamily}} |
| 434 | \renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}% |
| 435 | {-3.25ex\@plus -1ex \@minus -.2ex}% |
| 436 | {1.5ex \@plus .2ex}% |
| 437 | {\reset@font\large\py@HeaderFamily}} |
| 438 | \renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}% |
| 439 | {-3.25ex\@plus -1ex \@minus -.2ex}% |
| 440 | {1.5ex \@plus .2ex}% |
| 441 | {\reset@font\normalsize\py@HeaderFamily}} |
| 442 | \renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}% |
| 443 | {3.25ex \@plus1ex \@minus.2ex}% |
| 444 | {-1em}% |
| 445 | {\reset@font\normalsize\py@HeaderFamily}} |
| 446 | \renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}% |
| 447 | {3.25ex \@plus1ex \@minus .2ex}% |
| 448 | {-1em}% |
| 449 | {\reset@font\normalsize\py@HeaderFamily}} |
| 450 | |
| 451 | |
Fred Drake | 5420f33 | 1998-07-23 21:41:02 +0000 | [diff] [blame] | 452 | % This gets the underscores closer to the right width; the only change |
| 453 | % from standard LaTeX is the width specified. |
| 454 | |
| 455 | \DeclareTextCommandDefault{\textunderscore}{% |
| 456 | \leavevmode \kern.06em\vbox{\hrule\@width.55em}} |
| 457 | |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 458 | % Underscore hack (only act like subscript operator if in math mode) |
| 459 | % |
| 460 | % The following is due to Mark Wooding (the old version didn't work with |
| 461 | % Latex 2e. |
| 462 | |
| 463 | \DeclareRobustCommand\hackscore{% |
| 464 | \ifmmode_\else\textunderscore\fi% |
| 465 | } |
| 466 | \begingroup |
| 467 | \catcode`\_\active |
| 468 | \def\next{% |
| 469 | \AtBeginDocument{\catcode`\_\active\def_{\hackscore{}}}% |
| 470 | } |
| 471 | \expandafter\endgroup\next |
| 472 | |
| 473 | |
Fred Drake | 5371497 | 1998-04-02 22:33:16 +0000 | [diff] [blame] | 474 | % Now for a lot of semantically-loaded environments that do a ton of magical |
| 475 | % things to get the right formatting and index entries for the stuff in |
| 476 | % Python modules and C API. |
| 477 | |
| 478 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 479 | % {fulllineitems} is used in one place in libregex.tex, but is really for |
| 480 | % internal use in this file. |
| 481 | % |
Fred Drake | f9acc59 | 1998-09-09 15:27:43 +0000 | [diff] [blame] | 482 | \newcommand{\py@itemnewline}[1]{% |
| 483 | \@tempdima\linewidth% |
| 484 | \advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}% |
| 485 | } |
| 486 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 487 | \newenvironment{fulllineitems}{ |
| 488 | \begin{list}{}{\labelwidth \leftmargin \labelsep 0pt |
| 489 | \rightmargin 0pt \topsep -\parskip \partopsep \parskip |
| 490 | \itemsep -\parsep |
Fred Drake | f9acc59 | 1998-09-09 15:27:43 +0000 | [diff] [blame] | 491 | \let\makelabel=\py@itemnewline} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 492 | }{\end{list}} |
| 493 | |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 494 | % \optional is mostly for use in the arguments parameters to the various |
| 495 | % {*desc} environments defined below, but may be used elsewhere. Known to |
| 496 | % be used in the debugger chapter. |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 497 | % |
| 498 | % Typical usage: |
| 499 | % |
| 500 | % \begin{funcdesc}{myfunc}{reqparm\optional{, optparm}} |
| 501 | % ^^^ ^^^ |
| 502 | % No space here No space here |
| 503 | % |
| 504 | % When a function has multiple optional parameters, \optional should be |
| 505 | % nested, not chained. This is right: |
| 506 | % |
| 507 | % \begin{funcdesc}{myfunc}{\optional{parm1\optional{, parm2}}} |
| 508 | % |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 509 | \newcommand{\optional}[1]{% |
| 510 | {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}} |
| 511 | |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 512 | % C functions ------------------------------------------------------------ |
| 513 | % \begin{cfuncdesc}{type}{name}{arglist} |
| 514 | \newenvironment{cfuncdesc}[3]{ |
| 515 | \begin{fulllineitems} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 516 | \item[\code{#1 \bfcode{#2}(\py@varvars{#3})}\index{#2@{\py@idxcode{#2()}}}] |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 517 | }{\end{fulllineitems}} |
| 518 | |
| 519 | % C variables ------------------------------------------------------------ |
| 520 | % \begin{cvardesc}{type}{name} |
| 521 | \newenvironment{cvardesc}[2]{ |
| 522 | \begin{fulllineitems} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 523 | \item[\code{#1 \bfcode{#2}}\index{#2@{\py@idxcode{#2}}}] |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 524 | }{\end{fulllineitems}} |
| 525 | |
| 526 | % C data types ----------------------------------------------------------- |
| 527 | % \begin{ctypedesc}{typedef name} |
| 528 | \newenvironment{ctypedesc}[1]{ |
| 529 | \begin{fulllineitems} |
| 530 | \item[\bfcode{#1}\ttindex{#1}] |
| 531 | }{\end{fulllineitems}} |
| 532 | |
| 533 | % simple functions (not methods) ----------------------------------------- |
| 534 | % \begin{funcdesc}{name}{args} |
| 535 | \newcommand{\funcline}[2]{\funclineni{#1}{#2}\ttindex{#1()}} |
| 536 | \newenvironment{funcdesc}[2]{ |
| 537 | \begin{fulllineitems} |
| 538 | \funcline{#1}{#2} |
| 539 | }{\end{fulllineitems}} |
| 540 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 541 | % similar to {funcdesc}, but doesn't add to the index |
Fred Drake | 300775d | 1998-04-17 02:17:00 +0000 | [diff] [blame] | 542 | \newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(\py@varvars{#2})}]} |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 543 | \newenvironment{funcdescni}[2]{ |
| 544 | \begin{fulllineitems} |
| 545 | \funclineni{#1}{#2} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 546 | }{\end{fulllineitems}} |
| 547 | |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 548 | % classes ---------------------------------------------------------------- |
| 549 | % \begin{classdesc}{name}{constructor args} |
| 550 | \newenvironment{classdesc}[2]{ |
Fred Drake | 1cbd196 | 1998-11-25 17:13:28 +0000 | [diff] [blame] | 551 | % Using \renewcommand doesn't work for this, for unknown reasons: |
| 552 | \global\def\py@thisclass{#1} |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 553 | \begin{fulllineitems} |
Fred Drake | 300775d | 1998-04-17 02:17:00 +0000 | [diff] [blame] | 554 | \item[\code{\bfcode{#1}(\py@varvars{#2})}% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 555 | \withsubitem{(class in \py@thismodule)}{\ttindex{#1}}] |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 556 | }{\end{fulllineitems}} |
| 557 | |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 558 | |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 559 | \let\py@classbadkey=\@undefined |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 560 | |
| 561 | % object method ---------------------------------------------------------- |
| 562 | % \begin{methoddesc}[classname]{methodname}{args} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 563 | \newcommand{\methodline}[3][\py@classbadkey]{ |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 564 | \methodlineni{#2}{#3} |
| 565 | \ifx#1\@undefined |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 566 | \withsubitem{(\py@thisclass\ method)}{\ttindex{#2()}} |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 567 | \else |
| 568 | \withsubitem{(#1 method)}{\ttindex{#2()}} |
| 569 | \fi |
| 570 | } |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 571 | \newenvironment{methoddesc}[3][\py@classbadkey]{ |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 572 | \begin{fulllineitems} |
| 573 | \ifx#1\@undefined |
| 574 | \methodline{#2}{#3} |
| 575 | \else |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 576 | \def\py@thisclass{#1} |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 577 | \methodline[#1]{#2}{#3} |
| 578 | \fi |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 579 | }{\end{fulllineitems}} |
| 580 | |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 581 | % similar to {methoddesc}, but doesn't add to the index |
| 582 | % (never actually uses the optional argument) |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 583 | \newcommand{\methodlineni}[3][\py@classbadkey]{% |
Fred Drake | 300775d | 1998-04-17 02:17:00 +0000 | [diff] [blame] | 584 | \item[\code{\bfcode{#2}(\py@varvars{#3})}]} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 585 | \newenvironment{methoddescni}[3][\py@classbadkey]{ |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 586 | \begin{fulllineitems} |
| 587 | \methodlineni{#2}{#3} |
| 588 | }{\end{fulllineitems}} |
| 589 | |
| 590 | % object data attribute -------------------------------------------------- |
| 591 | % \begin{memberdesc}[classname]{membername} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 592 | \newcommand{\memberline}[2][\py@classbadkey]{% |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 593 | \ifx#1\@undefined |
| 594 | \memberlineni{#2} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 595 | \withsubitem{(\py@thisclass\ attribute)}{\ttindex{#2}} |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 596 | \else |
| 597 | \memberlineni{#2} |
Fred Drake | 41565f6 | 1998-04-07 19:32:40 +0000 | [diff] [blame] | 598 | \withsubitem{(#1 attribute)}{\ttindex{#2}} |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 599 | \fi |
| 600 | } |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 601 | \newenvironment{memberdesc}[2][\py@classbadkey]{ |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 602 | \begin{fulllineitems} |
| 603 | \ifx#1\@undefined |
| 604 | \memberline{#2} |
| 605 | \else |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 606 | \def\py@thisclass{#1} |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 607 | \memberline[#1]{#2} |
| 608 | \fi |
| 609 | }{\end{fulllineitems}} |
| 610 | |
| 611 | % similar to {memberdesc}, but doesn't add to the index |
| 612 | % (never actually uses the optional argument) |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 613 | \newcommand{\memberlineni}[2][\py@classbadkey]{\item[\bfcode{#2}]} |
| 614 | \newenvironment{memberdescni}[2][\py@classbadkey]{ |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 615 | \begin{fulllineitems} |
| 616 | \memberlineni{#2} |
| 617 | }{\end{fulllineitems}} |
| 618 | |
| 619 | % For exceptions: -------------------------------------------------------- |
| 620 | % \begin{excdesc}{name} |
| 621 | % -- need support for constructor; maybe use optional parameter? |
| 622 | \newenvironment{excdesc}[1]{ |
| 623 | \begin{fulllineitems} |
| 624 | \item[\bfcode{#1}\ttindex{#1}] |
| 625 | }{\end{fulllineitems}} |
| 626 | |
| 627 | % Module data or constants: ---------------------------------------------- |
| 628 | % \begin{datadesc}{name} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 629 | \newcommand{\dataline}[1]{\datalineni{#1}\ttindex{#1}} |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 630 | \newenvironment{datadesc}[1]{ |
| 631 | \begin{fulllineitems} |
| 632 | \dataline{#1} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 633 | }{\end{fulllineitems}} |
| 634 | |
| 635 | % similar to {datadesc}, but doesn't add to the index |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 636 | \newcommand{\datalineni}[1]{\item[\bfcode{#1}]\nopagebreak} |
| 637 | \newenvironment{datadescni}[1]{ |
| 638 | \begin{fulllineitems} |
| 639 | \datalineni{#1} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 640 | }{\end{fulllineitems}} |
| 641 | |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 642 | % bytecode instruction --------------------------------------------------- |
| 643 | % \begin{opcodedesc}{name}{var} |
| 644 | % -- {var} may be {} |
| 645 | \newenvironment{opcodedesc}[2]{ |
| 646 | \begin{fulllineitems} |
| 647 | \item[\bfcode{#1}\quad\var{#2}] |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 648 | }{\end{fulllineitems}} |
| 649 | |
| 650 | |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 651 | \newcommand{\nodename}[1]{\label{#1}} |
Fred Drake | 5573031 | 1998-03-25 15:41:23 +0000 | [diff] [blame] | 652 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 653 | % For these commands, use \command{} to get the typography right, not |
| 654 | % {\command}. This works better with the texinfo translation. |
| 655 | \newcommand{\ABC}{{\sc abc}} |
| 656 | \newcommand{\UNIX}{{\sc Unix}} |
| 657 | \newcommand{\POSIX}{POSIX} |
| 658 | \newcommand{\ASCII}{{\sc ascii}} |
| 659 | \newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}} |
| 660 | \newcommand{\C}{C} |
| 661 | \newcommand{\EOF}{{\sc eof}} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 662 | \newcommand{\NULL}{\constant{NULL}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 663 | |
Fred Drake | 5371497 | 1998-04-02 22:33:16 +0000 | [diff] [blame] | 664 | % Also for consistency: spell Python "Python", not "python"! |
| 665 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 666 | % code is the most difficult one... |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 667 | \newcommand{\code}[1]{{\@vobeyspaces\@noligs\def\{{\char`\{}\def\}{\char`\}}\def\~{\char`\~}\def\^{\char`\^}\def\e{\char`\\}\def\${\char`\$}\def\#{\char`\#}\def\&{\char`\&}\def\%{\char`\%}% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 668 | \texttt{#1}}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 669 | |
| 670 | \newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font |
Fred Drake | 8e54abe | 1998-07-01 14:49:25 +0000 | [diff] [blame] | 671 | \newcommand{\kbd}[1]{\code{#1}} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 672 | \newcommand{\samp}[1]{`\code{#1}'} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 673 | % This weird definition of \var{} allows it to always appear in roman |
| 674 | % italics, and won't get funky in code fragments when we play around |
Fred Drake | fa1cceb | 1998-11-30 14:42:59 +0000 | [diff] [blame] | 675 | % with fonts. This also works directly in math mode. |
| 676 | \newcommand{\var}[1]{% |
| 677 | \ifmmode% |
| 678 | \hbox{\normalsize\textrm{\textit{#1\/}}}% |
| 679 | \else% |
| 680 | \normalsize\textrm{\textit{#1\/}}% |
| 681 | \fi% |
| 682 | } |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 683 | \renewcommand{\emph}[1]{{\em #1}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 684 | \newcommand{\dfn}[1]{\emph{#1}} |
| 685 | \newcommand{\strong}[1]{{\bf #1}} |
| 686 | % let's experiment with a new font: |
Fred Drake | 0ee9f72 | 1998-03-12 06:41:40 +0000 | [diff] [blame] | 687 | \newcommand{\file}[1]{`{\small\textsf{#1}}'} |
Fred Drake | 0a0fd59 | 1999-04-28 14:59:44 +0000 | [diff] [blame] | 688 | \newcommand{\filenq}[1]{{\small\textsf{#1}}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 689 | |
| 690 | % Use this def/redef approach for \url{} since hyperref defined this already, |
| 691 | % but only if we actually used hyperref: |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 692 | \@ifundefined{pdfannotlink}{ |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 693 | \newcommand{\py@url}[1]{\mbox{\small\textsf{#1}}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 694 | }{ |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 695 | \newcommand{\py@url}[1]{{% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 696 | \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 697 | \py@LinkColor% color of the link text |
| 698 | \mbox{\small\textsf{#1}}% |
| 699 | \py@NormalColor% Turn it back off; these are declarative |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 700 | \pdfendlink}% and don't appear bound to the current |
| 701 | }% formatting "box". |
| 702 | } |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 703 | \let\url=\py@url |
Fred Drake | 0ee9f72 | 1998-03-12 06:41:40 +0000 | [diff] [blame] | 704 | \newcommand{\email}[1]{{\small\textsf{#1}}} |
Fred Drake | 454a4fb | 1998-04-01 22:20:14 +0000 | [diff] [blame] | 705 | \newcommand{\newsgroup}[1]{{\small\textsf{#1}}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 706 | |
Fred Drake | 300775d | 1998-04-17 02:17:00 +0000 | [diff] [blame] | 707 | \newcommand{\py@varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 708 | % let's see if this breaks anything now; we may be able to simplify... |
| 709 | \renewcommand{\py@varvars}[1]{\var{#1}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 710 | |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 711 | % I'd really like to get rid of this! |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 712 | \newif\iftexi\texifalse |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 713 | |
Fred Drake | 1e4973b | 1998-07-28 21:52:17 +0000 | [diff] [blame] | 714 | % This is used to get l2h to put the copyright and abstract on |
| 715 | % a separate HTML page. |
| 716 | \newif\ifhtml\htmlfalse |
| 717 | |
| 718 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 719 | % These should be used for all references to identifiers which are |
| 720 | % used to refer to instances of specific language constructs. See the |
| 721 | % names for specific semantic assignments. |
| 722 | % |
| 723 | % For now, don't do anything really fancy with them; just use them as |
| 724 | % logical markup. This might change in the future. |
| 725 | % |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 726 | \newcommand{\module}[1]{\texttt{#1}} |
| 727 | \newcommand{\keyword}[1]{\texttt{#1}} |
| 728 | \newcommand{\exception}[1]{\texttt{#1}} |
| 729 | \newcommand{\class}[1]{\texttt{#1}} |
| 730 | \newcommand{\function}[1]{\texttt{#1}} |
| 731 | \newcommand{\member}[1]{\texttt{#1}} |
| 732 | \newcommand{\method}[1]{\texttt{#1}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 733 | |
Fred Drake | 5371497 | 1998-04-02 22:33:16 +0000 | [diff] [blame] | 734 | \newcommand{\pytype}[1]{#1} % built-in Python type |
| 735 | |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 736 | \newcommand{\cfunction}[1]{\texttt{#1}} |
| 737 | \newcommand{\ctype}[1]{\texttt{#1}} % C struct or typedef name |
| 738 | \newcommand{\cdata}[1]{\texttt{#1}} % C variable, typically global |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 739 | |
Fred Drake | 0ee9f72 | 1998-03-12 06:41:40 +0000 | [diff] [blame] | 740 | \newcommand{\mimetype}[1]{{\small\textsf{#1}}} |
Fred Drake | 94fac13 | 1998-03-12 19:37:03 +0000 | [diff] [blame] | 741 | % The \! is a "negative thin space" in math mode. |
| 742 | \newcommand{\regexp}[1]{% |
| 743 | {\tiny$^{^\lceil}\!\!$% |
| 744 | {\normalsize\code{#1}}% |
Fred Drake | 47cfd03 | 1998-04-03 21:22:31 +0000 | [diff] [blame] | 745 | $\!\rfloor\!$% |
Fred Drake | 94fac13 | 1998-03-12 19:37:03 +0000 | [diff] [blame] | 746 | }} |
Fred Drake | 0ee9f72 | 1998-03-12 06:41:40 +0000 | [diff] [blame] | 747 | \newcommand{\envvar}[1]{% |
Fred Drake | 94fac13 | 1998-03-12 19:37:03 +0000 | [diff] [blame] | 748 | \$#1% $ <-- bow to font-lock 3 times! |
| 749 | \index{#1@{\$#1}}% $ |
| 750 | \index{environment variables!{\$#1}}% $ |
Fred Drake | 0ee9f72 | 1998-03-12 06:41:40 +0000 | [diff] [blame] | 751 | } |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 752 | \newcommand{\makevar}[1]{#1} % variable in a Makefile |
| 753 | \newcommand{\character}[1]{\samp{#1}} |
Fred Drake | 0ee9f72 | 1998-03-12 06:41:40 +0000 | [diff] [blame] | 754 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 755 | % constants defined in Python modules or C headers, not language constants: |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 756 | \newcommand{\constant}[1]{\code{#1}} % manifest constant, not syntactic |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 757 | |
| 758 | \newcommand{\manpage}[2]{{\emph{#1}(#2)}} |
| 759 | \newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}} |
| 760 | \newcommand{\program}[1]{\strong{#1}} |
| 761 | |
| 762 | |
| 763 | % Deprecation stuff. |
| 764 | % Should be extended to allow an index / list of deprecated stuff. But |
| 765 | % there's a lot of stuff that needs to be done to make that automatable. |
| 766 | % |
| 767 | % First parameter is the release number that deprecates the feature, the |
| 768 | % second is the action the should be taken by users of the feature. |
| 769 | % |
| 770 | % Example: |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 771 | % \deprecated{1.5.1}{Use \method{frobnicate()} instead.} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 772 | % |
| 773 | \newcommand{\deprecated}[2]{% |
| 774 | \strong{Deprecated since release #1.} #2\par} |
| 775 | |
Fred Drake | af958c7 | 1998-07-27 20:32:33 +0000 | [diff] [blame] | 776 | % New stuff. |
| 777 | % This should be used to mark things which have been added to the |
| 778 | % development tree but that aren't in the release, but are documented. |
| 779 | % This allows release of documentation that already includes updated |
Fred Drake | 2116d98 | 1999-02-02 18:02:48 +0000 | [diff] [blame] | 780 | % descriptions. Place at end of descriptor environment. |
Fred Drake | af958c7 | 1998-07-27 20:32:33 +0000 | [diff] [blame] | 781 | % |
| 782 | % Example: |
| 783 | % \versionadded{1.5.2} |
| 784 | % |
| 785 | \newcommand{\versionadded}[1]{% |
Fred Drake | 2116d98 | 1999-02-02 18:02:48 +0000 | [diff] [blame] | 786 | { New in version #1. }} |
Fred Drake | af958c7 | 1998-07-27 20:32:33 +0000 | [diff] [blame] | 787 | \newcommand{\versionchanged}[1]{% |
Fred Drake | 2116d98 | 1999-02-02 18:02:48 +0000 | [diff] [blame] | 788 | { Changed in version #1. }} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 789 | |
Fred Drake | af958c7 | 1998-07-27 20:32:33 +0000 | [diff] [blame] | 790 | |
| 791 | % Tables. |
| 792 | % |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 793 | \newenvironment{tableii}[4]{% |
| 794 | \begin{center}% |
| 795 | \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}% |
Fred Drake | ee60191 | 1998-04-11 20:53:03 +0000 | [diff] [blame] | 796 | \begin{tabular}{#1}\strong{#3}&\strong{#4} \\ \hline% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 797 | }{% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 798 | \end{tabular}% |
| 799 | \end{center}% |
| 800 | } |
| 801 | |
| 802 | \newenvironment{tableiii}[5]{% |
| 803 | \begin{center}% |
| 804 | \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}% |
Fred Drake | ee60191 | 1998-04-11 20:53:03 +0000 | [diff] [blame] | 805 | \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5} \\ \hline% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 806 | }{% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 807 | \end{tabular}% |
| 808 | \end{center}% |
| 809 | } |
| 810 | |
Fred Drake | 30e5265 | 1998-07-24 22:11:29 +0000 | [diff] [blame] | 811 | \newenvironment{tableiv}[6]{% |
| 812 | \begin{center}% |
| 813 | \def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}% |
| 814 | \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6} \\% |
| 815 | \hline% |
| 816 | }{% |
| 817 | \end{tabular}% |
| 818 | \end{center}% |
| 819 | } |
| 820 | |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 821 | % Cross-referencing (AMK, new impl. FLD) |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 822 | % Sample usage: |
| 823 | % \begin{seealso} |
| 824 | % \seemodule{rand}{Uniform random number generator}; % Module xref |
| 825 | % \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book |
Fred Drake | ebcb658 | 1998-03-06 21:25:17 +0000 | [diff] [blame] | 826 | % |
| 827 | % % A funky case: module name contains '_'; have to supply an optional key |
| 828 | % \seemodule[copyreg]{copy_reg}{pickle interface constructor registration} |
| 829 | % |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 830 | % \end{seealso} |
| 831 | |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 832 | \@ifundefined{pdfannotlink}{% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 833 | \newcommand{\py@seemodule}[3][\py@modulebadkey]{% |
Fred Drake | da94374 | 1999-01-13 17:09:06 +0000 | [diff] [blame] | 834 | \par% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 835 | \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi% |
| 836 | \ref{module-\py@modulekey}:\quad % |
Fred Drake | ebcb658 | 1998-03-06 21:25:17 +0000 | [diff] [blame] | 837 | Module \module{#2}% |
| 838 | \quad (#3)% |
| 839 | } |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 840 | }{\newcommand{\py@seemodule}[3][\py@modulebadkey]{% |
Fred Drake | da94374 | 1999-01-13 17:09:06 +0000 | [diff] [blame] | 841 | \par% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 842 | \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi% |
| 843 | \ref{module-\py@modulekey}:\quad % |
Fred Drake | aa2aea0 | 1999-01-27 17:37:36 +0000 | [diff] [blame] | 844 | \py@linkToName{label-module-\py@modulekey}{ Module \module{#2} } |
Fred Drake | ebcb658 | 1998-03-06 21:25:17 +0000 | [diff] [blame] | 845 | \quad (#3)% |
| 846 | } |
| 847 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 848 | \newenvironment{seealso}[0]{ |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 849 | \par |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 850 | \strong{See Also:}\par |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 851 | \def\seetext##1{\par{##1}} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 852 | \let\seemodule=\py@seemodule |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 853 | }{\par} |
| 854 | |
| 855 | |
Fred Drake | af958c7 | 1998-07-27 20:32:33 +0000 | [diff] [blame] | 856 | % Allow the Python release number to be specified independently of the |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 857 | % \date{}. This allows the date to reflect the document's date and |
| 858 | % release to specify the Python release that is documented. |
| 859 | % |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 860 | \newcommand{\py@release}{} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 861 | \newcommand{\version}{} |
| 862 | \newcommand{\releasename}{Release} |
| 863 | \newcommand{\release}[1]{% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 864 | \renewcommand{\py@release}{\releasename\space\version}% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 865 | \renewcommand{\version}{#1}} |
| 866 | |
| 867 | % Allow specification of the author's address separately from the |
| 868 | % author's name. This can be used to format them differently, which |
| 869 | % is a good thing. |
| 870 | % |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 871 | \newcommand{\py@authoraddress}{} |
| 872 | \newcommand{\authoraddress}[1]{\renewcommand{\py@authoraddress}{#1}} |
Fred Drake | 6df93ef | 1998-05-14 20:56:31 +0000 | [diff] [blame] | 873 | \let\developersaddress=\authoraddress |
| 874 | \let\developer=\author |
| 875 | \let\developers=\author |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 876 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 877 | % This sets up the fancy chapter headings that make the documents look |
| 878 | % at least a little better than the usual LaTeX output. |
| 879 | % |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 880 | \@ifundefined{ChTitleVar}{}{ |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 881 | \ChNameVar{\raggedleft\normalsize\py@HeaderFamily} |
| 882 | \ChNumVar{\raggedleft \bfseries\Large\py@HeaderFamily} |
| 883 | \ChTitleVar{\raggedleft \rm\Huge\py@HeaderFamily} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 884 | % This creates chapter heads without the leading \vspace*{}: |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 885 | \def\@makechapterhead#1{% |
| 886 | {\parindent \z@ \raggedright \normalfont |
| 887 | \ifnum \c@secnumdepth >\m@ne |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 888 | \DOCH |
| 889 | \fi |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 890 | \interlinepenalty\@M |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 891 | \DOTI{#1} |
| 892 | } |
| 893 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 894 | } |
| 895 | |
Fred Drake | 3bf7865 | 1998-05-20 17:42:17 +0000 | [diff] [blame] | 896 | |
| 897 | % Definition lists; requested by AMK for HOWTO documents. Probably useful |
| 898 | % elsewhere as well, so keep in in the general style support. |
| 899 | % |
| 900 | \newenvironment{definitions}{% |
| 901 | \begin{description}% |
Fred Drake | f9acc59 | 1998-09-09 15:27:43 +0000 | [diff] [blame] | 902 | \def\term##1{\item[##1]\mbox{}\\*[0mm]} |
Fred Drake | 3bf7865 | 1998-05-20 17:42:17 +0000 | [diff] [blame] | 903 | }{% |
| 904 | \end{description}% |
| 905 | } |
| 906 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 907 | % Tell TeX about pathological hyphenation cases: |
| 908 | \hyphenation{Base-HTTP-Re-quest-Hand-ler} |