blob: 6bf8eb1ff2cd4b1d110adee8e1bbad3ee7244848 [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 Drake454a4fb1998-04-01 22:20:14 +00009% These packages can be used to add marginal annotations which indicate
10% index entries and labels; useful for reviewing this messy documentation!
11%
12%\RequirePackage{showkeys}
13%\RequirePackage{showidx}
14
Fred Drakec0b2e451998-03-25 14:53:43 +000015% for PDF output, use maximal compression & a lot of other stuff
16% (test for PDF recommended by Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov>)
17%
Fred Drake24340ea1998-04-28 18:30:34 +000018\newif\ifpy@doing@page@targets
19\py@doing@page@targetsfalse
Fred Drake6cb71491998-03-27 05:22:53 +000020
Fred Drakec0b2e451998-03-25 14:53:43 +000021\ifx\pdfoutput\undefined\else\ifcase\pdfoutput
Fred Drakec0b2e451998-03-25 14:53:43 +000022\else
Fred Drake6659c301998-03-03 22:02:19 +000023 \input{pdfcolor}
Fred Drake24340ea1998-04-28 18:30:34 +000024 \let\py@LinkColor=\NavyBlue
25 \let\py@NormalColor=\Black
Fred Drake6659c301998-03-03 22:02:19 +000026 \pdfcompresslevel=9
Fred Drakeba1700c1998-05-11 20:42:54 +000027 \pdfpagewidth=\paperwidth % page width of PDF output
28 \pdfpageheight=\paperheight % page height of PDF output
Fred Drakeebcb6581998-03-06 21:25:17 +000029 %
Fred Drakea2c2a831998-04-15 17:50:01 +000030 % Pad the number with '0' to 3 digits wide so no page name is a prefix
31 % of any other.
32 %
Fred Drakea488f301998-07-23 17:50:45 +000033 \newcommand{\py@targetno}[1]{\ifnum#1<100 0\fi\ifnum#1<10 0\fi#1}
34 \newcommand{\py@pageno}{\py@targetno\thepage}
Fred Drakea2c2a831998-04-15 17:50:01 +000035 %
Fred Drakeebcb6581998-03-06 21:25:17 +000036 % This definition allows the entries in the page-view of the ToC to be
37 % active links. Some work, some don't.
38 %
Fred Drake24340ea1998-04-28 18:30:34 +000039 \let\py@OldContentsline=\contentsline
Fred Drakeaa2aea01999-01-27 17:37:36 +000040 %
41 % Macro that takes two args: the name to link to and the content of
42 % the link. This takes care of the PDF magic, getting the colors
43 % the same for each link, and avoids having lots of garbage all over
44 % this style file.
45 \newcommand{\py@linkToName}[2]{%
46 \pdfannotlink attr{/Border [0 0 0]} goto name{#1}%
47 \py@LinkColor#2\py@NormalColor%
48 \pdfendlink%
49 }
Fred Drakea2c2a831998-04-15 17:50:01 +000050 % Compute the padded page number separately since we end up with a pair of
51 % \relax tokens; this gets the right string computed and works.
Fred Drake6659c301998-03-03 22:02:19 +000052 \renewcommand{\contentsline}[3]{%
Fred Drakea2c2a831998-04-15 17:50:01 +000053 \def\my@pageno{\py@targetno{#3}}%
Fred Drakeaa2aea01999-01-27 17:37:36 +000054 \py@OldContentsline{#1}{\py@linkToName{page\my@pageno}{#2}}{#3}%
Fred Drake6659c301998-03-03 22:02:19 +000055 }
Fred Drakeebcb6581998-03-06 21:25:17 +000056 \AtEndDocument{
Fred Drakec0b2e451998-03-25 14:53:43 +000057 \InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{}
Fred Drakeebcb6581998-03-06 21:25:17 +000058 }
Fred Drakea2c2a831998-04-15 17:50:01 +000059 \newcommand{\py@target}[1]{%
Fred Drake24340ea1998-04-28 18:30:34 +000060 \ifpy@doing@page@targets%
Fred Drakea2c2a831998-04-15 17:50:01 +000061 {\pdfdest name{#1} fit}%
62 \fi%
63 }
Fred Drake24340ea1998-04-28 18:30:34 +000064 \let\py@OldLabel=\label
Fred Drake6659c301998-03-03 22:02:19 +000065 \renewcommand{\label}[1]{%
Fred Drake24340ea1998-04-28 18:30:34 +000066 \py@OldLabel{#1}%
Fred Drakea2c2a831998-04-15 17:50:01 +000067 \py@target{label-#1}%
Fred Drake6659c301998-03-03 22:02:19 +000068 }
Fred Drakeba1700c1998-05-11 20:42:54 +000069 % This stuff adds a page# destination to every PDF page, where # is three
70 % digits wide, padded with leading zeros. This doesn't really help with
71 % the frontmatter, but does fine with the body.
Fred Drake6659c301998-03-03 22:02:19 +000072 %
73 % This is *heavily* based on the hyperref package.
74 %
Fred Drake1c8d0e01998-03-07 05:29:15 +000075 \def\@begindvi{%
76 \unvbox \@begindvibox
77 \@hyperfixhead
Fred Drake6659c301998-03-03 22:02:19 +000078 }
Fred Drake1c8d0e01998-03-07 05:29:15 +000079 \def\@hyperfixhead{%
80 \let\H@old@thehead\@thehead
Fred Drakea2c2a831998-04-15 17:50:01 +000081 \global\def\@foo{\py@target{page\py@pageno}}%
Fred Drake1c8d0e01998-03-07 05:29:15 +000082 \expandafter\ifx\expandafter\@empty\H@old@thehead
83 \def\H@old@thehead{\hfil}\fi
84 \def\@thehead{\@foo\relax\H@old@thehead}%
Fred Drake6659c301998-03-03 22:02:19 +000085 }
Fred Drakec0b2e451998-03-25 14:53:43 +000086\fi\fi
Fred Drake6659c301998-03-03 22:02:19 +000087
88% Increase printable page size (copied from fullpage.sty)
89\topmargin 0pt
90\advance \topmargin by -\headheight
91\advance \topmargin by -\headsep
92
93% attempt to work a little better for A4 users
Fred Drake1c8d0e01998-03-07 05:29:15 +000094\@ifundefined{paperheight}{
Fred Drake6659c301998-03-03 22:02:19 +000095 \textheight 9in
96}{
97 \textheight \paperheight
98 \advance\textheight by -2in
99}
100
101\oddsidemargin 0pt
102\evensidemargin \oddsidemargin
103\marginparwidth 0.5in
104
Fred Drake1c8d0e01998-03-07 05:29:15 +0000105\@ifundefined{paperwidth}{
Fred Drake6659c301998-03-03 22:02:19 +0000106 \textwidth 6.5in
107}{
108 \textwidth \paperwidth
109 \advance\textwidth by -2in
110}
111
112
113% Style parameters and macros used by most documents here
114\raggedbottom
115\sloppy
116\parindent = 0mm
Fred Drake24340ea1998-04-28 18:30:34 +0000117\parskip = 2mm
Fred Drake6659c301998-03-03 22:02:19 +0000118\hbadness = 5000 % don't print trivial gripes
119
120\pagestyle{empty} % start this way; change for
121\pagenumbering{roman} % ToC & chapters
122\setcounter{secnumdepth}{1}
123
124% Use this to set the font family for headers and other decor:
Fred Drake24340ea1998-04-28 18:30:34 +0000125\newcommand{\py@HeaderFamily}{\sffamily}
Fred Drake6659c301998-03-03 22:02:19 +0000126
127% Redefine the 'normal' header/footer style when using "fancyhdr" package:
Fred Drake1c8d0e01998-03-07 05:29:15 +0000128\@ifundefined{fancyhf}{}{
Fred Drake6659c301998-03-03 22:02:19 +0000129 % Use \pagestyle{normal} as the primary pagestyle for text.
130 \fancypagestyle{normal}{
131 \fancyhf{}
Fred Drake24340ea1998-04-28 18:30:34 +0000132 \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
133 \fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}}
134 \fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}}
Fred Drake6659c301998-03-03 22:02:19 +0000135 \renewcommand{\headrulewidth}{0pt}
136 \renewcommand{\footrulewidth}{0.4pt}
137 }
138 % Update the plain style so we get the page number & footer line,
139 % but not a chapter or section title. This is to keep the first
140 % page of a chapter and the blank page between chapters `clean.'
141 \fancypagestyle{plain}{
142 \fancyhf{}
Fred Drake24340ea1998-04-28 18:30:34 +0000143 \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
Fred Drake6659c301998-03-03 22:02:19 +0000144 \renewcommand{\headrulewidth}{0pt}
145 \renewcommand{\footrulewidth}{0.4pt}
146 }
147 % Redefine \cleardoublepage so that the blank page between chapters
148 % gets the plain style and not the fancy style. This is described
149 % in the documentation for the fancyhdr package by Piet von Oostrum.
Fred Drake1c8d0e01998-03-07 05:29:15 +0000150 \@ifundefined{chapter}{}{
Fred Drake28f13911998-03-04 21:47:59 +0000151 \renewcommand{\cleardoublepage}{
Fred Drake1c8d0e01998-03-07 05:29:15 +0000152 \clearpage\if@openright \ifodd\c@page\else
Fred Drake28f13911998-03-04 21:47:59 +0000153 \hbox{}
154 \thispagestyle{plain}
155 \newpage
Fred Drake1c8d0e01998-03-07 05:29:15 +0000156 \if@twocolumn\hbox{}\newpage\fi\fi\fi
Fred Drake28f13911998-03-04 21:47:59 +0000157 }
158 }
Fred Drake6659c301998-03-03 22:02:19 +0000159}
160
Fred Drake6659c301998-03-03 22:02:19 +0000161% This sets up the {verbatim} environment to be indented and a minipage,
162% and to have all the other mostly nice properties that we want for
163% code samples.
164
165% Variable used by begin code command
Fred Drake24340ea1998-04-28 18:30:34 +0000166\newlength{\py@codewidth}
Fred Drake6659c301998-03-03 22:02:19 +0000167
Fred Drake24340ea1998-04-28 18:30:34 +0000168\newcommand{\py@examplevspace}{2mm}
169\newcommand{\py@exampleindent}{1cm}
Fred Drake6659c301998-03-03 22:02:19 +0000170
Fred Drake24340ea1998-04-28 18:30:34 +0000171\let\py@OldVerbatim=\verbatim
172\let\py@OldEndVerbatim=\endverbatim
Fred Drake6659c301998-03-03 22:02:19 +0000173\renewcommand{\verbatim}{%
174 \begingroup%
Fred Drake24340ea1998-04-28 18:30:34 +0000175 \setlength{\parindent}\py@exampleindent%
Fred Drake6659c301998-03-03 22:02:19 +0000176 % Calculate the text width for the minipage:
Fred Drake24340ea1998-04-28 18:30:34 +0000177 \setlength{\py@codewidth}{\linewidth}%
178 \addtolength{\py@codewidth}{-\parindent}%
Fred Drake6659c301998-03-03 22:02:19 +0000179 %
180 \par%
Fred Drake24340ea1998-04-28 18:30:34 +0000181 \vspace\py@examplevspace%
Fred Drake6659c301998-03-03 22:02:19 +0000182 \indent%
Fred Drake24340ea1998-04-28 18:30:34 +0000183 \begin{minipage}[t]{\py@codewidth}%
Fred Drake6659c301998-03-03 22:02:19 +0000184 \small%
Fred Drake24340ea1998-04-28 18:30:34 +0000185 \py@OldVerbatim%
Fred Drake6659c301998-03-03 22:02:19 +0000186}
187\renewcommand{\endverbatim}{%
Fred Drake24340ea1998-04-28 18:30:34 +0000188 \py@OldEndVerbatim%
Fred Drake6659c301998-03-03 22:02:19 +0000189 \end{minipage}%
190 \endgroup%
191}
192
Fred Drake6cb71491998-03-27 05:22:53 +0000193
Fred Drakea488f301998-07-23 17:50:45 +0000194\newcommand{\py@modulebadkey}{{--just-some-junk--}}
Fred Drake6659c301998-03-03 22:02:19 +0000195
Fred Drake6659c301998-03-03 22:02:19 +0000196
197%% Lots of index-entry generation support.
198
199% Command to wrap around stuff that refers to function / module /
200% attribute names in the index. Default behavior: like \code{}. To
201% just keep the index entries in the roman font, uncomment the second
Fred Drakea488f301998-07-23 17:50:45 +0000202% definition; it matches O'Reilly style more.
Fred Drake6659c301998-03-03 22:02:19 +0000203%
Fred Drake24340ea1998-04-28 18:30:34 +0000204\newcommand{\py@idxcode}[1]{\texttt{#1}}
205%\renewcommand{\py@idxcode}[1]{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000206
207% Command to generate two index entries (using subentries)
208\newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}}
209
210% And three entries (using only one level of subentries)
211\newcommand{\indexiii}[3]{\index{#1!#2 #3}\index{#2!#3, #1}\index{#3!#1 #2}}
212
213% And four (again, using only one level of subentries)
214\newcommand{\indexiv}[4]{
215\index{#1!#2 #3 #4}
216\index{#2!#3 #4, #1}
217\index{#3!#4, #1 #2}
218\index{#4!#1 #2 #3}
219}
220
221% Command to generate a reference to a function, statement, keyword,
222% operator.
Fred Drake0cabff91998-05-06 19:36:01 +0000223\newcommand{\kwindex}[1]{\indexii{keyword}{#1@{\py@idxcode{#1}}}}
Fred Drake24340ea1998-04-28 18:30:34 +0000224\newcommand{\stindex}[1]{\indexii{statement}{#1@{\py@idxcode{#1}}}}
225\newcommand{\opindex}[1]{\indexii{operator}{#1@{\py@idxcode{#1}}}}
226\newcommand{\exindex}[1]{\indexii{exception}{#1@{\py@idxcode{#1}}}}
Fred Drake6659c301998-03-03 22:02:19 +0000227\newcommand{\obindex}[1]{\indexii{object}{#1}}
Fred Drake2351c801998-04-02 18:48:32 +0000228\newcommand{\bifuncindex}[1]{\withsubitem{(built-in function)}{\ttindex{#1()}}}
Fred Drake6659c301998-03-03 22:02:19 +0000229
230% Add an index entry for a module
Fred Drake24340ea1998-04-28 18:30:34 +0000231\newcommand{\py@refmodule}[2]{\index{#1@{\py@idxcode{#1}} (#2module)}}
232\newcommand{\refmodindex}[1]{\py@refmodule{#1}{}}
233\newcommand{\refbimodindex}[1]{\py@refmodule{#1}{built-in }}
234\newcommand{\refexmodindex}[1]{\py@refmodule{#1}{extension }}
235\newcommand{\refstmodindex}[1]{\py@refmodule{#1}{standard }}
Fred Drake6659c301998-03-03 22:02:19 +0000236
Fred Drakeda943741999-01-13 17:09:06 +0000237% Refer to a module's documentation using a hyperlink of the module's
238% name, at least if we're building PDF:
239\@ifundefined{pdfannotlink}{%
240 \newcommand{\refmodule}[2][\py@modulebadkey]{\module{#2}}
Fred Drakeaa2aea01999-01-27 17:37:36 +0000241}{%
242 \newcommand{\refmodule}[2][\py@modulebadkey]{%
Fred Drakeda943741999-01-13 17:09:06 +0000243 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
Fred Drakeaa2aea01999-01-27 17:37:36 +0000244 \py@linkToName{label-module-\py@modulekey}{\module{#2}}%
Fred Drakeda943741999-01-13 17:09:06 +0000245 }
246}
247
Fred Drake6659c301998-03-03 22:02:19 +0000248% support for the module index
Fred Drake24340ea1998-04-28 18:30:34 +0000249\newif\ifpy@UseModuleIndex
250\py@UseModuleIndexfalse
Fred Drakeb390daf1998-03-09 16:35:36 +0000251
Fred Drakeb390daf1998-03-09 16:35:36 +0000252\newcommand{\makemodindex}{
253 \newwrite\modindexfile
254 \openout\modindexfile=mod\jobname.idx
Fred Drake24340ea1998-04-28 18:30:34 +0000255 \py@UseModuleIndextrue
Fred Drakeb390daf1998-03-09 16:35:36 +0000256}
257
Fred Drake0ee9f721998-03-12 06:41:40 +0000258% Add the defining entry for a module
Fred Drake24340ea1998-04-28 18:30:34 +0000259\newcommand{\py@modindex}[2]{%
Fred Drakea488f301998-07-23 17:50:45 +0000260 \renewcommand{\py@thismodule}{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000261 \setindexsubitem{(in module #1)}%
Fred Drake24340ea1998-04-28 18:30:34 +0000262 \index{#1@{\py@idxcode{#1}} (#2module)|textbf}%
263 \ifpy@UseModuleIndex%
Fred Drake9f253dc1999-01-26 19:23:09 +0000264 \write\modindexfile{\protect\indexentry{#1@{\texttt {#1}}}{\thepage}}%
Fred Drake0ee9f721998-03-12 06:41:40 +0000265 \fi%
266}
267
Fred Drake6659c301998-03-03 22:02:19 +0000268% built-in & Python modules in the main distribution
Fred Drake24340ea1998-04-28 18:30:34 +0000269\newcommand{\bimodindex}[1]{\py@modindex{#1}{built-in }}
270\newcommand{\stmodindex}[1]{\py@modindex{#1}{standard }}
Fred Drake6659c301998-03-03 22:02:19 +0000271
272% Python & extension modules outside the main distribution
Fred Drake24340ea1998-04-28 18:30:34 +0000273\newcommand{\modindex}[1]{\py@modindex{#1}{}}
274\newcommand{\exmodindex}[1]{\py@modindex{#1}{extension }}
Fred Drake6659c301998-03-03 22:02:19 +0000275
276% Additional string for an index entry
Fred Drake1c8d0e01998-03-07 05:29:15 +0000277\newcommand{\index@subitem}{}
278\newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}}
Fred Drake24340ea1998-04-28 18:30:34 +0000279\newcommand{\ttindex}[1]{\index{#1@{\py@idxcode{#1}} \index@subitem}}
Fred Drake6659c301998-03-03 22:02:19 +0000280
Fred Drake0ee9f721998-03-12 06:41:40 +0000281\newcommand{\withsubitem}[2]{%
282 \begingroup%
283 \def\index@subitem{#1}#2%
284 \endgroup%
285}
Fred Drake6659c301998-03-03 22:02:19 +0000286
Fred Drake53714971998-04-02 22:33:16 +0000287
Fred Drakea488f301998-07-23 17:50:45 +0000288% Module synopsis processing -----------------------------------------------
289%
290\newcommand{\py@standardIndexModule}[1]{\stmodindex{#1}}
291\newcommand{\py@builtinIndexModule}[1]{\bimodindex{#1}}
292\newcommand{\py@extensionIndexModule}[1]{\exmodindex{#1}}
293\newcommand{\py@IndexModule}[1]{\modindex{#1}}
294
295\newif\ifpy@HaveModSynopsis\py@HaveModSynopsisfalse
296\newif\ifpy@ModSynopsisFileIsOpen\py@ModSynopsisFileIsOpenfalse
297
298% \declaremodule[key]{type}{name}
299\newcommand{\declaremodule}[3][\py@modulebadkey]{
300 \py@openModSynopsisFile
301 \renewcommand{\py@thismoduletype}{#2}
302 \csname py@#2IndexModule\endcsname{#3}
303 \ifx\py@modulebadkey#1
304 \renewcommand{\py@thismodulekey}{#3}
305 \else
306 \renewcommand{\py@thismodulekey}{#1}
307 \fi
308 \label{module-\py@thismodulekey}
309 \py@HaveModSynopsistrue
310}
311
Fred Drakeb75c6151998-08-10 18:41:43 +0000312% \moduleauthor{name}{email}
313\newcommand{\moduleauthor}[2]{}
314
315% \sectionauthor{name}{email}
316\newcommand{\sectionauthor}[2]{}
317
Fred Drakea488f301998-07-23 17:50:45 +0000318
319\newcommand{\py@defsynopsis}{Module has no synopsis.}
320\newcommand{\py@modulesynopsis}{\py@defsynopsis}
321\newcommand{\modulesynopsis}[1]{
322 \renewcommand{\py@modulesynopsis}{#1}
323}
324
325% define the file
326\newwrite\py@ModSynopsisFile
327
328% hacked from \addtocontents from latex.ltx:
329\long\def\py@writeModSynopsisFile#1{%
330 \protected@write\py@ModSynopsisFile%
331 {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
332 {\string#1}%
333}
334\newcommand{\py@closeModSynopsisFile}{
335 \ifpy@ModSynopsisFileIsOpen
336 \closeout\py@ModSynopsisFile
337 \py@ModSynopsisFileIsOpenfalse
338 \fi
339}
340\newcommand{\py@openModSynopsisFile}{
341 \ifpy@ModSynopsisFileIsOpen\else
342 \openout\py@ModSynopsisFile=\py@ModSynopsisFilename
343 \py@ModSynopsisFileIsOpentrue
344 \fi
345}
346
347\newcommand{\py@ProcessModSynopsis}{
348 \ifpy@HaveModSynopsis
349 \py@writeModSynopsisFile{\modulesynopsis%
350 {\py@thismodulekey}{\py@thismodule}%
351 {\py@thismoduletype}{\py@modulesynopsis}}%
352 \py@HaveModSynopsisfalse
353 \fi
354 \renewcommand{\py@modulesynopsis}{\py@defsynopsis}
355}
356\AtEndDocument{\py@ProcessModSynopsis\py@closeModSynopsisFile}
357
358\newcommand{\localmoduletable}{
359 \IfFileExists{\py@ModSynopsisFilename}{
360 \begin{synopsistable}
361 \input{\py@ModSynopsisFilename}
362 \end{synopsistable}
363 }{}
364}
365
366\@ifundefined{pdfoutput}{
367 \newcommand{\py@ModSynopsisSummary}[4]{\bfcode{#2} & #4\\}
368}{
Fred Drakeaa2aea01999-01-27 17:37:36 +0000369 \newcommand{\py@ModSynopsisSummary}[4]{%
370 \py@linkToName{label-module-#1}{\bfcode{#2}} & #4\\
371 }
Fred Drakea488f301998-07-23 17:50:45 +0000372}
373\newenvironment{synopsistable}{
374 % key, name, type, synopsis
375 \let\modulesynopsis=\py@ModSynopsisSummary
376 \begin{tabular}{ll}
377}{
378 \end{tabular}
379}
380%
381% --------------------------------------------------------------------------
382
383
384\newcommand{\py@thisclass}{}
385\newcommand{\py@thismodule}{}
386\newcommand{\py@thismodulekey}{}
387\newcommand{\py@thismoduletype}{}
388
389\newcommand{\py@reset}{
390 \py@ProcessModSynopsis
391 \renewcommand{\py@thisclass}{}
392 \renewcommand{\py@thismodule}{}
393 \renewcommand{\py@thismodulekey}{}
394 \renewcommand{\py@thismoduletype}{}
395}
396
397% Augment the sectioning commands used to get our own font family in place,
398% and reset some internal data items:
399\renewcommand{\section}{\py@reset%
400 \@startsection{section}{1}{\z@}%
401 {-3.5ex \@plus -1ex \@minus -.2ex}%
402 {2.3ex \@plus.2ex}%
403 {\reset@font\Large\py@HeaderFamily}}
404\renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}%
405 {-3.25ex\@plus -1ex \@minus -.2ex}%
406 {1.5ex \@plus .2ex}%
407 {\reset@font\large\py@HeaderFamily}}
408\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}%
409 {-3.25ex\@plus -1ex \@minus -.2ex}%
410 {1.5ex \@plus .2ex}%
411 {\reset@font\normalsize\py@HeaderFamily}}
412\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}%
413 {3.25ex \@plus1ex \@minus.2ex}%
414 {-1em}%
415 {\reset@font\normalsize\py@HeaderFamily}}
416\renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}%
417 {3.25ex \@plus1ex \@minus .2ex}%
418 {-1em}%
419 {\reset@font\normalsize\py@HeaderFamily}}
420
421
Fred Drake5420f331998-07-23 21:41:02 +0000422% This gets the underscores closer to the right width; the only change
423% from standard LaTeX is the width specified.
424
425\DeclareTextCommandDefault{\textunderscore}{%
426 \leavevmode \kern.06em\vbox{\hrule\@width.55em}}
427
Fred Drakea488f301998-07-23 17:50:45 +0000428% Underscore hack (only act like subscript operator if in math mode)
429%
430% The following is due to Mark Wooding (the old version didn't work with
431% Latex 2e.
432
433\DeclareRobustCommand\hackscore{%
434 \ifmmode_\else\textunderscore\fi%
435}
436\begingroup
437\catcode`\_\active
438\def\next{%
439 \AtBeginDocument{\catcode`\_\active\def_{\hackscore{}}}%
440}
441\expandafter\endgroup\next
442
443
Fred Drake53714971998-04-02 22:33:16 +0000444% Now for a lot of semantically-loaded environments that do a ton of magical
445% things to get the right formatting and index entries for the stuff in
446% Python modules and C API.
447
448
Fred Drake6659c301998-03-03 22:02:19 +0000449% {fulllineitems} is used in one place in libregex.tex, but is really for
450% internal use in this file.
451%
Fred Drakef9acc591998-09-09 15:27:43 +0000452\newcommand{\py@itemnewline}[1]{%
453 \@tempdima\linewidth%
454 \advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}%
455}
456
Fred Drake6659c301998-03-03 22:02:19 +0000457\newenvironment{fulllineitems}{
458 \begin{list}{}{\labelwidth \leftmargin \labelsep 0pt
459 \rightmargin 0pt \topsep -\parskip \partopsep \parskip
460 \itemsep -\parsep
Fred Drakef9acc591998-09-09 15:27:43 +0000461 \let\makelabel=\py@itemnewline}
Fred Drake6659c301998-03-03 22:02:19 +0000462}{\end{list}}
463
Fred Drake6cb71491998-03-27 05:22:53 +0000464% \optional is mostly for use in the arguments parameters to the various
465% {*desc} environments defined below, but may be used elsewhere. Known to
466% be used in the debugger chapter.
Fred Drake24340ea1998-04-28 18:30:34 +0000467%
468% Typical usage:
469%
470% \begin{funcdesc}{myfunc}{reqparm\optional{, optparm}}
471% ^^^ ^^^
472% No space here No space here
473%
474% When a function has multiple optional parameters, \optional should be
475% nested, not chained. This is right:
476%
477% \begin{funcdesc}{myfunc}{\optional{parm1\optional{, parm2}}}
478%
Fred Drake6659c301998-03-03 22:02:19 +0000479\newcommand{\optional}[1]{%
480 {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
481
Fred Drake6cb71491998-03-27 05:22:53 +0000482% C functions ------------------------------------------------------------
483% \begin{cfuncdesc}{type}{name}{arglist}
484\newenvironment{cfuncdesc}[3]{
485 \begin{fulllineitems}
Fred Drake24340ea1998-04-28 18:30:34 +0000486 \item[\code{#1 \bfcode{#2}(\py@varvars{#3})}\index{#2@{\py@idxcode{#2()}}}]
Fred Drake6cb71491998-03-27 05:22:53 +0000487}{\end{fulllineitems}}
488
489% C variables ------------------------------------------------------------
490% \begin{cvardesc}{type}{name}
491\newenvironment{cvardesc}[2]{
492 \begin{fulllineitems}
Fred Drake24340ea1998-04-28 18:30:34 +0000493 \item[\code{#1 \bfcode{#2}}\index{#2@{\py@idxcode{#2}}}]
Fred Drake6cb71491998-03-27 05:22:53 +0000494}{\end{fulllineitems}}
495
496% C data types -----------------------------------------------------------
497% \begin{ctypedesc}{typedef name}
498\newenvironment{ctypedesc}[1]{
499 \begin{fulllineitems}
500 \item[\bfcode{#1}\ttindex{#1}]
501}{\end{fulllineitems}}
502
503% simple functions (not methods) -----------------------------------------
504% \begin{funcdesc}{name}{args}
505\newcommand{\funcline}[2]{\funclineni{#1}{#2}\ttindex{#1()}}
506\newenvironment{funcdesc}[2]{
507 \begin{fulllineitems}
508 \funcline{#1}{#2}
509}{\end{fulllineitems}}
510
Fred Drake6659c301998-03-03 22:02:19 +0000511% similar to {funcdesc}, but doesn't add to the index
Fred Drake300775d1998-04-17 02:17:00 +0000512\newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(\py@varvars{#2})}]}
Fred Drake6cb71491998-03-27 05:22:53 +0000513\newenvironment{funcdescni}[2]{
514 \begin{fulllineitems}
515 \funclineni{#1}{#2}
Fred Drake6659c301998-03-03 22:02:19 +0000516}{\end{fulllineitems}}
517
Fred Drake6cb71491998-03-27 05:22:53 +0000518% classes ----------------------------------------------------------------
519% \begin{classdesc}{name}{constructor args}
520\newenvironment{classdesc}[2]{
Fred Drake1cbd1961998-11-25 17:13:28 +0000521 % Using \renewcommand doesn't work for this, for unknown reasons:
522 \global\def\py@thisclass{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000523 \begin{fulllineitems}
Fred Drake300775d1998-04-17 02:17:00 +0000524 \item[\code{\bfcode{#1}(\py@varvars{#2})}%
Fred Drake24340ea1998-04-28 18:30:34 +0000525 \withsubitem{(class in \py@thismodule)}{\ttindex{#1}}]
Fred Drake6659c301998-03-03 22:02:19 +0000526}{\end{fulllineitems}}
527
Fred Drake6cb71491998-03-27 05:22:53 +0000528
Fred Drake24340ea1998-04-28 18:30:34 +0000529\let\py@classbadkey=\@undefined
Fred Drake6cb71491998-03-27 05:22:53 +0000530
531% object method ----------------------------------------------------------
532% \begin{methoddesc}[classname]{methodname}{args}
Fred Drake24340ea1998-04-28 18:30:34 +0000533\newcommand{\methodline}[3][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000534 \methodlineni{#2}{#3}
535 \ifx#1\@undefined
Fred Drake24340ea1998-04-28 18:30:34 +0000536 \withsubitem{(\py@thisclass\ method)}{\ttindex{#2()}}
Fred Drake6cb71491998-03-27 05:22:53 +0000537 \else
538 \withsubitem{(#1 method)}{\ttindex{#2()}}
539 \fi
540}
Fred Drake24340ea1998-04-28 18:30:34 +0000541\newenvironment{methoddesc}[3][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000542 \begin{fulllineitems}
543 \ifx#1\@undefined
544 \methodline{#2}{#3}
545 \else
Fred Drake24340ea1998-04-28 18:30:34 +0000546 \def\py@thisclass{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000547 \methodline[#1]{#2}{#3}
548 \fi
Fred Drake6659c301998-03-03 22:02:19 +0000549}{\end{fulllineitems}}
550
Fred Drake6cb71491998-03-27 05:22:53 +0000551% similar to {methoddesc}, but doesn't add to the index
552% (never actually uses the optional argument)
Fred Drake24340ea1998-04-28 18:30:34 +0000553\newcommand{\methodlineni}[3][\py@classbadkey]{%
Fred Drake300775d1998-04-17 02:17:00 +0000554 \item[\code{\bfcode{#2}(\py@varvars{#3})}]}
Fred Drake24340ea1998-04-28 18:30:34 +0000555\newenvironment{methoddescni}[3][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000556 \begin{fulllineitems}
557 \methodlineni{#2}{#3}
558}{\end{fulllineitems}}
559
560% object data attribute --------------------------------------------------
561% \begin{memberdesc}[classname]{membername}
Fred Drake24340ea1998-04-28 18:30:34 +0000562\newcommand{\memberline}[2][\py@classbadkey]{%
Fred Drake6cb71491998-03-27 05:22:53 +0000563 \ifx#1\@undefined
564 \memberlineni{#2}
Fred Drake24340ea1998-04-28 18:30:34 +0000565 \withsubitem{(\py@thisclass\ attribute)}{\ttindex{#2}}
Fred Drake6cb71491998-03-27 05:22:53 +0000566 \else
567 \memberlineni{#2}
Fred Drake41565f61998-04-07 19:32:40 +0000568 \withsubitem{(#1 attribute)}{\ttindex{#2}}
Fred Drake6cb71491998-03-27 05:22:53 +0000569 \fi
570}
Fred Drake24340ea1998-04-28 18:30:34 +0000571\newenvironment{memberdesc}[2][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000572 \begin{fulllineitems}
573 \ifx#1\@undefined
574 \memberline{#2}
575 \else
Fred Drake24340ea1998-04-28 18:30:34 +0000576 \def\py@thisclass{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000577 \memberline[#1]{#2}
578 \fi
579}{\end{fulllineitems}}
580
581% similar to {memberdesc}, but doesn't add to the index
582% (never actually uses the optional argument)
Fred Drake24340ea1998-04-28 18:30:34 +0000583\newcommand{\memberlineni}[2][\py@classbadkey]{\item[\bfcode{#2}]}
584\newenvironment{memberdescni}[2][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000585 \begin{fulllineitems}
586 \memberlineni{#2}
587}{\end{fulllineitems}}
588
589% For exceptions: --------------------------------------------------------
590% \begin{excdesc}{name}
591% -- need support for constructor; maybe use optional parameter?
592\newenvironment{excdesc}[1]{
593 \begin{fulllineitems}
594 \item[\bfcode{#1}\ttindex{#1}]
595}{\end{fulllineitems}}
596
597% Module data or constants: ----------------------------------------------
598% \begin{datadesc}{name}
Fred Drake6659c301998-03-03 22:02:19 +0000599\newcommand{\dataline}[1]{\datalineni{#1}\ttindex{#1}}
Fred Drake6cb71491998-03-27 05:22:53 +0000600\newenvironment{datadesc}[1]{
601 \begin{fulllineitems}
602 \dataline{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000603}{\end{fulllineitems}}
604
605% similar to {datadesc}, but doesn't add to the index
Fred Drake6cb71491998-03-27 05:22:53 +0000606\newcommand{\datalineni}[1]{\item[\bfcode{#1}]\nopagebreak}
607\newenvironment{datadescni}[1]{
608 \begin{fulllineitems}
609 \datalineni{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000610}{\end{fulllineitems}}
611
Fred Drake6cb71491998-03-27 05:22:53 +0000612% bytecode instruction ---------------------------------------------------
613% \begin{opcodedesc}{name}{var}
614% -- {var} may be {}
615\newenvironment{opcodedesc}[2]{
616 \begin{fulllineitems}
617 \item[\bfcode{#1}\quad\var{#2}]
Fred Drake6659c301998-03-03 22:02:19 +0000618}{\end{fulllineitems}}
619
620
Fred Drake24340ea1998-04-28 18:30:34 +0000621\newcommand{\nodename}[1]{\label{#1}}
Fred Drake55730311998-03-25 15:41:23 +0000622
Fred Drake6659c301998-03-03 22:02:19 +0000623% For these commands, use \command{} to get the typography right, not
624% {\command}. This works better with the texinfo translation.
625\newcommand{\ABC}{{\sc abc}}
626\newcommand{\UNIX}{{\sc Unix}}
627\newcommand{\POSIX}{POSIX}
628\newcommand{\ASCII}{{\sc ascii}}
629\newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}}
630\newcommand{\C}{C}
631\newcommand{\EOF}{{\sc eof}}
Fred Drake24340ea1998-04-28 18:30:34 +0000632\newcommand{\NULL}{\constant{NULL}}
Fred Drake6659c301998-03-03 22:02:19 +0000633
Fred Drake53714971998-04-02 22:33:16 +0000634% Also for consistency: spell Python "Python", not "python"!
635
Fred Drake6659c301998-03-03 22:02:19 +0000636% code is the most difficult one...
Fred Drake1c8d0e01998-03-07 05:29:15 +0000637\newcommand{\code}[1]{{\@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 +0000638\texttt{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000639
640\newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font
Fred Drake8e54abe1998-07-01 14:49:25 +0000641\newcommand{\kbd}[1]{\code{#1}}
Fred Drake24340ea1998-04-28 18:30:34 +0000642\newcommand{\samp}[1]{`\code{#1}'}
Fred Drake6659c301998-03-03 22:02:19 +0000643% This weird definition of \var{} allows it to always appear in roman
644% italics, and won't get funky in code fragments when we play around
Fred Drakefa1cceb1998-11-30 14:42:59 +0000645% with fonts. This also works directly in math mode.
646\newcommand{\var}[1]{%
647 \ifmmode%
648 \hbox{\normalsize\textrm{\textit{#1\/}}}%
649 \else%
650 \normalsize\textrm{\textit{#1\/}}%
651 \fi%
652}
Fred Drake24340ea1998-04-28 18:30:34 +0000653\renewcommand{\emph}[1]{{\em #1}}
Fred Drake6659c301998-03-03 22:02:19 +0000654\newcommand{\dfn}[1]{\emph{#1}}
655\newcommand{\strong}[1]{{\bf #1}}
656% let's experiment with a new font:
Fred Drake0ee9f721998-03-12 06:41:40 +0000657\newcommand{\file}[1]{`{\small\textsf{#1}}'}
Fred Drake6659c301998-03-03 22:02:19 +0000658
659% Use this def/redef approach for \url{} since hyperref defined this already,
660% but only if we actually used hyperref:
Fred Drake6cb71491998-03-27 05:22:53 +0000661\@ifundefined{pdfannotlink}{
Fred Drakea2c2a831998-04-15 17:50:01 +0000662 \newcommand{\py@url}[1]{\mbox{\small\textsf{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000663}{
Fred Drakea2c2a831998-04-15 17:50:01 +0000664 \newcommand{\py@url}[1]{{%
Fred Drake6659c301998-03-03 22:02:19 +0000665 \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}%
Fred Drake24340ea1998-04-28 18:30:34 +0000666 \py@LinkColor% color of the link text
667 \mbox{\small\textsf{#1}}%
668 \py@NormalColor% Turn it back off; these are declarative
Fred Drake6659c301998-03-03 22:02:19 +0000669 \pdfendlink}% and don't appear bound to the current
670 }% formatting "box".
671}
Fred Drakea2c2a831998-04-15 17:50:01 +0000672\let\url=\py@url
Fred Drake0ee9f721998-03-12 06:41:40 +0000673\newcommand{\email}[1]{{\small\textsf{#1}}}
Fred Drake454a4fb1998-04-01 22:20:14 +0000674\newcommand{\newsgroup}[1]{{\small\textsf{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000675
Fred Drake300775d1998-04-17 02:17:00 +0000676\newcommand{\py@varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}}
Fred Drake24340ea1998-04-28 18:30:34 +0000677% let's see if this breaks anything now; we may be able to simplify...
678\renewcommand{\py@varvars}[1]{\var{#1}}
Fred Drake6659c301998-03-03 22:02:19 +0000679
Fred Drake24340ea1998-04-28 18:30:34 +0000680% I'd really like to get rid of this!
Fred Drake6659c301998-03-03 22:02:19 +0000681\newif\iftexi\texifalse
Fred Drake6659c301998-03-03 22:02:19 +0000682
Fred Drake1e4973b1998-07-28 21:52:17 +0000683% This is used to get l2h to put the copyright and abstract on
684% a separate HTML page.
685\newif\ifhtml\htmlfalse
686
687
Fred Drake6659c301998-03-03 22:02:19 +0000688% These should be used for all references to identifiers which are
689% used to refer to instances of specific language constructs. See the
690% names for specific semantic assignments.
691%
692% For now, don't do anything really fancy with them; just use them as
693% logical markup. This might change in the future.
694%
Fred Drake24340ea1998-04-28 18:30:34 +0000695\newcommand{\module}[1]{\texttt{#1}}
696\newcommand{\keyword}[1]{\texttt{#1}}
697\newcommand{\exception}[1]{\texttt{#1}}
698\newcommand{\class}[1]{\texttt{#1}}
699\newcommand{\function}[1]{\texttt{#1}}
700\newcommand{\member}[1]{\texttt{#1}}
701\newcommand{\method}[1]{\texttt{#1}}
Fred Drake6659c301998-03-03 22:02:19 +0000702
Fred Drake53714971998-04-02 22:33:16 +0000703\newcommand{\pytype}[1]{#1} % built-in Python type
704
Fred Drake24340ea1998-04-28 18:30:34 +0000705\newcommand{\cfunction}[1]{\texttt{#1}}
706\newcommand{\ctype}[1]{\texttt{#1}} % C struct or typedef name
707\newcommand{\cdata}[1]{\texttt{#1}} % C variable, typically global
Fred Drake6659c301998-03-03 22:02:19 +0000708
Fred Drake0ee9f721998-03-12 06:41:40 +0000709\newcommand{\mimetype}[1]{{\small\textsf{#1}}}
Fred Drake94fac131998-03-12 19:37:03 +0000710% The \! is a "negative thin space" in math mode.
711\newcommand{\regexp}[1]{%
712 {\tiny$^{^\lceil}\!\!$%
713 {\normalsize\code{#1}}%
Fred Drake47cfd031998-04-03 21:22:31 +0000714 $\!\rfloor\!$%
Fred Drake94fac131998-03-12 19:37:03 +0000715 }}
Fred Drake0ee9f721998-03-12 06:41:40 +0000716\newcommand{\envvar}[1]{%
Fred Drake94fac131998-03-12 19:37:03 +0000717 \$#1% $ <-- bow to font-lock 3 times!
718 \index{#1@{\$#1}}% $
719 \index{environment variables!{\$#1}}% $
Fred Drake0ee9f721998-03-12 06:41:40 +0000720}
Fred Drake24340ea1998-04-28 18:30:34 +0000721\newcommand{\makevar}[1]{#1} % variable in a Makefile
722\newcommand{\character}[1]{\samp{#1}}
Fred Drake0ee9f721998-03-12 06:41:40 +0000723
Fred Drake6659c301998-03-03 22:02:19 +0000724% constants defined in Python modules or C headers, not language constants:
Fred Drake24340ea1998-04-28 18:30:34 +0000725\newcommand{\constant}[1]{\code{#1}} % manifest constant, not syntactic
Fred Drake6659c301998-03-03 22:02:19 +0000726
727\newcommand{\manpage}[2]{{\emph{#1}(#2)}}
728\newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}}
729\newcommand{\program}[1]{\strong{#1}}
730
731
732% Deprecation stuff.
733% Should be extended to allow an index / list of deprecated stuff. But
734% there's a lot of stuff that needs to be done to make that automatable.
735%
736% First parameter is the release number that deprecates the feature, the
737% second is the action the should be taken by users of the feature.
738%
739% Example:
Fred Drake24340ea1998-04-28 18:30:34 +0000740% \deprecated{1.5.1}{Use \method{frobnicate()} instead.}
Fred Drake6659c301998-03-03 22:02:19 +0000741%
742\newcommand{\deprecated}[2]{%
743 \strong{Deprecated since release #1.} #2\par}
744
Fred Drakeaf958c71998-07-27 20:32:33 +0000745% New stuff.
746% This should be used to mark things which have been added to the
747% development tree but that aren't in the release, but are documented.
748% This allows release of documentation that already includes updated
Fred Drake2116d981999-02-02 18:02:48 +0000749% descriptions. Place at end of descriptor environment.
Fred Drakeaf958c71998-07-27 20:32:33 +0000750%
751% Example:
752% \versionadded{1.5.2}
753%
754\newcommand{\versionadded}[1]{%
Fred Drake2116d981999-02-02 18:02:48 +0000755 { New in version #1. }}
Fred Drakeaf958c71998-07-27 20:32:33 +0000756\newcommand{\versionchanged}[1]{%
Fred Drake2116d981999-02-02 18:02:48 +0000757 { Changed in version #1. }}
Fred Drake6659c301998-03-03 22:02:19 +0000758
Fred Drakeaf958c71998-07-27 20:32:33 +0000759
760% Tables.
761%
Fred Drake6659c301998-03-03 22:02:19 +0000762\newenvironment{tableii}[4]{%
763 \begin{center}%
764 \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
Fred Drakeee601911998-04-11 20:53:03 +0000765 \begin{tabular}{#1}\strong{#3}&\strong{#4} \\ \hline%
Fred Drake6659c301998-03-03 22:02:19 +0000766}{%
Fred Drake6659c301998-03-03 22:02:19 +0000767 \end{tabular}%
768 \end{center}%
769}
770
771\newenvironment{tableiii}[5]{%
772 \begin{center}%
773 \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
Fred Drakeee601911998-04-11 20:53:03 +0000774 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5} \\ \hline%
Fred Drake6659c301998-03-03 22:02:19 +0000775}{%
Fred Drake6659c301998-03-03 22:02:19 +0000776 \end{tabular}%
777 \end{center}%
778}
779
Fred Drake30e52651998-07-24 22:11:29 +0000780\newenvironment{tableiv}[6]{%
781 \begin{center}%
782 \def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}%
783 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6} \\%
784 \hline%
785}{%
786 \end{tabular}%
787 \end{center}%
788}
789
Fred Drake24340ea1998-04-28 18:30:34 +0000790% Cross-referencing (AMK, new impl. FLD)
Fred Drake6659c301998-03-03 22:02:19 +0000791% Sample usage:
792% \begin{seealso}
793% \seemodule{rand}{Uniform random number generator}; % Module xref
794% \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book
Fred Drakeebcb6581998-03-06 21:25:17 +0000795%
796% % A funky case: module name contains '_'; have to supply an optional key
797% \seemodule[copyreg]{copy_reg}{pickle interface constructor registration}
798%
Fred Drake6659c301998-03-03 22:02:19 +0000799% \end{seealso}
800
Fred Drake1c8d0e01998-03-07 05:29:15 +0000801\@ifundefined{pdfannotlink}{%
Fred Drake24340ea1998-04-28 18:30:34 +0000802 \newcommand{\py@seemodule}[3][\py@modulebadkey]{%
Fred Drakeda943741999-01-13 17:09:06 +0000803 \par%
Fred Drake24340ea1998-04-28 18:30:34 +0000804 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
805 \ref{module-\py@modulekey}:\quad %
Fred Drakeebcb6581998-03-06 21:25:17 +0000806 Module \module{#2}%
807 \quad (#3)%
808 }
Fred Drake24340ea1998-04-28 18:30:34 +0000809}{\newcommand{\py@seemodule}[3][\py@modulebadkey]{%
Fred Drakeda943741999-01-13 17:09:06 +0000810 \par%
Fred Drake24340ea1998-04-28 18:30:34 +0000811 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
812 \ref{module-\py@modulekey}:\quad %
Fred Drakeaa2aea01999-01-27 17:37:36 +0000813 \py@linkToName{label-module-\py@modulekey}{ Module \module{#2} }
Fred Drakeebcb6581998-03-06 21:25:17 +0000814 \quad (#3)%
815 }
816}
Fred Drake6659c301998-03-03 22:02:19 +0000817\newenvironment{seealso}[0]{
818 \strong{See Also:}\par
Fred Drake6659c301998-03-03 22:02:19 +0000819 \def\seetext##1{\par{##1}}
Fred Drake24340ea1998-04-28 18:30:34 +0000820 \let\seemodule=\py@seemodule
Fred Drake6659c301998-03-03 22:02:19 +0000821}{\par}
822
823
Fred Drakeaf958c71998-07-27 20:32:33 +0000824% Allow the Python release number to be specified independently of the
Fred Drake6659c301998-03-03 22:02:19 +0000825% \date{}. This allows the date to reflect the document's date and
826% release to specify the Python release that is documented.
827%
Fred Drake24340ea1998-04-28 18:30:34 +0000828\newcommand{\py@release}{}
Fred Drake6659c301998-03-03 22:02:19 +0000829\newcommand{\version}{}
830\newcommand{\releasename}{Release}
831\newcommand{\release}[1]{%
Fred Drake24340ea1998-04-28 18:30:34 +0000832 \renewcommand{\py@release}{\releasename\space\version}%
Fred Drake6659c301998-03-03 22:02:19 +0000833 \renewcommand{\version}{#1}}
834
835% Allow specification of the author's address separately from the
836% author's name. This can be used to format them differently, which
837% is a good thing.
838%
Fred Drake24340ea1998-04-28 18:30:34 +0000839\newcommand{\py@authoraddress}{}
840\newcommand{\authoraddress}[1]{\renewcommand{\py@authoraddress}{#1}}
Fred Drake6df93ef1998-05-14 20:56:31 +0000841\let\developersaddress=\authoraddress
842\let\developer=\author
843\let\developers=\author
Fred Drake6659c301998-03-03 22:02:19 +0000844
Fred Drake6659c301998-03-03 22:02:19 +0000845% This sets up the fancy chapter headings that make the documents look
846% at least a little better than the usual LaTeX output.
847%
Fred Drake1c8d0e01998-03-07 05:29:15 +0000848\@ifundefined{ChTitleVar}{}{
Fred Drake24340ea1998-04-28 18:30:34 +0000849 \ChNameVar{\raggedleft\normalsize\py@HeaderFamily}
850 \ChNumVar{\raggedleft \bfseries\Large\py@HeaderFamily}
851 \ChTitleVar{\raggedleft \rm\Huge\py@HeaderFamily}
Fred Drake6659c301998-03-03 22:02:19 +0000852 % This creates chapter heads without the leading \vspace*{}:
Fred Drake1c8d0e01998-03-07 05:29:15 +0000853 \def\@makechapterhead#1{%
854 {\parindent \z@ \raggedright \normalfont
855 \ifnum \c@secnumdepth >\m@ne
Fred Drake6659c301998-03-03 22:02:19 +0000856 \DOCH
857 \fi
Fred Drake1c8d0e01998-03-07 05:29:15 +0000858 \interlinepenalty\@M
Fred Drake6659c301998-03-03 22:02:19 +0000859 \DOTI{#1}
860 }
861 }
Fred Drake6659c301998-03-03 22:02:19 +0000862}
863
Fred Drake3bf78651998-05-20 17:42:17 +0000864
865% Definition lists; requested by AMK for HOWTO documents. Probably useful
866% elsewhere as well, so keep in in the general style support.
867%
868\newenvironment{definitions}{%
869 \begin{description}%
Fred Drakef9acc591998-09-09 15:27:43 +0000870 \def\term##1{\item[##1]\mbox{}\\*[0mm]}
Fred Drake3bf78651998-05-20 17:42:17 +0000871}{%
872 \end{description}%
873}
874
Fred Drake6659c301998-03-03 22:02:19 +0000875% Tell TeX about pathological hyphenation cases:
876\hyphenation{Base-HTTP-Re-quest-Hand-ler}