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