source: anuga_core/documentation/user_manual/python.sty @ 7297

Last change on this file since 7297 was 7134, checked in by rwilson, 15 years ago

Major wide-spread changes to the user manual.

File size: 40.1 KB
Line 
1%
2% python.sty for the Python docummentation  [works only with Latex2e]
3%
4
5\NeedsTeXFormat{LaTeX2e}[1995/12/01]
6\ProvidesPackage{python}
7             [1998/01/11 LaTeX package (Python markup)]
8
9\RequirePackage{longtable}
10\RequirePackage{underscore}
11
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
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
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
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%
32\newif\ifpy@doing@page@targets
33\py@doing@page@targetsfalse
34
35\newif\ifpdf\pdffalse
36\ifx\pdfoutput\undefined\else\ifcase\pdfoutput
37\else
38  \pdftrue
39  \input{pdfcolor}
40  \let\py@LinkColor=\NavyBlue
41  \let\py@NormalColor=\Black
42  \pdfcompresslevel=9
43  \pdfpagewidth=\paperwidth    % page width of PDF output
44  \pdfpageheight=\paperheight  % page height of PDF output
45  %
46  % Pad the number with '0' to 3 digits wide so no page name is a prefix
47  % of any other.
48  %
49  \newcommand{\py@targetno}[1]{\ifnum#1<100 0\fi\ifnum#1<10 0\fi#1}
50  \newcommand{\py@pageno}{\py@targetno\thepage}
51  %
52  % This definition allows the entries in the page-view of the ToC to be
53  % active links.  Some work, some don't.
54  %
55  \let\py@OldContentsline=\contentsline
56  %
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  %
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  %
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]{%
77    \py@pdfstartlink attr{/Border [0 0 0]} goto name{#1}%
78      \py@LinkColor#2\py@NormalColor%
79    \pdfendlink%
80  }
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.
83  \renewcommand{\contentsline}[3]{%
84    \def\my@pageno{\py@targetno{#3}}%
85    \py@OldContentsline{#1}{\py@linkToName{page\my@pageno}{#2}}{#3}%
86  }
87  \AtEndDocument{
88    \def\_{\string_}
89    \InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{}
90  }
91  \newcommand{\py@target}[1]{%
92    \ifpy@doing@page@targets%
93      {\pdfdest name{#1} xyz}%
94    \fi%
95  }
96  \let\py@OldLabel=\label
97  \renewcommand{\label}[1]{%
98    \py@OldLabel{#1}%
99    \py@target{label-#1}%
100  }
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.
104  %
105  % This is *heavily* based on the hyperref package.
106  %
107  \def\@begindvi{%
108    \unvbox \@begindvibox
109    \@hyperfixhead
110  }
111  \def\@hyperfixhead{%
112   \let\H@old@thehead\@thehead
113       \global\def\@foo{\py@target{page\py@pageno}}%
114     \expandafter\ifx\expandafter\@empty\H@old@thehead
115       \def\H@old@thehead{\hfil}\fi
116    \def\@thehead{\@foo\relax\H@old@thehead}%
117  }
118\fi\fi
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
126\textheight \paperheight
127\advance\textheight by -2in
128
129\oddsidemargin 0pt
130\evensidemargin 0pt
131%\evensidemargin -.25in  % for ``manual size'' documents
132\marginparwidth 0.5in
133
134\textwidth \paperwidth
135\advance\textwidth by -2in
136
137
138% Style parameters and macros used by most documents here
139\raggedbottom
140\sloppy
141\parindent = 0mm
142\parskip = 2mm
143\hbadness = 5000                % don't print trivial gripes
144
145\pagestyle{empty}               % start this way; change for
146\pagenumbering{roman}           % ToC & chapters
147
148% Use this to set the font family for headers and other decor:
149\newcommand{\py@HeaderFamily}{\sffamily}
150
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
154\let\py@oldmakefntext\@makefntext
155\def\@makefntext#1{%
156  \bgroup%
157    \py@infootnotetrue
158    \py@oldmakefntext{#1}%
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
168% Redefine the 'normal' header/footer style when using "fancyhdr" package:
169\@ifundefined{fancyhf}{}{
170  % Use \pagestyle{normal} as the primary pagestyle for text.
171  \fancypagestyle{normal}{
172    \fancyhf{}
173    \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
174    \fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}}
175    \fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}}
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{}
184    \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
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.
191  \@ifundefined{chapter}{}{
192    \renewcommand{\cleardoublepage}{
193      \clearpage\if@openright \ifodd\c@page\else
194      \hbox{}
195      \thispagestyle{plain}
196      \newpage
197      \if@twocolumn\hbox{}\newpage\fi\fi\fi
198    }
199  }
200}
201
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
206\let\py@OldVerbatim=\verbatim
207\let\py@OldEndVerbatim=\endverbatim
208\RequirePackage{verbatim}
209\let\py@OldVerbatimInput=\verbatiminput
210
211% Variable used by begin code command
212\newlength{\py@codewidth}
213
214\renewcommand{\verbatim}{%
215  \setlength{\parindent}{1cm}%
216  % Calculate the text width for the minipage:
217  \setlength{\py@codewidth}{\linewidth}%
218  \addtolength{\py@codewidth}{-\parindent}%
219  %
220  \par\indent%
221  \begin{minipage}[t]{\py@codewidth}%
222    \small%
223    \py@OldVerbatim%
224}
225\renewcommand{\endverbatim}{%
226    \py@OldEndVerbatim%
227  \end{minipage}%
228}
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}
242
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}%
253  \let\e=\textbackslash%
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
265
266\newcommand{\py@modulebadkey}{{--just-some-junk--}}
267
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
274% definition; it matches O'Reilly style more.
275%
276\newcommand{\py@idxcode}[1]{\texttt{#1}}
277%\renewcommand{\py@idxcode}[1]{#1}
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.
295\newcommand{\kwindex}[1]{\indexii{keyword}{#1@{\py@idxcode{#1}}}}
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}}}}
299\newcommand{\obindex}[1]{\indexii{object}{#1}}
300\newcommand{\bifuncindex}[1]{%
301  \index{#1@{\py@idxcode{#1()}} (built-in function)}}
302
303% Add an index entry for a module
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 }}
309
310% Refer to a module's documentation using a hyperlink of the module's
311% name, at least if we're building PDF:
312\ifpdf
313  \newcommand{\refmodule}[2][\py@modulebadkey]{%
314    \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
315    \py@linkToName{label-module-\py@modulekey}{\module{#2}}%
316  }
317\else
318  \newcommand{\refmodule}[2][\py@modulebadkey]{\module{#2}}
319\fi
320
321% support for the module index
322\newif\ifpy@UseModuleIndex
323\py@UseModuleIndexfalse
324
325\newcommand{\makemodindex}{
326  \newwrite\modindexfile
327  \openout\modindexfile=mod\jobname.idx
328  \py@UseModuleIndextrue
329}
330
331% Add the defining entry for a module
332\newcommand{\py@modindex}[2]{%
333  \renewcommand{\py@thismodule}{#1}
334  \setindexsubitem{(in module #1)}%
335  \index{#1@{\py@idxcode{#1}} (#2module)|textbf}%
336  \ifpy@UseModuleIndex%
337    \@ifundefined{py@modplat@\py@thismodulekey}{
338      \write\modindexfile{\protect\indexentry{#1@{\texttt{#1}}}{\thepage}}%
339    }{\write\modindexfile{\protect\indexentry{#1@{\texttt{#1} %
340        \emph{(\py@platformof[\py@thismodulekey]{})}}}{\thepage}}%
341    }
342  \fi%
343}
344
345% *** XXX *** THE NEXT FOUR MACROS ARE NOW OBSOLETE !!! ***
346
347% built-in & Python modules in the main distribution
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!}}
352
353% Python & extension modules outside the main distribution
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!}}
358
359% Additional string for an index entry
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}
371\newcommand{\withsubitem}[2]{%
372  \begingroup%
373    \def\ttindex##1{\index{##1@{\py@idxcode{##1}} #1}}%
374    #2%
375  \endgroup%
376}
377
378
379% Module synopsis processing -----------------------------------------------
380%
381\newcommand{\py@thisclass}{}
382\newcommand{\py@thismodule}{}
383\newcommand{\py@thismodulekey}{}
384\newcommand{\py@thismoduletype}{}
385
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}{}}
390
391\newif\ifpy@HaveModSynopsis       \py@HaveModSynopsisfalse
392\newif\ifpy@ModSynopsisFileIsOpen \py@ModSynopsisFileIsOpenfalse
393\newif\ifpy@HaveModPlatform       \py@HaveModPlatformfalse
394
395% \declaremodule[key]{type}{name}
396\newcommand{\declaremodule}[3][\py@modulebadkey]{
397  \py@openModSynopsisFile
398  \renewcommand{\py@thismoduletype}{#2}
399  \ifx\py@modulebadkey#1
400    \renewcommand{\py@thismodulekey}{#3}
401  \else
402    \renewcommand{\py@thismodulekey}{#1}
403  \fi
404  \@ifundefined{py@#2IndexModule}{%
405    \typeout{*** MACRO declaremodule called with unknown module type: `#2'}
406    \py@IndexModule{#3}%
407  }{%
408    \csname py@#2IndexModule\endcsname{#3}%
409  }
410  \label{module-\py@thismodulekey}
411}
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
420}
421\InputIfFileExists{\jobname.pla}{}{}
422\newcommand{\py@platformof}[2][\py@modulebadkey]{%
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]{}
429
430% \moduleauthor{name}{email}
431\newcommand{\moduleauthor}[2]{}
432
433% \sectionauthor{name}{email}
434\newcommand{\sectionauthor}[2]{}
435
436
437\newcommand{\py@defsynopsis}{Module has no synopsis.}
438\newcommand{\py@modulesynopsis}{\py@defsynopsis}
439\newcommand{\modulesynopsis}[1]{
440  \py@HaveModSynopsistrue
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
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
485\newcommand{\localmoduletable}{
486  \IfFileExists{\py@ModSynopsisFilename}{
487    \begin{synopsistable}
488      \input{\py@ModSynopsisFilename}
489    \end{synopsistable}
490  }{}
491}
492
493\ifpdf
494  \newcommand{\py@ModSynopsisSummary}[4]{%
495    \py@linkToName{label-module-#1}{\bfcode{#2}} & #4\\
496  }
497\else
498  \newcommand{\py@ModSynopsisSummary}[4]{\bfcode{#2} & #4\\}
499\fi
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
511\newcommand{\py@reset}{
512  \py@usingsubitemfalse
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
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
550% {fulllineitems} is used in one place in libregex.tex, but is really for
551% internal use in this file.
552%
553\newcommand{\py@itemnewline}[1]{%
554  \@tempdima\linewidth%
555  \advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}%
556}
557
558\newenvironment{fulllineitems}{
559  \begin{list}{}{\labelwidth \leftmargin \labelsep 0pt
560                 \rightmargin 0pt \topsep -\parskip \partopsep \parskip
561                 \itemsep -\parsep
562                 \let\makelabel=\py@itemnewline}
563}{\end{list}}
564
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.
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%
580\let\py@badkey=\@undefined
581
582\newcommand{\optional}[1]{%
583  {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
584
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
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
604% C functions ------------------------------------------------------------
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.
608\newcommand{\cfuncline}[3]{
609  \py@sigline{\code{#1 \bfcode{#2}}}{#3}%
610  \index{#2@{\py@idxcode{#2()}}}
611}
612\newenvironment{cfuncdesc}[4][\py@badkey]{
613  \linebreak
614  \linebreak
615  \begin{fulllineitems}
616    \cfuncline{#2}{#3}{#4}
617    \ifx#1\@undefined\else%
618      \emph{Return value: \textbf{#1}.}\\
619    \fi
620  \linebreak
621  \linebreak
622}{\end{fulllineitems}}
623
624% C variables ------------------------------------------------------------
625% \begin{cvardesc}{type}{name}
626\newenvironment{cvardesc}[2]{
627  \begin{fulllineitems}
628    \item[\code{#1 \bfcode{#2}}\index{#2@{\py@idxcode{#2}}}]
629}{\end{fulllineitems}}
630
631% C data types -----------------------------------------------------------
632% \begin{ctypedesc}[index name]{typedef name}
633\newenvironment{ctypedesc}[2][\py@badkey]{
634  \begin{fulllineitems}
635    \item[\bfcode{#2}%
636    \ifx#1\@undefined%
637      \index{#2@{\py@idxcode{#2}} (C type)}
638    \else%
639      \index{#2@{\py@idxcode{#1}} (C type)}
640    \fi]
641}{\end{fulllineitems}}
642
643% C type fields ----------------------------------------------------------
644% \begin{cmemberdesc}{container type}{ctype}{membername}
645\newcommand{\cmemberline}[3]{
646  \item[\code{#2 \bfcode{#3}}]
647  \index{#3@{\py@idxcode{#3}} (#1 member)}
648}
649\newenvironment{cmemberdesc}[3]{
650  \begin{fulllineitems}
651    \cmemberline{#1}{#2}{#3}
652}{\end{fulllineitems}}
653
654% Funky macros -----------------------------------------------------------
655% \begin{csimplemacrodesc}{name}
656% -- "simple" because it has no args; NOT for constant definitions!
657\newenvironment{csimplemacrodesc}[1]{
658  \begin{fulllineitems}
659    \item[\bfcode{#1}\index{#1@{\py@idxcode{#1}} (macro)}]
660}{\end{fulllineitems}}
661
662% simple functions (not methods) -----------------------------------------
663% \begin{funcdesc}{name}{args}
664\newcommand{\funcline}[2]{%
665  \funclineni{#1}{#2}%
666  \index{#1@{\py@idxcode{#1()}} (in module \py@thismodule)}}
667\newenvironment{funcdesc}[2]{
668  \begin{fulllineitems}
669    \funcline{#1}{#2}
670}{\end{fulllineitems}}
671
672% similar to {funcdesc}, but doesn't add to the index
673\newcommand{\funclineni}[2]{%
674  \py@sigline{\bfcode{#1}}{#2}}
675\newenvironment{funcdescni}[2]{
676  \begin{fulllineitems}
677    \funclineni{#1}{#2}
678}{\end{fulllineitems}}
679
680% classes ----------------------------------------------------------------
681% \begin{classdesc}{name}{constructor args}
682\newenvironment{classdesc}[2]{
683  % Using \renewcommand doesn't work for this, for unknown reasons:
684  \global\def\py@thisclass{#1}
685  \begin{fulllineitems}
686    \py@sigline{\strong{class }\bfcode{#1}}{#2}%
687    \index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}
688}{\end{fulllineitems}}
689
690% \begin{classdesc*}{name}
691\newenvironment{classdesc*}[1]{
692  % Using \renewcommand doesn't work for this, for unknown reasons:
693  \global\def\py@thisclass{#1}
694  \begin{fulllineitems}
695    \item[\strong{class }\code{\bfcode{#1}}%
696      \index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}]
697}{\end{fulllineitems}}
698
699% \begin{excclassdesc}{name}{constructor args}
700% but indexes as an exception
701\newenvironment{excclassdesc}[2]{
702  % Using \renewcommand doesn't work for this, for unknown reasons:
703  \global\def\py@thisclass{#1}
704  \begin{fulllineitems}
705    \py@sigline{\strong{exception }\bfcode{#1}}{#2}%
706    \index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}
707}{\end{fulllineitems}}
708
709% There is no corresponding {excclassdesc*} environment.  To describe
710% a class exception without parameters, use the {excdesc} environment.
711
712
713\let\py@classbadkey=\@undefined
714
715% object method ----------------------------------------------------------
716% \begin{methoddesc}[classname]{methodname}{args}
717\newcommand{\methodline}[3][\@undefined]{
718  \methodlineni{#2}{#3}
719  \ifx#1\@undefined
720    \index{#2@{\py@idxcode{#2()}} (\py@thisclass\ method)}
721  \else
722    \index{#2@{\py@idxcode{#2()}} (#1 method)}
723  \fi
724}
725\newenvironment{methoddesc}[3][\@undefined]{
726  \begin{fulllineitems}
727    \ifx#1\@undefined
728      \methodline{#2}{#3}
729    \else
730      \def\py@thisclass{#1}
731      \methodline{#2}{#3}
732    \fi
733}{\end{fulllineitems}}
734
735% similar to {methoddesc}, but doesn't add to the index
736% (never actually uses the optional argument)
737\newcommand{\methodlineni}[3][\py@classbadkey]{%
738  \py@sigline{\bfcode{#2}}{#3}}
739\newenvironment{methoddescni}[3][\py@classbadkey]{
740  \begin{fulllineitems}
741    \methodlineni{#2}{#3}
742}{\end{fulllineitems}}
743
744% object data attribute --------------------------------------------------
745% \begin{memberdesc}[classname]{membername}
746\newcommand{\memberline}[2][\py@classbadkey]{%
747  \ifx#1\@undefined
748    \memberlineni{#2}
749    \index{#2@{\py@idxcode{#2}} (\py@thisclass\ attribute)}
750  \else
751    \memberlineni{#2}
752    \index{#2@{\py@idxcode{#2}} (#1 attribute)}
753  \fi
754}
755\newenvironment{memberdesc}[2][\py@classbadkey]{
756  \begin{fulllineitems}
757    \ifx#1\@undefined
758      \memberline{#2}
759    \else
760      \def\py@thisclass{#1}
761      \memberline{#2}
762    \fi
763}{\end{fulllineitems}}
764
765% similar to {memberdesc}, but doesn't add to the index
766% (never actually uses the optional argument)
767\newcommand{\memberlineni}[2][\py@classbadkey]{\item[\bfcode{#2}]}
768\newenvironment{memberdescni}[2][\py@classbadkey]{
769  \begin{fulllineitems}
770    \memberlineni{#2}
771}{\end{fulllineitems}}
772
773% For exceptions: --------------------------------------------------------
774% \begin{excdesc}{name}
775%  -- for constructor information, use excclassdesc instead
776\newenvironment{excdesc}[1]{
777  \begin{fulllineitems}
778    \item[\strong{exception }\bfcode{#1}%
779          \index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}]
780}{\end{fulllineitems}}
781
782% Module data or constants: ----------------------------------------------
783% \begin{datadesc}{name}
784\newcommand{\dataline}[1]{%
785  \datalineni{#1}\index{#1@{\py@idxcode{#1}} (data in \py@thismodule)}}
786\newenvironment{datadesc}[1]{
787  \begin{fulllineitems}
788    \dataline{#1}
789}{\end{fulllineitems}}
790
791% similar to {datadesc}, but doesn't add to the index
792\newcommand{\datalineni}[1]{\item[\bfcode{#1}]\nopagebreak}
793\newenvironment{datadescni}[1]{
794  \begin{fulllineitems}
795    \datalineni{#1}
796}{\end{fulllineitems}}
797
798% bytecode instruction ---------------------------------------------------
799% \begin{opcodedesc}{name}{var}
800% -- {var} may be {}
801\newenvironment{opcodedesc}[2]{
802  \begin{fulllineitems}
803    \item[\bfcode{#1}\quad\var{#2}]
804}{\end{fulllineitems}}
805
806
807\newcommand{\nodename}[1]{\label{#1}}
808
809% For these commands, use \command{} to get the typography right, not
810% {\command}.  This works better with the texinfo translation.
811\newcommand{\ABC}{{\sc abc}}
812\newcommand{\UNIX}{{\sc Unix}}
813\newcommand{\POSIX}{POSIX}
814\newcommand{\ASCII}{{\sc ascii}}
815\newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}}
816\newcommand{\C}{C}
817\newcommand{\EOF}{{\sc eof}}
818\newcommand{\NULL}{\constant{NULL}}
819\newcommand{\infinity}{\ensuremath{\infty}}
820\newcommand{\plusminus}{\ensuremath{\pm}}
821
822% \guilabel{Start}
823\newcommand{\guilabel}[1]{\textsf{#1}}
824% \menuselection{Start \sub Programs \sub Python}
825\newcommand{\menuselection}[1]{\guilabel{{\def\sub{ \ensuremath{>} }#1}}}
826
827% Also for consistency: spell Python "Python", not "python"!
828
829% code is the most difficult one...
830\newcommand{\code}[1]{\textrm{\@vobeyspaces\@noligs\def\{{\char`\{}\def\}{\char`\}}\def\~{\char`\~}\def\^{\char`\^}\def\e{\char`\\}\def\${\char`\$}\def\#{\char`\#}\def\&{\char`\&}\def\%{\char`\%}%
831\texttt{#1}}}
832
833\newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font
834\newcommand{\csimplemacro}[1]{\code{#1}}
835\newcommand{\kbd}[1]{\code{#1}}
836\newcommand{\samp}[1]{`\code{#1}'}
837\newcommand{\var}[1]{%
838  \ifmmode%
839    \hbox{\py@defaultsize\textrm{\textit{#1\/}}}%
840  \else%
841    \py@defaultsize\textrm{\textit{#1\/}}%
842  \fi%
843}
844\renewcommand{\emph}[1]{{\em #1}}
845\newcommand{\dfn}[1]{\emph{#1}}
846\newcommand{\strong}[1]{{\bf #1}}
847% let's experiment with a new font:
848\newcommand{\file}[1]{`\filenq{#1}'}
849\newcommand{\filenq}[1]{{\py@smallsize\textsf{\let\e=\textbackslash#1}}}
850
851% Use this def/redef approach for \url{} since hyperref defined this already,
852% but only if we actually used hyperref:
853\ifpdf
854  \newcommand{\url}[1]{{%
855    \py@pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}%
856    \py@LinkColor%                              color of the link text
857    \py@smallsize\sf #1%
858    \py@NormalColor%                    Turn it back off; these are declarative
859    \pdfendlink}%                       and don't appear bound to the current
860  }%                                    formatting "box".
861\else
862  \newcommand{\url}[1]{\mbox{\py@smallsize\textsf{#1}}}
863\fi
864\newcommand{\email}[1]{{\py@smallsize\textsf{#1}}}
865\newcommand{\newsgroup}[1]{{\py@smallsize\textsf{#1}}}
866
867\newcommand{\py@varvars}[1]{{%
868  {\let\unspecified=\py@unspecified%
869   \let\moreargs=\py@moreargs%
870   \var{#1}}}}
871
872% I'd really like to get rid of this!
873\newif\iftexi\texifalse
874
875% This is used to get l2h to put the copyright and abstract on
876% a separate HTML page.
877\newif\ifhtml\htmlfalse
878
879
880% These should be used for all references to identifiers which are
881% used to refer to instances of specific language constructs.  See the
882% names for specific semantic assignments.
883%
884% For now, don't do anything really fancy with them; just use them as
885% logical markup.  This might change in the future.
886%
887\newcommand{\module}[1]{\texttt{#1}}
888\newcommand{\keyword}[1]{\texttt{#1}}
889\newcommand{\exception}[1]{\texttt{#1}}
890\newcommand{\class}[1]{\texttt{#1}}
891\newcommand{\function}[1]{\texttt{#1}}
892\newcommand{\member}[1]{\texttt{#1}}
893\newcommand{\method}[1]{\texttt{#1}}
894
895\newcommand{\pytype}[1]{#1}             % built-in Python type
896
897\newcommand{\cfunction}[1]{\texttt{#1}}
898\newcommand{\ctype}[1]{\texttt{#1}}     % C struct or typedef name
899\newcommand{\cdata}[1]{\texttt{#1}}     % C variable, typically global
900
901\newcommand{\mailheader}[1]{{\py@smallsize\textsf{#1:}}}
902\newcommand{\mimetype}[1]{{\py@smallsize\textsf{#1}}}
903% The \! is a "negative thin space" in math mode.
904\newcommand{\regexp}[1]{%
905  {\tiny$^{^\lceil}\!\!$%
906   {\py@defaultsize\code{#1}}%
907   $\!\rfloor\!$%
908  }}
909\newcommand{\envvar}[1]{%
910  #1%
911  \index{#1}%
912  \index{environment variables!{#1}}%
913}
914\newcommand{\makevar}[1]{#1}            % variable in a Makefile
915\newcommand{\character}[1]{\samp{#1}}
916
917% constants defined in Python modules or C headers, not language constants:
918\newcommand{\constant}[1]{\code{#1}}    % manifest constant, not syntactic
919
920\newcommand{\manpage}[2]{{\emph{#1}(#2)}}
921\newcommand{\pep}[1]{PEP #1\index{Python Enhancement Proposals!PEP #1}}
922\newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}}
923\newcommand{\program}[1]{\strong{#1}}
924\newcommand{\programopt}[1]{\strong{#1}}
925% Note that \longprogramopt provides the '--'!
926\newcommand{\longprogramopt}[1]{\strong{-{}-#1}}
927
928% \ulink{link text}{URL}
929\ifpdf
930  \newcommand{\ulink}[2]{{%
931    % For PDF, we *should* only generate a link when the URL is absolute.
932    \py@pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#2)}%
933    \py@LinkColor%                              color of the link text
934    #1%
935    \py@NormalColor%                    Turn it back off; these are declarative
936    \pdfendlink}%                       and don't appear bound to the current
937  }%                                    formatting "box".
938\else
939  \newcommand{\ulink}[2]{#1}
940\fi
941
942% cited titles:  \citetitle{Title of Work}
943%       online:  \citetitle[url-to-resource]{Title of Work}
944\ifpdf
945  \newcommand{\citetitle}[2][\py@modulebadkey]{%
946    \ifx\py@modulebadkey#1\emph{#2}\else\ulink{\emph{#2}}{#1}\fi%
947  }
948\else
949  \newcommand{\citetitle}[2][URL]{\emph{#2}}
950\fi
951
952
953
954% This version is being checked in for the historical record; it shows
955% how I've managed to get some aspects of this to work.  It will not
956% be used in practice, so a subsequent revision will change things
957% again.  This version has problems, but shows how to do something
958% that proved more tedious than I'd expected, so I don't want to lose
959% the example completely.
960%
961\newcommand{\grammartoken}[1]{\texttt{#1}}
962\newenvironment{productionlist}[1][\py@badkey]{
963  \def\optional##1{{\Large[}##1{\Large]}}
964  \def\production##1##2{\code{##1}&::=&\code{##2}\\}
965  \def\productioncont##1{& &\code{##1}\\}
966  \def\token##1{##1}
967  \let\grammartoken=\token
968  \parindent=2em
969  \indent
970  \begin{tabular}{lcl}
971}{%
972  \end{tabular}
973}
974
975\newlength{\py@noticelength}
976
977\newcommand{\py@heavybox}{
978  \setlength{\fboxrule}{2pt}
979  \setlength{\fboxsep}{7pt}
980  \setlength{\py@noticelength}{\linewidth}
981  \addtolength{\py@noticelength}{-2\fboxsep}
982  \addtolength{\py@noticelength}{-2\fboxrule}
983  \setlength{\shadowsize}{3pt}
984  \Sbox
985  \minipage{\py@noticelength}
986}
987\newcommand{\py@endheavybox}{
988  \endminipage
989  \endSbox
990  \fbox{\TheSbox}
991}
992
993% a 'note' is as plain as it gets:
994\newcommand{\py@noticelabel@note}{Note:}
995\newcommand{\py@noticestart@note}{}
996\newcommand{\py@noticeend@note}{}
997
998% a 'warning' gets more visible distinction:
999\newcommand{\py@noticelabel@warning}{Warning:}
1000\newcommand{\py@noticestart@warning}{\py@heavybox}
1001\newcommand{\py@noticeend@warning}{\py@endheavybox}
1002
1003\newenvironment{notice}[1][note]{
1004  \def\py@noticetype{#1}
1005  \csname py@noticestart@#1\endcsname
1006  \par\strong{\csname py@noticelabel@#1\endcsname}
1007}{\csname py@noticeend@\py@noticetype\endcsname}
1008\newcommand{\note}[1]{\strong{\py@noticelabel@note} #1}
1009\newcommand{\warning}[1]{\strong{\py@noticelabel@warning} #1}
1010
1011% Deprecation stuff.
1012% Should be extended to allow an index / list of deprecated stuff.  But
1013% there's a lot of stuff that needs to be done to make that automatable.
1014%
1015% First parameter is the release number that deprecates the feature, the
1016% second is the action the should be taken by users of the feature.
1017%
1018% Example:
1019%  \deprecated{1.5.1}{Use \method{frobnicate()} instead.}
1020%
1021\newcommand{\deprecated}[2]{%
1022  \strong{Deprecated since release #1.}  #2\par}
1023
1024% New stuff.
1025% This should be used to mark things which have been added to the
1026% development tree but that aren't in the release, but are documented.
1027% This allows release of documentation that already includes updated
1028% descriptions.  Place at end of descriptor environment.
1029%
1030% Example:
1031%  \versionadded{1.5.2}
1032%  \versionchanged[short explanation]{2.0}
1033%
1034\newcommand{\versionadded}[2][\py@badkey]{%
1035  \ifx#1\@undefined%
1036    {  New in version #2.  }%
1037  \else%
1038    {  New in version #2:\ #1.  }%
1039  \fi%
1040}
1041\newcommand{\versionchanged}[2][\py@badkey]{%
1042  \ifx#1\@undefined%
1043    {  Changed in version #2.  }%
1044  \else%
1045    {  Changed in version #2:\ #1.  }%
1046  \fi%
1047}
1048
1049
1050% Tables.
1051%
1052\newenvironment{tableii}[4]{%
1053  \begin{center}%
1054    \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
1055    \begin{tabular}{#1}\strong{#3}&\strong{#4} \\* \hline%
1056}{%
1057    \end{tabular}%
1058  \end{center}%
1059}
1060
1061\newenvironment{longtableii}[4]{%
1062  \begin{center}%
1063    \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
1064    \begin{longtable}[c]{#1}\strong{#3}&\strong{#4} \\* \hline\endhead%
1065}{%
1066    \end{longtable}%
1067  \end{center}%
1068}
1069
1070\newenvironment{tableiii}[5]{%
1071  \begin{center}%
1072    \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
1073    \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5} \\%
1074      \hline%
1075}{%
1076    \end{tabular}%
1077  \end{center}%
1078}
1079
1080\newenvironment{longtableiii}[5]{%
1081  \begin{center}%
1082    \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
1083    \begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5} \\%
1084      \hline\endhead%
1085}{%
1086    \end{longtable}%
1087  \end{center}%
1088}
1089
1090\newenvironment{tableiv}[6]{%
1091  \begin{center}%
1092    \def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}%
1093    \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6} \\%
1094      \hline%
1095}{%
1096    \end{tabular}%
1097  \end{center}%
1098}
1099
1100\newenvironment{longtableiv}[6]{%
1101  \begin{center}%
1102    \def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}%
1103    \begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}%
1104      \\%
1105      \hline\endhead%
1106}{%
1107    \end{longtable}%
1108  \end{center}%
1109}
1110
1111\newenvironment{tablev}[7]{%
1112  \begin{center}%
1113    \def\linev##1##2##3##4##5{\csname#2\endcsname{##1}&##2&##3&##4&##5\\}%
1114    \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}&\strong{#7} \\%
1115      \hline%
1116}{%
1117    \end{tabular}%
1118  \end{center}%
1119}
1120
1121\newenvironment{longtablev}[7]{%
1122  \begin{center}%
1123    \def\linev##1##2##3##4##5{\csname#2\endcsname{##1}&##2&##3&##4&##5\\}%
1124    \begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}&\strong{#7}%
1125      \\%
1126      \hline\endhead%
1127}{%
1128    \end{longtable}%
1129  \end{center}%
1130}
1131
1132% XXX Don't think we can use this yet, though it cleans up some
1133% tedious markup.  There's no equivalent for the HTML transform yet,
1134% and that needs to exist.  I don't know how to write it.
1135%
1136% This should really have something that makes it easier to bind a
1137% table's ``Notes'' column and an associated tablenotes environment,
1138% and generates the right magic for getting the numbers right in the
1139% table.
1140%
1141% So this is quite incomplete.
1142%
1143\newcounter{py@tablenotescounter}
1144\newenvironment{tablenotes}{%
1145  \noindent Notes:
1146  \par
1147  \setcounter{py@tablenotescounter}{0}
1148  \begin{list}{(\arabic{py@tablenotescounter})}%
1149              {\usecounter{py@tablenotescounter}}
1150}{\end{list}}
1151
1152
1153% Cross-referencing (AMK, new impl. FLD)
1154% Sample usage:
1155%  \begin{seealso}
1156%    \seemodule{rand}{Uniform random number generator.}; % Module xref
1157%    \seetext{\emph{Encyclopedia Britannica}}.           % Ref to a book
1158%
1159%    % A funky case: module name contains '_'; have to supply an optional key
1160%    \seemodule[copyreg]{copy_reg}{Interface constructor registration for
1161%                                  \module{pickle}.}
1162%  \end{seealso}
1163%
1164% Note that the last parameter for \seemodule and \seetext should be complete
1165% sentences and be terminated with the proper punctuation.
1166
1167\ifpdf
1168  \newcommand{\py@seemodule}[3][\py@modulebadkey]{%
1169    \par%
1170    \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
1171    \begin{fulllineitems}
1172      \item[\py@linkToName{label-module-\py@modulekey}{Module \module{#2}}
1173            (section \ref{module-\py@modulekey}):]
1174      #3
1175    \end{fulllineitems}
1176  }
1177\else
1178  \newcommand{\py@seemodule}[3][\py@modulebadkey]{%
1179    \par%
1180    \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
1181    \begin{fulllineitems}
1182      \item[Module \module{#2} (section \ref{module-\py@modulekey}):]
1183      #3
1184    \end{fulllineitems}
1185  }
1186\fi
1187
1188% \seelink{url}{link text}{why it's interesting}
1189\newcommand{\py@seelink}[3]{%
1190  \par
1191  \begin{fulllineitems}
1192    \item[\ulink{#2}{#1}]
1193    #3
1194  \end{fulllineitems}
1195}
1196% \seetitle[url]{title}{why it's interesting}
1197\newcommand{\py@seetitle}[3][\py@modulebadkey]{%
1198  \par
1199  \begin{fulllineitems}
1200    \item[\citetitle{#2}]
1201    \ifx\py@modulebadkey#1\else
1202      \item[{\small{(\url{#1})}}]
1203    \fi
1204    #3
1205  \end{fulllineitems}
1206}
1207% \seepep{number}{title}{why it's interesting}
1208\newcommand{\py@seepep}[3]{%
1209  \par%
1210  \begin{fulllineitems}
1211    \item[\pep{#1}, ``\emph{#2}'']
1212    #3
1213  \end{fulllineitems}
1214}
1215% \seerfc{number}{title}{why it's interesting}
1216\newcommand{\py@seerfc}[3]{%
1217  \par%
1218  \begin{fulllineitems}
1219    \item[\rfc{#1}, ``\emph{#2}'']
1220    #3
1221  \end{fulllineitems}
1222}
1223% \seeurl{url}{why it's interesting}
1224\newcommand{\py@seeurl}[2]{%
1225  \par%
1226  \begin{fulllineitems}
1227    \item[\url{#1}]
1228    #2
1229  \end{fulllineitems}
1230}
1231
1232\newenvironment{seealso*}{
1233  \par
1234  \def\seetext##1{\par{##1}}
1235  \let\seemodule=\py@seemodule
1236  \let\seepep=\py@seepep
1237  \let\seerfc=\py@seerfc
1238  \let\seetitle=\py@seetitle
1239  \let\seeurl=\py@seeurl
1240  \let\seelink=\py@seelink
1241}{\par}
1242\newenvironment{seealso}{
1243  \par
1244  \strong{See Also:}
1245  \par
1246  \def\seetext##1{\par{##1}}
1247  \let\seemodule=\py@seemodule
1248  \let\seepep=\py@seepep
1249  \let\seerfc=\py@seerfc
1250  \let\seetitle=\py@seetitle
1251  \let\seeurl=\py@seeurl
1252  \let\seelink=\py@seelink
1253}{\par}
1254
1255% Allow the Python release number to be specified independently of the
1256% \date{}.  This allows the date to reflect the document's date and
1257% release to specify the Python release that is documented.
1258%
1259\newcommand{\py@release}{}
1260\newcommand{\version}{}
1261\newcommand{\shortversion}{}
1262\newcommand{\releaseinfo}{}
1263\newcommand{\releasename}{Release}
1264\newcommand{\release}[1]{%
1265  \renewcommand{\py@release}{\releasename\space\version}%
1266  \renewcommand{\version}{#1}}
1267\newcommand{\setshortversion}[1]{%
1268  \renewcommand{\shortversion}{#1}}
1269\newcommand{\setreleaseinfo}[1]{%
1270  \renewcommand{\releaseinfo}{#1}}
1271
1272% Allow specification of the author's address separately from the
1273% author's name.  This can be used to format them differently, which
1274% is a good thing.
1275%
1276\newcommand{\py@authoraddress}{}
1277\newcommand{\authoraddress}[1]{\renewcommand{\py@authoraddress}{#1}}
1278\let\developersaddress=\authoraddress
1279\let\developer=\author
1280\let\developers=\author
1281
1282% This sets up the fancy chapter headings that make the documents look
1283% at least a little better than the usual LaTeX output.
1284%
1285\@ifundefined{ChTitleVar}{}{
1286  \ChNameVar{\raggedleft\normalsize\py@HeaderFamily}
1287  \ChNumVar{\raggedleft \bfseries\Large\py@HeaderFamily}
1288  \ChTitleVar{\raggedleft \rm\Huge\py@HeaderFamily}
1289  % This creates chapter heads without the leading \vspace*{}:
1290  \def\@makechapterhead#1{%
1291    {\parindent \z@ \raggedright \normalfont
1292      \ifnum \c@secnumdepth >\m@ne
1293        \DOCH
1294      \fi
1295      \interlinepenalty\@M
1296      \DOTI{#1}
1297    }
1298  }
1299}
1300
1301
1302% Definition lists; requested by AMK for HOWTO documents.  Probably useful
1303% elsewhere as well, so keep in in the general style support.
1304%
1305\newenvironment{definitions}{%
1306  \begin{description}%
1307  \def\term##1{\item[##1]\mbox{}\\*[0mm]}
1308}{%
1309  \end{description}%
1310}
1311
1312% Tell TeX about pathological hyphenation cases:
1313\hyphenation{Base-HTTP-Re-quest-Hand-ler}
Note: See TracBrowser for help on using the repository browser.