comparison Doc/texinputs/python.sty @ 8190:25c2aea64501 legacy-trunk

Fixed \code so word wrapping is allowed. Removed some old stuff. Do better hiding of internal names.
author Fred Drake <fdrake@acm.org>
date Tue, 28 Apr 1998 18:30:34 +0000
parents de029e6f9838
children df752c08b462
comparison
equal deleted inserted replaced
8189:ce2d120c3903 8190:25c2aea64501
13 %\RequirePackage{showidx} 13 %\RequirePackage{showidx}
14 14
15 % for PDF output, use maximal compression & a lot of other stuff 15 % for PDF output, use maximal compression & a lot of other stuff
16 % (test for PDF recommended by Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov>) 16 % (test for PDF recommended by Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov>)
17 % 17 %
18 \newif\if@doing@page@targets 18 \newif\ifpy@doing@page@targets
19 \@doing@page@targetsfalse 19 \py@doing@page@targetsfalse
20 20
21 \ifx\pdfoutput\undefined\else\ifcase\pdfoutput 21 \ifx\pdfoutput\undefined\else\ifcase\pdfoutput
22 \let\LinkColor=\relax
23 \let\NormalColor=\relax
24 \else 22 \else
25 \input{pdfcolor} 23 \input{pdfcolor}
26 \let\LinkColor=\NavyBlue 24 \let\py@LinkColor=\NavyBlue
27 \let\NormalColor=\Black 25 \let\py@NormalColor=\Black
28 \pdfcompresslevel=9 26 \pdfcompresslevel=9
29 % 27 %
30 % Pad the number with '0' to 3 digits wide so no page name is a prefix 28 % Pad the number with '0' to 3 digits wide so no page name is a prefix
31 % of any other. 29 % of any other.
32 % 30 %
34 \def\py@pageno{\py@targetno\thepage} 32 \def\py@pageno{\py@targetno\thepage}
35 % 33 %
36 % This definition allows the entries in the page-view of the ToC to be 34 % This definition allows the entries in the page-view of the ToC to be
37 % active links. Some work, some don't. 35 % active links. Some work, some don't.
38 % 36 %
39 \let\OldContentsline=\contentsline 37 \let\py@OldContentsline=\contentsline
40 % Compute the padded page number separately since we end up with a pair of 38 % Compute the padded page number separately since we end up with a pair of
41 % \relax tokens; this gets the right string computed and works. 39 % \relax tokens; this gets the right string computed and works.
42 \renewcommand{\contentsline}[3]{% 40 \renewcommand{\contentsline}[3]{%
43 \def\my@pageno{\py@targetno{#3}}% 41 \def\my@pageno{\py@targetno{#3}}%
44 \OldContentsline{#1}{% 42 \py@OldContentsline{#1}{%
45 \pdfannotlink attr{/Border [0 0 0]} goto name{page\my@pageno}% 43 \pdfannotlink attr{/Border [0 0 0]} goto name{page\my@pageno}%
46 \LinkColor#2\NormalColor% 44 \py@LinkColor#2\py@NormalColor%
47 \pdfendlink% 45 \pdfendlink%
48 }{#3}% 46 }{#3}%
49 } 47 }
50 % 48 %
51 % This is supposed to build the "outline" view of the document; it seems 49 % This is supposed to build the "outline" view of the document; it seems
53 % 51 %
54 \AtEndDocument{ 52 \AtEndDocument{
55 \InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{} 53 \InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{}
56 } 54 }
57 \newcommand{\py@target}[1]{% 55 \newcommand{\py@target}[1]{%
58 \if@doing@page@targets% 56 \ifpy@doing@page@targets%
59 {\pdfdest name{#1} fit}% 57 {\pdfdest name{#1} fit}%
60 \fi% 58 \fi%
61 } 59 }
62 \let\OldLabel=\label 60 \let\py@OldLabel=\label
63 \renewcommand{\label}[1]{% 61 \renewcommand{\label}[1]{%
64 \OldLabel{#1}% 62 \py@OldLabel{#1}%
65 \py@target{label-#1}% 63 \py@target{label-#1}%
66 } 64 }
67 % This stuff adds a page# destination to every PDF page, where # has 65 % This stuff adds a page# destination to every PDF page, where # has
68 % the same formatting as the displayed page number. This doesn't really 66 % the same formatting as the displayed page number. This doesn't really
69 % help with the frontmatter, but does fine with the body. 67 % help with the frontmatter, but does fine with the body.
110 108
111 % Style parameters and macros used by most documents here 109 % Style parameters and macros used by most documents here
112 \raggedbottom 110 \raggedbottom
113 \sloppy 111 \sloppy
114 \parindent = 0mm 112 \parindent = 0mm
115 \parskip = 2mm 113 \parskip = 2mm
116 \hbadness = 5000 % don't print trivial gripes 114 \hbadness = 5000 % don't print trivial gripes
117 115
118 \pagestyle{empty} % start this way; change for 116 \pagestyle{empty} % start this way; change for
119 \pagenumbering{roman} % ToC & chapters 117 \pagenumbering{roman} % ToC & chapters
120 \setcounter{secnumdepth}{1} 118 \setcounter{secnumdepth}{1}
121 119
122 % Use this to set the font family for headers and other decor: 120 % Use this to set the font family for headers and other decor:
123 \newcommand{\HeaderFamily}{\sffamily} 121 \newcommand{\py@HeaderFamily}{\sffamily}
124 122
125 % Redefine the 'normal' header/footer style when using "fancyhdr" package: 123 % Redefine the 'normal' header/footer style when using "fancyhdr" package:
126 \@ifundefined{fancyhf}{}{ 124 \@ifundefined{fancyhf}{}{
127 % Use \pagestyle{normal} as the primary pagestyle for text. 125 % Use \pagestyle{normal} as the primary pagestyle for text.
128 \fancypagestyle{normal}{ 126 \fancypagestyle{normal}{
129 \fancyhf{} 127 \fancyhf{}
130 \fancyfoot[LE,RO]{{\HeaderFamily\thepage}} 128 \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
131 \fancyfoot[LO]{{\HeaderFamily\nouppercase{\rightmark}}} 129 \fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}}
132 \fancyfoot[RE]{{\HeaderFamily\nouppercase{\leftmark}}} 130 \fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}}
133 \renewcommand{\headrulewidth}{0pt} 131 \renewcommand{\headrulewidth}{0pt}
134 \renewcommand{\footrulewidth}{0.4pt} 132 \renewcommand{\footrulewidth}{0.4pt}
135 } 133 }
136 % Update the plain style so we get the page number & footer line, 134 % Update the plain style so we get the page number & footer line,
137 % but not a chapter or section title. This is to keep the first 135 % but not a chapter or section title. This is to keep the first
138 % page of a chapter and the blank page between chapters `clean.' 136 % page of a chapter and the blank page between chapters `clean.'
139 \fancypagestyle{plain}{ 137 \fancypagestyle{plain}{
140 \fancyhf{} 138 \fancyhf{}
141 \fancyfoot[LE,RO]{{\HeaderFamily\thepage}} 139 \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
142 \renewcommand{\headrulewidth}{0pt} 140 \renewcommand{\headrulewidth}{0pt}
143 \renewcommand{\footrulewidth}{0.4pt} 141 \renewcommand{\footrulewidth}{0.4pt}
144 } 142 }
145 % Redefine \cleardoublepage so that the blank page between chapters 143 % Redefine \cleardoublepage so that the blank page between chapters
146 % gets the plain style and not the fancy style. This is described 144 % gets the plain style and not the fancy style. This is described
154 \if@twocolumn\hbox{}\newpage\fi\fi\fi 152 \if@twocolumn\hbox{}\newpage\fi\fi\fi
155 } 153 }
156 } 154 }
157 } 155 }
158 156
159 % old code font selections:
160 \let\codefont=\tt
161 \let\sectcodefont=\tt
162
163 % (Haven't found a new one that gets <, >, and _ right without being
164 % monospaced.)
165
166
167 % This sets up the {verbatim} environment to be indented and a minipage, 157 % This sets up the {verbatim} environment to be indented and a minipage,
168 % and to have all the other mostly nice properties that we want for 158 % and to have all the other mostly nice properties that we want for
169 % code samples. 159 % code samples.
170 160
171 % Variable used by begin code command 161 % Variable used by begin code command
172 \newlength{\codewidth} 162 \newlength{\py@codewidth}
173 163
174 \newcommand{\examplevspace}{2mm} 164 \newcommand{\py@examplevspace}{2mm}
175 \newcommand{\exampleindent}{1cm} 165 \newcommand{\py@exampleindent}{1cm}
176 166
177 \let\OldVerbatim=\verbatim 167 \let\py@OldVerbatim=\verbatim
178 \let\OldEndVerbatim=\endverbatim 168 \let\py@OldEndVerbatim=\endverbatim
179 \renewcommand{\verbatim}{% 169 \renewcommand{\verbatim}{%
180 \begingroup% 170 \begingroup%
181 \setlength{\parindent}\exampleindent% 171 \setlength{\parindent}\py@exampleindent%
182 % Calculate the text width for the minipage: 172 % Calculate the text width for the minipage:
183 \setlength{\codewidth}{\linewidth}% 173 \setlength{\py@codewidth}{\linewidth}%
184 \addtolength{\codewidth}{-\parindent}% 174 \addtolength{\py@codewidth}{-\parindent}%
185 % 175 %
186 \par% 176 \par%
187 \vspace\examplevspace% 177 \vspace\py@examplevspace%
188 \indent% 178 \indent%
189 \begin{minipage}[t]{\codewidth}% 179 \begin{minipage}[t]{\py@codewidth}%
190 \small% 180 \small%
191 \OldVerbatim% 181 \py@OldVerbatim%
192 } 182 }
193 \renewcommand{\endverbatim}{% 183 \renewcommand{\endverbatim}{%
194 \OldEndVerbatim% 184 \py@OldEndVerbatim%
195 \end{minipage}% 185 \end{minipage}%
196 \endgroup% 186 \endgroup%
197 } 187 }
198 188
199 \newcommand{\reset@python}{ 189 \newcommand{\reset@python}{
200 \global\let\@thisclass=\@undefined 190 \global\let\py@thisclass=\@undefined
201 \global\let\@thismodule=\@undefined 191 \global\let\py@thismodule=\@undefined
202 } 192 }
203 \reset@python 193 \reset@python
204 194
205 % Augment the sectioning commands used to get our own font family in place, 195 % Augment the sectioning commands used to get our own font family in place,
206 % and reset some internal data items: 196 % and reset some internal data items:
207 \renewcommand{\section}{\reset@python% 197 \renewcommand{\section}{\reset@python%
208 \@startsection{section}{1}{\z@}% 198 \@startsection{section}{1}{\z@}%
209 {-3.5ex \@plus -1ex \@minus -.2ex}% 199 {-3.5ex \@plus -1ex \@minus -.2ex}%
210 {2.3ex \@plus.2ex}% 200 {2.3ex \@plus.2ex}%
211 {\reset@font\Large\HeaderFamily}} 201 {\reset@font\Large\py@HeaderFamily}}
212 \renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}% 202 \renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}%
213 {-3.25ex\@plus -1ex \@minus -.2ex}% 203 {-3.25ex\@plus -1ex \@minus -.2ex}%
214 {1.5ex \@plus .2ex}% 204 {1.5ex \@plus .2ex}%
215 {\reset@font\large\HeaderFamily}} 205 {\reset@font\large\py@HeaderFamily}}
216 \renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}% 206 \renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}%
217 {-3.25ex\@plus -1ex \@minus -.2ex}% 207 {-3.25ex\@plus -1ex \@minus -.2ex}%
218 {1.5ex \@plus .2ex}% 208 {1.5ex \@plus .2ex}%
219 {\reset@font\normalsize\HeaderFamily}} 209 {\reset@font\normalsize\py@HeaderFamily}}
220 \renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}% 210 \renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}%
221 {3.25ex \@plus1ex \@minus.2ex}% 211 {3.25ex \@plus1ex \@minus.2ex}%
222 {-1em}% 212 {-1em}%
223 {\reset@font\normalsize\HeaderFamily}} 213 {\reset@font\normalsize\py@HeaderFamily}}
224 \renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}% 214 \renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}%
225 {3.25ex \@plus1ex \@minus .2ex}% 215 {3.25ex \@plus1ex \@minus .2ex}%
226 {-1em}% 216 {-1em}%
227 {\reset@font\normalsize\HeaderFamily}} 217 {\reset@font\normalsize\py@HeaderFamily}}
228 218
229 219
230 % Underscore hack (only act like subscript operator if in math mode) 220 % Underscore hack (only act like subscript operator if in math mode)
231 % 221 %
232 % The following is due to Mark Wooding (the old version didn't work with 222 % The following is due to Mark Wooding (the old version didn't work with
248 % Command to wrap around stuff that refers to function / module / 238 % Command to wrap around stuff that refers to function / module /
249 % attribute names in the index. Default behavior: like \code{}. To 239 % attribute names in the index. Default behavior: like \code{}. To
250 % just keep the index entries in the roman font, uncomment the second 240 % just keep the index entries in the roman font, uncomment the second
251 % definition to use instead; it matches O'Reilly style more. 241 % definition to use instead; it matches O'Reilly style more.
252 % 242 %
253 \newcommand{\idxcode}[1]{\codefont{#1}} 243 \newcommand{\py@idxcode}[1]{\texttt{#1}}
254 %\renewcommand{\idxcode}[1]{#1} 244 %\renewcommand{\py@idxcode}[1]{#1}
255 245
256 % Command to generate two index entries (using subentries) 246 % Command to generate two index entries (using subentries)
257 \newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}} 247 \newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}}
258 248
259 % And three entries (using only one level of subentries) 249 % And three entries (using only one level of subentries)
267 \index{#4!#1 #2 #3} 257 \index{#4!#1 #2 #3}
268 } 258 }
269 259
270 % Command to generate a reference to a function, statement, keyword, 260 % Command to generate a reference to a function, statement, keyword,
271 % operator. 261 % operator.
272 \newcommand{\stindex}[1]{\indexii{statement}{#1@{\idxcode{#1}}}} 262 \newcommand{\stindex}[1]{\indexii{statement}{#1@{\py@idxcode{#1}}}}
273 \newcommand{\opindex}[1]{\indexii{operator}{#1@{\idxcode{#1}}}} 263 \newcommand{\opindex}[1]{\indexii{operator}{#1@{\py@idxcode{#1}}}}
274 \newcommand{\exindex}[1]{\indexii{exception}{#1@{\idxcode{#1}}}} 264 \newcommand{\exindex}[1]{\indexii{exception}{#1@{\py@idxcode{#1}}}}
275 \newcommand{\obindex}[1]{\indexii{object}{#1}} 265 \newcommand{\obindex}[1]{\indexii{object}{#1}}
276 \newcommand{\bifuncindex}[1]{\withsubitem{(built-in function)}{\ttindex{#1()}}} 266 \newcommand{\bifuncindex}[1]{\withsubitem{(built-in function)}{\ttindex{#1()}}}
277 267
278 % Add an index entry for a module 268 % Add an index entry for a module
279 \newcommand{\refmodule}[2]{\index{#1@{\idxcode{#1}} (#2module)}} 269 \newcommand{\py@refmodule}[2]{\index{#1@{\py@idxcode{#1}} (#2module)}}
280 \newcommand{\refmodindex}[1]{\refmodule{#1}{}} 270 \newcommand{\refmodindex}[1]{\py@refmodule{#1}{}}
281 \newcommand{\refbimodindex}[1]{\refmodule{#1}{built-in }} 271 \newcommand{\refbimodindex}[1]{\py@refmodule{#1}{built-in }}
282 \newcommand{\refexmodindex}[1]{\refmodule{#1}{extension }} 272 \newcommand{\refexmodindex}[1]{\py@refmodule{#1}{extension }}
283 \newcommand{\refstmodindex}[1]{\refmodule{#1}{standard }} 273 \newcommand{\refstmodindex}[1]{\py@refmodule{#1}{standard }}
284 274
285 % support for the module index 275 % support for the module index
286 \newif\if@UseModuleIndex 276 \newif\ifpy@UseModuleIndex
287 \@UseModuleIndexfalse 277 \py@UseModuleIndexfalse
288 278
289 \newcommand{\makemodindex}{ 279 \newcommand{\makemodindex}{
290 \newwrite\modindexfile 280 \newwrite\modindexfile
291 \openout\modindexfile=mod\jobname.idx 281 \openout\modindexfile=mod\jobname.idx
292 \@UseModuleIndextrue 282 \py@UseModuleIndextrue
293 } 283 }
294 284
295 % Add the defining entry for a module 285 % Add the defining entry for a module
296 \newcommand{\@modindex}[2]{% 286 \newcommand{\py@modindex}[2]{%
297 \global\def\@thismodule{#1} 287 \global\def\py@thismodule{#1}
298 \setindexsubitem{(in module #1)}% 288 \setindexsubitem{(in module #1)}%
299 \index{#1@{\idxcode{#1}} (#2module)|textbf}% 289 \index{#1@{\py@idxcode{#1}} (#2module)|textbf}%
300 \if@UseModuleIndex% 290 \ifpy@UseModuleIndex%
301 \write\modindexfile{\protect\indexentry{#1@{\tt #1}}{\thepage}}% 291 \write\modindexfile{\protect\indexentry{#1@{\tt #1}}{\thepage}}%
302 \fi% 292 \fi%
303 } 293 }
304 294
305 % built-in & Python modules in the main distribution 295 % built-in & Python modules in the main distribution
306 \newcommand{\bimodindex}[1]{\@modindex{#1}{built-in }} 296 \newcommand{\bimodindex}[1]{\py@modindex{#1}{built-in }}
307 \newcommand{\stmodindex}[1]{\@modindex{#1}{standard }} 297 \newcommand{\stmodindex}[1]{\py@modindex{#1}{standard }}
308 298
309 % Python & extension modules outside the main distribution 299 % Python & extension modules outside the main distribution
310 \newcommand{\modindex}[1]{\@modindex{#1}{}} 300 \newcommand{\modindex}[1]{\py@modindex{#1}{}}
311 \newcommand{\exmodindex}[1]{\@modindex{#1}{extension }} 301 \newcommand{\exmodindex}[1]{\py@modindex{#1}{extension }}
312 302
313 % Additional string for an index entry 303 % Additional string for an index entry
314 \newcommand{\index@subitem}{} 304 \newcommand{\index@subitem}{}
315 \newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}} 305 \newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}}
316 \newcommand{\ttindex}[1]{\index{#1@{\idxcode{#1}} \index@subitem}} 306 \newcommand{\ttindex}[1]{\index{#1@{\py@idxcode{#1}} \index@subitem}}
317 307
318 \newcommand{\withsubitem}[2]{% 308 \newcommand{\withsubitem}[2]{%
319 \begingroup% 309 \begingroup%
320 \def\index@subitem{#1}#2% 310 \def\index@subitem{#1}#2%
321 \endgroup% 311 \endgroup%
338 }{\end{list}} 328 }{\end{list}}
339 329
340 % \optional is mostly for use in the arguments parameters to the various 330 % \optional is mostly for use in the arguments parameters to the various
341 % {*desc} environments defined below, but may be used elsewhere. Known to 331 % {*desc} environments defined below, but may be used elsewhere. Known to
342 % be used in the debugger chapter. 332 % be used in the debugger chapter.
333 %
334 % Typical usage:
335 %
336 % \begin{funcdesc}{myfunc}{reqparm\optional{, optparm}}
337 % ^^^ ^^^
338 % No space here No space here
339 %
340 % When a function has multiple optional parameters, \optional should be
341 % nested, not chained. This is right:
342 %
343 % \begin{funcdesc}{myfunc}{\optional{parm1\optional{, parm2}}}
344 %
343 \newcommand{\optional}[1]{% 345 \newcommand{\optional}[1]{%
344 {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}} 346 {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
345 347
346 % C functions ------------------------------------------------------------ 348 % C functions ------------------------------------------------------------
347 % \begin{cfuncdesc}{type}{name}{arglist} 349 % \begin{cfuncdesc}{type}{name}{arglist}
348 \newenvironment{cfuncdesc}[3]{ 350 \newenvironment{cfuncdesc}[3]{
349 \begin{fulllineitems} 351 \begin{fulllineitems}
350 \item[\code{#1 \bfcode{#2}(\py@varvars{#3})}\index{#2@{\idxcode{#2()}}}] 352 \item[\code{#1 \bfcode{#2}(\py@varvars{#3})}\index{#2@{\py@idxcode{#2()}}}]
351 }{\end{fulllineitems}} 353 }{\end{fulllineitems}}
352 354
353 % C variables ------------------------------------------------------------ 355 % C variables ------------------------------------------------------------
354 % \begin{cvardesc}{type}{name} 356 % \begin{cvardesc}{type}{name}
355 \newenvironment{cvardesc}[2]{ 357 \newenvironment{cvardesc}[2]{
356 \begin{fulllineitems} 358 \begin{fulllineitems}
357 \item[\code{#1 \bfcode{#2}}\index{#2@{\idxcode{#2}}}] 359 \item[\code{#1 \bfcode{#2}}\index{#2@{\py@idxcode{#2}}}]
358 }{\end{fulllineitems}} 360 }{\end{fulllineitems}}
359 361
360 % C data types ----------------------------------------------------------- 362 % C data types -----------------------------------------------------------
361 % \begin{ctypedesc}{typedef name} 363 % \begin{ctypedesc}{typedef name}
362 \newenvironment{ctypedesc}[1]{ 364 \newenvironment{ctypedesc}[1]{
380 }{\end{fulllineitems}} 382 }{\end{fulllineitems}}
381 383
382 % classes ---------------------------------------------------------------- 384 % classes ----------------------------------------------------------------
383 % \begin{classdesc}{name}{constructor args} 385 % \begin{classdesc}{name}{constructor args}
384 \newenvironment{classdesc}[2]{ 386 \newenvironment{classdesc}[2]{
385 \global\def\@thisclass{#1} 387 \global\def\py@thisclass{#1}
386 \begin{fulllineitems} 388 \begin{fulllineitems}
387 \item[\code{\bfcode{#1}(\py@varvars{#2})}% 389 \item[\code{\bfcode{#1}(\py@varvars{#2})}%
388 \withsubitem{(class in \@thismodule)}{\ttindex{#1}}] 390 \withsubitem{(class in \py@thismodule)}{\ttindex{#1}}]
389 \def\baseclasses##1{} 391 }{\end{fulllineitems}}
390 }{\end{fulllineitems}} 392
391 393
392 394 \let\py@classbadkey=\@undefined
393 \newcommand{\@classbadkey}{--bad current class--}
394 \let\@classbadkey=\@undefined
395 395
396 % object method ---------------------------------------------------------- 396 % object method ----------------------------------------------------------
397 % \begin{methoddesc}[classname]{methodname}{args} 397 % \begin{methoddesc}[classname]{methodname}{args}
398 \newcommand{\methodline}[3][\@classbadkey]{ 398 \newcommand{\methodline}[3][\py@classbadkey]{
399 \methodlineni{#2}{#3} 399 \methodlineni{#2}{#3}
400 \ifx#1\@undefined 400 \ifx#1\@undefined
401 \withsubitem{(\@thisclass\ method)}{\ttindex{#2()}} 401 \withsubitem{(\py@thisclass\ method)}{\ttindex{#2()}}
402 \else 402 \else
403 \withsubitem{(#1 method)}{\ttindex{#2()}} 403 \withsubitem{(#1 method)}{\ttindex{#2()}}
404 \fi 404 \fi
405 } 405 }
406 \newenvironment{methoddesc}[3][\@classbadkey]{ 406 \newenvironment{methoddesc}[3][\py@classbadkey]{
407 \begin{fulllineitems} 407 \begin{fulllineitems}
408 \ifx#1\@undefined 408 \ifx#1\@undefined
409 \methodline{#2}{#3} 409 \methodline{#2}{#3}
410 \else 410 \else
411 \def\@thisclass{#1} 411 \def\py@thisclass{#1}
412 \methodline[#1]{#2}{#3} 412 \methodline[#1]{#2}{#3}
413 \fi 413 \fi
414 }{\end{fulllineitems}} 414 }{\end{fulllineitems}}
415 415
416 % similar to {methoddesc}, but doesn't add to the index 416 % similar to {methoddesc}, but doesn't add to the index
417 % (never actually uses the optional argument) 417 % (never actually uses the optional argument)
418 \newcommand{\methodlineni}[3][\@classbadkey]{% 418 \newcommand{\methodlineni}[3][\py@classbadkey]{%
419 \item[\code{\bfcode{#2}(\py@varvars{#3})}]} 419 \item[\code{\bfcode{#2}(\py@varvars{#3})}]}
420 \newenvironment{methoddescni}[3][\@classbadkey]{ 420 \newenvironment{methoddescni}[3][\py@classbadkey]{
421 \begin{fulllineitems} 421 \begin{fulllineitems}
422 \methodlineni{#2}{#3} 422 \methodlineni{#2}{#3}
423 }{\end{fulllineitems}} 423 }{\end{fulllineitems}}
424 424
425 % object data attribute -------------------------------------------------- 425 % object data attribute --------------------------------------------------
426 % \begin{memberdesc}[classname]{membername} 426 % \begin{memberdesc}[classname]{membername}
427 \newcommand{\memberline}[2][\@classbadkey]{% 427 \newcommand{\memberline}[2][\py@classbadkey]{%
428 \ifx#1\@undefined 428 \ifx#1\@undefined
429 \memberlineni{#2} 429 \memberlineni{#2}
430 \withsubitem{(\@thisclass\ attribute)}{\ttindex{#2}} 430 \withsubitem{(\py@thisclass\ attribute)}{\ttindex{#2}}
431 \else 431 \else
432 \memberlineni{#2} 432 \memberlineni{#2}
433 \withsubitem{(#1 attribute)}{\ttindex{#2}} 433 \withsubitem{(#1 attribute)}{\ttindex{#2}}
434 \fi 434 \fi
435 } 435 }
436 \newenvironment{memberdesc}[2][\@classbadkey]{ 436 \newenvironment{memberdesc}[2][\py@classbadkey]{
437 \begin{fulllineitems} 437 \begin{fulllineitems}
438 \ifx#1\@undefined 438 \ifx#1\@undefined
439 \memberline{#2} 439 \memberline{#2}
440 \else 440 \else
441 \def\@thisclass{#1} 441 \def\py@thisclass{#1}
442 \memberline[#1]{#2} 442 \memberline[#1]{#2}
443 \fi 443 \fi
444 }{\end{fulllineitems}} 444 }{\end{fulllineitems}}
445 445
446 % similar to {memberdesc}, but doesn't add to the index 446 % similar to {memberdesc}, but doesn't add to the index
447 % (never actually uses the optional argument) 447 % (never actually uses the optional argument)
448 \newcommand{\memberlineni}[2][\@classbadkey]{\item[\bfcode{#2}]} 448 \newcommand{\memberlineni}[2][\py@classbadkey]{\item[\bfcode{#2}]}
449 \newenvironment{memberdescni}[2][\@classbadkey]{ 449 \newenvironment{memberdescni}[2][\py@classbadkey]{
450 \begin{fulllineitems} 450 \begin{fulllineitems}
451 \memberlineni{#2} 451 \memberlineni{#2}
452 }{\end{fulllineitems}} 452 }{\end{fulllineitems}}
453 453
454 % For exceptions: -------------------------------------------------------- 454 % For exceptions: --------------------------------------------------------
481 \begin{fulllineitems} 481 \begin{fulllineitems}
482 \item[\bfcode{#1}\quad\var{#2}] 482 \item[\bfcode{#1}\quad\var{#2}]
483 }{\end{fulllineitems}} 483 }{\end{fulllineitems}}
484 484
485 485
486 \let\nodename=\label 486 \newcommand{\nodename}[1]{\label{#1}}
487
488 \newcommand{\sectcode}[1]{{\sectcodefont{#1}}}
489 487
490 % For these commands, use \command{} to get the typography right, not 488 % For these commands, use \command{} to get the typography right, not
491 % {\command}. This works better with the texinfo translation. 489 % {\command}. This works better with the texinfo translation.
492 \newcommand{\ABC}{{\sc abc}} 490 \newcommand{\ABC}{{\sc abc}}
493 \newcommand{\UNIX}{{\sc Unix}} 491 \newcommand{\UNIX}{{\sc Unix}}
494 \newcommand{\POSIX}{POSIX} 492 \newcommand{\POSIX}{POSIX}
495 \newcommand{\ASCII}{{\sc ascii}} 493 \newcommand{\ASCII}{{\sc ascii}}
496 \newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}} 494 \newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}}
497 \newcommand{\C}{C} 495 \newcommand{\C}{C}
498 \newcommand{\EOF}{{\sc eof}} 496 \newcommand{\EOF}{{\sc eof}}
499 \newcommand{\NULL}{\sectcode{NULL}} 497 \newcommand{\NULL}{\constant{NULL}}
500 498
501 % Also for consistency: spell Python "Python", not "python"! 499 % Also for consistency: spell Python "Python", not "python"!
502 500
503 % code is the most difficult one... 501 % code is the most difficult one...
504 \newcommand{\code}[1]{{\@vobeyspaces\@noligs\def\{{\char`\{}\def\}{\char`\}}\def\~{\char`\~}\def\^{\char`\^}\def\e{\char`\\}\def\${\char`\$}\def\#{\char`\#}\def\&{\char`\&}\def\%{\char`\%}% 502 \newcommand{\code}[1]{{\@vobeyspaces\@noligs\def\{{\char`\{}\def\}{\char`\}}\def\~{\char`\~}\def\^{\char`\^}\def\e{\char`\\}\def\${\char`\$}\def\#{\char`\#}\def\&{\char`\&}\def\%{\char`\%}%
505 \mbox{\codefont{#1}}}} 503 \texttt{#1}}}
506 504
507 \newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font 505 \newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font
508 \newcommand{\kbd}[1]{\mbox{\tt #1}} 506 \newcommand{\kbd}[1]{\tt #1}
509 \newcommand{\key}[1]{\mbox{\tt #1}} 507 \newcommand{\samp}[1]{`\code{#1}'}
510 \newcommand{\samp}[1]{\mbox{`\code{#1}'}}
511 % This weird definition of \var{} allows it to always appear in roman 508 % This weird definition of \var{} allows it to always appear in roman
512 % italics, and won't get funky in code fragments when we play around 509 % italics, and won't get funky in code fragments when we play around
513 % with fonts. 510 % with fonts.
514 \newcommand{\var}[1]{\mbox{\normalsize\textrm{\textit{#1\/}}}} 511 \newcommand{\var}[1]{\normalsize\textrm{\textit{#1\/}}}
515 \renewcommand{\emph}[1]{{\em #1\/}} 512 \renewcommand{\emph}[1]{{\em #1}}
516 \newcommand{\dfn}[1]{\emph{#1}} 513 \newcommand{\dfn}[1]{\emph{#1}}
517 \newcommand{\strong}[1]{{\bf #1}} 514 \newcommand{\strong}[1]{{\bf #1}}
518 % let's experiment with a new font: 515 % let's experiment with a new font:
519 \newcommand{\file}[1]{`{\small\textsf{#1}}'} 516 \newcommand{\file}[1]{`{\small\textsf{#1}}'}
520 517
523 \@ifundefined{pdfannotlink}{ 520 \@ifundefined{pdfannotlink}{
524 \newcommand{\py@url}[1]{\mbox{\small\textsf{#1}}} 521 \newcommand{\py@url}[1]{\mbox{\small\textsf{#1}}}
525 }{ 522 }{
526 \newcommand{\py@url}[1]{{% 523 \newcommand{\py@url}[1]{{%
527 \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% 524 \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}%
528 \LinkColor% color of the link text 525 \py@LinkColor% color of the link text
529 {\small\textsf{#1}}% 526 \mbox{\small\textsf{#1}}%
530 \NormalColor% Turn it back off; these are declarative 527 \py@NormalColor% Turn it back off; these are declarative
531 \pdfendlink}% and don't appear bound to the current 528 \pdfendlink}% and don't appear bound to the current
532 }% formatting "box". 529 }% formatting "box".
533 } 530 }
534 \let\url=\py@url 531 \let\url=\py@url
535 \newcommand{\email}[1]{{\small\textsf{#1}}} 532 \newcommand{\email}[1]{{\small\textsf{#1}}}
536 \newcommand{\newsgroup}[1]{{\small\textsf{#1}}} 533 \newcommand{\newsgroup}[1]{{\small\textsf{#1}}}
537 534
538 \newcommand{\py@varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}} 535 \newcommand{\py@varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}}
539 536 % let's see if this breaks anything now; we may be able to simplify...
537 \renewcommand{\py@varvars}[1]{\var{#1}}
538
539 % I'd really like to get rid of this!
540 \newif\iftexi\texifalse 540 \newif\iftexi\texifalse
541 \newif\iflatex\latextrue
542 541
543 % These should be used for all references to identifiers which are 542 % These should be used for all references to identifiers which are
544 % used to refer to instances of specific language constructs. See the 543 % used to refer to instances of specific language constructs. See the
545 % names for specific semantic assignments. 544 % names for specific semantic assignments.
546 % 545 %
547 % For now, don't do anything really fancy with them; just use them as 546 % For now, don't do anything really fancy with them; just use them as
548 % logical markup. This might change in the future. 547 % logical markup. This might change in the future.
549 % 548 %
550 \let\module=\sectcode 549 \newcommand{\module}[1]{\texttt{#1}}
551 \let\keyword=\sectcode 550 \newcommand{\keyword}[1]{\texttt{#1}}
552 \let\exception=\sectcode 551 \newcommand{\exception}[1]{\texttt{#1}}
553 \let\class=\sectcode 552 \newcommand{\class}[1]{\texttt{#1}}
554 \let\function=\sectcode 553 \newcommand{\function}[1]{\texttt{#1}}
555 \let\member=\sectcode 554 \newcommand{\member}[1]{\texttt{#1}}
556 \let\method=\sectcode 555 \newcommand{\method}[1]{\texttt{#1}}
557 556
558 \newcommand{\pytype}[1]{#1} % built-in Python type 557 \newcommand{\pytype}[1]{#1} % built-in Python type
559 558
560 \let\cfunction=\sectcode 559 \newcommand{\cfunction}[1]{\texttt{#1}}
561 \let\ctype=\sectcode 560 \newcommand{\ctype}[1]{\texttt{#1}} % C struct or typedef name
562 \let\cdata=\sectcode 561 \newcommand{\cdata}[1]{\texttt{#1}} % C variable, typically global
563 562
564 \newcommand{\mimetype}[1]{{\small\textsf{#1}}} 563 \newcommand{\mimetype}[1]{{\small\textsf{#1}}}
565 % The \! is a "negative thin space" in math mode. 564 % The \! is a "negative thin space" in math mode.
566 \newcommand{\regexp}[1]{% 565 \newcommand{\regexp}[1]{%
567 {\tiny$^{^\lceil}\!\!$% 566 {\tiny$^{^\lceil}\!\!$%
571 \newcommand{\envvar}[1]{% 570 \newcommand{\envvar}[1]{%
572 \$#1% $ <-- bow to font-lock 3 times! 571 \$#1% $ <-- bow to font-lock 3 times!
573 \index{#1@{\$#1}}% $ 572 \index{#1@{\$#1}}% $
574 \index{environment variables!{\$#1}}% $ 573 \index{environment variables!{\$#1}}% $
575 } 574 }
576 \newcommand{\makevar}[1]{#1} 575 \newcommand{\makevar}[1]{#1} % variable in a Makefile
577 \let\character=\samp 576 \newcommand{\character}[1]{\samp{#1}}
578 577
579 % constants defined in Python modules or C headers, not language constants: 578 % constants defined in Python modules or C headers, not language constants:
580 \let\constant=\sectcode 579 \newcommand{\constant}[1]{\code{#1}} % manifest constant, not syntactic
581 580
582 \newcommand{\manpage}[2]{{\emph{#1}(#2)}} 581 \newcommand{\manpage}[2]{{\emph{#1}(#2)}}
583 \newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}} 582 \newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}}
584 \newcommand{\program}[1]{\strong{#1}} 583 \newcommand{\program}[1]{\strong{#1}}
585 584
591 % First parameter is the release number that deprecates the feature, the 590 % First parameter is the release number that deprecates the feature, the
592 % second is the action the should be taken by users of the feature. 591 % second is the action the should be taken by users of the feature.
593 % 592 %
594 % Example: 593 % Example:
595 % 594 %
596 % \deprecated {1.5.1} 595 % \deprecated{1.5.1}{Use \method{frobnicate()} instead.}
597 % {Use \method{frobnicate()} instead.}
598 % 596 %
599 \newcommand{\deprecated}[2]{% 597 \newcommand{\deprecated}[2]{%
600 \strong{Deprecated since release #1.} #2\par} 598 \strong{Deprecated since release #1.} #2\par}
601 599
602 600
621 \newcommand{\itemnewline}[1]{% 619 \newcommand{\itemnewline}[1]{%
622 \@tempdima\linewidth% 620 \@tempdima\linewidth%
623 \advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}% 621 \advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}%
624 } 622 }
625 623
626 % Cross-referencing (AMK) 624 % Cross-referencing (AMK, new impl. FLD)
627 % Sample usage: 625 % Sample usage:
628 % \begin{seealso} 626 % \begin{seealso}
629 % \seemodule{rand}{Uniform random number generator}; % Module xref 627 % \seemodule{rand}{Uniform random number generator}; % Module xref
630 % \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book 628 % \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book
631 % 629 %
632 % % A funky case: module name contains '_'; have to supply an optional key 630 % % A funky case: module name contains '_'; have to supply an optional key
633 % \seemodule[copyreg]{copy_reg}{pickle interface constructor registration} 631 % \seemodule[copyreg]{copy_reg}{pickle interface constructor registration}
634 % 632 %
635 % \end{seealso} 633 % \end{seealso}
636 634
637 \newcommand{\@modulebadkey}{{--just-some-junk--}} 635 \newcommand{\py@modulebadkey}{{--just-some-junk--}}
638 636
639 \@ifundefined{pdfannotlink}{% 637 \@ifundefined{pdfannotlink}{%
640 \newcommand{\seemodule}[3][\@modulebadkey]{% 638 \newcommand{\py@seemodule}[3][\py@modulebadkey]{%
641 \ifx\@modulebadkey#1\def\@modulekey{#2}\else\def\@modulekey{#1}\fi% 639 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
642 \ref{module-\@modulekey}:\quad % 640 \ref{module-\py@modulekey}:\quad %
643 Module \module{#2}% 641 Module \module{#2}%
644 \quad (#3)% 642 \quad (#3)%
645 } 643 }
646 }{\newcommand{\seemodule}[3][\@modulebadkey]{% 644 }{\newcommand{\py@seemodule}[3][\py@modulebadkey]{%
647 \ifx\@modulebadkey#1\def\@modulekey{#2}\else\def\@modulekey{#1}\fi% 645 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
648 \ref{module-\@modulekey}:\quad % 646 \ref{module-\py@modulekey}:\quad %
649 {\pdfannotlink attr{/Border [0 0 0]} goto name{label-module-\@modulekey}% 647 {\pdfannotlink attr{/Border [0 0 0]} goto name{label-module-\py@modulekey}%
650 \LinkColor Module \module{#2} \NormalColor% 648 \py@LinkColor Module \module{#2} \py@NormalColor%
651 \pdfendlink% 649 \pdfendlink%
652 }% 650 }%
653 \quad (#3)% 651 \quad (#3)%
654 } 652 }
655 } 653 }
656 \newenvironment{seealso}[0]{ 654 \newenvironment{seealso}[0]{
657 \strong{See Also:}\par 655 \strong{See Also:}\par
658 \def\seetext##1{\par{##1}} 656 \def\seetext##1{\par{##1}}
657 \let\seemodule=\py@seemodule
659 }{\par} 658 }{\par}
660 659
661 660
662 % Allow the release number to be specified independently of the 661 % Allow the release number to be specified independently of the
663 % \date{}. This allows the date to reflect the document's date and 662 % \date{}. This allows the date to reflect the document's date and
664 % release to specify the Python release that is documented. 663 % release to specify the Python release that is documented.
665 % 664 %
666 \newcommand{\@release}{} 665 \newcommand{\py@release}{}
667 \newcommand{\version}{} 666 \newcommand{\version}{}
668 \newcommand{\releasename}{Release} 667 \newcommand{\releasename}{Release}
669 \newcommand{\release}[1]{% 668 \newcommand{\release}[1]{%
670 \renewcommand{\@release}{\releasename\space\version}% 669 \renewcommand{\py@release}{\releasename\space\version}%
671 \renewcommand{\version}{#1}} 670 \renewcommand{\version}{#1}}
672 671
673 % Allow specification of the author's address separately from the 672 % Allow specification of the author's address separately from the
674 % author's name. This can be used to format them differently, which 673 % author's name. This can be used to format them differently, which
675 % is a good thing. 674 % is a good thing.
676 % 675 %
677 \newcommand{\@authoraddress}{} 676 \newcommand{\py@authoraddress}{}
678 \newcommand{\authoraddress}[1]{\renewcommand{\@authoraddress}{#1}} 677 \newcommand{\authoraddress}[1]{\renewcommand{\py@authoraddress}{#1}}
679 678
680 % This sets up the fancy chapter headings that make the documents look 679 % This sets up the fancy chapter headings that make the documents look
681 % at least a little better than the usual LaTeX output. 680 % at least a little better than the usual LaTeX output.
682 % 681 %
683 \@ifundefined{ChTitleVar}{}{ 682 \@ifundefined{ChTitleVar}{}{
684 \ChNameVar{\raggedleft\normalsize\HeaderFamily} 683 \ChNameVar{\raggedleft\normalsize\py@HeaderFamily}
685 \ChNumVar{\raggedleft \bfseries\Large\HeaderFamily} 684 \ChNumVar{\raggedleft \bfseries\Large\py@HeaderFamily}
686 \ChTitleVar{\raggedleft \rm\Huge\HeaderFamily} 685 \ChTitleVar{\raggedleft \rm\Huge\py@HeaderFamily}
687 % This creates chapter heads without the leading \vspace*{}: 686 % This creates chapter heads without the leading \vspace*{}:
688 \def\@makechapterhead#1{% 687 \def\@makechapterhead#1{%
689 {\parindent \z@ \raggedright \normalfont 688 {\parindent \z@ \raggedright \normalfont
690 \ifnum \c@secnumdepth >\m@ne 689 \ifnum \c@secnumdepth >\m@ne
691 \DOCH 690 \DOCH