blob: a83f794f076bf08046eadf67616a5339070f801f [file] [log] [blame]
Fred Drake6659c301998-03-03 22:02:19 +00001%
Fred Drake6663b221998-03-06 22:33:06 +00002% python.sty for the Python docummentation [works only with with Latex2e]
Fred Drake6659c301998-03-03 22:02:19 +00003%
4
5\NeedsTeXFormat{LaTeX2e}[1995/12/01]
6\ProvidesPackage{python}
Fred Drakec0b2e451998-03-25 14:53:43 +00007 [1998/01/11 LaTeX package (Python markup)]
Fred Drake6659c301998-03-03 22:02:19 +00008
Fred Drakeda72b932000-09-21 15:58:02 +00009\RequirePackage{longtable}
10
Fred Drake9466b9a1999-03-18 16:18:27 +000011% Uncomment these two lines to ignore the paper size and make the page
12% size more like a typical published manual.
13%\renewcommand{\paperheight}{9in}
14%\renewcommand{\paperwidth}{8.5in} % typical squarish manual
15%\renewcommand{\paperwidth}{7in} % O'Reilly ``Programmming Python''
16
Fred Drake454a4fb1998-04-01 22:20:14 +000017% These packages can be used to add marginal annotations which indicate
18% index entries and labels; useful for reviewing this messy documentation!
19%
20%\RequirePackage{showkeys}
21%\RequirePackage{showidx}
22
Fred Drakec0b2e451998-03-25 14:53:43 +000023% for PDF output, use maximal compression & a lot of other stuff
24% (test for PDF recommended by Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov>)
25%
Fred Drake24340ea1998-04-28 18:30:34 +000026\newif\ifpy@doing@page@targets
27\py@doing@page@targetsfalse
Fred Drake6cb71491998-03-27 05:22:53 +000028
Fred Drakee59feb52001-10-29 21:02:28 +000029\newif\ifpdf\pdffalse
Fred Drakec0b2e451998-03-25 14:53:43 +000030\ifx\pdfoutput\undefined\else\ifcase\pdfoutput
Fred Drakec0b2e451998-03-25 14:53:43 +000031\else
Fred Drakee59feb52001-10-29 21:02:28 +000032 \pdftrue
Fred Drake6659c301998-03-03 22:02:19 +000033 \input{pdfcolor}
Fred Drake24340ea1998-04-28 18:30:34 +000034 \let\py@LinkColor=\NavyBlue
35 \let\py@NormalColor=\Black
Fred Drake6659c301998-03-03 22:02:19 +000036 \pdfcompresslevel=9
Fred Drakeba1700c1998-05-11 20:42:54 +000037 \pdfpagewidth=\paperwidth % page width of PDF output
38 \pdfpageheight=\paperheight % page height of PDF output
Fred Drakeebcb6581998-03-06 21:25:17 +000039 %
Fred Drakea2c2a831998-04-15 17:50:01 +000040 % Pad the number with '0' to 3 digits wide so no page name is a prefix
41 % of any other.
42 %
Fred Drakea488f301998-07-23 17:50:45 +000043 \newcommand{\py@targetno}[1]{\ifnum#1<100 0\fi\ifnum#1<10 0\fi#1}
44 \newcommand{\py@pageno}{\py@targetno\thepage}
Fred Drakea2c2a831998-04-15 17:50:01 +000045 %
Fred Drakeebcb6581998-03-06 21:25:17 +000046 % This definition allows the entries in the page-view of the ToC to be
47 % active links. Some work, some don't.
48 %
Fred Drake24340ea1998-04-28 18:30:34 +000049 \let\py@OldContentsline=\contentsline
Fred Drakeaa2aea01999-01-27 17:37:36 +000050 %
Fred Drake0e4cd7f2002-03-16 04:52:36 +000051 % Backward compatibility hack: pdfTeX 0.13 defined \pdfannotlink,
52 % but it changed to \pdfstartlink in 0.14. This let's us use either
53 % version and still get useful behavior.
54 %
55 \@ifundefined{pdfstartlink}{
56 \let\pdfstartlink=\pdfannotlink
57 }{}
58 %
Fred Drakeaa2aea01999-01-27 17:37:36 +000059 % Macro that takes two args: the name to link to and the content of
60 % the link. This takes care of the PDF magic, getting the colors
61 % the same for each link, and avoids having lots of garbage all over
62 % this style file.
63 \newcommand{\py@linkToName}[2]{%
Fred Drake53815882002-03-15 23:21:37 +000064 \pdfstartlink attr{/Border [0 0 0]} goto name{#1}%
Fred Drakeaa2aea01999-01-27 17:37:36 +000065 \py@LinkColor#2\py@NormalColor%
66 \pdfendlink%
Fred Drake53815882002-03-15 23:21:37 +000067 }
Fred Drakea2c2a831998-04-15 17:50:01 +000068 % Compute the padded page number separately since we end up with a pair of
69 % \relax tokens; this gets the right string computed and works.
Fred Drake6659c301998-03-03 22:02:19 +000070 \renewcommand{\contentsline}[3]{%
Fred Drakea2c2a831998-04-15 17:50:01 +000071 \def\my@pageno{\py@targetno{#3}}%
Fred Drakeaa2aea01999-01-27 17:37:36 +000072 \py@OldContentsline{#1}{\py@linkToName{page\my@pageno}{#2}}{#3}%
Fred Drake6659c301998-03-03 22:02:19 +000073 }
Fred Drakeebcb6581998-03-06 21:25:17 +000074 \AtEndDocument{
Fred Drakec0b2e451998-03-25 14:53:43 +000075 \InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{}
Fred Drakeebcb6581998-03-06 21:25:17 +000076 }
Fred Drakea2c2a831998-04-15 17:50:01 +000077 \newcommand{\py@target}[1]{%
Fred Drake24340ea1998-04-28 18:30:34 +000078 \ifpy@doing@page@targets%
Fred Drake9b8afde1999-03-24 14:16:17 +000079 {\pdfdest name{#1} xyz}%
Fred Drakea2c2a831998-04-15 17:50:01 +000080 \fi%
81 }
Fred Drake24340ea1998-04-28 18:30:34 +000082 \let\py@OldLabel=\label
Fred Drake6659c301998-03-03 22:02:19 +000083 \renewcommand{\label}[1]{%
Fred Drake24340ea1998-04-28 18:30:34 +000084 \py@OldLabel{#1}%
Fred Drakea2c2a831998-04-15 17:50:01 +000085 \py@target{label-#1}%
Fred Drake6659c301998-03-03 22:02:19 +000086 }
Fred Drakeba1700c1998-05-11 20:42:54 +000087 % This stuff adds a page# destination to every PDF page, where # is three
88 % digits wide, padded with leading zeros. This doesn't really help with
89 % the frontmatter, but does fine with the body.
Fred Drake6659c301998-03-03 22:02:19 +000090 %
91 % This is *heavily* based on the hyperref package.
92 %
Fred Drake1c8d0e01998-03-07 05:29:15 +000093 \def\@begindvi{%
94 \unvbox \@begindvibox
95 \@hyperfixhead
Fred Drake6659c301998-03-03 22:02:19 +000096 }
Fred Drake1c8d0e01998-03-07 05:29:15 +000097 \def\@hyperfixhead{%
98 \let\H@old@thehead\@thehead
Fred Drakea2c2a831998-04-15 17:50:01 +000099 \global\def\@foo{\py@target{page\py@pageno}}%
Fred Drake1c8d0e01998-03-07 05:29:15 +0000100 \expandafter\ifx\expandafter\@empty\H@old@thehead
101 \def\H@old@thehead{\hfil}\fi
102 \def\@thehead{\@foo\relax\H@old@thehead}%
Fred Drake6659c301998-03-03 22:02:19 +0000103 }
Fred Drakec0b2e451998-03-25 14:53:43 +0000104\fi\fi
Fred Drake6659c301998-03-03 22:02:19 +0000105
106% Increase printable page size (copied from fullpage.sty)
107\topmargin 0pt
108\advance \topmargin by -\headheight
109\advance \topmargin by -\headsep
110
111% attempt to work a little better for A4 users
Fred Drake9466b9a1999-03-18 16:18:27 +0000112\textheight \paperheight
113\advance\textheight by -2in
Fred Drake6659c301998-03-03 22:02:19 +0000114
115\oddsidemargin 0pt
Fred Drake9466b9a1999-03-18 16:18:27 +0000116\evensidemargin 0pt
117%\evensidemargin -.25in % for ``manual size'' documents
Fred Drake6659c301998-03-03 22:02:19 +0000118\marginparwidth 0.5in
119
Fred Drake9466b9a1999-03-18 16:18:27 +0000120\textwidth \paperwidth
121\advance\textwidth by -2in
Fred Drake6659c301998-03-03 22:02:19 +0000122
123
124% Style parameters and macros used by most documents here
125\raggedbottom
126\sloppy
127\parindent = 0mm
Fred Drake24340ea1998-04-28 18:30:34 +0000128\parskip = 2mm
Fred Drakeab357ec2001-03-02 18:57:05 +0000129\hbadness = 5000 % don't print trivial gripes
Fred Drake6659c301998-03-03 22:02:19 +0000130
Fred Drakeab357ec2001-03-02 18:57:05 +0000131\pagestyle{empty} % start this way; change for
132\pagenumbering{roman} % ToC & chapters
Fred Drake6659c301998-03-03 22:02:19 +0000133
134% Use this to set the font family for headers and other decor:
Fred Drake24340ea1998-04-28 18:30:34 +0000135\newcommand{\py@HeaderFamily}{\sffamily}
Fred Drake6659c301998-03-03 22:02:19 +0000136
137% Redefine the 'normal' header/footer style when using "fancyhdr" package:
Fred Drake1c8d0e01998-03-07 05:29:15 +0000138\@ifundefined{fancyhf}{}{
Fred Drake6659c301998-03-03 22:02:19 +0000139 % Use \pagestyle{normal} as the primary pagestyle for text.
140 \fancypagestyle{normal}{
141 \fancyhf{}
Fred Drake24340ea1998-04-28 18:30:34 +0000142 \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
143 \fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}}
144 \fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}}
Fred Drake6659c301998-03-03 22:02:19 +0000145 \renewcommand{\headrulewidth}{0pt}
146 \renewcommand{\footrulewidth}{0.4pt}
147 }
148 % Update the plain style so we get the page number & footer line,
149 % but not a chapter or section title. This is to keep the first
150 % page of a chapter and the blank page between chapters `clean.'
151 \fancypagestyle{plain}{
152 \fancyhf{}
Fred Drake24340ea1998-04-28 18:30:34 +0000153 \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
Fred Drake6659c301998-03-03 22:02:19 +0000154 \renewcommand{\headrulewidth}{0pt}
155 \renewcommand{\footrulewidth}{0.4pt}
156 }
157 % Redefine \cleardoublepage so that the blank page between chapters
158 % gets the plain style and not the fancy style. This is described
159 % in the documentation for the fancyhdr package by Piet von Oostrum.
Fred Drake1c8d0e01998-03-07 05:29:15 +0000160 \@ifundefined{chapter}{}{
Fred Drake28f13911998-03-04 21:47:59 +0000161 \renewcommand{\cleardoublepage}{
Fred Drake1c8d0e01998-03-07 05:29:15 +0000162 \clearpage\if@openright \ifodd\c@page\else
Fred Drake28f13911998-03-04 21:47:59 +0000163 \hbox{}
164 \thispagestyle{plain}
165 \newpage
Fred Drake1c8d0e01998-03-07 05:29:15 +0000166 \if@twocolumn\hbox{}\newpage\fi\fi\fi
Fred Drake28f13911998-03-04 21:47:59 +0000167 }
168 }
Fred Drake6659c301998-03-03 22:02:19 +0000169}
170
Fred Drake6659c301998-03-03 22:02:19 +0000171% This sets up the {verbatim} environment to be indented and a minipage,
172% and to have all the other mostly nice properties that we want for
173% code samples.
174
Fred Drake9466b9a1999-03-18 16:18:27 +0000175\let\py@OldVerbatim=\verbatim
176\let\py@OldEndVerbatim=\endverbatim
177\RequirePackage{verbatim}
Fred Drake00f712e2002-03-28 22:28:43 +0000178\let\py@OldVerbatimInput=\verbatiminput
Fred Drake9466b9a1999-03-18 16:18:27 +0000179
Fred Drake6659c301998-03-03 22:02:19 +0000180% Variable used by begin code command
Fred Drake24340ea1998-04-28 18:30:34 +0000181\newlength{\py@codewidth}
Fred Drake6659c301998-03-03 22:02:19 +0000182
Fred Drake6659c301998-03-03 22:02:19 +0000183\renewcommand{\verbatim}{%
Fred Drake9466b9a1999-03-18 16:18:27 +0000184 \setlength{\parindent}{1cm}%
Fred Drake6659c301998-03-03 22:02:19 +0000185 % Calculate the text width for the minipage:
Fred Drake24340ea1998-04-28 18:30:34 +0000186 \setlength{\py@codewidth}{\linewidth}%
187 \addtolength{\py@codewidth}{-\parindent}%
Fred Drake6659c301998-03-03 22:02:19 +0000188 %
Fred Drake9466b9a1999-03-18 16:18:27 +0000189 \par\indent%
Fred Drake24340ea1998-04-28 18:30:34 +0000190 \begin{minipage}[t]{\py@codewidth}%
Fred Drake6659c301998-03-03 22:02:19 +0000191 \small%
Fred Drake24340ea1998-04-28 18:30:34 +0000192 \py@OldVerbatim%
Fred Drake6659c301998-03-03 22:02:19 +0000193}
194\renewcommand{\endverbatim}{%
Fred Drake24340ea1998-04-28 18:30:34 +0000195 \py@OldEndVerbatim%
Fred Drake6659c301998-03-03 22:02:19 +0000196 \end{minipage}%
Fred Drake6659c301998-03-03 22:02:19 +0000197}
Fred Drake00f712e2002-03-28 22:28:43 +0000198\renewcommand{\verbatiminput}[1]{%
199 {\setlength{\parindent}{1cm}%
200 % Calculate the text width for the minipage:
201 \setlength{\py@codewidth}{\linewidth}%
202 \addtolength{\py@codewidth}{-\parindent}%
203 %
204 \small%
205 \begin{list}{}{\setlength{\leftmargin}{1cm}}
206 \item%
207 \py@OldVerbatimInput{#1}%
208 \end{list}
209 }%
210}
Fred Drake6659c301998-03-03 22:02:19 +0000211
Fred Drakeb5309a92001-04-10 15:53:06 +0000212% This does a similar thing for the {alltt} environment:
213\RequirePackage{alltt}
214\let\py@OldAllTT=\alltt
215\let\py@OldEndAllTT=\endalltt
216
217\renewcommand{\alltt}{%
218 \setlength{\parindent}{1cm}%
219 % Calculate the text width for the minipage:
220 \setlength{\py@codewidth}{\linewidth}%
221 \addtolength{\py@codewidth}{-\parindent}%
222 %
223 \par\indent%
224 \begin{minipage}[t]{\py@codewidth}%
225 \small%
226 \py@OldAllTT%
227}
228\renewcommand{\endalltt}{%
229 \py@OldEndAllTT%
230 \end{minipage}%
231}
232
Fred Drake6cb71491998-03-27 05:22:53 +0000233
Fred Drakea488f301998-07-23 17:50:45 +0000234\newcommand{\py@modulebadkey}{{--just-some-junk--}}
Fred Drake6659c301998-03-03 22:02:19 +0000235
Fred Drake6659c301998-03-03 22:02:19 +0000236
237%% Lots of index-entry generation support.
238
239% Command to wrap around stuff that refers to function / module /
240% attribute names in the index. Default behavior: like \code{}. To
241% just keep the index entries in the roman font, uncomment the second
Fred Drakea488f301998-07-23 17:50:45 +0000242% definition; it matches O'Reilly style more.
Fred Drake6659c301998-03-03 22:02:19 +0000243%
Fred Drake24340ea1998-04-28 18:30:34 +0000244\newcommand{\py@idxcode}[1]{\texttt{#1}}
245%\renewcommand{\py@idxcode}[1]{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000246
247% Command to generate two index entries (using subentries)
248\newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}}
249
250% And three entries (using only one level of subentries)
251\newcommand{\indexiii}[3]{\index{#1!#2 #3}\index{#2!#3, #1}\index{#3!#1 #2}}
252
253% And four (again, using only one level of subentries)
254\newcommand{\indexiv}[4]{
255\index{#1!#2 #3 #4}
256\index{#2!#3 #4, #1}
257\index{#3!#4, #1 #2}
258\index{#4!#1 #2 #3}
259}
260
261% Command to generate a reference to a function, statement, keyword,
262% operator.
Fred Drake0cabff91998-05-06 19:36:01 +0000263\newcommand{\kwindex}[1]{\indexii{keyword}{#1@{\py@idxcode{#1}}}}
Fred Drake24340ea1998-04-28 18:30:34 +0000264\newcommand{\stindex}[1]{\indexii{statement}{#1@{\py@idxcode{#1}}}}
265\newcommand{\opindex}[1]{\indexii{operator}{#1@{\py@idxcode{#1}}}}
266\newcommand{\exindex}[1]{\indexii{exception}{#1@{\py@idxcode{#1}}}}
Fred Drake6659c301998-03-03 22:02:19 +0000267\newcommand{\obindex}[1]{\indexii{object}{#1}}
Fred Drakea33c5662000-10-29 05:19:16 +0000268\newcommand{\bifuncindex}[1]{%
269 \index{#1@{\py@idxcode{#1()}} (built-in function)}}
Fred Drake6659c301998-03-03 22:02:19 +0000270
271% Add an index entry for a module
Fred Drake24340ea1998-04-28 18:30:34 +0000272\newcommand{\py@refmodule}[2]{\index{#1@{\py@idxcode{#1}} (#2module)}}
273\newcommand{\refmodindex}[1]{\py@refmodule{#1}{}}
274\newcommand{\refbimodindex}[1]{\py@refmodule{#1}{built-in }}
275\newcommand{\refexmodindex}[1]{\py@refmodule{#1}{extension }}
276\newcommand{\refstmodindex}[1]{\py@refmodule{#1}{standard }}
Fred Drake6659c301998-03-03 22:02:19 +0000277
Fred Drakeda943741999-01-13 17:09:06 +0000278% Refer to a module's documentation using a hyperlink of the module's
279% name, at least if we're building PDF:
Fred Drakee59feb52001-10-29 21:02:28 +0000280\ifpdf
Fred Drakeaa2aea01999-01-27 17:37:36 +0000281 \newcommand{\refmodule}[2][\py@modulebadkey]{%
Fred Drakeda943741999-01-13 17:09:06 +0000282 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
Fred Drakeaa2aea01999-01-27 17:37:36 +0000283 \py@linkToName{label-module-\py@modulekey}{\module{#2}}%
Fred Drakeda943741999-01-13 17:09:06 +0000284 }
Fred Drakee59feb52001-10-29 21:02:28 +0000285\else
286 \newcommand{\refmodule}[2][\py@modulebadkey]{\module{#2}}
287\fi
Fred Drakeda943741999-01-13 17:09:06 +0000288
Fred Drake6659c301998-03-03 22:02:19 +0000289% support for the module index
Fred Drake24340ea1998-04-28 18:30:34 +0000290\newif\ifpy@UseModuleIndex
291\py@UseModuleIndexfalse
Fred Drakeb390daf1998-03-09 16:35:36 +0000292
Fred Drakeb390daf1998-03-09 16:35:36 +0000293\newcommand{\makemodindex}{
294 \newwrite\modindexfile
295 \openout\modindexfile=mod\jobname.idx
Fred Drake24340ea1998-04-28 18:30:34 +0000296 \py@UseModuleIndextrue
Fred Drakeb390daf1998-03-09 16:35:36 +0000297}
298
Fred Drake0ee9f721998-03-12 06:41:40 +0000299% Add the defining entry for a module
Fred Drake24340ea1998-04-28 18:30:34 +0000300\newcommand{\py@modindex}[2]{%
Fred Drakea488f301998-07-23 17:50:45 +0000301 \renewcommand{\py@thismodule}{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000302 \setindexsubitem{(in module #1)}%
Fred Drake24340ea1998-04-28 18:30:34 +0000303 \index{#1@{\py@idxcode{#1}} (#2module)|textbf}%
304 \ifpy@UseModuleIndex%
Fred Drake0c275fa1999-03-02 16:17:44 +0000305 \@ifundefined{py@modplat@\py@thismodulekey}{
306 \write\modindexfile{\protect\indexentry{#1@{\texttt{#1}}}{\thepage}}%
307 }{\write\modindexfile{\protect\indexentry{#1@{\texttt{#1} %
Fred Drake9466b9a1999-03-18 16:18:27 +0000308 \emph{(\py@platformof[\py@thismodulekey]{})}}}{\thepage}}%
Fred Drake0c275fa1999-03-02 16:17:44 +0000309 }
Fred Drake0ee9f721998-03-12 06:41:40 +0000310 \fi%
311}
312
Fred Drake9466b9a1999-03-18 16:18:27 +0000313% *** XXX *** THE NEXT FOUR MACROS ARE NOW OBSOLETE !!! ***
314
Fred Drake6659c301998-03-03 22:02:19 +0000315% built-in & Python modules in the main distribution
Fred Drake9466b9a1999-03-18 16:18:27 +0000316\newcommand{\bimodindex}[1]{\py@modindex{#1}{built-in }%
317 \typeout{*** MACRO bimodindex IS OBSOLETE -- USE declaremodule INSTEAD!}}
318\newcommand{\stmodindex}[1]{\py@modindex{#1}{standard }%
319 \typeout{*** MACRO stmodindex IS OBSOLETE -- USE declaremodule INSTEAD!}}
Fred Drake6659c301998-03-03 22:02:19 +0000320
321% Python & extension modules outside the main distribution
Fred Drake9466b9a1999-03-18 16:18:27 +0000322\newcommand{\modindex}[1]{\py@modindex{#1}{}%
323 \typeout{*** MACRO modindex IS OBSOLETE -- USE declaremodule INSTEAD!}}
324\newcommand{\exmodindex}[1]{\py@modindex{#1}{extension }%
325 \typeout{*** MACRO exmodindex IS OBSOLETE -- USE declaremodule INSTEAD!}}
Fred Drake6659c301998-03-03 22:02:19 +0000326
327% Additional string for an index entry
Fred Drakeba828782000-04-03 04:19:14 +0000328\newif\ifpy@usingsubitem\py@usingsubitemfalse
329\newcommand{\py@indexsubitem}{}
330\newcommand{\setindexsubitem}[1]{\renewcommand{\py@indexsubitem}{ #1}%
331 \py@usingsubitemtrue}
332\newcommand{\ttindex}[1]{%
333 \ifpy@usingsubitem
334 \index{#1@{\py@idxcode{#1}}\py@indexsubitem}%
335 \else%
336 \index{#1@{\py@idxcode{#1}}}%
337 \fi%
338}
Fred Drake0ee9f721998-03-12 06:41:40 +0000339\newcommand{\withsubitem}[2]{%
340 \begingroup%
Fred Drakeec77e652000-10-30 06:22:22 +0000341 \def\ttindex##1{\index{##1@{\py@idxcode{##1}} #1}}%
342 #2%
Fred Drake0ee9f721998-03-12 06:41:40 +0000343 \endgroup%
344}
Fred Drake6659c301998-03-03 22:02:19 +0000345
Fred Drake53714971998-04-02 22:33:16 +0000346
Fred Drakea488f301998-07-23 17:50:45 +0000347% Module synopsis processing -----------------------------------------------
348%
Fred Drake0c275fa1999-03-02 16:17:44 +0000349\newcommand{\py@thisclass}{}
350\newcommand{\py@thismodule}{}
351\newcommand{\py@thismodulekey}{}
352\newcommand{\py@thismoduletype}{}
353
Fred Drake9466b9a1999-03-18 16:18:27 +0000354\newcommand{\py@standardIndexModule}[1]{\py@modindex{#1}{standard }}
355\newcommand{\py@builtinIndexModule}[1]{\py@modindex{#1}{built-in }}
356\newcommand{\py@extensionIndexModule}[1]{\py@modindex{#1}{extension }}
357\newcommand{\py@IndexModule}[1]{\py@modindex{#1}{}}
Fred Drakea488f301998-07-23 17:50:45 +0000358
Fred Drake0c275fa1999-03-02 16:17:44 +0000359\newif\ifpy@HaveModSynopsis \py@HaveModSynopsisfalse
360\newif\ifpy@ModSynopsisFileIsOpen \py@ModSynopsisFileIsOpenfalse
361\newif\ifpy@HaveModPlatform \py@HaveModPlatformfalse
Fred Drakea488f301998-07-23 17:50:45 +0000362
363% \declaremodule[key]{type}{name}
364\newcommand{\declaremodule}[3][\py@modulebadkey]{
365 \py@openModSynopsisFile
366 \renewcommand{\py@thismoduletype}{#2}
Fred Drakea488f301998-07-23 17:50:45 +0000367 \ifx\py@modulebadkey#1
368 \renewcommand{\py@thismodulekey}{#3}
369 \else
370 \renewcommand{\py@thismodulekey}{#1}
371 \fi
Fred Drake5bc8d991999-05-17 14:47:10 +0000372 \@ifundefined{py@#2IndexModule}{%
373 \typeout{*** MACRO declaremodule called with unknown module type: `#2'}
Fred Drake66823021999-05-17 14:57:26 +0000374 \py@IndexModule{#3}%
Fred Drake5bc8d991999-05-17 14:47:10 +0000375 }{%
376 \csname py@#2IndexModule\endcsname{#3}%
377 }
Fred Drakea488f301998-07-23 17:50:45 +0000378 \label{module-\py@thismodulekey}
Fred Drakea488f301998-07-23 17:50:45 +0000379}
Fred Drake0c275fa1999-03-02 16:17:44 +0000380\newif\ifpy@ModPlatformFileIsOpen \py@ModPlatformFileIsOpenfalse
381\newcommand{\py@ModPlatformFilename}{\jobname.pla}
382\newcommand{\platform}[1]{
383 \ifpy@ModPlatformFileIsOpen\else
384 \newwrite\py@ModPlatformFile
385 \openout\py@ModPlatformFile=\py@ModPlatformFilename
386 \py@ModPlatformFileIsOpentrue
387 \fi
Fred Drake0c275fa1999-03-02 16:17:44 +0000388}
389\InputIfFileExists{\jobname.pla}{}{}
Fred Drake9466b9a1999-03-18 16:18:27 +0000390\newcommand{\py@platformof}[2][\py@modulebadkey]{%
Fred Drake0c275fa1999-03-02 16:17:44 +0000391 \ifx\py@modulebadkey#1 \def\py@key{#2}%
392 \else \def\py@key{#1}%
393 \fi%
394 \csname py@modplat@\py@key\endcsname%
395}
396\newcommand{\ignorePlatformAnnotation}[1]{}
Fred Drakea488f301998-07-23 17:50:45 +0000397
Fred Drakeb75c6151998-08-10 18:41:43 +0000398% \moduleauthor{name}{email}
399\newcommand{\moduleauthor}[2]{}
400
401% \sectionauthor{name}{email}
402\newcommand{\sectionauthor}[2]{}
403
Fred Drakea488f301998-07-23 17:50:45 +0000404
405\newcommand{\py@defsynopsis}{Module has no synopsis.}
406\newcommand{\py@modulesynopsis}{\py@defsynopsis}
407\newcommand{\modulesynopsis}[1]{
Fred Drake0c275fa1999-03-02 16:17:44 +0000408 \py@HaveModSynopsistrue
Fred Drakea488f301998-07-23 17:50:45 +0000409 \renewcommand{\py@modulesynopsis}{#1}
410}
411
412% define the file
413\newwrite\py@ModSynopsisFile
414
415% hacked from \addtocontents from latex.ltx:
416\long\def\py@writeModSynopsisFile#1{%
417 \protected@write\py@ModSynopsisFile%
418 {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
419 {\string#1}%
420}
421\newcommand{\py@closeModSynopsisFile}{
422 \ifpy@ModSynopsisFileIsOpen
423 \closeout\py@ModSynopsisFile
424 \py@ModSynopsisFileIsOpenfalse
425 \fi
426}
427\newcommand{\py@openModSynopsisFile}{
428 \ifpy@ModSynopsisFileIsOpen\else
429 \openout\py@ModSynopsisFile=\py@ModSynopsisFilename
430 \py@ModSynopsisFileIsOpentrue
431 \fi
432}
433
434\newcommand{\py@ProcessModSynopsis}{
435 \ifpy@HaveModSynopsis
436 \py@writeModSynopsisFile{\modulesynopsis%
437 {\py@thismodulekey}{\py@thismodule}%
438 {\py@thismoduletype}{\py@modulesynopsis}}%
439 \py@HaveModSynopsisfalse
440 \fi
441 \renewcommand{\py@modulesynopsis}{\py@defsynopsis}
442}
443\AtEndDocument{\py@ProcessModSynopsis\py@closeModSynopsisFile}
444
Fred Drake0c275fa1999-03-02 16:17:44 +0000445
446\long\def\py@writeModPlatformFile#1{%
447 \protected@write\py@ModPlatformFile%
448 {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
449 {\string#1}%
450}
451
452
Fred Drakea488f301998-07-23 17:50:45 +0000453\newcommand{\localmoduletable}{
454 \IfFileExists{\py@ModSynopsisFilename}{
455 \begin{synopsistable}
456 \input{\py@ModSynopsisFilename}
457 \end{synopsistable}
458 }{}
459}
460
Fred Drakee59feb52001-10-29 21:02:28 +0000461\ifpdf
Fred Drakeaa2aea01999-01-27 17:37:36 +0000462 \newcommand{\py@ModSynopsisSummary}[4]{%
463 \py@linkToName{label-module-#1}{\bfcode{#2}} & #4\\
464 }
Fred Drakee59feb52001-10-29 21:02:28 +0000465\else
466 \newcommand{\py@ModSynopsisSummary}[4]{\bfcode{#2} & #4\\}
467\fi
Fred Drakea488f301998-07-23 17:50:45 +0000468\newenvironment{synopsistable}{
469 % key, name, type, synopsis
470 \let\modulesynopsis=\py@ModSynopsisSummary
471 \begin{tabular}{ll}
472}{
473 \end{tabular}
474}
475%
476% --------------------------------------------------------------------------
477
478
Fred Drakea488f301998-07-23 17:50:45 +0000479\newcommand{\py@reset}{
Fred Drakeba828782000-04-03 04:19:14 +0000480 \py@usingsubitemfalse
Fred Drakea488f301998-07-23 17:50:45 +0000481 \py@ProcessModSynopsis
482 \renewcommand{\py@thisclass}{}
483 \renewcommand{\py@thismodule}{}
484 \renewcommand{\py@thismodulekey}{}
485 \renewcommand{\py@thismoduletype}{}
486}
487
488% Augment the sectioning commands used to get our own font family in place,
489% and reset some internal data items:
490\renewcommand{\section}{\py@reset%
491 \@startsection{section}{1}{\z@}%
492 {-3.5ex \@plus -1ex \@minus -.2ex}%
493 {2.3ex \@plus.2ex}%
494 {\reset@font\Large\py@HeaderFamily}}
495\renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}%
496 {-3.25ex\@plus -1ex \@minus -.2ex}%
497 {1.5ex \@plus .2ex}%
498 {\reset@font\large\py@HeaderFamily}}
499\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}%
500 {-3.25ex\@plus -1ex \@minus -.2ex}%
501 {1.5ex \@plus .2ex}%
502 {\reset@font\normalsize\py@HeaderFamily}}
503\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}%
504 {3.25ex \@plus1ex \@minus.2ex}%
505 {-1em}%
506 {\reset@font\normalsize\py@HeaderFamily}}
507\renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}%
508 {3.25ex \@plus1ex \@minus .2ex}%
509 {-1em}%
510 {\reset@font\normalsize\py@HeaderFamily}}
511
512
Fred Drake5420f331998-07-23 21:41:02 +0000513% This gets the underscores closer to the right width; the only change
514% from standard LaTeX is the width specified.
515
516\DeclareTextCommandDefault{\textunderscore}{%
517 \leavevmode \kern.06em\vbox{\hrule\@width.55em}}
518
Fred Drakea488f301998-07-23 17:50:45 +0000519% Underscore hack (only act like subscript operator if in math mode)
520%
521% The following is due to Mark Wooding (the old version didn't work with
522% Latex 2e.
523
524\DeclareRobustCommand\hackscore{%
525 \ifmmode_\else\textunderscore\fi%
526}
527\begingroup
528\catcode`\_\active
529\def\next{%
530 \AtBeginDocument{\catcode`\_\active\def_{\hackscore{}}}%
531}
532\expandafter\endgroup\next
533
534
Fred Drake53714971998-04-02 22:33:16 +0000535% Now for a lot of semantically-loaded environments that do a ton of magical
536% things to get the right formatting and index entries for the stuff in
537% Python modules and C API.
538
539
Fred Drake6659c301998-03-03 22:02:19 +0000540% {fulllineitems} is used in one place in libregex.tex, but is really for
541% internal use in this file.
542%
Fred Drakef9acc591998-09-09 15:27:43 +0000543\newcommand{\py@itemnewline}[1]{%
544 \@tempdima\linewidth%
545 \advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}%
546}
547
Fred Drake6659c301998-03-03 22:02:19 +0000548\newenvironment{fulllineitems}{
549 \begin{list}{}{\labelwidth \leftmargin \labelsep 0pt
550 \rightmargin 0pt \topsep -\parskip \partopsep \parskip
551 \itemsep -\parsep
Fred Drakef9acc591998-09-09 15:27:43 +0000552 \let\makelabel=\py@itemnewline}
Fred Drake6659c301998-03-03 22:02:19 +0000553}{\end{list}}
554
Fred Drake6cb71491998-03-27 05:22:53 +0000555% \optional is mostly for use in the arguments parameters to the various
556% {*desc} environments defined below, but may be used elsewhere. Known to
557% be used in the debugger chapter.
Fred Drake24340ea1998-04-28 18:30:34 +0000558%
559% Typical usage:
560%
561% \begin{funcdesc}{myfunc}{reqparm\optional{, optparm}}
562% ^^^ ^^^
563% No space here No space here
564%
565% When a function has multiple optional parameters, \optional should be
566% nested, not chained. This is right:
567%
568% \begin{funcdesc}{myfunc}{\optional{parm1\optional{, parm2}}}
569%
Fred Drakeba828782000-04-03 04:19:14 +0000570\let\py@badkey=\@undefined
571
Fred Drake6659c301998-03-03 22:02:19 +0000572\newcommand{\optional}[1]{%
573 {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
574
Fred Drakeba828782000-04-03 04:19:14 +0000575% This can be used when a function or method accepts an varying number
576% of arguments, such as by using the *args syntax in the parameter list.
577\newcommand{\py@moreargs}{...}
578
579% This can be used when you don't want to document the parameters to a
580% function or method, but simply state that it's an alias for
581% something else.
582\newcommand{\py@unspecified}{...}
583
Fred Drake6cb71491998-03-27 05:22:53 +0000584% C functions ------------------------------------------------------------
Fred Drakeba828782000-04-03 04:19:14 +0000585% \begin{cfuncdesc}[refcount]{type}{name}{arglist}
586% Note that the [refcount] slot should only be filled in by
587% tools/anno-api.py; it pulls the value from the refcounts database.
588\newenvironment{cfuncdesc}[4][\py@badkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000589 \begin{fulllineitems}
Fred Drakeba828782000-04-03 04:19:14 +0000590 \item[\code{#2 \bfcode{#3}(\py@varvars{#4})}\index{#3@{\py@idxcode{#3()}}}]
591 \ifx#1\@undefined\else%
Fred Drake0a863da2000-04-10 18:21:38 +0000592 \emph{Return value: \textbf{#1}.}\\
Fred Drakeba828782000-04-03 04:19:14 +0000593 \fi
Fred Drake6cb71491998-03-27 05:22:53 +0000594}{\end{fulllineitems}}
595
596% C variables ------------------------------------------------------------
597% \begin{cvardesc}{type}{name}
598\newenvironment{cvardesc}[2]{
599 \begin{fulllineitems}
Fred Drake24340ea1998-04-28 18:30:34 +0000600 \item[\code{#1 \bfcode{#2}}\index{#2@{\py@idxcode{#2}}}]
Fred Drake6cb71491998-03-27 05:22:53 +0000601}{\end{fulllineitems}}
602
603% C data types -----------------------------------------------------------
Fred Drakeba828782000-04-03 04:19:14 +0000604% \begin{ctypedesc}[index name]{typedef name}
605\newenvironment{ctypedesc}[2][\py@badkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000606 \begin{fulllineitems}
Fred Drakeba828782000-04-03 04:19:14 +0000607 \item[\bfcode{#2}%
608 \ifx#1\@undefined%
Fred Drakea33c5662000-10-29 05:19:16 +0000609 \index{#2@{\py@idxcode{#2}} (C type)}
Fred Drakeba828782000-04-03 04:19:14 +0000610 \else%
Fred Drakea33c5662000-10-29 05:19:16 +0000611 \index{#2@{\py@idxcode{#1}} (C type)}
Fred Drakeba828782000-04-03 04:19:14 +0000612 \fi]
613}{\end{fulllineitems}}
614
615% Funky macros -----------------------------------------------------------
616% \begin{csimplemacro}{name}
617% -- "simple" because it has no args; NOT for constant definitions!
618\newenvironment{csimplemacrodesc}[1]{
619 \begin{fulllineitems}
Fred Drakea33c5662000-10-29 05:19:16 +0000620 \item[\bfcode{#1}\index{#1@{\py@idxcode{#1}} (macro)}]
Fred Drake6cb71491998-03-27 05:22:53 +0000621}{\end{fulllineitems}}
622
623% simple functions (not methods) -----------------------------------------
624% \begin{funcdesc}{name}{args}
Fred Drakeec77e652000-10-30 06:22:22 +0000625\newcommand{\funcline}[2]{%
626 \funclineni{#1}{#2}%
627 \index{#1@{\py@idxcode{#1()}} (in module \py@thismodule)}}
Fred Drake6cb71491998-03-27 05:22:53 +0000628\newenvironment{funcdesc}[2]{
629 \begin{fulllineitems}
630 \funcline{#1}{#2}
631}{\end{fulllineitems}}
632
Fred Drake6659c301998-03-03 22:02:19 +0000633% similar to {funcdesc}, but doesn't add to the index
Fred Drake300775d1998-04-17 02:17:00 +0000634\newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(\py@varvars{#2})}]}
Fred Drake6cb71491998-03-27 05:22:53 +0000635\newenvironment{funcdescni}[2]{
636 \begin{fulllineitems}
637 \funclineni{#1}{#2}
Fred Drake6659c301998-03-03 22:02:19 +0000638}{\end{fulllineitems}}
639
Fred Drake6cb71491998-03-27 05:22:53 +0000640% classes ----------------------------------------------------------------
641% \begin{classdesc}{name}{constructor args}
642\newenvironment{classdesc}[2]{
Fred Drake1cbd1961998-11-25 17:13:28 +0000643 % Using \renewcommand doesn't work for this, for unknown reasons:
644 \global\def\py@thisclass{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000645 \begin{fulllineitems}
Fred Drakeab357ec2001-03-02 18:57:05 +0000646 \item[\strong{class }\code{\bfcode{#1}(\py@varvars{#2})}%
Fred Drakea33c5662000-10-29 05:19:16 +0000647 \index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}]
Fred Drake6659c301998-03-03 22:02:19 +0000648}{\end{fulllineitems}}
649
Fred Drake06a01e82001-05-11 01:00:30 +0000650% \begin{classdesc*}{name}
651\newenvironment{classdesc*}[1]{
652 % Using \renewcommand doesn't work for this, for unknown reasons:
653 \global\def\py@thisclass{#1}
654 \begin{fulllineitems}
655 \item[\strong{class }\code{\bfcode{#1}}%
656 \index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}]
657}{\end{fulllineitems}}
658
Fred Drake4e607962000-09-09 06:01:25 +0000659% \begin{excclassdesc}{name}{constructor args}
660% but indexes as an exception
661\newenvironment{excclassdesc}[2]{
662 % Using \renewcommand doesn't work for this, for unknown reasons:
663 \global\def\py@thisclass{#1}
664 \begin{fulllineitems}
Fred Drakeab357ec2001-03-02 18:57:05 +0000665 \item[\strong{exception }\code{\bfcode{#1}(\py@varvars{#2})}%
Fred Drakea33c5662000-10-29 05:19:16 +0000666 \index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}]
Fred Drake4e607962000-09-09 06:01:25 +0000667}{\end{fulllineitems}}
668
Fred Drake06a01e82001-05-11 01:00:30 +0000669% There is no corresponding {excclassdesc*} environment. To describe
670% a class exception without parameters, use the {excdesc} environment.
671
Fred Drake6cb71491998-03-27 05:22:53 +0000672
Fred Drake24340ea1998-04-28 18:30:34 +0000673\let\py@classbadkey=\@undefined
Fred Drake6cb71491998-03-27 05:22:53 +0000674
675% object method ----------------------------------------------------------
676% \begin{methoddesc}[classname]{methodname}{args}
Fred Drakea33c5662000-10-29 05:19:16 +0000677\newcommand{\methodline}[3][\@undefined]{
Fred Drake6cb71491998-03-27 05:22:53 +0000678 \methodlineni{#2}{#3}
679 \ifx#1\@undefined
Fred Drakea33c5662000-10-29 05:19:16 +0000680 \index{#2@{\py@idxcode{#2()}} (\py@thisclass\ method)}
Fred Drake6cb71491998-03-27 05:22:53 +0000681 \else
Fred Drakea33c5662000-10-29 05:19:16 +0000682 \index{#2@{\py@idxcode{#2()}} (#1 method)}
Fred Drake6cb71491998-03-27 05:22:53 +0000683 \fi
684}
Fred Drakea33c5662000-10-29 05:19:16 +0000685\newenvironment{methoddesc}[3][\@undefined]{
Fred Drake6cb71491998-03-27 05:22:53 +0000686 \begin{fulllineitems}
687 \ifx#1\@undefined
688 \methodline{#2}{#3}
689 \else
Fred Drake24340ea1998-04-28 18:30:34 +0000690 \def\py@thisclass{#1}
Fred Drakea33c5662000-10-29 05:19:16 +0000691 \methodline{#2}{#3}
Fred Drake6cb71491998-03-27 05:22:53 +0000692 \fi
Fred Drake6659c301998-03-03 22:02:19 +0000693}{\end{fulllineitems}}
694
Fred Drake6cb71491998-03-27 05:22:53 +0000695% similar to {methoddesc}, but doesn't add to the index
696% (never actually uses the optional argument)
Fred Drake24340ea1998-04-28 18:30:34 +0000697\newcommand{\methodlineni}[3][\py@classbadkey]{%
Fred Drake300775d1998-04-17 02:17:00 +0000698 \item[\code{\bfcode{#2}(\py@varvars{#3})}]}
Fred Drake24340ea1998-04-28 18:30:34 +0000699\newenvironment{methoddescni}[3][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000700 \begin{fulllineitems}
701 \methodlineni{#2}{#3}
702}{\end{fulllineitems}}
703
704% object data attribute --------------------------------------------------
705% \begin{memberdesc}[classname]{membername}
Fred Drake24340ea1998-04-28 18:30:34 +0000706\newcommand{\memberline}[2][\py@classbadkey]{%
Fred Drake6cb71491998-03-27 05:22:53 +0000707 \ifx#1\@undefined
708 \memberlineni{#2}
Fred Drakea33c5662000-10-29 05:19:16 +0000709 \index{#2@{\py@idxcode{#2}} (\py@thisclass\ attribute)}
Fred Drake6cb71491998-03-27 05:22:53 +0000710 \else
711 \memberlineni{#2}
Fred Drakea33c5662000-10-29 05:19:16 +0000712 \index{#2@{\py@idxcode{#2}} (#1 attribute)}
Fred Drake6cb71491998-03-27 05:22:53 +0000713 \fi
714}
Fred Drake24340ea1998-04-28 18:30:34 +0000715\newenvironment{memberdesc}[2][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000716 \begin{fulllineitems}
717 \ifx#1\@undefined
718 \memberline{#2}
719 \else
Fred Drake24340ea1998-04-28 18:30:34 +0000720 \def\py@thisclass{#1}
Fred Drakea33c5662000-10-29 05:19:16 +0000721 \memberline{#2}
Fred Drake6cb71491998-03-27 05:22:53 +0000722 \fi
723}{\end{fulllineitems}}
724
725% similar to {memberdesc}, but doesn't add to the index
726% (never actually uses the optional argument)
Fred Drake24340ea1998-04-28 18:30:34 +0000727\newcommand{\memberlineni}[2][\py@classbadkey]{\item[\bfcode{#2}]}
728\newenvironment{memberdescni}[2][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000729 \begin{fulllineitems}
730 \memberlineni{#2}
731}{\end{fulllineitems}}
732
733% For exceptions: --------------------------------------------------------
734% \begin{excdesc}{name}
Fred Drakea33c5662000-10-29 05:19:16 +0000735% -- for constructor information, use excclassdesc instead
Fred Drake6cb71491998-03-27 05:22:53 +0000736\newenvironment{excdesc}[1]{
737 \begin{fulllineitems}
Fred Drakeab357ec2001-03-02 18:57:05 +0000738 \item[\strong{exception }\bfcode{#1}%
Fred Drakea33c5662000-10-29 05:19:16 +0000739 \index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}]
Fred Drake6cb71491998-03-27 05:22:53 +0000740}{\end{fulllineitems}}
741
742% Module data or constants: ----------------------------------------------
743% \begin{datadesc}{name}
Fred Drakea33c5662000-10-29 05:19:16 +0000744\newcommand{\dataline}[1]{%
745 \datalineni{#1}\index{#1@{\py@idxcode{#1}} (data in \py@thismodule)}}
Fred Drake6cb71491998-03-27 05:22:53 +0000746\newenvironment{datadesc}[1]{
747 \begin{fulllineitems}
748 \dataline{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000749}{\end{fulllineitems}}
750
751% similar to {datadesc}, but doesn't add to the index
Fred Drake6cb71491998-03-27 05:22:53 +0000752\newcommand{\datalineni}[1]{\item[\bfcode{#1}]\nopagebreak}
753\newenvironment{datadescni}[1]{
754 \begin{fulllineitems}
755 \datalineni{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000756}{\end{fulllineitems}}
757
Fred Drake6cb71491998-03-27 05:22:53 +0000758% bytecode instruction ---------------------------------------------------
759% \begin{opcodedesc}{name}{var}
760% -- {var} may be {}
761\newenvironment{opcodedesc}[2]{
762 \begin{fulllineitems}
763 \item[\bfcode{#1}\quad\var{#2}]
Fred Drake6659c301998-03-03 22:02:19 +0000764}{\end{fulllineitems}}
765
766
Fred Drake24340ea1998-04-28 18:30:34 +0000767\newcommand{\nodename}[1]{\label{#1}}
Fred Drake55730311998-03-25 15:41:23 +0000768
Fred Drake6659c301998-03-03 22:02:19 +0000769% For these commands, use \command{} to get the typography right, not
770% {\command}. This works better with the texinfo translation.
771\newcommand{\ABC}{{\sc abc}}
772\newcommand{\UNIX}{{\sc Unix}}
773\newcommand{\POSIX}{POSIX}
774\newcommand{\ASCII}{{\sc ascii}}
775\newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}}
776\newcommand{\C}{C}
777\newcommand{\EOF}{{\sc eof}}
Fred Drake24340ea1998-04-28 18:30:34 +0000778\newcommand{\NULL}{\constant{NULL}}
Fred Drake5445e5e2001-06-23 03:11:45 +0000779\newcommand{\infinity}{\ensuremath{\infty}}
780\newcommand{\plusminus}{\ensuremath{\pm}}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000781\newcommand{\menuselection}[1]{{\def\sub{ \ensuremath{>} }#1}}
Fred Drake6659c301998-03-03 22:02:19 +0000782
Fred Drake53714971998-04-02 22:33:16 +0000783% Also for consistency: spell Python "Python", not "python"!
784
Fred Drake6659c301998-03-03 22:02:19 +0000785% code is the most difficult one...
Fred Drake46346ec2000-06-30 17:57:05 +0000786\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 Drake24340ea1998-04-28 18:30:34 +0000787\texttt{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000788
789\newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font
Fred Drake8e54abe1998-07-01 14:49:25 +0000790\newcommand{\kbd}[1]{\code{#1}}
Fred Drake24340ea1998-04-28 18:30:34 +0000791\newcommand{\samp}[1]{`\code{#1}'}
Fred Drake6659c301998-03-03 22:02:19 +0000792% This weird definition of \var{} allows it to always appear in roman
793% italics, and won't get funky in code fragments when we play around
Fred Drakefa1cceb1998-11-30 14:42:59 +0000794% with fonts. This also works directly in math mode.
795\newcommand{\var}[1]{%
796 \ifmmode%
797 \hbox{\normalsize\textrm{\textit{#1\/}}}%
798 \else%
799 \normalsize\textrm{\textit{#1\/}}%
800 \fi%
801}
Fred Drake24340ea1998-04-28 18:30:34 +0000802\renewcommand{\emph}[1]{{\em #1}}
Fred Drake6659c301998-03-03 22:02:19 +0000803\newcommand{\dfn}[1]{\emph{#1}}
804\newcommand{\strong}[1]{{\bf #1}}
805% let's experiment with a new font:
Fred Drake0ee9f721998-03-12 06:41:40 +0000806\newcommand{\file}[1]{`{\small\textsf{#1}}'}
Fred Drake0a0fd591999-04-28 14:59:44 +0000807\newcommand{\filenq}[1]{{\small\textsf{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000808
809% Use this def/redef approach for \url{} since hyperref defined this already,
810% but only if we actually used hyperref:
Fred Drakee59feb52001-10-29 21:02:28 +0000811\ifpdf
812 \newcommand{\url}[1]{{%
Fred Drake15fc72c2002-03-26 19:14:41 +0000813 \noindent%
Fred Drake53815882002-03-15 23:21:37 +0000814 \pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}%
Fred Drakeab357ec2001-03-02 18:57:05 +0000815 \py@LinkColor% color of the link text
Fred Drakee59feb52001-10-29 21:02:28 +0000816 \small\sf #1%
Fred Drakeab357ec2001-03-02 18:57:05 +0000817 \py@NormalColor% Turn it back off; these are declarative
818 \pdfendlink}% and don't appear bound to the current
819 }% formatting "box".
Fred Drakee59feb52001-10-29 21:02:28 +0000820\else
821 \newcommand{\url}[1]{\mbox{\small\textsf{#1}}}
822\fi
Fred Drake0ee9f721998-03-12 06:41:40 +0000823\newcommand{\email}[1]{{\small\textsf{#1}}}
Fred Drake454a4fb1998-04-01 22:20:14 +0000824\newcommand{\newsgroup}[1]{{\small\textsf{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000825
Fred Drakecc2b81e2000-08-03 17:38:30 +0000826\newcommand{\py@varvars}[1]{{%
Fred Drakeba828782000-04-03 04:19:14 +0000827 {\let\unspecified=\py@unspecified%
828 \let\moreargs=\py@moreargs%
Fred Drakecc2b81e2000-08-03 17:38:30 +0000829 \var{#1}}}}
Fred Drake6659c301998-03-03 22:02:19 +0000830
Fred Drake24340ea1998-04-28 18:30:34 +0000831% I'd really like to get rid of this!
Fred Drake6659c301998-03-03 22:02:19 +0000832\newif\iftexi\texifalse
Fred Drake6659c301998-03-03 22:02:19 +0000833
Fred Drake1e4973b1998-07-28 21:52:17 +0000834% This is used to get l2h to put the copyright and abstract on
835% a separate HTML page.
836\newif\ifhtml\htmlfalse
837
838
Fred Drake6659c301998-03-03 22:02:19 +0000839% These should be used for all references to identifiers which are
840% used to refer to instances of specific language constructs. See the
841% names for specific semantic assignments.
842%
843% For now, don't do anything really fancy with them; just use them as
844% logical markup. This might change in the future.
845%
Fred Drake24340ea1998-04-28 18:30:34 +0000846\newcommand{\module}[1]{\texttt{#1}}
847\newcommand{\keyword}[1]{\texttt{#1}}
848\newcommand{\exception}[1]{\texttt{#1}}
849\newcommand{\class}[1]{\texttt{#1}}
850\newcommand{\function}[1]{\texttt{#1}}
851\newcommand{\member}[1]{\texttt{#1}}
852\newcommand{\method}[1]{\texttt{#1}}
Fred Drake6659c301998-03-03 22:02:19 +0000853
Fred Drakeab357ec2001-03-02 18:57:05 +0000854\newcommand{\pytype}[1]{#1} % built-in Python type
Fred Drake53714971998-04-02 22:33:16 +0000855
Fred Drake24340ea1998-04-28 18:30:34 +0000856\newcommand{\cfunction}[1]{\texttt{#1}}
Fred Drakeab357ec2001-03-02 18:57:05 +0000857\newcommand{\ctype}[1]{\texttt{#1}} % C struct or typedef name
858\newcommand{\cdata}[1]{\texttt{#1}} % C variable, typically global
Fred Drake6659c301998-03-03 22:02:19 +0000859
Fred Drake479384e2001-09-26 18:46:36 +0000860\newcommand{\mailheader}[1]{{\small\textsf{#1:}}}
Fred Drake0ee9f721998-03-12 06:41:40 +0000861\newcommand{\mimetype}[1]{{\small\textsf{#1}}}
Fred Drake94fac131998-03-12 19:37:03 +0000862% The \! is a "negative thin space" in math mode.
863\newcommand{\regexp}[1]{%
864 {\tiny$^{^\lceil}\!\!$%
865 {\normalsize\code{#1}}%
Fred Drake47cfd031998-04-03 21:22:31 +0000866 $\!\rfloor\!$%
Fred Drake94fac131998-03-12 19:37:03 +0000867 }}
Fred Drake0ee9f721998-03-12 06:41:40 +0000868\newcommand{\envvar}[1]{%
Fred Drake31ab2982001-01-22 17:50:42 +0000869 #1%
Fred Drakee59feb52001-10-29 21:02:28 +0000870 \index{#1}%
Fred Drake31ab2982001-01-22 17:50:42 +0000871 \index{environment variables!{#1}}%
Fred Drake0ee9f721998-03-12 06:41:40 +0000872}
Fred Drakeab357ec2001-03-02 18:57:05 +0000873\newcommand{\makevar}[1]{#1} % variable in a Makefile
Fred Drake24340ea1998-04-28 18:30:34 +0000874\newcommand{\character}[1]{\samp{#1}}
Fred Drake0ee9f721998-03-12 06:41:40 +0000875
Fred Drake6659c301998-03-03 22:02:19 +0000876% constants defined in Python modules or C headers, not language constants:
Fred Drakeab357ec2001-03-02 18:57:05 +0000877\newcommand{\constant}[1]{\code{#1}} % manifest constant, not syntactic
Fred Drake6659c301998-03-03 22:02:19 +0000878
879\newcommand{\manpage}[2]{{\emph{#1}(#2)}}
Fred Drake4e607962000-09-09 06:01:25 +0000880\newcommand{\pep}[1]{PEP #1\index{Python Enhancement Proposals!PEP #1}}
Fred Drake6659c301998-03-03 22:02:19 +0000881\newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}}
882\newcommand{\program}[1]{\strong{#1}}
Fred Drake7b8195a1999-11-09 17:02:11 +0000883\newcommand{\programopt}[1]{\strong{#1}}
Fred Drake49362492000-04-11 18:47:59 +0000884% Note that \longprogramopt provides the '--'!
885\newcommand{\longprogramopt}[1]{\strong{-{}-#1}}
Fred Drakee59feb52001-10-29 21:02:28 +0000886
Fred Drakeb4b64da2001-07-06 22:44:48 +0000887% \ulink{link text}{URL}
Fred Drakee59feb52001-10-29 21:02:28 +0000888\ifpdf
889 % The \noindent here is a hack -- we're forcing pdfTeX into
Fred Drake53815882002-03-15 23:21:37 +0000890 % horizontal mode since \pdfstartlink requires that.
Fred Drakee59feb52001-10-29 21:02:28 +0000891 \newcommand{\ulink}[2]{\noindent{%
Fred Drake53815882002-03-15 23:21:37 +0000892 \pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#2)}%
Fred Drakee59feb52001-10-29 21:02:28 +0000893 \py@LinkColor% color of the link text
894 #1%
895 \py@NormalColor% Turn it back off; these are declarative
896 \pdfendlink}% and don't appear bound to the current
897 }% formatting "box".
898\else
899 \newcommand{\ulink}[2]{#1}
900\fi
Fred Drake7b8195a1999-11-09 17:02:11 +0000901
902% cited titles: \citetitle{Title of Work}
903% online: \citetitle[url-to-resource]{Title of Work}
Fred Drakee59feb52001-10-29 21:02:28 +0000904\ifpdf
905 \newcommand{\citetitle}[2][\py@modulebadkey]{%
906 \ifx\py@modulebadkey#1\emph{#2}\else\ulink{\emph{#2}}{#1}\fi%
907 }
908\else
Fred Drake622087a2001-11-02 20:53:19 +0000909 \newcommand{\citetitle}[2][URL]{\emph{#2}}
Fred Drakee59feb52001-10-29 21:02:28 +0000910\fi
911
Fred Drake6659c301998-03-03 22:02:19 +0000912
913
Fred Drakec82bd722001-12-11 18:47:36 +0000914% This version is being checked in for the historical record; it shows
915% how I've managed to get some aspects of this to work. It will not
916% be used in practice, so a subsequent revision will change things
917% again. This version has problems, but shows how to do something
918% that proved more tedious than I'd expected, so I don't want to lose
919% the example completely.
920%
Fred Drake16bb4192001-08-20 21:36:38 +0000921\newcommand{\grammartoken}[1]{\texttt{#1}}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000922\newenvironment{productionlist}[1][\py@badkey]{
923 \def\optional##1{{\Large[}##1{\Large]}}
924 \def\production##1##2{\code{##1}&::=&\code{##2}\\}
Fred Drake53815882002-03-15 23:21:37 +0000925 \def\productioncont##1{& &\code{##1}\\}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000926 \def\token##1{##1}
Fred Drake16bb4192001-08-20 21:36:38 +0000927 \let\grammartoken=\token
Fred Drakec82bd722001-12-11 18:47:36 +0000928 \parindent=2em
929 \indent
930 \begin{tabular}{lcl}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000931}{%
Fred Drakec82bd722001-12-11 18:47:36 +0000932 \end{tabular}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000933}
934
Fred Drake6ca33772001-12-14 22:50:06 +0000935\newcommand{\py@noticelabel@note}{Note:}
936\newcommand{\py@noticelabel@warning}{Warning:}
937\newenvironment{notice}[1][note]{
938 \par\strong{\csname py@noticelabel@#1\endcsname}
939}{}
940\newcommand{\note}[1]{\strong{\py@noticelabel@note} #1}
941\newcommand{\warning}[1]{\strong{\py@noticelabel@warning} #1}
Fred Drake92350b32001-10-09 18:01:23 +0000942
Fred Drake6659c301998-03-03 22:02:19 +0000943% Deprecation stuff.
944% Should be extended to allow an index / list of deprecated stuff. But
945% there's a lot of stuff that needs to be done to make that automatable.
946%
947% First parameter is the release number that deprecates the feature, the
948% second is the action the should be taken by users of the feature.
949%
950% Example:
Fred Drake24340ea1998-04-28 18:30:34 +0000951% \deprecated{1.5.1}{Use \method{frobnicate()} instead.}
Fred Drake6659c301998-03-03 22:02:19 +0000952%
953\newcommand{\deprecated}[2]{%
954 \strong{Deprecated since release #1.} #2\par}
955
Fred Drakeaf958c71998-07-27 20:32:33 +0000956% New stuff.
957% This should be used to mark things which have been added to the
958% development tree but that aren't in the release, but are documented.
959% This allows release of documentation that already includes updated
Fred Drake2116d981999-02-02 18:02:48 +0000960% descriptions. Place at end of descriptor environment.
Fred Drakeaf958c71998-07-27 20:32:33 +0000961%
962% Example:
963% \versionadded{1.5.2}
Fred Drake46346ec2000-06-30 17:57:05 +0000964% \versionchanged[short explanation]{2.0}
Fred Drakeaf958c71998-07-27 20:32:33 +0000965%
Fred Drakefdfb05b2001-04-18 03:08:54 +0000966\newcommand{\versionadded}[2][\py@badkey]{%
967 \ifx#1\@undefined%
968 { New in version #2. }%
969 \else%
970 { New in version #2:\ #1. }%
971 \fi%
972}
Fred Drakea6e83392000-05-02 17:28:36 +0000973\newcommand{\versionchanged}[2][\py@badkey]{%
974 \ifx#1\@undefined%
975 { Changed in version #2. }%
976 \else%
977 { Changed in version #2:\ #1. }%
978 \fi%
979}
Fred Drake6659c301998-03-03 22:02:19 +0000980
Fred Drakeaf958c71998-07-27 20:32:33 +0000981
982% Tables.
983%
Fred Drake6659c301998-03-03 22:02:19 +0000984\newenvironment{tableii}[4]{%
985 \begin{center}%
986 \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
Fred Drakef61eac42000-10-24 02:18:30 +0000987 \begin{tabular}{#1}\strong{#3}&\strong{#4} \\* \hline%
Fred Drake6659c301998-03-03 22:02:19 +0000988}{%
Fred Drake6659c301998-03-03 22:02:19 +0000989 \end{tabular}%
990 \end{center}%
991}
992
Fred Drakeda72b932000-09-21 15:58:02 +0000993\newenvironment{longtableii}[4]{%
994 \begin{center}%
995 \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
Fred Drakef61eac42000-10-24 02:18:30 +0000996 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4} \\* \hline\endhead%
Fred Drakeda72b932000-09-21 15:58:02 +0000997}{%
998 \end{longtable}%
999 \end{center}%
1000}
1001
Fred Drake6659c301998-03-03 22:02:19 +00001002\newenvironment{tableiii}[5]{%
1003 \begin{center}%
1004 \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
Fred Drakeda72b932000-09-21 15:58:02 +00001005 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5} \\%
Fred Drakef61eac42000-10-24 02:18:30 +00001006 \hline%
Fred Drake6659c301998-03-03 22:02:19 +00001007}{%
Fred Drake6659c301998-03-03 22:02:19 +00001008 \end{tabular}%
1009 \end{center}%
1010}
1011
Fred Drakeda72b932000-09-21 15:58:02 +00001012\newenvironment{longtableiii}[5]{%
1013 \begin{center}%
1014 \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
1015 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5} \\%
Fred Drakef61eac42000-10-24 02:18:30 +00001016 \hline\endhead%
Fred Drakeda72b932000-09-21 15:58:02 +00001017}{%
1018 \end{longtable}%
1019 \end{center}%
1020}
1021
Fred Drake30e52651998-07-24 22:11:29 +00001022\newenvironment{tableiv}[6]{%
1023 \begin{center}%
1024 \def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}%
1025 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6} \\%
Fred Drakef61eac42000-10-24 02:18:30 +00001026 \hline%
Fred Drake30e52651998-07-24 22:11:29 +00001027}{%
1028 \end{tabular}%
1029 \end{center}%
1030}
1031
Fred Drakeda72b932000-09-21 15:58:02 +00001032\newenvironment{longtableiv}[6]{%
1033 \begin{center}%
1034 \def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}%
1035 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}%
1036 \\%
Fred Drakef61eac42000-10-24 02:18:30 +00001037 \hline\endhead%
Fred Drakeda72b932000-09-21 15:58:02 +00001038}{%
1039 \end{longtable}%
1040 \end{center}%
1041}
1042
Fred Drakef269e592001-07-17 23:05:57 +00001043\newenvironment{tablev}[7]{%
1044 \begin{center}%
1045 \def\linev##1##2##3##4##5{\csname#2\endcsname{##1}&##2&##3&##4&##5\\}%
1046 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}&\strong{#7} \\%
1047 \hline%
1048}{%
1049 \end{tabular}%
1050 \end{center}%
1051}
1052
1053\newenvironment{longtablev}[7]{%
1054 \begin{center}%
1055 \def\linev##1##2##3##4##5{\csname#2\endcsname{##1}&##2&##3&##4&##5\\}%
1056 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}&\strong{#7}%
1057 \\%
1058 \hline\endhead%
1059}{%
1060 \end{longtable}%
1061 \end{center}%
1062}
1063
Fred Drake24340ea1998-04-28 18:30:34 +00001064% Cross-referencing (AMK, new impl. FLD)
Fred Drake6659c301998-03-03 22:02:19 +00001065% Sample usage:
1066% \begin{seealso}
Fred Drake84bd6f31999-05-11 15:42:51 +00001067% \seemodule{rand}{Uniform random number generator.}; % Module xref
1068% \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book
Fred Drakeebcb6581998-03-06 21:25:17 +00001069%
1070% % A funky case: module name contains '_'; have to supply an optional key
Fred Drake84bd6f31999-05-11 15:42:51 +00001071% \seemodule[copyreg]{copy_reg}{Interface constructor registration for
1072% \module{pickle}.}
Fred Drake6659c301998-03-03 22:02:19 +00001073% \end{seealso}
Fred Drake84bd6f31999-05-11 15:42:51 +00001074%
1075% Note that the last parameter for \seemodule and \seetext should be complete
1076% sentences and be terminated with the proper punctuation.
Fred Drake6659c301998-03-03 22:02:19 +00001077
Fred Drakee59feb52001-10-29 21:02:28 +00001078\ifpdf
Fred Drake24340ea1998-04-28 18:30:34 +00001079 \newcommand{\py@seemodule}[3][\py@modulebadkey]{%
Fred Drakeda943741999-01-13 17:09:06 +00001080 \par%
Fred Drake24340ea1998-04-28 18:30:34 +00001081 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
Fred Drake84bd6f31999-05-11 15:42:51 +00001082 \begin{fulllineitems}
Fred Drake84bd6f31999-05-11 15:42:51 +00001083 \item[\py@linkToName{label-module-\py@modulekey}{Module \module{#2}}
1084 (section \ref{module-\py@modulekey}):]
1085 #3
1086 \end{fulllineitems}
Fred Drakeebcb6581998-03-06 21:25:17 +00001087 }
Fred Drakee59feb52001-10-29 21:02:28 +00001088\else
1089 \newcommand{\py@seemodule}[3][\py@modulebadkey]{%
1090 \par%
1091 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
1092 \begin{fulllineitems}
1093 \item[Module \module{#2} (section \ref{module-\py@modulekey}):]
1094 #3
1095 \end{fulllineitems}
1096 }
1097\fi
1098
Fred Drake48449982000-09-12 17:52:33 +00001099% \seetitle[url]{title}{why it's interesting}
1100\newcommand{\py@seetitle}[3][\py@modulebadkey]{%
1101 \par
1102 \begin{fulllineitems}
1103 \item[\citetitle{#2}]
1104 \ifx\py@modulebadkey#1\else
1105 \item[{\small{(\url{#1})}}]
1106 \fi
1107 #3
1108 \end{fulllineitems}
1109}
Fred Drake4e607962000-09-09 06:01:25 +00001110% \seepep{number}{title}{why it's interesting}
1111\newcommand{\py@seepep}[3]{%
1112 \par%
1113 \begin{fulllineitems}
1114 \item[\pep{#1}, ``\emph{#2}'']
1115 #3
1116 \end{fulllineitems}
1117}
Fred Drake64b72b62000-04-26 18:13:58 +00001118% \seerfc{number}{title}{why it's interesting}
1119\newcommand{\py@seerfc}[3]{%
1120 \par%
1121 \begin{fulllineitems}
1122 \item[\rfc{#1}, ``\emph{#2}'']
1123 #3
1124 \end{fulllineitems}
1125}
Fred Drake51313f12000-05-09 16:18:44 +00001126% \seeurl{url}{why it's interesting}
1127\newcommand{\py@seeurl}[2]{%
1128 \par%
1129 \begin{fulllineitems}
1130 \item[\url{#1}]
1131 #2
1132 \end{fulllineitems}
1133}
Fred Drake5ed35fd2001-11-30 18:09:54 +00001134
1135\newenvironment{seealso*}{
Fred Drake9466b9a1999-03-18 16:18:27 +00001136 \par
Fred Drake6659c301998-03-03 22:02:19 +00001137 \def\seetext##1{\par{##1}}
Fred Drake24340ea1998-04-28 18:30:34 +00001138 \let\seemodule=\py@seemodule
Fred Drake48449982000-09-12 17:52:33 +00001139 \let\seepep=\py@seepep
Fred Drake64b72b62000-04-26 18:13:58 +00001140 \let\seerfc=\py@seerfc
Fred Drake48449982000-09-12 17:52:33 +00001141 \let\seetitle=\py@seetitle
Fred Drake51313f12000-05-09 16:18:44 +00001142 \let\seeurl=\py@seeurl
Fred Drake6659c301998-03-03 22:02:19 +00001143}{\par}
Fred Drake5ed35fd2001-11-30 18:09:54 +00001144\newenvironment{seealso}{
1145 \par
1146 \strong{See Also:}
1147 \par
1148 \def\seetext##1{\par{##1}}
1149 \let\seemodule=\py@seemodule
1150 \let\seepep=\py@seepep
1151 \let\seerfc=\py@seerfc
1152 \let\seetitle=\py@seetitle
1153 \let\seeurl=\py@seeurl
1154}{\par}
Fred Drake6659c301998-03-03 22:02:19 +00001155
Fred Drakeaf958c71998-07-27 20:32:33 +00001156% Allow the Python release number to be specified independently of the
Fred Drake6659c301998-03-03 22:02:19 +00001157% \date{}. This allows the date to reflect the document's date and
1158% release to specify the Python release that is documented.
1159%
Fred Drake24340ea1998-04-28 18:30:34 +00001160\newcommand{\py@release}{}
Fred Drake6659c301998-03-03 22:02:19 +00001161\newcommand{\version}{}
Fred Drakeaf2b7142000-09-14 20:11:05 +00001162\newcommand{\shortversion}{}
Fred Drakec65218e2001-06-20 21:17:09 +00001163\newcommand{\releaseinfo}{}
Fred Drake6659c301998-03-03 22:02:19 +00001164\newcommand{\releasename}{Release}
1165\newcommand{\release}[1]{%
Fred Drake24340ea1998-04-28 18:30:34 +00001166 \renewcommand{\py@release}{\releasename\space\version}%
Fred Drake6659c301998-03-03 22:02:19 +00001167 \renewcommand{\version}{#1}}
Fred Drakeaf2b7142000-09-14 20:11:05 +00001168\newcommand{\setshortversion}[1]{%
1169 \renewcommand{\shortversion}{#1}}
Fred Drakec65218e2001-06-20 21:17:09 +00001170\newcommand{\setreleaseinfo}[1]{%
1171 \renewcommand{\releaseinfo}{#1}}
Fred Drake6659c301998-03-03 22:02:19 +00001172
1173% Allow specification of the author's address separately from the
1174% author's name. This can be used to format them differently, which
1175% is a good thing.
1176%
Fred Drake24340ea1998-04-28 18:30:34 +00001177\newcommand{\py@authoraddress}{}
1178\newcommand{\authoraddress}[1]{\renewcommand{\py@authoraddress}{#1}}
Fred Drake6df93ef1998-05-14 20:56:31 +00001179\let\developersaddress=\authoraddress
1180\let\developer=\author
1181\let\developers=\author
Fred Drake6659c301998-03-03 22:02:19 +00001182
Fred Drake6659c301998-03-03 22:02:19 +00001183% This sets up the fancy chapter headings that make the documents look
1184% at least a little better than the usual LaTeX output.
1185%
Fred Drake1c8d0e01998-03-07 05:29:15 +00001186\@ifundefined{ChTitleVar}{}{
Fred Drake24340ea1998-04-28 18:30:34 +00001187 \ChNameVar{\raggedleft\normalsize\py@HeaderFamily}
1188 \ChNumVar{\raggedleft \bfseries\Large\py@HeaderFamily}
1189 \ChTitleVar{\raggedleft \rm\Huge\py@HeaderFamily}
Fred Drake6659c301998-03-03 22:02:19 +00001190 % This creates chapter heads without the leading \vspace*{}:
Fred Drake1c8d0e01998-03-07 05:29:15 +00001191 \def\@makechapterhead#1{%
1192 {\parindent \z@ \raggedright \normalfont
1193 \ifnum \c@secnumdepth >\m@ne
Fred Drake6659c301998-03-03 22:02:19 +00001194 \DOCH
1195 \fi
Fred Drake1c8d0e01998-03-07 05:29:15 +00001196 \interlinepenalty\@M
Fred Drake6659c301998-03-03 22:02:19 +00001197 \DOTI{#1}
1198 }
1199 }
Fred Drake6659c301998-03-03 22:02:19 +00001200}
1201
Fred Drake3bf78651998-05-20 17:42:17 +00001202
1203% Definition lists; requested by AMK for HOWTO documents. Probably useful
1204% elsewhere as well, so keep in in the general style support.
1205%
1206\newenvironment{definitions}{%
1207 \begin{description}%
Fred Drakef9acc591998-09-09 15:27:43 +00001208 \def\term##1{\item[##1]\mbox{}\\*[0mm]}
Fred Drake3bf78651998-05-20 17:42:17 +00001209}{%
1210 \end{description}%
1211}
1212
Fred Drake6659c301998-03-03 22:02:19 +00001213% Tell TeX about pathological hyphenation cases:
1214\hyphenation{Base-HTTP-Re-quest-Hand-ler}