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