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