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