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