blob: 0b2c63793879f19ea720813059ee354ff5e69604 [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 Drakead74b7d2002-07-02 20:32:50 +0000584
585\newlength{\py@argswidth}
586\newcommand{\py@sigparams}[1]{%
587 \parbox[t]{\py@argswidth}{\py@varvars{#1}\code{)}}}
588\newcommand{\py@sigline}[2]{%
589 \settowidth{\py@argswidth}{#1\code{(}}%
590 \addtolength{\py@argswidth}{-2\py@argswidth}%
591 \addtolength{\py@argswidth}{\textwidth}%
592 \item[#1\code{(}\py@sigparams{#2}]}
593
Fred Drake6cb71491998-03-27 05:22:53 +0000594% C functions ------------------------------------------------------------
Fred Drakeba828782000-04-03 04:19:14 +0000595% \begin{cfuncdesc}[refcount]{type}{name}{arglist}
596% Note that the [refcount] slot should only be filled in by
597% tools/anno-api.py; it pulls the value from the refcounts database.
Fred Drake34adb8a2002-04-15 20:48:40 +0000598\newcommand{\cfuncline}[3]{
Fred Drakead74b7d2002-07-02 20:32:50 +0000599 \py@sigline{\code{#1 \bfcode{#2}}}{#3}%
600 \index{#2@{\py@idxcode{#2()}}}
Fred Drake34adb8a2002-04-15 20:48:40 +0000601}
Fred Drakeba828782000-04-03 04:19:14 +0000602\newenvironment{cfuncdesc}[4][\py@badkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000603 \begin{fulllineitems}
Fred Drake34adb8a2002-04-15 20:48:40 +0000604 \cfuncline{#2}{#3}{#4}
Fred Drakeba828782000-04-03 04:19:14 +0000605 \ifx#1\@undefined\else%
Fred Drake0a863da2000-04-10 18:21:38 +0000606 \emph{Return value: \textbf{#1}.}\\
Fred Drakeba828782000-04-03 04:19:14 +0000607 \fi
Fred Drake6cb71491998-03-27 05:22:53 +0000608}{\end{fulllineitems}}
609
610% C variables ------------------------------------------------------------
611% \begin{cvardesc}{type}{name}
612\newenvironment{cvardesc}[2]{
613 \begin{fulllineitems}
Fred Drake24340ea1998-04-28 18:30:34 +0000614 \item[\code{#1 \bfcode{#2}}\index{#2@{\py@idxcode{#2}}}]
Fred Drake6cb71491998-03-27 05:22:53 +0000615}{\end{fulllineitems}}
616
617% C data types -----------------------------------------------------------
Fred Drakeba828782000-04-03 04:19:14 +0000618% \begin{ctypedesc}[index name]{typedef name}
619\newenvironment{ctypedesc}[2][\py@badkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000620 \begin{fulllineitems}
Fred Drakeba828782000-04-03 04:19:14 +0000621 \item[\bfcode{#2}%
622 \ifx#1\@undefined%
Fred Drakea33c5662000-10-29 05:19:16 +0000623 \index{#2@{\py@idxcode{#2}} (C type)}
Fred Drakeba828782000-04-03 04:19:14 +0000624 \else%
Fred Drakea33c5662000-10-29 05:19:16 +0000625 \index{#2@{\py@idxcode{#1}} (C type)}
Fred Drakeba828782000-04-03 04:19:14 +0000626 \fi]
627}{\end{fulllineitems}}
628
Fred Drake01e94612002-04-12 22:48:02 +0000629% C type fields ----------------------------------------------------------
630% \begin{cmemberdesc}{container type}{ctype}{membername}
631\newcommand{\cmemberline}[3]{
632 \item[\code{#2 \bfcode{#3}}]
633 \index{#3@{\py@idxcode{#3}} (#1 member)}
634}
635\newenvironment{cmemberdesc}[3]{
636 \begin{fulllineitems}
637 \cmemberline{#1}{#2}{#3}
638}{\end{fulllineitems}}
639
Fred Drakeba828782000-04-03 04:19:14 +0000640% Funky macros -----------------------------------------------------------
Fred Drake19f827e2002-04-09 20:16:47 +0000641% \begin{csimplemacrodesc}{name}
Fred Drakeba828782000-04-03 04:19:14 +0000642% -- "simple" because it has no args; NOT for constant definitions!
643\newenvironment{csimplemacrodesc}[1]{
644 \begin{fulllineitems}
Fred Drakea33c5662000-10-29 05:19:16 +0000645 \item[\bfcode{#1}\index{#1@{\py@idxcode{#1}} (macro)}]
Fred Drake6cb71491998-03-27 05:22:53 +0000646}{\end{fulllineitems}}
647
648% simple functions (not methods) -----------------------------------------
649% \begin{funcdesc}{name}{args}
Fred Drakeec77e652000-10-30 06:22:22 +0000650\newcommand{\funcline}[2]{%
651 \funclineni{#1}{#2}%
652 \index{#1@{\py@idxcode{#1()}} (in module \py@thismodule)}}
Fred Drake6cb71491998-03-27 05:22:53 +0000653\newenvironment{funcdesc}[2]{
654 \begin{fulllineitems}
655 \funcline{#1}{#2}
656}{\end{fulllineitems}}
657
Fred Drake6659c301998-03-03 22:02:19 +0000658% similar to {funcdesc}, but doesn't add to the index
Fred Drakead74b7d2002-07-02 20:32:50 +0000659\newcommand{\funclineni}[2]{%
660 \py@sigline{\bfcode{#1}}{#2}}
Fred Drake6cb71491998-03-27 05:22:53 +0000661\newenvironment{funcdescni}[2]{
662 \begin{fulllineitems}
663 \funclineni{#1}{#2}
Fred Drake6659c301998-03-03 22:02:19 +0000664}{\end{fulllineitems}}
665
Fred Drake6cb71491998-03-27 05:22:53 +0000666% classes ----------------------------------------------------------------
667% \begin{classdesc}{name}{constructor args}
668\newenvironment{classdesc}[2]{
Fred Drake1cbd1961998-11-25 17:13:28 +0000669 % Using \renewcommand doesn't work for this, for unknown reasons:
670 \global\def\py@thisclass{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000671 \begin{fulllineitems}
Fred Drakead74b7d2002-07-02 20:32:50 +0000672 \py@sigline{\strong{class }\bfcode{#1}}{#2}%
673 \index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}
Fred Drake6659c301998-03-03 22:02:19 +0000674}{\end{fulllineitems}}
675
Fred Drake06a01e82001-05-11 01:00:30 +0000676% \begin{classdesc*}{name}
677\newenvironment{classdesc*}[1]{
678 % Using \renewcommand doesn't work for this, for unknown reasons:
679 \global\def\py@thisclass{#1}
680 \begin{fulllineitems}
681 \item[\strong{class }\code{\bfcode{#1}}%
682 \index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}]
683}{\end{fulllineitems}}
684
Fred Drake4e607962000-09-09 06:01:25 +0000685% \begin{excclassdesc}{name}{constructor args}
686% but indexes as an exception
687\newenvironment{excclassdesc}[2]{
688 % Using \renewcommand doesn't work for this, for unknown reasons:
689 \global\def\py@thisclass{#1}
690 \begin{fulllineitems}
Fred Drakead74b7d2002-07-02 20:32:50 +0000691 \py@sigline{\strong{exception }\bfcode{#1}}{#2}%
692 \index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}
Fred Drake4e607962000-09-09 06:01:25 +0000693}{\end{fulllineitems}}
694
Fred Drake06a01e82001-05-11 01:00:30 +0000695% There is no corresponding {excclassdesc*} environment. To describe
696% a class exception without parameters, use the {excdesc} environment.
697
Fred Drake6cb71491998-03-27 05:22:53 +0000698
Fred Drake24340ea1998-04-28 18:30:34 +0000699\let\py@classbadkey=\@undefined
Fred Drake6cb71491998-03-27 05:22:53 +0000700
701% object method ----------------------------------------------------------
702% \begin{methoddesc}[classname]{methodname}{args}
Fred Drakea33c5662000-10-29 05:19:16 +0000703\newcommand{\methodline}[3][\@undefined]{
Fred Drake6cb71491998-03-27 05:22:53 +0000704 \methodlineni{#2}{#3}
705 \ifx#1\@undefined
Fred Drakea33c5662000-10-29 05:19:16 +0000706 \index{#2@{\py@idxcode{#2()}} (\py@thisclass\ method)}
Fred Drake6cb71491998-03-27 05:22:53 +0000707 \else
Fred Drakea33c5662000-10-29 05:19:16 +0000708 \index{#2@{\py@idxcode{#2()}} (#1 method)}
Fred Drake6cb71491998-03-27 05:22:53 +0000709 \fi
710}
Fred Drakea33c5662000-10-29 05:19:16 +0000711\newenvironment{methoddesc}[3][\@undefined]{
Fred Drake6cb71491998-03-27 05:22:53 +0000712 \begin{fulllineitems}
713 \ifx#1\@undefined
714 \methodline{#2}{#3}
715 \else
Fred Drake24340ea1998-04-28 18:30:34 +0000716 \def\py@thisclass{#1}
Fred Drakea33c5662000-10-29 05:19:16 +0000717 \methodline{#2}{#3}
Fred Drake6cb71491998-03-27 05:22:53 +0000718 \fi
Fred Drake6659c301998-03-03 22:02:19 +0000719}{\end{fulllineitems}}
720
Fred Drake6cb71491998-03-27 05:22:53 +0000721% similar to {methoddesc}, but doesn't add to the index
722% (never actually uses the optional argument)
Fred Drake24340ea1998-04-28 18:30:34 +0000723\newcommand{\methodlineni}[3][\py@classbadkey]{%
Fred Drakead74b7d2002-07-02 20:32:50 +0000724 \py@sigline{\bfcode{#2}}{#3}}
Fred Drake24340ea1998-04-28 18:30:34 +0000725\newenvironment{methoddescni}[3][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000726 \begin{fulllineitems}
727 \methodlineni{#2}{#3}
728}{\end{fulllineitems}}
729
730% object data attribute --------------------------------------------------
731% \begin{memberdesc}[classname]{membername}
Fred Drake24340ea1998-04-28 18:30:34 +0000732\newcommand{\memberline}[2][\py@classbadkey]{%
Fred Drake6cb71491998-03-27 05:22:53 +0000733 \ifx#1\@undefined
734 \memberlineni{#2}
Fred Drakea33c5662000-10-29 05:19:16 +0000735 \index{#2@{\py@idxcode{#2}} (\py@thisclass\ attribute)}
Fred Drake6cb71491998-03-27 05:22:53 +0000736 \else
737 \memberlineni{#2}
Fred Drakea33c5662000-10-29 05:19:16 +0000738 \index{#2@{\py@idxcode{#2}} (#1 attribute)}
Fred Drake6cb71491998-03-27 05:22:53 +0000739 \fi
740}
Fred Drake24340ea1998-04-28 18:30:34 +0000741\newenvironment{memberdesc}[2][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000742 \begin{fulllineitems}
743 \ifx#1\@undefined
744 \memberline{#2}
745 \else
Fred Drake24340ea1998-04-28 18:30:34 +0000746 \def\py@thisclass{#1}
Fred Drakea33c5662000-10-29 05:19:16 +0000747 \memberline{#2}
Fred Drake6cb71491998-03-27 05:22:53 +0000748 \fi
749}{\end{fulllineitems}}
750
751% similar to {memberdesc}, but doesn't add to the index
752% (never actually uses the optional argument)
Fred Drake24340ea1998-04-28 18:30:34 +0000753\newcommand{\memberlineni}[2][\py@classbadkey]{\item[\bfcode{#2}]}
754\newenvironment{memberdescni}[2][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000755 \begin{fulllineitems}
756 \memberlineni{#2}
757}{\end{fulllineitems}}
758
759% For exceptions: --------------------------------------------------------
760% \begin{excdesc}{name}
Fred Drakea33c5662000-10-29 05:19:16 +0000761% -- for constructor information, use excclassdesc instead
Fred Drake6cb71491998-03-27 05:22:53 +0000762\newenvironment{excdesc}[1]{
763 \begin{fulllineitems}
Fred Drakeab357ec2001-03-02 18:57:05 +0000764 \item[\strong{exception }\bfcode{#1}%
Fred Drakea33c5662000-10-29 05:19:16 +0000765 \index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}]
Fred Drake6cb71491998-03-27 05:22:53 +0000766}{\end{fulllineitems}}
767
768% Module data or constants: ----------------------------------------------
769% \begin{datadesc}{name}
Fred Drakea33c5662000-10-29 05:19:16 +0000770\newcommand{\dataline}[1]{%
771 \datalineni{#1}\index{#1@{\py@idxcode{#1}} (data in \py@thismodule)}}
Fred Drake6cb71491998-03-27 05:22:53 +0000772\newenvironment{datadesc}[1]{
773 \begin{fulllineitems}
774 \dataline{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000775}{\end{fulllineitems}}
776
777% similar to {datadesc}, but doesn't add to the index
Fred Drake6cb71491998-03-27 05:22:53 +0000778\newcommand{\datalineni}[1]{\item[\bfcode{#1}]\nopagebreak}
779\newenvironment{datadescni}[1]{
780 \begin{fulllineitems}
781 \datalineni{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000782}{\end{fulllineitems}}
783
Fred Drake6cb71491998-03-27 05:22:53 +0000784% bytecode instruction ---------------------------------------------------
785% \begin{opcodedesc}{name}{var}
786% -- {var} may be {}
787\newenvironment{opcodedesc}[2]{
788 \begin{fulllineitems}
789 \item[\bfcode{#1}\quad\var{#2}]
Fred Drake6659c301998-03-03 22:02:19 +0000790}{\end{fulllineitems}}
791
792
Fred Drake24340ea1998-04-28 18:30:34 +0000793\newcommand{\nodename}[1]{\label{#1}}
Fred Drake55730311998-03-25 15:41:23 +0000794
Fred Drake6659c301998-03-03 22:02:19 +0000795% For these commands, use \command{} to get the typography right, not
796% {\command}. This works better with the texinfo translation.
797\newcommand{\ABC}{{\sc abc}}
798\newcommand{\UNIX}{{\sc Unix}}
799\newcommand{\POSIX}{POSIX}
800\newcommand{\ASCII}{{\sc ascii}}
801\newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}}
802\newcommand{\C}{C}
803\newcommand{\EOF}{{\sc eof}}
Fred Drake24340ea1998-04-28 18:30:34 +0000804\newcommand{\NULL}{\constant{NULL}}
Fred Drake5445e5e2001-06-23 03:11:45 +0000805\newcommand{\infinity}{\ensuremath{\infty}}
806\newcommand{\plusminus}{\ensuremath{\pm}}
Fred Drakeb4812862002-08-02 18:30:22 +0000807% \menuselection{Start \sub Programs \sub Python}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000808\newcommand{\menuselection}[1]{{\def\sub{ \ensuremath{>} }#1}}
Fred Drake6659c301998-03-03 22:02:19 +0000809
Fred Drake53714971998-04-02 22:33:16 +0000810% Also for consistency: spell Python "Python", not "python"!
811
Fred Drake6659c301998-03-03 22:02:19 +0000812% code is the most difficult one...
Fred Drake46346ec2000-06-30 17:57:05 +0000813\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 +0000814\texttt{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000815
816\newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font
Fred Drake19f827e2002-04-09 20:16:47 +0000817\newcommand{\csimplemacro}[1]{\code{#1}}
Fred Drake8e54abe1998-07-01 14:49:25 +0000818\newcommand{\kbd}[1]{\code{#1}}
Fred Drake24340ea1998-04-28 18:30:34 +0000819\newcommand{\samp}[1]{`\code{#1}'}
Fred Drake6659c301998-03-03 22:02:19 +0000820% This weird definition of \var{} allows it to always appear in roman
821% italics, and won't get funky in code fragments when we play around
Fred Drakefa1cceb1998-11-30 14:42:59 +0000822% with fonts. This also works directly in math mode.
823\newcommand{\var}[1]{%
824 \ifmmode%
825 \hbox{\normalsize\textrm{\textit{#1\/}}}%
826 \else%
827 \normalsize\textrm{\textit{#1\/}}%
828 \fi%
829}
Fred Drake24340ea1998-04-28 18:30:34 +0000830\renewcommand{\emph}[1]{{\em #1}}
Fred Drake6659c301998-03-03 22:02:19 +0000831\newcommand{\dfn}[1]{\emph{#1}}
832\newcommand{\strong}[1]{{\bf #1}}
833% let's experiment with a new font:
Fred Drake0ee9f721998-03-12 06:41:40 +0000834\newcommand{\file}[1]{`{\small\textsf{#1}}'}
Fred Drake0a0fd591999-04-28 14:59:44 +0000835\newcommand{\filenq}[1]{{\small\textsf{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000836
837% Use this def/redef approach for \url{} since hyperref defined this already,
838% but only if we actually used hyperref:
Fred Drakee59feb52001-10-29 21:02:28 +0000839\ifpdf
840 \newcommand{\url}[1]{{%
Fred Drake15fc72c2002-03-26 19:14:41 +0000841 \noindent%
Fred Drake53815882002-03-15 23:21:37 +0000842 \pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}%
Fred Drakeab357ec2001-03-02 18:57:05 +0000843 \py@LinkColor% color of the link text
Fred Drakee59feb52001-10-29 21:02:28 +0000844 \small\sf #1%
Fred Drakeab357ec2001-03-02 18:57:05 +0000845 \py@NormalColor% Turn it back off; these are declarative
846 \pdfendlink}% and don't appear bound to the current
847 }% formatting "box".
Fred Drakee59feb52001-10-29 21:02:28 +0000848\else
849 \newcommand{\url}[1]{\mbox{\small\textsf{#1}}}
850\fi
Fred Drake0ee9f721998-03-12 06:41:40 +0000851\newcommand{\email}[1]{{\small\textsf{#1}}}
Fred Drake454a4fb1998-04-01 22:20:14 +0000852\newcommand{\newsgroup}[1]{{\small\textsf{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000853
Fred Drakecc2b81e2000-08-03 17:38:30 +0000854\newcommand{\py@varvars}[1]{{%
Fred Drakeba828782000-04-03 04:19:14 +0000855 {\let\unspecified=\py@unspecified%
856 \let\moreargs=\py@moreargs%
Fred Drakecc2b81e2000-08-03 17:38:30 +0000857 \var{#1}}}}
Fred Drake6659c301998-03-03 22:02:19 +0000858
Fred Drake24340ea1998-04-28 18:30:34 +0000859% I'd really like to get rid of this!
Fred Drake6659c301998-03-03 22:02:19 +0000860\newif\iftexi\texifalse
Fred Drake6659c301998-03-03 22:02:19 +0000861
Fred Drake1e4973b1998-07-28 21:52:17 +0000862% This is used to get l2h to put the copyright and abstract on
863% a separate HTML page.
864\newif\ifhtml\htmlfalse
865
866
Fred Drake6659c301998-03-03 22:02:19 +0000867% These should be used for all references to identifiers which are
868% used to refer to instances of specific language constructs. See the
869% names for specific semantic assignments.
870%
871% For now, don't do anything really fancy with them; just use them as
872% logical markup. This might change in the future.
873%
Fred Drake24340ea1998-04-28 18:30:34 +0000874\newcommand{\module}[1]{\texttt{#1}}
875\newcommand{\keyword}[1]{\texttt{#1}}
876\newcommand{\exception}[1]{\texttt{#1}}
877\newcommand{\class}[1]{\texttt{#1}}
878\newcommand{\function}[1]{\texttt{#1}}
879\newcommand{\member}[1]{\texttt{#1}}
880\newcommand{\method}[1]{\texttt{#1}}
Fred Drake6659c301998-03-03 22:02:19 +0000881
Fred Drakeab357ec2001-03-02 18:57:05 +0000882\newcommand{\pytype}[1]{#1} % built-in Python type
Fred Drake53714971998-04-02 22:33:16 +0000883
Fred Drake24340ea1998-04-28 18:30:34 +0000884\newcommand{\cfunction}[1]{\texttt{#1}}
Fred Drakeab357ec2001-03-02 18:57:05 +0000885\newcommand{\ctype}[1]{\texttt{#1}} % C struct or typedef name
886\newcommand{\cdata}[1]{\texttt{#1}} % C variable, typically global
Fred Drake6659c301998-03-03 22:02:19 +0000887
Fred Drake479384e2001-09-26 18:46:36 +0000888\newcommand{\mailheader}[1]{{\small\textsf{#1:}}}
Fred Drake0ee9f721998-03-12 06:41:40 +0000889\newcommand{\mimetype}[1]{{\small\textsf{#1}}}
Fred Drake94fac131998-03-12 19:37:03 +0000890% The \! is a "negative thin space" in math mode.
891\newcommand{\regexp}[1]{%
892 {\tiny$^{^\lceil}\!\!$%
893 {\normalsize\code{#1}}%
Fred Drake47cfd031998-04-03 21:22:31 +0000894 $\!\rfloor\!$%
Fred Drake94fac131998-03-12 19:37:03 +0000895 }}
Fred Drake0ee9f721998-03-12 06:41:40 +0000896\newcommand{\envvar}[1]{%
Fred Drake31ab2982001-01-22 17:50:42 +0000897 #1%
Fred Drakee59feb52001-10-29 21:02:28 +0000898 \index{#1}%
Fred Drake31ab2982001-01-22 17:50:42 +0000899 \index{environment variables!{#1}}%
Fred Drake0ee9f721998-03-12 06:41:40 +0000900}
Fred Drakeab357ec2001-03-02 18:57:05 +0000901\newcommand{\makevar}[1]{#1} % variable in a Makefile
Fred Drake24340ea1998-04-28 18:30:34 +0000902\newcommand{\character}[1]{\samp{#1}}
Fred Drake0ee9f721998-03-12 06:41:40 +0000903
Fred Drake6659c301998-03-03 22:02:19 +0000904% constants defined in Python modules or C headers, not language constants:
Fred Drakeab357ec2001-03-02 18:57:05 +0000905\newcommand{\constant}[1]{\code{#1}} % manifest constant, not syntactic
Fred Drake6659c301998-03-03 22:02:19 +0000906
907\newcommand{\manpage}[2]{{\emph{#1}(#2)}}
Fred Drake4e607962000-09-09 06:01:25 +0000908\newcommand{\pep}[1]{PEP #1\index{Python Enhancement Proposals!PEP #1}}
Fred Drake6659c301998-03-03 22:02:19 +0000909\newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}}
910\newcommand{\program}[1]{\strong{#1}}
Fred Drake7b8195a1999-11-09 17:02:11 +0000911\newcommand{\programopt}[1]{\strong{#1}}
Fred Drake49362492000-04-11 18:47:59 +0000912% Note that \longprogramopt provides the '--'!
913\newcommand{\longprogramopt}[1]{\strong{-{}-#1}}
Fred Drakee59feb52001-10-29 21:02:28 +0000914
Fred Drakeb4b64da2001-07-06 22:44:48 +0000915% \ulink{link text}{URL}
Fred Drakee59feb52001-10-29 21:02:28 +0000916\ifpdf
917 % The \noindent here is a hack -- we're forcing pdfTeX into
Fred Drake53815882002-03-15 23:21:37 +0000918 % horizontal mode since \pdfstartlink requires that.
Fred Drakee59feb52001-10-29 21:02:28 +0000919 \newcommand{\ulink}[2]{\noindent{%
Fred Drake53815882002-03-15 23:21:37 +0000920 \pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#2)}%
Fred Drakee59feb52001-10-29 21:02:28 +0000921 \py@LinkColor% color of the link text
922 #1%
923 \py@NormalColor% Turn it back off; these are declarative
924 \pdfendlink}% and don't appear bound to the current
925 }% formatting "box".
926\else
927 \newcommand{\ulink}[2]{#1}
928\fi
Fred Drake7b8195a1999-11-09 17:02:11 +0000929
930% cited titles: \citetitle{Title of Work}
931% online: \citetitle[url-to-resource]{Title of Work}
Fred Drakee59feb52001-10-29 21:02:28 +0000932\ifpdf
933 \newcommand{\citetitle}[2][\py@modulebadkey]{%
934 \ifx\py@modulebadkey#1\emph{#2}\else\ulink{\emph{#2}}{#1}\fi%
935 }
936\else
Fred Drake622087a2001-11-02 20:53:19 +0000937 \newcommand{\citetitle}[2][URL]{\emph{#2}}
Fred Drakee59feb52001-10-29 21:02:28 +0000938\fi
939
Fred Drake6659c301998-03-03 22:02:19 +0000940
941
Fred Drakec82bd722001-12-11 18:47:36 +0000942% This version is being checked in for the historical record; it shows
943% how I've managed to get some aspects of this to work. It will not
944% be used in practice, so a subsequent revision will change things
945% again. This version has problems, but shows how to do something
946% that proved more tedious than I'd expected, so I don't want to lose
947% the example completely.
948%
Fred Drake16bb4192001-08-20 21:36:38 +0000949\newcommand{\grammartoken}[1]{\texttt{#1}}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000950\newenvironment{productionlist}[1][\py@badkey]{
951 \def\optional##1{{\Large[}##1{\Large]}}
952 \def\production##1##2{\code{##1}&::=&\code{##2}\\}
Fred Drake53815882002-03-15 23:21:37 +0000953 \def\productioncont##1{& &\code{##1}\\}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000954 \def\token##1{##1}
Fred Drake16bb4192001-08-20 21:36:38 +0000955 \let\grammartoken=\token
Fred Drakec82bd722001-12-11 18:47:36 +0000956 \parindent=2em
957 \indent
958 \begin{tabular}{lcl}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000959}{%
Fred Drakec82bd722001-12-11 18:47:36 +0000960 \end{tabular}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000961}
962
Fred Drake6ca33772001-12-14 22:50:06 +0000963\newcommand{\py@noticelabel@note}{Note:}
964\newcommand{\py@noticelabel@warning}{Warning:}
965\newenvironment{notice}[1][note]{
966 \par\strong{\csname py@noticelabel@#1\endcsname}
967}{}
968\newcommand{\note}[1]{\strong{\py@noticelabel@note} #1}
969\newcommand{\warning}[1]{\strong{\py@noticelabel@warning} #1}
Fred Drake92350b32001-10-09 18:01:23 +0000970
Fred Drake6659c301998-03-03 22:02:19 +0000971% Deprecation stuff.
972% Should be extended to allow an index / list of deprecated stuff. But
973% there's a lot of stuff that needs to be done to make that automatable.
974%
975% First parameter is the release number that deprecates the feature, the
976% second is the action the should be taken by users of the feature.
977%
978% Example:
Fred Drake24340ea1998-04-28 18:30:34 +0000979% \deprecated{1.5.1}{Use \method{frobnicate()} instead.}
Fred Drake6659c301998-03-03 22:02:19 +0000980%
981\newcommand{\deprecated}[2]{%
982 \strong{Deprecated since release #1.} #2\par}
983
Fred Drakeaf958c71998-07-27 20:32:33 +0000984% New stuff.
985% This should be used to mark things which have been added to the
986% development tree but that aren't in the release, but are documented.
987% This allows release of documentation that already includes updated
Fred Drake2116d981999-02-02 18:02:48 +0000988% descriptions. Place at end of descriptor environment.
Fred Drakeaf958c71998-07-27 20:32:33 +0000989%
990% Example:
991% \versionadded{1.5.2}
Fred Drake46346ec2000-06-30 17:57:05 +0000992% \versionchanged[short explanation]{2.0}
Fred Drakeaf958c71998-07-27 20:32:33 +0000993%
Fred Drakefdfb05b2001-04-18 03:08:54 +0000994\newcommand{\versionadded}[2][\py@badkey]{%
995 \ifx#1\@undefined%
996 { New in version #2. }%
997 \else%
998 { New in version #2:\ #1. }%
999 \fi%
1000}
Fred Drakea6e83392000-05-02 17:28:36 +00001001\newcommand{\versionchanged}[2][\py@badkey]{%
1002 \ifx#1\@undefined%
1003 { Changed in version #2. }%
1004 \else%
1005 { Changed in version #2:\ #1. }%
1006 \fi%
1007}
Fred Drake6659c301998-03-03 22:02:19 +00001008
Fred Drakeaf958c71998-07-27 20:32:33 +00001009
1010% Tables.
1011%
Fred Drake6659c301998-03-03 22:02:19 +00001012\newenvironment{tableii}[4]{%
1013 \begin{center}%
1014 \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
Fred Drakef61eac42000-10-24 02:18:30 +00001015 \begin{tabular}{#1}\strong{#3}&\strong{#4} \\* \hline%
Fred Drake6659c301998-03-03 22:02:19 +00001016}{%
Fred Drake6659c301998-03-03 22:02:19 +00001017 \end{tabular}%
1018 \end{center}%
1019}
1020
Fred Drakeda72b932000-09-21 15:58:02 +00001021\newenvironment{longtableii}[4]{%
1022 \begin{center}%
1023 \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
Fred Drakef61eac42000-10-24 02:18:30 +00001024 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4} \\* \hline\endhead%
Fred Drakeda72b932000-09-21 15:58:02 +00001025}{%
1026 \end{longtable}%
1027 \end{center}%
1028}
1029
Fred Drake6659c301998-03-03 22:02:19 +00001030\newenvironment{tableiii}[5]{%
1031 \begin{center}%
1032 \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
Fred Drakeda72b932000-09-21 15:58:02 +00001033 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5} \\%
Fred Drakef61eac42000-10-24 02:18:30 +00001034 \hline%
Fred Drake6659c301998-03-03 22:02:19 +00001035}{%
Fred Drake6659c301998-03-03 22:02:19 +00001036 \end{tabular}%
1037 \end{center}%
1038}
1039
Fred Drakeda72b932000-09-21 15:58:02 +00001040\newenvironment{longtableiii}[5]{%
1041 \begin{center}%
1042 \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
1043 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5} \\%
Fred Drakef61eac42000-10-24 02:18:30 +00001044 \hline\endhead%
Fred Drakeda72b932000-09-21 15:58:02 +00001045}{%
1046 \end{longtable}%
1047 \end{center}%
1048}
1049
Fred Drake30e52651998-07-24 22:11:29 +00001050\newenvironment{tableiv}[6]{%
1051 \begin{center}%
1052 \def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}%
1053 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6} \\%
Fred Drakef61eac42000-10-24 02:18:30 +00001054 \hline%
Fred Drake30e52651998-07-24 22:11:29 +00001055}{%
1056 \end{tabular}%
1057 \end{center}%
1058}
1059
Fred Drakeda72b932000-09-21 15:58:02 +00001060\newenvironment{longtableiv}[6]{%
1061 \begin{center}%
1062 \def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}%
1063 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}%
1064 \\%
Fred Drakef61eac42000-10-24 02:18:30 +00001065 \hline\endhead%
Fred Drakeda72b932000-09-21 15:58:02 +00001066}{%
1067 \end{longtable}%
1068 \end{center}%
1069}
1070
Fred Drakef269e592001-07-17 23:05:57 +00001071\newenvironment{tablev}[7]{%
1072 \begin{center}%
1073 \def\linev##1##2##3##4##5{\csname#2\endcsname{##1}&##2&##3&##4&##5\\}%
1074 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}&\strong{#7} \\%
1075 \hline%
1076}{%
1077 \end{tabular}%
1078 \end{center}%
1079}
1080
1081\newenvironment{longtablev}[7]{%
1082 \begin{center}%
1083 \def\linev##1##2##3##4##5{\csname#2\endcsname{##1}&##2&##3&##4&##5\\}%
1084 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}&\strong{#7}%
1085 \\%
1086 \hline\endhead%
1087}{%
1088 \end{longtable}%
1089 \end{center}%
1090}
1091
Fred Drake24340ea1998-04-28 18:30:34 +00001092% Cross-referencing (AMK, new impl. FLD)
Fred Drake6659c301998-03-03 22:02:19 +00001093% Sample usage:
1094% \begin{seealso}
Fred Drake84bd6f31999-05-11 15:42:51 +00001095% \seemodule{rand}{Uniform random number generator.}; % Module xref
1096% \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book
Fred Drakeebcb6581998-03-06 21:25:17 +00001097%
1098% % A funky case: module name contains '_'; have to supply an optional key
Fred Drake84bd6f31999-05-11 15:42:51 +00001099% \seemodule[copyreg]{copy_reg}{Interface constructor registration for
1100% \module{pickle}.}
Fred Drake6659c301998-03-03 22:02:19 +00001101% \end{seealso}
Fred Drake84bd6f31999-05-11 15:42:51 +00001102%
1103% Note that the last parameter for \seemodule and \seetext should be complete
1104% sentences and be terminated with the proper punctuation.
Fred Drake6659c301998-03-03 22:02:19 +00001105
Fred Drakee59feb52001-10-29 21:02:28 +00001106\ifpdf
Fred Drake24340ea1998-04-28 18:30:34 +00001107 \newcommand{\py@seemodule}[3][\py@modulebadkey]{%
Fred Drakeda943741999-01-13 17:09:06 +00001108 \par%
Fred Drake24340ea1998-04-28 18:30:34 +00001109 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
Fred Drake84bd6f31999-05-11 15:42:51 +00001110 \begin{fulllineitems}
Fred Drake84bd6f31999-05-11 15:42:51 +00001111 \item[\py@linkToName{label-module-\py@modulekey}{Module \module{#2}}
1112 (section \ref{module-\py@modulekey}):]
1113 #3
1114 \end{fulllineitems}
Fred Drakeebcb6581998-03-06 21:25:17 +00001115 }
Fred Drakee59feb52001-10-29 21:02:28 +00001116\else
1117 \newcommand{\py@seemodule}[3][\py@modulebadkey]{%
1118 \par%
1119 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
1120 \begin{fulllineitems}
1121 \item[Module \module{#2} (section \ref{module-\py@modulekey}):]
1122 #3
1123 \end{fulllineitems}
1124 }
1125\fi
1126
Fred Drake48449982000-09-12 17:52:33 +00001127% \seetitle[url]{title}{why it's interesting}
1128\newcommand{\py@seetitle}[3][\py@modulebadkey]{%
1129 \par
1130 \begin{fulllineitems}
1131 \item[\citetitle{#2}]
1132 \ifx\py@modulebadkey#1\else
1133 \item[{\small{(\url{#1})}}]
1134 \fi
1135 #3
1136 \end{fulllineitems}
1137}
Fred Drake4e607962000-09-09 06:01:25 +00001138% \seepep{number}{title}{why it's interesting}
1139\newcommand{\py@seepep}[3]{%
1140 \par%
1141 \begin{fulllineitems}
1142 \item[\pep{#1}, ``\emph{#2}'']
1143 #3
1144 \end{fulllineitems}
1145}
Fred Drake64b72b62000-04-26 18:13:58 +00001146% \seerfc{number}{title}{why it's interesting}
1147\newcommand{\py@seerfc}[3]{%
1148 \par%
1149 \begin{fulllineitems}
1150 \item[\rfc{#1}, ``\emph{#2}'']
1151 #3
1152 \end{fulllineitems}
1153}
Fred Drake51313f12000-05-09 16:18:44 +00001154% \seeurl{url}{why it's interesting}
1155\newcommand{\py@seeurl}[2]{%
1156 \par%
1157 \begin{fulllineitems}
1158 \item[\url{#1}]
1159 #2
1160 \end{fulllineitems}
1161}
Fred Drake5ed35fd2001-11-30 18:09:54 +00001162
1163\newenvironment{seealso*}{
Fred Drake9466b9a1999-03-18 16:18:27 +00001164 \par
Fred Drake6659c301998-03-03 22:02:19 +00001165 \def\seetext##1{\par{##1}}
Fred Drake24340ea1998-04-28 18:30:34 +00001166 \let\seemodule=\py@seemodule
Fred Drake48449982000-09-12 17:52:33 +00001167 \let\seepep=\py@seepep
Fred Drake64b72b62000-04-26 18:13:58 +00001168 \let\seerfc=\py@seerfc
Fred Drake48449982000-09-12 17:52:33 +00001169 \let\seetitle=\py@seetitle
Fred Drake51313f12000-05-09 16:18:44 +00001170 \let\seeurl=\py@seeurl
Fred Drake6659c301998-03-03 22:02:19 +00001171}{\par}
Fred Drake5ed35fd2001-11-30 18:09:54 +00001172\newenvironment{seealso}{
1173 \par
1174 \strong{See Also:}
1175 \par
1176 \def\seetext##1{\par{##1}}
1177 \let\seemodule=\py@seemodule
1178 \let\seepep=\py@seepep
1179 \let\seerfc=\py@seerfc
1180 \let\seetitle=\py@seetitle
1181 \let\seeurl=\py@seeurl
1182}{\par}
Fred Drake6659c301998-03-03 22:02:19 +00001183
Fred Drakeaf958c71998-07-27 20:32:33 +00001184% Allow the Python release number to be specified independently of the
Fred Drake6659c301998-03-03 22:02:19 +00001185% \date{}. This allows the date to reflect the document's date and
1186% release to specify the Python release that is documented.
1187%
Fred Drake24340ea1998-04-28 18:30:34 +00001188\newcommand{\py@release}{}
Fred Drake6659c301998-03-03 22:02:19 +00001189\newcommand{\version}{}
Fred Drakeaf2b7142000-09-14 20:11:05 +00001190\newcommand{\shortversion}{}
Fred Drakec65218e2001-06-20 21:17:09 +00001191\newcommand{\releaseinfo}{}
Fred Drake6659c301998-03-03 22:02:19 +00001192\newcommand{\releasename}{Release}
1193\newcommand{\release}[1]{%
Fred Drake24340ea1998-04-28 18:30:34 +00001194 \renewcommand{\py@release}{\releasename\space\version}%
Fred Drake6659c301998-03-03 22:02:19 +00001195 \renewcommand{\version}{#1}}
Fred Drakeaf2b7142000-09-14 20:11:05 +00001196\newcommand{\setshortversion}[1]{%
1197 \renewcommand{\shortversion}{#1}}
Fred Drakec65218e2001-06-20 21:17:09 +00001198\newcommand{\setreleaseinfo}[1]{%
1199 \renewcommand{\releaseinfo}{#1}}
Fred Drake6659c301998-03-03 22:02:19 +00001200
1201% Allow specification of the author's address separately from the
1202% author's name. This can be used to format them differently, which
1203% is a good thing.
1204%
Fred Drake24340ea1998-04-28 18:30:34 +00001205\newcommand{\py@authoraddress}{}
1206\newcommand{\authoraddress}[1]{\renewcommand{\py@authoraddress}{#1}}
Fred Drake6df93ef1998-05-14 20:56:31 +00001207\let\developersaddress=\authoraddress
1208\let\developer=\author
1209\let\developers=\author
Fred Drake6659c301998-03-03 22:02:19 +00001210
Fred Drake6659c301998-03-03 22:02:19 +00001211% This sets up the fancy chapter headings that make the documents look
1212% at least a little better than the usual LaTeX output.
1213%
Fred Drake1c8d0e01998-03-07 05:29:15 +00001214\@ifundefined{ChTitleVar}{}{
Fred Drake24340ea1998-04-28 18:30:34 +00001215 \ChNameVar{\raggedleft\normalsize\py@HeaderFamily}
1216 \ChNumVar{\raggedleft \bfseries\Large\py@HeaderFamily}
1217 \ChTitleVar{\raggedleft \rm\Huge\py@HeaderFamily}
Fred Drake6659c301998-03-03 22:02:19 +00001218 % This creates chapter heads without the leading \vspace*{}:
Fred Drake1c8d0e01998-03-07 05:29:15 +00001219 \def\@makechapterhead#1{%
1220 {\parindent \z@ \raggedright \normalfont
1221 \ifnum \c@secnumdepth >\m@ne
Fred Drake6659c301998-03-03 22:02:19 +00001222 \DOCH
1223 \fi
Fred Drake1c8d0e01998-03-07 05:29:15 +00001224 \interlinepenalty\@M
Fred Drake6659c301998-03-03 22:02:19 +00001225 \DOTI{#1}
1226 }
1227 }
Fred Drake6659c301998-03-03 22:02:19 +00001228}
1229
Fred Drake3bf78651998-05-20 17:42:17 +00001230
1231% Definition lists; requested by AMK for HOWTO documents. Probably useful
1232% elsewhere as well, so keep in in the general style support.
1233%
1234\newenvironment{definitions}{%
1235 \begin{description}%
Fred Drakef9acc591998-09-09 15:27:43 +00001236 \def\term##1{\item[##1]\mbox{}\\*[0mm]}
Fred Drake3bf78651998-05-20 17:42:17 +00001237}{%
1238 \end{description}%
1239}
1240
Fred Drake6659c301998-03-03 22:02:19 +00001241% Tell TeX about pathological hyphenation cases:
1242\hyphenation{Base-HTTP-Re-quest-Hand-ler}