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