blob: 580741605222b558a80a687aab7806c357cd6c9c [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
Fred Drake01e94612002-04-12 22:48:02 +0000615% C type fields ----------------------------------------------------------
616% \begin{cmemberdesc}{container type}{ctype}{membername}
617\newcommand{\cmemberline}[3]{
618 \item[\code{#2 \bfcode{#3}}]
619 \index{#3@{\py@idxcode{#3}} (#1 member)}
620}
621\newenvironment{cmemberdesc}[3]{
622 \begin{fulllineitems}
623 \cmemberline{#1}{#2}{#3}
624}{\end{fulllineitems}}
625
Fred Drakeba828782000-04-03 04:19:14 +0000626% Funky macros -----------------------------------------------------------
Fred Drake19f827e2002-04-09 20:16:47 +0000627% \begin{csimplemacrodesc}{name}
Fred Drakeba828782000-04-03 04:19:14 +0000628% -- "simple" because it has no args; NOT for constant definitions!
629\newenvironment{csimplemacrodesc}[1]{
630 \begin{fulllineitems}
Fred Drakea33c5662000-10-29 05:19:16 +0000631 \item[\bfcode{#1}\index{#1@{\py@idxcode{#1}} (macro)}]
Fred Drake6cb71491998-03-27 05:22:53 +0000632}{\end{fulllineitems}}
633
634% simple functions (not methods) -----------------------------------------
635% \begin{funcdesc}{name}{args}
Fred Drakeec77e652000-10-30 06:22:22 +0000636\newcommand{\funcline}[2]{%
637 \funclineni{#1}{#2}%
638 \index{#1@{\py@idxcode{#1()}} (in module \py@thismodule)}}
Fred Drake6cb71491998-03-27 05:22:53 +0000639\newenvironment{funcdesc}[2]{
640 \begin{fulllineitems}
641 \funcline{#1}{#2}
642}{\end{fulllineitems}}
643
Fred Drake6659c301998-03-03 22:02:19 +0000644% similar to {funcdesc}, but doesn't add to the index
Fred Drake300775d1998-04-17 02:17:00 +0000645\newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(\py@varvars{#2})}]}
Fred Drake6cb71491998-03-27 05:22:53 +0000646\newenvironment{funcdescni}[2]{
647 \begin{fulllineitems}
648 \funclineni{#1}{#2}
Fred Drake6659c301998-03-03 22:02:19 +0000649}{\end{fulllineitems}}
650
Fred Drake6cb71491998-03-27 05:22:53 +0000651% classes ----------------------------------------------------------------
652% \begin{classdesc}{name}{constructor args}
653\newenvironment{classdesc}[2]{
Fred Drake1cbd1961998-11-25 17:13:28 +0000654 % Using \renewcommand doesn't work for this, for unknown reasons:
655 \global\def\py@thisclass{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000656 \begin{fulllineitems}
Fred Drakeab357ec2001-03-02 18:57:05 +0000657 \item[\strong{class }\code{\bfcode{#1}(\py@varvars{#2})}%
Fred Drakea33c5662000-10-29 05:19:16 +0000658 \index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}]
Fred Drake6659c301998-03-03 22:02:19 +0000659}{\end{fulllineitems}}
660
Fred Drake06a01e82001-05-11 01:00:30 +0000661% \begin{classdesc*}{name}
662\newenvironment{classdesc*}[1]{
663 % Using \renewcommand doesn't work for this, for unknown reasons:
664 \global\def\py@thisclass{#1}
665 \begin{fulllineitems}
666 \item[\strong{class }\code{\bfcode{#1}}%
667 \index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}]
668}{\end{fulllineitems}}
669
Fred Drake4e607962000-09-09 06:01:25 +0000670% \begin{excclassdesc}{name}{constructor args}
671% but indexes as an exception
672\newenvironment{excclassdesc}[2]{
673 % Using \renewcommand doesn't work for this, for unknown reasons:
674 \global\def\py@thisclass{#1}
675 \begin{fulllineitems}
Fred Drakeab357ec2001-03-02 18:57:05 +0000676 \item[\strong{exception }\code{\bfcode{#1}(\py@varvars{#2})}%
Fred Drakea33c5662000-10-29 05:19:16 +0000677 \index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}]
Fred Drake4e607962000-09-09 06:01:25 +0000678}{\end{fulllineitems}}
679
Fred Drake06a01e82001-05-11 01:00:30 +0000680% There is no corresponding {excclassdesc*} environment. To describe
681% a class exception without parameters, use the {excdesc} environment.
682
Fred Drake6cb71491998-03-27 05:22:53 +0000683
Fred Drake24340ea1998-04-28 18:30:34 +0000684\let\py@classbadkey=\@undefined
Fred Drake6cb71491998-03-27 05:22:53 +0000685
686% object method ----------------------------------------------------------
687% \begin{methoddesc}[classname]{methodname}{args}
Fred Drakea33c5662000-10-29 05:19:16 +0000688\newcommand{\methodline}[3][\@undefined]{
Fred Drake6cb71491998-03-27 05:22:53 +0000689 \methodlineni{#2}{#3}
690 \ifx#1\@undefined
Fred Drakea33c5662000-10-29 05:19:16 +0000691 \index{#2@{\py@idxcode{#2()}} (\py@thisclass\ method)}
Fred Drake6cb71491998-03-27 05:22:53 +0000692 \else
Fred Drakea33c5662000-10-29 05:19:16 +0000693 \index{#2@{\py@idxcode{#2()}} (#1 method)}
Fred Drake6cb71491998-03-27 05:22:53 +0000694 \fi
695}
Fred Drakea33c5662000-10-29 05:19:16 +0000696\newenvironment{methoddesc}[3][\@undefined]{
Fred Drake6cb71491998-03-27 05:22:53 +0000697 \begin{fulllineitems}
698 \ifx#1\@undefined
699 \methodline{#2}{#3}
700 \else
Fred Drake24340ea1998-04-28 18:30:34 +0000701 \def\py@thisclass{#1}
Fred Drakea33c5662000-10-29 05:19:16 +0000702 \methodline{#2}{#3}
Fred Drake6cb71491998-03-27 05:22:53 +0000703 \fi
Fred Drake6659c301998-03-03 22:02:19 +0000704}{\end{fulllineitems}}
705
Fred Drake6cb71491998-03-27 05:22:53 +0000706% similar to {methoddesc}, but doesn't add to the index
707% (never actually uses the optional argument)
Fred Drake24340ea1998-04-28 18:30:34 +0000708\newcommand{\methodlineni}[3][\py@classbadkey]{%
Fred Drake300775d1998-04-17 02:17:00 +0000709 \item[\code{\bfcode{#2}(\py@varvars{#3})}]}
Fred Drake24340ea1998-04-28 18:30:34 +0000710\newenvironment{methoddescni}[3][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000711 \begin{fulllineitems}
712 \methodlineni{#2}{#3}
713}{\end{fulllineitems}}
714
715% object data attribute --------------------------------------------------
716% \begin{memberdesc}[classname]{membername}
Fred Drake24340ea1998-04-28 18:30:34 +0000717\newcommand{\memberline}[2][\py@classbadkey]{%
Fred Drake6cb71491998-03-27 05:22:53 +0000718 \ifx#1\@undefined
719 \memberlineni{#2}
Fred Drakea33c5662000-10-29 05:19:16 +0000720 \index{#2@{\py@idxcode{#2}} (\py@thisclass\ attribute)}
Fred Drake6cb71491998-03-27 05:22:53 +0000721 \else
722 \memberlineni{#2}
Fred Drakea33c5662000-10-29 05:19:16 +0000723 \index{#2@{\py@idxcode{#2}} (#1 attribute)}
Fred Drake6cb71491998-03-27 05:22:53 +0000724 \fi
725}
Fred Drake24340ea1998-04-28 18:30:34 +0000726\newenvironment{memberdesc}[2][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000727 \begin{fulllineitems}
728 \ifx#1\@undefined
729 \memberline{#2}
730 \else
Fred Drake24340ea1998-04-28 18:30:34 +0000731 \def\py@thisclass{#1}
Fred Drakea33c5662000-10-29 05:19:16 +0000732 \memberline{#2}
Fred Drake6cb71491998-03-27 05:22:53 +0000733 \fi
734}{\end{fulllineitems}}
735
736% similar to {memberdesc}, but doesn't add to the index
737% (never actually uses the optional argument)
Fred Drake24340ea1998-04-28 18:30:34 +0000738\newcommand{\memberlineni}[2][\py@classbadkey]{\item[\bfcode{#2}]}
739\newenvironment{memberdescni}[2][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000740 \begin{fulllineitems}
741 \memberlineni{#2}
742}{\end{fulllineitems}}
743
744% For exceptions: --------------------------------------------------------
745% \begin{excdesc}{name}
Fred Drakea33c5662000-10-29 05:19:16 +0000746% -- for constructor information, use excclassdesc instead
Fred Drake6cb71491998-03-27 05:22:53 +0000747\newenvironment{excdesc}[1]{
748 \begin{fulllineitems}
Fred Drakeab357ec2001-03-02 18:57:05 +0000749 \item[\strong{exception }\bfcode{#1}%
Fred Drakea33c5662000-10-29 05:19:16 +0000750 \index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}]
Fred Drake6cb71491998-03-27 05:22:53 +0000751}{\end{fulllineitems}}
752
753% Module data or constants: ----------------------------------------------
754% \begin{datadesc}{name}
Fred Drakea33c5662000-10-29 05:19:16 +0000755\newcommand{\dataline}[1]{%
756 \datalineni{#1}\index{#1@{\py@idxcode{#1}} (data in \py@thismodule)}}
Fred Drake6cb71491998-03-27 05:22:53 +0000757\newenvironment{datadesc}[1]{
758 \begin{fulllineitems}
759 \dataline{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000760}{\end{fulllineitems}}
761
762% similar to {datadesc}, but doesn't add to the index
Fred Drake6cb71491998-03-27 05:22:53 +0000763\newcommand{\datalineni}[1]{\item[\bfcode{#1}]\nopagebreak}
764\newenvironment{datadescni}[1]{
765 \begin{fulllineitems}
766 \datalineni{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000767}{\end{fulllineitems}}
768
Fred Drake6cb71491998-03-27 05:22:53 +0000769% bytecode instruction ---------------------------------------------------
770% \begin{opcodedesc}{name}{var}
771% -- {var} may be {}
772\newenvironment{opcodedesc}[2]{
773 \begin{fulllineitems}
774 \item[\bfcode{#1}\quad\var{#2}]
Fred Drake6659c301998-03-03 22:02:19 +0000775}{\end{fulllineitems}}
776
777
Fred Drake24340ea1998-04-28 18:30:34 +0000778\newcommand{\nodename}[1]{\label{#1}}
Fred Drake55730311998-03-25 15:41:23 +0000779
Fred Drake6659c301998-03-03 22:02:19 +0000780% For these commands, use \command{} to get the typography right, not
781% {\command}. This works better with the texinfo translation.
782\newcommand{\ABC}{{\sc abc}}
783\newcommand{\UNIX}{{\sc Unix}}
784\newcommand{\POSIX}{POSIX}
785\newcommand{\ASCII}{{\sc ascii}}
786\newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}}
787\newcommand{\C}{C}
788\newcommand{\EOF}{{\sc eof}}
Fred Drake24340ea1998-04-28 18:30:34 +0000789\newcommand{\NULL}{\constant{NULL}}
Fred Drake5445e5e2001-06-23 03:11:45 +0000790\newcommand{\infinity}{\ensuremath{\infty}}
791\newcommand{\plusminus}{\ensuremath{\pm}}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000792\newcommand{\menuselection}[1]{{\def\sub{ \ensuremath{>} }#1}}
Fred Drake6659c301998-03-03 22:02:19 +0000793
Fred Drake53714971998-04-02 22:33:16 +0000794% Also for consistency: spell Python "Python", not "python"!
795
Fred Drake6659c301998-03-03 22:02:19 +0000796% code is the most difficult one...
Fred Drake46346ec2000-06-30 17:57:05 +0000797\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 +0000798\texttt{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000799
800\newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font
Fred Drake19f827e2002-04-09 20:16:47 +0000801\newcommand{\csimplemacro}[1]{\code{#1}}
Fred Drake8e54abe1998-07-01 14:49:25 +0000802\newcommand{\kbd}[1]{\code{#1}}
Fred Drake24340ea1998-04-28 18:30:34 +0000803\newcommand{\samp}[1]{`\code{#1}'}
Fred Drake6659c301998-03-03 22:02:19 +0000804% This weird definition of \var{} allows it to always appear in roman
805% italics, and won't get funky in code fragments when we play around
Fred Drakefa1cceb1998-11-30 14:42:59 +0000806% with fonts. This also works directly in math mode.
807\newcommand{\var}[1]{%
808 \ifmmode%
809 \hbox{\normalsize\textrm{\textit{#1\/}}}%
810 \else%
811 \normalsize\textrm{\textit{#1\/}}%
812 \fi%
813}
Fred Drake24340ea1998-04-28 18:30:34 +0000814\renewcommand{\emph}[1]{{\em #1}}
Fred Drake6659c301998-03-03 22:02:19 +0000815\newcommand{\dfn}[1]{\emph{#1}}
816\newcommand{\strong}[1]{{\bf #1}}
817% let's experiment with a new font:
Fred Drake0ee9f721998-03-12 06:41:40 +0000818\newcommand{\file}[1]{`{\small\textsf{#1}}'}
Fred Drake0a0fd591999-04-28 14:59:44 +0000819\newcommand{\filenq}[1]{{\small\textsf{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000820
821% Use this def/redef approach for \url{} since hyperref defined this already,
822% but only if we actually used hyperref:
Fred Drakee59feb52001-10-29 21:02:28 +0000823\ifpdf
824 \newcommand{\url}[1]{{%
Fred Drake15fc72c2002-03-26 19:14:41 +0000825 \noindent%
Fred Drake53815882002-03-15 23:21:37 +0000826 \pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}%
Fred Drakeab357ec2001-03-02 18:57:05 +0000827 \py@LinkColor% color of the link text
Fred Drakee59feb52001-10-29 21:02:28 +0000828 \small\sf #1%
Fred Drakeab357ec2001-03-02 18:57:05 +0000829 \py@NormalColor% Turn it back off; these are declarative
830 \pdfendlink}% and don't appear bound to the current
831 }% formatting "box".
Fred Drakee59feb52001-10-29 21:02:28 +0000832\else
833 \newcommand{\url}[1]{\mbox{\small\textsf{#1}}}
834\fi
Fred Drake0ee9f721998-03-12 06:41:40 +0000835\newcommand{\email}[1]{{\small\textsf{#1}}}
Fred Drake454a4fb1998-04-01 22:20:14 +0000836\newcommand{\newsgroup}[1]{{\small\textsf{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000837
Fred Drakecc2b81e2000-08-03 17:38:30 +0000838\newcommand{\py@varvars}[1]{{%
Fred Drakeba828782000-04-03 04:19:14 +0000839 {\let\unspecified=\py@unspecified%
840 \let\moreargs=\py@moreargs%
Fred Drakecc2b81e2000-08-03 17:38:30 +0000841 \var{#1}}}}
Fred Drake6659c301998-03-03 22:02:19 +0000842
Fred Drake24340ea1998-04-28 18:30:34 +0000843% I'd really like to get rid of this!
Fred Drake6659c301998-03-03 22:02:19 +0000844\newif\iftexi\texifalse
Fred Drake6659c301998-03-03 22:02:19 +0000845
Fred Drake1e4973b1998-07-28 21:52:17 +0000846% This is used to get l2h to put the copyright and abstract on
847% a separate HTML page.
848\newif\ifhtml\htmlfalse
849
850
Fred Drake6659c301998-03-03 22:02:19 +0000851% These should be used for all references to identifiers which are
852% used to refer to instances of specific language constructs. See the
853% names for specific semantic assignments.
854%
855% For now, don't do anything really fancy with them; just use them as
856% logical markup. This might change in the future.
857%
Fred Drake24340ea1998-04-28 18:30:34 +0000858\newcommand{\module}[1]{\texttt{#1}}
859\newcommand{\keyword}[1]{\texttt{#1}}
860\newcommand{\exception}[1]{\texttt{#1}}
861\newcommand{\class}[1]{\texttt{#1}}
862\newcommand{\function}[1]{\texttt{#1}}
863\newcommand{\member}[1]{\texttt{#1}}
864\newcommand{\method}[1]{\texttt{#1}}
Fred Drake6659c301998-03-03 22:02:19 +0000865
Fred Drakeab357ec2001-03-02 18:57:05 +0000866\newcommand{\pytype}[1]{#1} % built-in Python type
Fred Drake53714971998-04-02 22:33:16 +0000867
Fred Drake24340ea1998-04-28 18:30:34 +0000868\newcommand{\cfunction}[1]{\texttt{#1}}
Fred Drakeab357ec2001-03-02 18:57:05 +0000869\newcommand{\ctype}[1]{\texttt{#1}} % C struct or typedef name
870\newcommand{\cdata}[1]{\texttt{#1}} % C variable, typically global
Fred Drake6659c301998-03-03 22:02:19 +0000871
Fred Drake479384e2001-09-26 18:46:36 +0000872\newcommand{\mailheader}[1]{{\small\textsf{#1:}}}
Fred Drake0ee9f721998-03-12 06:41:40 +0000873\newcommand{\mimetype}[1]{{\small\textsf{#1}}}
Fred Drake94fac131998-03-12 19:37:03 +0000874% The \! is a "negative thin space" in math mode.
875\newcommand{\regexp}[1]{%
876 {\tiny$^{^\lceil}\!\!$%
877 {\normalsize\code{#1}}%
Fred Drake47cfd031998-04-03 21:22:31 +0000878 $\!\rfloor\!$%
Fred Drake94fac131998-03-12 19:37:03 +0000879 }}
Fred Drake0ee9f721998-03-12 06:41:40 +0000880\newcommand{\envvar}[1]{%
Fred Drake31ab2982001-01-22 17:50:42 +0000881 #1%
Fred Drakee59feb52001-10-29 21:02:28 +0000882 \index{#1}%
Fred Drake31ab2982001-01-22 17:50:42 +0000883 \index{environment variables!{#1}}%
Fred Drake0ee9f721998-03-12 06:41:40 +0000884}
Fred Drakeab357ec2001-03-02 18:57:05 +0000885\newcommand{\makevar}[1]{#1} % variable in a Makefile
Fred Drake24340ea1998-04-28 18:30:34 +0000886\newcommand{\character}[1]{\samp{#1}}
Fred Drake0ee9f721998-03-12 06:41:40 +0000887
Fred Drake6659c301998-03-03 22:02:19 +0000888% constants defined in Python modules or C headers, not language constants:
Fred Drakeab357ec2001-03-02 18:57:05 +0000889\newcommand{\constant}[1]{\code{#1}} % manifest constant, not syntactic
Fred Drake6659c301998-03-03 22:02:19 +0000890
891\newcommand{\manpage}[2]{{\emph{#1}(#2)}}
Fred Drake4e607962000-09-09 06:01:25 +0000892\newcommand{\pep}[1]{PEP #1\index{Python Enhancement Proposals!PEP #1}}
Fred Drake6659c301998-03-03 22:02:19 +0000893\newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}}
894\newcommand{\program}[1]{\strong{#1}}
Fred Drake7b8195a1999-11-09 17:02:11 +0000895\newcommand{\programopt}[1]{\strong{#1}}
Fred Drake49362492000-04-11 18:47:59 +0000896% Note that \longprogramopt provides the '--'!
897\newcommand{\longprogramopt}[1]{\strong{-{}-#1}}
Fred Drakee59feb52001-10-29 21:02:28 +0000898
Fred Drakeb4b64da2001-07-06 22:44:48 +0000899% \ulink{link text}{URL}
Fred Drakee59feb52001-10-29 21:02:28 +0000900\ifpdf
901 % The \noindent here is a hack -- we're forcing pdfTeX into
Fred Drake53815882002-03-15 23:21:37 +0000902 % horizontal mode since \pdfstartlink requires that.
Fred Drakee59feb52001-10-29 21:02:28 +0000903 \newcommand{\ulink}[2]{\noindent{%
Fred Drake53815882002-03-15 23:21:37 +0000904 \pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#2)}%
Fred Drakee59feb52001-10-29 21:02:28 +0000905 \py@LinkColor% color of the link text
906 #1%
907 \py@NormalColor% Turn it back off; these are declarative
908 \pdfendlink}% and don't appear bound to the current
909 }% formatting "box".
910\else
911 \newcommand{\ulink}[2]{#1}
912\fi
Fred Drake7b8195a1999-11-09 17:02:11 +0000913
914% cited titles: \citetitle{Title of Work}
915% online: \citetitle[url-to-resource]{Title of Work}
Fred Drakee59feb52001-10-29 21:02:28 +0000916\ifpdf
917 \newcommand{\citetitle}[2][\py@modulebadkey]{%
918 \ifx\py@modulebadkey#1\emph{#2}\else\ulink{\emph{#2}}{#1}\fi%
919 }
920\else
Fred Drake622087a2001-11-02 20:53:19 +0000921 \newcommand{\citetitle}[2][URL]{\emph{#2}}
Fred Drakee59feb52001-10-29 21:02:28 +0000922\fi
923
Fred Drake6659c301998-03-03 22:02:19 +0000924
925
Fred Drakec82bd722001-12-11 18:47:36 +0000926% This version is being checked in for the historical record; it shows
927% how I've managed to get some aspects of this to work. It will not
928% be used in practice, so a subsequent revision will change things
929% again. This version has problems, but shows how to do something
930% that proved more tedious than I'd expected, so I don't want to lose
931% the example completely.
932%
Fred Drake16bb4192001-08-20 21:36:38 +0000933\newcommand{\grammartoken}[1]{\texttt{#1}}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000934\newenvironment{productionlist}[1][\py@badkey]{
935 \def\optional##1{{\Large[}##1{\Large]}}
936 \def\production##1##2{\code{##1}&::=&\code{##2}\\}
Fred Drake53815882002-03-15 23:21:37 +0000937 \def\productioncont##1{& &\code{##1}\\}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000938 \def\token##1{##1}
Fred Drake16bb4192001-08-20 21:36:38 +0000939 \let\grammartoken=\token
Fred Drakec82bd722001-12-11 18:47:36 +0000940 \parindent=2em
941 \indent
942 \begin{tabular}{lcl}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000943}{%
Fred Drakec82bd722001-12-11 18:47:36 +0000944 \end{tabular}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000945}
946
Fred Drake6ca33772001-12-14 22:50:06 +0000947\newcommand{\py@noticelabel@note}{Note:}
948\newcommand{\py@noticelabel@warning}{Warning:}
949\newenvironment{notice}[1][note]{
950 \par\strong{\csname py@noticelabel@#1\endcsname}
951}{}
952\newcommand{\note}[1]{\strong{\py@noticelabel@note} #1}
953\newcommand{\warning}[1]{\strong{\py@noticelabel@warning} #1}
Fred Drake92350b32001-10-09 18:01:23 +0000954
Fred Drake6659c301998-03-03 22:02:19 +0000955% Deprecation stuff.
956% Should be extended to allow an index / list of deprecated stuff. But
957% there's a lot of stuff that needs to be done to make that automatable.
958%
959% First parameter is the release number that deprecates the feature, the
960% second is the action the should be taken by users of the feature.
961%
962% Example:
Fred Drake24340ea1998-04-28 18:30:34 +0000963% \deprecated{1.5.1}{Use \method{frobnicate()} instead.}
Fred Drake6659c301998-03-03 22:02:19 +0000964%
965\newcommand{\deprecated}[2]{%
966 \strong{Deprecated since release #1.} #2\par}
967
Fred Drakeaf958c71998-07-27 20:32:33 +0000968% New stuff.
969% This should be used to mark things which have been added to the
970% development tree but that aren't in the release, but are documented.
971% This allows release of documentation that already includes updated
Fred Drake2116d981999-02-02 18:02:48 +0000972% descriptions. Place at end of descriptor environment.
Fred Drakeaf958c71998-07-27 20:32:33 +0000973%
974% Example:
975% \versionadded{1.5.2}
Fred Drake46346ec2000-06-30 17:57:05 +0000976% \versionchanged[short explanation]{2.0}
Fred Drakeaf958c71998-07-27 20:32:33 +0000977%
Fred Drakefdfb05b2001-04-18 03:08:54 +0000978\newcommand{\versionadded}[2][\py@badkey]{%
979 \ifx#1\@undefined%
980 { New in version #2. }%
981 \else%
982 { New in version #2:\ #1. }%
983 \fi%
984}
Fred Drakea6e83392000-05-02 17:28:36 +0000985\newcommand{\versionchanged}[2][\py@badkey]{%
986 \ifx#1\@undefined%
987 { Changed in version #2. }%
988 \else%
989 { Changed in version #2:\ #1. }%
990 \fi%
991}
Fred Drake6659c301998-03-03 22:02:19 +0000992
Fred Drakeaf958c71998-07-27 20:32:33 +0000993
994% Tables.
995%
Fred Drake6659c301998-03-03 22:02:19 +0000996\newenvironment{tableii}[4]{%
997 \begin{center}%
998 \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
Fred Drakef61eac42000-10-24 02:18:30 +0000999 \begin{tabular}{#1}\strong{#3}&\strong{#4} \\* \hline%
Fred Drake6659c301998-03-03 22:02:19 +00001000}{%
Fred Drake6659c301998-03-03 22:02:19 +00001001 \end{tabular}%
1002 \end{center}%
1003}
1004
Fred Drakeda72b932000-09-21 15:58:02 +00001005\newenvironment{longtableii}[4]{%
1006 \begin{center}%
1007 \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
Fred Drakef61eac42000-10-24 02:18:30 +00001008 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4} \\* \hline\endhead%
Fred Drakeda72b932000-09-21 15:58:02 +00001009}{%
1010 \end{longtable}%
1011 \end{center}%
1012}
1013
Fred Drake6659c301998-03-03 22:02:19 +00001014\newenvironment{tableiii}[5]{%
1015 \begin{center}%
1016 \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
Fred Drakeda72b932000-09-21 15:58:02 +00001017 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5} \\%
Fred Drakef61eac42000-10-24 02:18:30 +00001018 \hline%
Fred Drake6659c301998-03-03 22:02:19 +00001019}{%
Fred Drake6659c301998-03-03 22:02:19 +00001020 \end{tabular}%
1021 \end{center}%
1022}
1023
Fred Drakeda72b932000-09-21 15:58:02 +00001024\newenvironment{longtableiii}[5]{%
1025 \begin{center}%
1026 \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
1027 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5} \\%
Fred Drakef61eac42000-10-24 02:18:30 +00001028 \hline\endhead%
Fred Drakeda72b932000-09-21 15:58:02 +00001029}{%
1030 \end{longtable}%
1031 \end{center}%
1032}
1033
Fred Drake30e52651998-07-24 22:11:29 +00001034\newenvironment{tableiv}[6]{%
1035 \begin{center}%
1036 \def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}%
1037 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6} \\%
Fred Drakef61eac42000-10-24 02:18:30 +00001038 \hline%
Fred Drake30e52651998-07-24 22:11:29 +00001039}{%
1040 \end{tabular}%
1041 \end{center}%
1042}
1043
Fred Drakeda72b932000-09-21 15:58:02 +00001044\newenvironment{longtableiv}[6]{%
1045 \begin{center}%
1046 \def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}%
1047 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}%
1048 \\%
Fred Drakef61eac42000-10-24 02:18:30 +00001049 \hline\endhead%
Fred Drakeda72b932000-09-21 15:58:02 +00001050}{%
1051 \end{longtable}%
1052 \end{center}%
1053}
1054
Fred Drakef269e592001-07-17 23:05:57 +00001055\newenvironment{tablev}[7]{%
1056 \begin{center}%
1057 \def\linev##1##2##3##4##5{\csname#2\endcsname{##1}&##2&##3&##4&##5\\}%
1058 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}&\strong{#7} \\%
1059 \hline%
1060}{%
1061 \end{tabular}%
1062 \end{center}%
1063}
1064
1065\newenvironment{longtablev}[7]{%
1066 \begin{center}%
1067 \def\linev##1##2##3##4##5{\csname#2\endcsname{##1}&##2&##3&##4&##5\\}%
1068 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}&\strong{#7}%
1069 \\%
1070 \hline\endhead%
1071}{%
1072 \end{longtable}%
1073 \end{center}%
1074}
1075
Fred Drake24340ea1998-04-28 18:30:34 +00001076% Cross-referencing (AMK, new impl. FLD)
Fred Drake6659c301998-03-03 22:02:19 +00001077% Sample usage:
1078% \begin{seealso}
Fred Drake84bd6f31999-05-11 15:42:51 +00001079% \seemodule{rand}{Uniform random number generator.}; % Module xref
1080% \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book
Fred Drakeebcb6581998-03-06 21:25:17 +00001081%
1082% % A funky case: module name contains '_'; have to supply an optional key
Fred Drake84bd6f31999-05-11 15:42:51 +00001083% \seemodule[copyreg]{copy_reg}{Interface constructor registration for
1084% \module{pickle}.}
Fred Drake6659c301998-03-03 22:02:19 +00001085% \end{seealso}
Fred Drake84bd6f31999-05-11 15:42:51 +00001086%
1087% Note that the last parameter for \seemodule and \seetext should be complete
1088% sentences and be terminated with the proper punctuation.
Fred Drake6659c301998-03-03 22:02:19 +00001089
Fred Drakee59feb52001-10-29 21:02:28 +00001090\ifpdf
Fred Drake24340ea1998-04-28 18:30:34 +00001091 \newcommand{\py@seemodule}[3][\py@modulebadkey]{%
Fred Drakeda943741999-01-13 17:09:06 +00001092 \par%
Fred Drake24340ea1998-04-28 18:30:34 +00001093 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
Fred Drake84bd6f31999-05-11 15:42:51 +00001094 \begin{fulllineitems}
Fred Drake84bd6f31999-05-11 15:42:51 +00001095 \item[\py@linkToName{label-module-\py@modulekey}{Module \module{#2}}
1096 (section \ref{module-\py@modulekey}):]
1097 #3
1098 \end{fulllineitems}
Fred Drakeebcb6581998-03-06 21:25:17 +00001099 }
Fred Drakee59feb52001-10-29 21:02:28 +00001100\else
1101 \newcommand{\py@seemodule}[3][\py@modulebadkey]{%
1102 \par%
1103 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
1104 \begin{fulllineitems}
1105 \item[Module \module{#2} (section \ref{module-\py@modulekey}):]
1106 #3
1107 \end{fulllineitems}
1108 }
1109\fi
1110
Fred Drake48449982000-09-12 17:52:33 +00001111% \seetitle[url]{title}{why it's interesting}
1112\newcommand{\py@seetitle}[3][\py@modulebadkey]{%
1113 \par
1114 \begin{fulllineitems}
1115 \item[\citetitle{#2}]
1116 \ifx\py@modulebadkey#1\else
1117 \item[{\small{(\url{#1})}}]
1118 \fi
1119 #3
1120 \end{fulllineitems}
1121}
Fred Drake4e607962000-09-09 06:01:25 +00001122% \seepep{number}{title}{why it's interesting}
1123\newcommand{\py@seepep}[3]{%
1124 \par%
1125 \begin{fulllineitems}
1126 \item[\pep{#1}, ``\emph{#2}'']
1127 #3
1128 \end{fulllineitems}
1129}
Fred Drake64b72b62000-04-26 18:13:58 +00001130% \seerfc{number}{title}{why it's interesting}
1131\newcommand{\py@seerfc}[3]{%
1132 \par%
1133 \begin{fulllineitems}
1134 \item[\rfc{#1}, ``\emph{#2}'']
1135 #3
1136 \end{fulllineitems}
1137}
Fred Drake51313f12000-05-09 16:18:44 +00001138% \seeurl{url}{why it's interesting}
1139\newcommand{\py@seeurl}[2]{%
1140 \par%
1141 \begin{fulllineitems}
1142 \item[\url{#1}]
1143 #2
1144 \end{fulllineitems}
1145}
Fred Drake5ed35fd2001-11-30 18:09:54 +00001146
1147\newenvironment{seealso*}{
Fred Drake9466b9a1999-03-18 16:18:27 +00001148 \par
Fred Drake6659c301998-03-03 22:02:19 +00001149 \def\seetext##1{\par{##1}}
Fred Drake24340ea1998-04-28 18:30:34 +00001150 \let\seemodule=\py@seemodule
Fred Drake48449982000-09-12 17:52:33 +00001151 \let\seepep=\py@seepep
Fred Drake64b72b62000-04-26 18:13:58 +00001152 \let\seerfc=\py@seerfc
Fred Drake48449982000-09-12 17:52:33 +00001153 \let\seetitle=\py@seetitle
Fred Drake51313f12000-05-09 16:18:44 +00001154 \let\seeurl=\py@seeurl
Fred Drake6659c301998-03-03 22:02:19 +00001155}{\par}
Fred Drake5ed35fd2001-11-30 18:09:54 +00001156\newenvironment{seealso}{
1157 \par
1158 \strong{See Also:}
1159 \par
1160 \def\seetext##1{\par{##1}}
1161 \let\seemodule=\py@seemodule
1162 \let\seepep=\py@seepep
1163 \let\seerfc=\py@seerfc
1164 \let\seetitle=\py@seetitle
1165 \let\seeurl=\py@seeurl
1166}{\par}
Fred Drake6659c301998-03-03 22:02:19 +00001167
Fred Drakeaf958c71998-07-27 20:32:33 +00001168% Allow the Python release number to be specified independently of the
Fred Drake6659c301998-03-03 22:02:19 +00001169% \date{}. This allows the date to reflect the document's date and
1170% release to specify the Python release that is documented.
1171%
Fred Drake24340ea1998-04-28 18:30:34 +00001172\newcommand{\py@release}{}
Fred Drake6659c301998-03-03 22:02:19 +00001173\newcommand{\version}{}
Fred Drakeaf2b7142000-09-14 20:11:05 +00001174\newcommand{\shortversion}{}
Fred Drakec65218e2001-06-20 21:17:09 +00001175\newcommand{\releaseinfo}{}
Fred Drake6659c301998-03-03 22:02:19 +00001176\newcommand{\releasename}{Release}
1177\newcommand{\release}[1]{%
Fred Drake24340ea1998-04-28 18:30:34 +00001178 \renewcommand{\py@release}{\releasename\space\version}%
Fred Drake6659c301998-03-03 22:02:19 +00001179 \renewcommand{\version}{#1}}
Fred Drakeaf2b7142000-09-14 20:11:05 +00001180\newcommand{\setshortversion}[1]{%
1181 \renewcommand{\shortversion}{#1}}
Fred Drakec65218e2001-06-20 21:17:09 +00001182\newcommand{\setreleaseinfo}[1]{%
1183 \renewcommand{\releaseinfo}{#1}}
Fred Drake6659c301998-03-03 22:02:19 +00001184
1185% Allow specification of the author's address separately from the
1186% author's name. This can be used to format them differently, which
1187% is a good thing.
1188%
Fred Drake24340ea1998-04-28 18:30:34 +00001189\newcommand{\py@authoraddress}{}
1190\newcommand{\authoraddress}[1]{\renewcommand{\py@authoraddress}{#1}}
Fred Drake6df93ef1998-05-14 20:56:31 +00001191\let\developersaddress=\authoraddress
1192\let\developer=\author
1193\let\developers=\author
Fred Drake6659c301998-03-03 22:02:19 +00001194
Fred Drake6659c301998-03-03 22:02:19 +00001195% This sets up the fancy chapter headings that make the documents look
1196% at least a little better than the usual LaTeX output.
1197%
Fred Drake1c8d0e01998-03-07 05:29:15 +00001198\@ifundefined{ChTitleVar}{}{
Fred Drake24340ea1998-04-28 18:30:34 +00001199 \ChNameVar{\raggedleft\normalsize\py@HeaderFamily}
1200 \ChNumVar{\raggedleft \bfseries\Large\py@HeaderFamily}
1201 \ChTitleVar{\raggedleft \rm\Huge\py@HeaderFamily}
Fred Drake6659c301998-03-03 22:02:19 +00001202 % This creates chapter heads without the leading \vspace*{}:
Fred Drake1c8d0e01998-03-07 05:29:15 +00001203 \def\@makechapterhead#1{%
1204 {\parindent \z@ \raggedright \normalfont
1205 \ifnum \c@secnumdepth >\m@ne
Fred Drake6659c301998-03-03 22:02:19 +00001206 \DOCH
1207 \fi
Fred Drake1c8d0e01998-03-07 05:29:15 +00001208 \interlinepenalty\@M
Fred Drake6659c301998-03-03 22:02:19 +00001209 \DOTI{#1}
1210 }
1211 }
Fred Drake6659c301998-03-03 22:02:19 +00001212}
1213
Fred Drake3bf78651998-05-20 17:42:17 +00001214
1215% Definition lists; requested by AMK for HOWTO documents. Probably useful
1216% elsewhere as well, so keep in in the general style support.
1217%
1218\newenvironment{definitions}{%
1219 \begin{description}%
Fred Drakef9acc591998-09-09 15:27:43 +00001220 \def\term##1{\item[##1]\mbox{}\\*[0mm]}
Fred Drake3bf78651998-05-20 17:42:17 +00001221}{%
1222 \end{description}%
1223}
1224
Fred Drake6659c301998-03-03 22:02:19 +00001225% Tell TeX about pathological hyphenation cases:
1226\hyphenation{Base-HTTP-Re-quest-Hand-ler}