blob: 904e971d39fed9f0981e6bab96f696d29cbd3142 [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 Drakea2c2a831998-04-15 17:50:01 +000040 % Compute the padded page number separately since we end up with a pair of
41 % \relax tokens; this gets the right string computed and works.
Fred Drake6659c301998-03-03 22:02:19 +000042 \renewcommand{\contentsline}[3]{%
Fred Drakea2c2a831998-04-15 17:50:01 +000043 \def\my@pageno{\py@targetno{#3}}%
Fred Drake24340ea1998-04-28 18:30:34 +000044 \py@OldContentsline{#1}{%
Fred Drakea2c2a831998-04-15 17:50:01 +000045 \pdfannotlink attr{/Border [0 0 0]} goto name{page\my@pageno}%
Fred Drake24340ea1998-04-28 18:30:34 +000046 \py@LinkColor#2\py@NormalColor%
Fred Drake6659c301998-03-03 22:02:19 +000047 \pdfendlink%
48 }{#3}%
49 }
Fred Drakeebcb6581998-03-06 21:25:17 +000050 \AtEndDocument{
Fred Drakec0b2e451998-03-25 14:53:43 +000051 \InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{}
Fred Drakeebcb6581998-03-06 21:25:17 +000052 }
Fred Drakea2c2a831998-04-15 17:50:01 +000053 \newcommand{\py@target}[1]{%
Fred Drake24340ea1998-04-28 18:30:34 +000054 \ifpy@doing@page@targets%
Fred Drakea2c2a831998-04-15 17:50:01 +000055 {\pdfdest name{#1} fit}%
56 \fi%
57 }
Fred Drake24340ea1998-04-28 18:30:34 +000058 \let\py@OldLabel=\label
Fred Drake6659c301998-03-03 22:02:19 +000059 \renewcommand{\label}[1]{%
Fred Drake24340ea1998-04-28 18:30:34 +000060 \py@OldLabel{#1}%
Fred Drakea2c2a831998-04-15 17:50:01 +000061 \py@target{label-#1}%
Fred Drake6659c301998-03-03 22:02:19 +000062 }
Fred Drakeba1700c1998-05-11 20:42:54 +000063 % This stuff adds a page# destination to every PDF page, where # is three
64 % digits wide, padded with leading zeros. This doesn't really help with
65 % the frontmatter, but does fine with the body.
Fred Drake6659c301998-03-03 22:02:19 +000066 %
67 % This is *heavily* based on the hyperref package.
68 %
Fred Drake1c8d0e01998-03-07 05:29:15 +000069 \def\@begindvi{%
70 \unvbox \@begindvibox
71 \@hyperfixhead
Fred Drake6659c301998-03-03 22:02:19 +000072 }
Fred Drake1c8d0e01998-03-07 05:29:15 +000073 \def\@hyperfixhead{%
74 \let\H@old@thehead\@thehead
Fred Drakea2c2a831998-04-15 17:50:01 +000075 \global\def\@foo{\py@target{page\py@pageno}}%
Fred Drake1c8d0e01998-03-07 05:29:15 +000076 \expandafter\ifx\expandafter\@empty\H@old@thehead
77 \def\H@old@thehead{\hfil}\fi
78 \def\@thehead{\@foo\relax\H@old@thehead}%
Fred Drake6659c301998-03-03 22:02:19 +000079 }
Fred Drakec0b2e451998-03-25 14:53:43 +000080\fi\fi
Fred Drake6659c301998-03-03 22:02:19 +000081
82% Increase printable page size (copied from fullpage.sty)
83\topmargin 0pt
84\advance \topmargin by -\headheight
85\advance \topmargin by -\headsep
86
87% attempt to work a little better for A4 users
Fred Drake1c8d0e01998-03-07 05:29:15 +000088\@ifundefined{paperheight}{
Fred Drake6659c301998-03-03 22:02:19 +000089 \textheight 9in
90}{
91 \textheight \paperheight
92 \advance\textheight by -2in
93}
94
95\oddsidemargin 0pt
96\evensidemargin \oddsidemargin
97\marginparwidth 0.5in
98
Fred Drake1c8d0e01998-03-07 05:29:15 +000099\@ifundefined{paperwidth}{
Fred Drake6659c301998-03-03 22:02:19 +0000100 \textwidth 6.5in
101}{
102 \textwidth \paperwidth
103 \advance\textwidth by -2in
104}
105
106
107% Style parameters and macros used by most documents here
108\raggedbottom
109\sloppy
110\parindent = 0mm
Fred Drake24340ea1998-04-28 18:30:34 +0000111\parskip = 2mm
Fred Drake6659c301998-03-03 22:02:19 +0000112\hbadness = 5000 % don't print trivial gripes
113
114\pagestyle{empty} % start this way; change for
115\pagenumbering{roman} % ToC & chapters
116\setcounter{secnumdepth}{1}
117
118% Use this to set the font family for headers and other decor:
Fred Drake24340ea1998-04-28 18:30:34 +0000119\newcommand{\py@HeaderFamily}{\sffamily}
Fred Drake6659c301998-03-03 22:02:19 +0000120
121% Redefine the 'normal' header/footer style when using "fancyhdr" package:
Fred Drake1c8d0e01998-03-07 05:29:15 +0000122\@ifundefined{fancyhf}{}{
Fred Drake6659c301998-03-03 22:02:19 +0000123 % Use \pagestyle{normal} as the primary pagestyle for text.
124 \fancypagestyle{normal}{
125 \fancyhf{}
Fred Drake24340ea1998-04-28 18:30:34 +0000126 \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
127 \fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}}
128 \fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}}
Fred Drake6659c301998-03-03 22:02:19 +0000129 \renewcommand{\headrulewidth}{0pt}
130 \renewcommand{\footrulewidth}{0.4pt}
131 }
132 % Update the plain style so we get the page number & footer line,
133 % but not a chapter or section title. This is to keep the first
134 % page of a chapter and the blank page between chapters `clean.'
135 \fancypagestyle{plain}{
136 \fancyhf{}
Fred Drake24340ea1998-04-28 18:30:34 +0000137 \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
Fred Drake6659c301998-03-03 22:02:19 +0000138 \renewcommand{\headrulewidth}{0pt}
139 \renewcommand{\footrulewidth}{0.4pt}
140 }
141 % Redefine \cleardoublepage so that the blank page between chapters
142 % gets the plain style and not the fancy style. This is described
143 % in the documentation for the fancyhdr package by Piet von Oostrum.
Fred Drake1c8d0e01998-03-07 05:29:15 +0000144 \@ifundefined{chapter}{}{
Fred Drake28f13911998-03-04 21:47:59 +0000145 \renewcommand{\cleardoublepage}{
Fred Drake1c8d0e01998-03-07 05:29:15 +0000146 \clearpage\if@openright \ifodd\c@page\else
Fred Drake28f13911998-03-04 21:47:59 +0000147 \hbox{}
148 \thispagestyle{plain}
149 \newpage
Fred Drake1c8d0e01998-03-07 05:29:15 +0000150 \if@twocolumn\hbox{}\newpage\fi\fi\fi
Fred Drake28f13911998-03-04 21:47:59 +0000151 }
152 }
Fred Drake6659c301998-03-03 22:02:19 +0000153}
154
Fred Drake6659c301998-03-03 22:02:19 +0000155% This sets up the {verbatim} environment to be indented and a minipage,
156% and to have all the other mostly nice properties that we want for
157% code samples.
158
159% Variable used by begin code command
Fred Drake24340ea1998-04-28 18:30:34 +0000160\newlength{\py@codewidth}
Fred Drake6659c301998-03-03 22:02:19 +0000161
Fred Drake24340ea1998-04-28 18:30:34 +0000162\newcommand{\py@examplevspace}{2mm}
163\newcommand{\py@exampleindent}{1cm}
Fred Drake6659c301998-03-03 22:02:19 +0000164
Fred Drake24340ea1998-04-28 18:30:34 +0000165\let\py@OldVerbatim=\verbatim
166\let\py@OldEndVerbatim=\endverbatim
Fred Drake6659c301998-03-03 22:02:19 +0000167\renewcommand{\verbatim}{%
168 \begingroup%
Fred Drake24340ea1998-04-28 18:30:34 +0000169 \setlength{\parindent}\py@exampleindent%
Fred Drake6659c301998-03-03 22:02:19 +0000170 % Calculate the text width for the minipage:
Fred Drake24340ea1998-04-28 18:30:34 +0000171 \setlength{\py@codewidth}{\linewidth}%
172 \addtolength{\py@codewidth}{-\parindent}%
Fred Drake6659c301998-03-03 22:02:19 +0000173 %
174 \par%
Fred Drake24340ea1998-04-28 18:30:34 +0000175 \vspace\py@examplevspace%
Fred Drake6659c301998-03-03 22:02:19 +0000176 \indent%
Fred Drake24340ea1998-04-28 18:30:34 +0000177 \begin{minipage}[t]{\py@codewidth}%
Fred Drake6659c301998-03-03 22:02:19 +0000178 \small%
Fred Drake24340ea1998-04-28 18:30:34 +0000179 \py@OldVerbatim%
Fred Drake6659c301998-03-03 22:02:19 +0000180}
181\renewcommand{\endverbatim}{%
Fred Drake24340ea1998-04-28 18:30:34 +0000182 \py@OldEndVerbatim%
Fred Drake6659c301998-03-03 22:02:19 +0000183 \end{minipage}%
184 \endgroup%
185}
186
Fred Drake6cb71491998-03-27 05:22:53 +0000187
Fred Drakea488f301998-07-23 17:50:45 +0000188\newcommand{\py@modulebadkey}{{--just-some-junk--}}
Fred Drake6659c301998-03-03 22:02:19 +0000189
Fred Drake6659c301998-03-03 22:02:19 +0000190
191%% Lots of index-entry generation support.
192
193% Command to wrap around stuff that refers to function / module /
194% attribute names in the index. Default behavior: like \code{}. To
195% just keep the index entries in the roman font, uncomment the second
Fred Drakea488f301998-07-23 17:50:45 +0000196% definition; it matches O'Reilly style more.
Fred Drake6659c301998-03-03 22:02:19 +0000197%
Fred Drake24340ea1998-04-28 18:30:34 +0000198\newcommand{\py@idxcode}[1]{\texttt{#1}}
199%\renewcommand{\py@idxcode}[1]{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000200
201% Command to generate two index entries (using subentries)
202\newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}}
203
204% And three entries (using only one level of subentries)
205\newcommand{\indexiii}[3]{\index{#1!#2 #3}\index{#2!#3, #1}\index{#3!#1 #2}}
206
207% And four (again, using only one level of subentries)
208\newcommand{\indexiv}[4]{
209\index{#1!#2 #3 #4}
210\index{#2!#3 #4, #1}
211\index{#3!#4, #1 #2}
212\index{#4!#1 #2 #3}
213}
214
215% Command to generate a reference to a function, statement, keyword,
216% operator.
Fred Drake0cabff91998-05-06 19:36:01 +0000217\newcommand{\kwindex}[1]{\indexii{keyword}{#1@{\py@idxcode{#1}}}}
Fred Drake24340ea1998-04-28 18:30:34 +0000218\newcommand{\stindex}[1]{\indexii{statement}{#1@{\py@idxcode{#1}}}}
219\newcommand{\opindex}[1]{\indexii{operator}{#1@{\py@idxcode{#1}}}}
220\newcommand{\exindex}[1]{\indexii{exception}{#1@{\py@idxcode{#1}}}}
Fred Drake6659c301998-03-03 22:02:19 +0000221\newcommand{\obindex}[1]{\indexii{object}{#1}}
Fred Drake2351c801998-04-02 18:48:32 +0000222\newcommand{\bifuncindex}[1]{\withsubitem{(built-in function)}{\ttindex{#1()}}}
Fred Drake6659c301998-03-03 22:02:19 +0000223
224% Add an index entry for a module
Fred Drake24340ea1998-04-28 18:30:34 +0000225\newcommand{\py@refmodule}[2]{\index{#1@{\py@idxcode{#1}} (#2module)}}
226\newcommand{\refmodindex}[1]{\py@refmodule{#1}{}}
227\newcommand{\refbimodindex}[1]{\py@refmodule{#1}{built-in }}
228\newcommand{\refexmodindex}[1]{\py@refmodule{#1}{extension }}
229\newcommand{\refstmodindex}[1]{\py@refmodule{#1}{standard }}
Fred Drake6659c301998-03-03 22:02:19 +0000230
Fred Drakeda943741999-01-13 17:09:06 +0000231% Refer to a module's documentation using a hyperlink of the module's
232% name, at least if we're building PDF:
233\@ifundefined{pdfannotlink}{%
234 \newcommand{\refmodule}[2][\py@modulebadkey]{\module{#2}}
235}{\newcommand{\refmodule}[2][\py@modulebadkey]{%
236 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
237 {\pdfannotlink attr{/Border [0 0 0]} goto name{label-module-\py@modulekey}%
238 \py@LinkColor\module{#2}\py@NormalColor%
239 \pdfendlink%
240 }%
241 }
242}
243
Fred Drake6659c301998-03-03 22:02:19 +0000244% support for the module index
Fred Drake24340ea1998-04-28 18:30:34 +0000245\newif\ifpy@UseModuleIndex
246\py@UseModuleIndexfalse
Fred Drakeb390daf1998-03-09 16:35:36 +0000247
Fred Drakeb390daf1998-03-09 16:35:36 +0000248\newcommand{\makemodindex}{
249 \newwrite\modindexfile
250 \openout\modindexfile=mod\jobname.idx
Fred Drake24340ea1998-04-28 18:30:34 +0000251 \py@UseModuleIndextrue
Fred Drakeb390daf1998-03-09 16:35:36 +0000252}
253
Fred Drake0ee9f721998-03-12 06:41:40 +0000254% Add the defining entry for a module
Fred Drake24340ea1998-04-28 18:30:34 +0000255\newcommand{\py@modindex}[2]{%
Fred Drakea488f301998-07-23 17:50:45 +0000256 \renewcommand{\py@thismodule}{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000257 \setindexsubitem{(in module #1)}%
Fred Drake24340ea1998-04-28 18:30:34 +0000258 \index{#1@{\py@idxcode{#1}} (#2module)|textbf}%
259 \ifpy@UseModuleIndex%
Fred Drake0ee9f721998-03-12 06:41:40 +0000260 \write\modindexfile{\protect\indexentry{#1@{\tt #1}}{\thepage}}%
261 \fi%
262}
263
Fred Drake6659c301998-03-03 22:02:19 +0000264% built-in & Python modules in the main distribution
Fred Drake24340ea1998-04-28 18:30:34 +0000265\newcommand{\bimodindex}[1]{\py@modindex{#1}{built-in }}
266\newcommand{\stmodindex}[1]{\py@modindex{#1}{standard }}
Fred Drake6659c301998-03-03 22:02:19 +0000267
268% Python & extension modules outside the main distribution
Fred Drake24340ea1998-04-28 18:30:34 +0000269\newcommand{\modindex}[1]{\py@modindex{#1}{}}
270\newcommand{\exmodindex}[1]{\py@modindex{#1}{extension }}
Fred Drake6659c301998-03-03 22:02:19 +0000271
272% Additional string for an index entry
Fred Drake1c8d0e01998-03-07 05:29:15 +0000273\newcommand{\index@subitem}{}
274\newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}}
Fred Drake24340ea1998-04-28 18:30:34 +0000275\newcommand{\ttindex}[1]{\index{#1@{\py@idxcode{#1}} \index@subitem}}
Fred Drake6659c301998-03-03 22:02:19 +0000276
Fred Drake0ee9f721998-03-12 06:41:40 +0000277\newcommand{\withsubitem}[2]{%
278 \begingroup%
279 \def\index@subitem{#1}#2%
280 \endgroup%
281}
Fred Drake6659c301998-03-03 22:02:19 +0000282
Fred Drake53714971998-04-02 22:33:16 +0000283
Fred Drakea488f301998-07-23 17:50:45 +0000284% Module synopsis processing -----------------------------------------------
285%
286\newcommand{\py@standardIndexModule}[1]{\stmodindex{#1}}
287\newcommand{\py@builtinIndexModule}[1]{\bimodindex{#1}}
288\newcommand{\py@extensionIndexModule}[1]{\exmodindex{#1}}
289\newcommand{\py@IndexModule}[1]{\modindex{#1}}
290
291\newif\ifpy@HaveModSynopsis\py@HaveModSynopsisfalse
292\newif\ifpy@ModSynopsisFileIsOpen\py@ModSynopsisFileIsOpenfalse
293
294% \declaremodule[key]{type}{name}
295\newcommand{\declaremodule}[3][\py@modulebadkey]{
296 \py@openModSynopsisFile
297 \renewcommand{\py@thismoduletype}{#2}
298 \csname py@#2IndexModule\endcsname{#3}
299 \ifx\py@modulebadkey#1
300 \renewcommand{\py@thismodulekey}{#3}
301 \else
302 \renewcommand{\py@thismodulekey}{#1}
303 \fi
304 \label{module-\py@thismodulekey}
305 \py@HaveModSynopsistrue
306}
307
Fred Drakeb75c6151998-08-10 18:41:43 +0000308% \moduleauthor{name}{email}
309\newcommand{\moduleauthor}[2]{}
310
311% \sectionauthor{name}{email}
312\newcommand{\sectionauthor}[2]{}
313
Fred Drakea488f301998-07-23 17:50:45 +0000314
315\newcommand{\py@defsynopsis}{Module has no synopsis.}
316\newcommand{\py@modulesynopsis}{\py@defsynopsis}
317\newcommand{\modulesynopsis}[1]{
318 \renewcommand{\py@modulesynopsis}{#1}
319}
320
321% define the file
322\newwrite\py@ModSynopsisFile
323
324% hacked from \addtocontents from latex.ltx:
325\long\def\py@writeModSynopsisFile#1{%
326 \protected@write\py@ModSynopsisFile%
327 {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
328 {\string#1}%
329}
330\newcommand{\py@closeModSynopsisFile}{
331 \ifpy@ModSynopsisFileIsOpen
332 \closeout\py@ModSynopsisFile
333 \py@ModSynopsisFileIsOpenfalse
334 \fi
335}
336\newcommand{\py@openModSynopsisFile}{
337 \ifpy@ModSynopsisFileIsOpen\else
338 \openout\py@ModSynopsisFile=\py@ModSynopsisFilename
339 \py@ModSynopsisFileIsOpentrue
340 \fi
341}
342
343\newcommand{\py@ProcessModSynopsis}{
344 \ifpy@HaveModSynopsis
345 \py@writeModSynopsisFile{\modulesynopsis%
346 {\py@thismodulekey}{\py@thismodule}%
347 {\py@thismoduletype}{\py@modulesynopsis}}%
348 \py@HaveModSynopsisfalse
349 \fi
350 \renewcommand{\py@modulesynopsis}{\py@defsynopsis}
351}
352\AtEndDocument{\py@ProcessModSynopsis\py@closeModSynopsisFile}
353
354\newcommand{\localmoduletable}{
355 \IfFileExists{\py@ModSynopsisFilename}{
356 \begin{synopsistable}
357 \input{\py@ModSynopsisFilename}
358 \end{synopsistable}
359 }{}
360}
361
362\@ifundefined{pdfoutput}{
363 \newcommand{\py@ModSynopsisSummary}[4]{\bfcode{#2} & #4\\}
364}{
365 \newcommand{\py@ModSynopsisSummary}[4]{
366 {\pdfannotlink attr{/Border [0 0 0]} goto name{label-module-#1}
367 \py@LinkColor \bfcode{#2} \py@NormalColor
368 \pdfendlink}& #4\\}
369}
370\newenvironment{synopsistable}{
371 % key, name, type, synopsis
372 \let\modulesynopsis=\py@ModSynopsisSummary
373 \begin{tabular}{ll}
374}{
375 \end{tabular}
376}
377%
378% --------------------------------------------------------------------------
379
380
381\newcommand{\py@thisclass}{}
382\newcommand{\py@thismodule}{}
383\newcommand{\py@thismodulekey}{}
384\newcommand{\py@thismoduletype}{}
385
386\newcommand{\py@reset}{
387 \py@ProcessModSynopsis
388 \renewcommand{\py@thisclass}{}
389 \renewcommand{\py@thismodule}{}
390 \renewcommand{\py@thismodulekey}{}
391 \renewcommand{\py@thismoduletype}{}
392}
393
394% Augment the sectioning commands used to get our own font family in place,
395% and reset some internal data items:
396\renewcommand{\section}{\py@reset%
397 \@startsection{section}{1}{\z@}%
398 {-3.5ex \@plus -1ex \@minus -.2ex}%
399 {2.3ex \@plus.2ex}%
400 {\reset@font\Large\py@HeaderFamily}}
401\renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}%
402 {-3.25ex\@plus -1ex \@minus -.2ex}%
403 {1.5ex \@plus .2ex}%
404 {\reset@font\large\py@HeaderFamily}}
405\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}%
406 {-3.25ex\@plus -1ex \@minus -.2ex}%
407 {1.5ex \@plus .2ex}%
408 {\reset@font\normalsize\py@HeaderFamily}}
409\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}%
410 {3.25ex \@plus1ex \@minus.2ex}%
411 {-1em}%
412 {\reset@font\normalsize\py@HeaderFamily}}
413\renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}%
414 {3.25ex \@plus1ex \@minus .2ex}%
415 {-1em}%
416 {\reset@font\normalsize\py@HeaderFamily}}
417
418
Fred Drake5420f331998-07-23 21:41:02 +0000419% This gets the underscores closer to the right width; the only change
420% from standard LaTeX is the width specified.
421
422\DeclareTextCommandDefault{\textunderscore}{%
423 \leavevmode \kern.06em\vbox{\hrule\@width.55em}}
424
Fred Drakea488f301998-07-23 17:50:45 +0000425% Underscore hack (only act like subscript operator if in math mode)
426%
427% The following is due to Mark Wooding (the old version didn't work with
428% Latex 2e.
429
430\DeclareRobustCommand\hackscore{%
431 \ifmmode_\else\textunderscore\fi%
432}
433\begingroup
434\catcode`\_\active
435\def\next{%
436 \AtBeginDocument{\catcode`\_\active\def_{\hackscore{}}}%
437}
438\expandafter\endgroup\next
439
440
Fred Drake53714971998-04-02 22:33:16 +0000441% Now for a lot of semantically-loaded environments that do a ton of magical
442% things to get the right formatting and index entries for the stuff in
443% Python modules and C API.
444
445
Fred Drake6659c301998-03-03 22:02:19 +0000446% {fulllineitems} is used in one place in libregex.tex, but is really for
447% internal use in this file.
448%
Fred Drakef9acc591998-09-09 15:27:43 +0000449\newcommand{\py@itemnewline}[1]{%
450 \@tempdima\linewidth%
451 \advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}%
452}
453
Fred Drake6659c301998-03-03 22:02:19 +0000454\newenvironment{fulllineitems}{
455 \begin{list}{}{\labelwidth \leftmargin \labelsep 0pt
456 \rightmargin 0pt \topsep -\parskip \partopsep \parskip
457 \itemsep -\parsep
Fred Drakef9acc591998-09-09 15:27:43 +0000458 \let\makelabel=\py@itemnewline}
Fred Drake6659c301998-03-03 22:02:19 +0000459}{\end{list}}
460
Fred Drake6cb71491998-03-27 05:22:53 +0000461% \optional is mostly for use in the arguments parameters to the various
462% {*desc} environments defined below, but may be used elsewhere. Known to
463% be used in the debugger chapter.
Fred Drake24340ea1998-04-28 18:30:34 +0000464%
465% Typical usage:
466%
467% \begin{funcdesc}{myfunc}{reqparm\optional{, optparm}}
468% ^^^ ^^^
469% No space here No space here
470%
471% When a function has multiple optional parameters, \optional should be
472% nested, not chained. This is right:
473%
474% \begin{funcdesc}{myfunc}{\optional{parm1\optional{, parm2}}}
475%
Fred Drake6659c301998-03-03 22:02:19 +0000476\newcommand{\optional}[1]{%
477 {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
478
Fred Drake6cb71491998-03-27 05:22:53 +0000479% C functions ------------------------------------------------------------
480% \begin{cfuncdesc}{type}{name}{arglist}
481\newenvironment{cfuncdesc}[3]{
482 \begin{fulllineitems}
Fred Drake24340ea1998-04-28 18:30:34 +0000483 \item[\code{#1 \bfcode{#2}(\py@varvars{#3})}\index{#2@{\py@idxcode{#2()}}}]
Fred Drake6cb71491998-03-27 05:22:53 +0000484}{\end{fulllineitems}}
485
486% C variables ------------------------------------------------------------
487% \begin{cvardesc}{type}{name}
488\newenvironment{cvardesc}[2]{
489 \begin{fulllineitems}
Fred Drake24340ea1998-04-28 18:30:34 +0000490 \item[\code{#1 \bfcode{#2}}\index{#2@{\py@idxcode{#2}}}]
Fred Drake6cb71491998-03-27 05:22:53 +0000491}{\end{fulllineitems}}
492
493% C data types -----------------------------------------------------------
494% \begin{ctypedesc}{typedef name}
495\newenvironment{ctypedesc}[1]{
496 \begin{fulllineitems}
497 \item[\bfcode{#1}\ttindex{#1}]
498}{\end{fulllineitems}}
499
500% simple functions (not methods) -----------------------------------------
501% \begin{funcdesc}{name}{args}
502\newcommand{\funcline}[2]{\funclineni{#1}{#2}\ttindex{#1()}}
503\newenvironment{funcdesc}[2]{
504 \begin{fulllineitems}
505 \funcline{#1}{#2}
506}{\end{fulllineitems}}
507
Fred Drake6659c301998-03-03 22:02:19 +0000508% similar to {funcdesc}, but doesn't add to the index
Fred Drake300775d1998-04-17 02:17:00 +0000509\newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(\py@varvars{#2})}]}
Fred Drake6cb71491998-03-27 05:22:53 +0000510\newenvironment{funcdescni}[2]{
511 \begin{fulllineitems}
512 \funclineni{#1}{#2}
Fred Drake6659c301998-03-03 22:02:19 +0000513}{\end{fulllineitems}}
514
Fred Drake6cb71491998-03-27 05:22:53 +0000515% classes ----------------------------------------------------------------
516% \begin{classdesc}{name}{constructor args}
517\newenvironment{classdesc}[2]{
Fred Drake1cbd1961998-11-25 17:13:28 +0000518 % Using \renewcommand doesn't work for this, for unknown reasons:
519 \global\def\py@thisclass{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000520 \begin{fulllineitems}
Fred Drake300775d1998-04-17 02:17:00 +0000521 \item[\code{\bfcode{#1}(\py@varvars{#2})}%
Fred Drake24340ea1998-04-28 18:30:34 +0000522 \withsubitem{(class in \py@thismodule)}{\ttindex{#1}}]
Fred Drake6659c301998-03-03 22:02:19 +0000523}{\end{fulllineitems}}
524
Fred Drake6cb71491998-03-27 05:22:53 +0000525
Fred Drake24340ea1998-04-28 18:30:34 +0000526\let\py@classbadkey=\@undefined
Fred Drake6cb71491998-03-27 05:22:53 +0000527
528% object method ----------------------------------------------------------
529% \begin{methoddesc}[classname]{methodname}{args}
Fred Drake24340ea1998-04-28 18:30:34 +0000530\newcommand{\methodline}[3][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000531 \methodlineni{#2}{#3}
532 \ifx#1\@undefined
Fred Drake24340ea1998-04-28 18:30:34 +0000533 \withsubitem{(\py@thisclass\ method)}{\ttindex{#2()}}
Fred Drake6cb71491998-03-27 05:22:53 +0000534 \else
535 \withsubitem{(#1 method)}{\ttindex{#2()}}
536 \fi
537}
Fred Drake24340ea1998-04-28 18:30:34 +0000538\newenvironment{methoddesc}[3][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000539 \begin{fulllineitems}
540 \ifx#1\@undefined
541 \methodline{#2}{#3}
542 \else
Fred Drake24340ea1998-04-28 18:30:34 +0000543 \def\py@thisclass{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000544 \methodline[#1]{#2}{#3}
545 \fi
Fred Drake6659c301998-03-03 22:02:19 +0000546}{\end{fulllineitems}}
547
Fred Drake6cb71491998-03-27 05:22:53 +0000548% similar to {methoddesc}, but doesn't add to the index
549% (never actually uses the optional argument)
Fred Drake24340ea1998-04-28 18:30:34 +0000550\newcommand{\methodlineni}[3][\py@classbadkey]{%
Fred Drake300775d1998-04-17 02:17:00 +0000551 \item[\code{\bfcode{#2}(\py@varvars{#3})}]}
Fred Drake24340ea1998-04-28 18:30:34 +0000552\newenvironment{methoddescni}[3][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000553 \begin{fulllineitems}
554 \methodlineni{#2}{#3}
555}{\end{fulllineitems}}
556
557% object data attribute --------------------------------------------------
558% \begin{memberdesc}[classname]{membername}
Fred Drake24340ea1998-04-28 18:30:34 +0000559\newcommand{\memberline}[2][\py@classbadkey]{%
Fred Drake6cb71491998-03-27 05:22:53 +0000560 \ifx#1\@undefined
561 \memberlineni{#2}
Fred Drake24340ea1998-04-28 18:30:34 +0000562 \withsubitem{(\py@thisclass\ attribute)}{\ttindex{#2}}
Fred Drake6cb71491998-03-27 05:22:53 +0000563 \else
564 \memberlineni{#2}
Fred Drake41565f61998-04-07 19:32:40 +0000565 \withsubitem{(#1 attribute)}{\ttindex{#2}}
Fred Drake6cb71491998-03-27 05:22:53 +0000566 \fi
567}
Fred Drake24340ea1998-04-28 18:30:34 +0000568\newenvironment{memberdesc}[2][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000569 \begin{fulllineitems}
570 \ifx#1\@undefined
571 \memberline{#2}
572 \else
Fred Drake24340ea1998-04-28 18:30:34 +0000573 \def\py@thisclass{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000574 \memberline[#1]{#2}
575 \fi
576}{\end{fulllineitems}}
577
578% similar to {memberdesc}, but doesn't add to the index
579% (never actually uses the optional argument)
Fred Drake24340ea1998-04-28 18:30:34 +0000580\newcommand{\memberlineni}[2][\py@classbadkey]{\item[\bfcode{#2}]}
581\newenvironment{memberdescni}[2][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000582 \begin{fulllineitems}
583 \memberlineni{#2}
584}{\end{fulllineitems}}
585
586% For exceptions: --------------------------------------------------------
587% \begin{excdesc}{name}
588% -- need support for constructor; maybe use optional parameter?
589\newenvironment{excdesc}[1]{
590 \begin{fulllineitems}
591 \item[\bfcode{#1}\ttindex{#1}]
592}{\end{fulllineitems}}
593
594% Module data or constants: ----------------------------------------------
595% \begin{datadesc}{name}
Fred Drake6659c301998-03-03 22:02:19 +0000596\newcommand{\dataline}[1]{\datalineni{#1}\ttindex{#1}}
Fred Drake6cb71491998-03-27 05:22:53 +0000597\newenvironment{datadesc}[1]{
598 \begin{fulllineitems}
599 \dataline{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000600}{\end{fulllineitems}}
601
602% similar to {datadesc}, but doesn't add to the index
Fred Drake6cb71491998-03-27 05:22:53 +0000603\newcommand{\datalineni}[1]{\item[\bfcode{#1}]\nopagebreak}
604\newenvironment{datadescni}[1]{
605 \begin{fulllineitems}
606 \datalineni{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000607}{\end{fulllineitems}}
608
Fred Drake6cb71491998-03-27 05:22:53 +0000609% bytecode instruction ---------------------------------------------------
610% \begin{opcodedesc}{name}{var}
611% -- {var} may be {}
612\newenvironment{opcodedesc}[2]{
613 \begin{fulllineitems}
614 \item[\bfcode{#1}\quad\var{#2}]
Fred Drake6659c301998-03-03 22:02:19 +0000615}{\end{fulllineitems}}
616
617
Fred Drake24340ea1998-04-28 18:30:34 +0000618\newcommand{\nodename}[1]{\label{#1}}
Fred Drake55730311998-03-25 15:41:23 +0000619
Fred Drake6659c301998-03-03 22:02:19 +0000620% For these commands, use \command{} to get the typography right, not
621% {\command}. This works better with the texinfo translation.
622\newcommand{\ABC}{{\sc abc}}
623\newcommand{\UNIX}{{\sc Unix}}
624\newcommand{\POSIX}{POSIX}
625\newcommand{\ASCII}{{\sc ascii}}
626\newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}}
627\newcommand{\C}{C}
628\newcommand{\EOF}{{\sc eof}}
Fred Drake24340ea1998-04-28 18:30:34 +0000629\newcommand{\NULL}{\constant{NULL}}
Fred Drake6659c301998-03-03 22:02:19 +0000630
Fred Drake53714971998-04-02 22:33:16 +0000631% Also for consistency: spell Python "Python", not "python"!
632
Fred Drake6659c301998-03-03 22:02:19 +0000633% code is the most difficult one...
Fred Drake1c8d0e01998-03-07 05:29:15 +0000634\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 +0000635\texttt{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000636
637\newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font
Fred Drake8e54abe1998-07-01 14:49:25 +0000638\newcommand{\kbd}[1]{\code{#1}}
Fred Drake24340ea1998-04-28 18:30:34 +0000639\newcommand{\samp}[1]{`\code{#1}'}
Fred Drake6659c301998-03-03 22:02:19 +0000640% This weird definition of \var{} allows it to always appear in roman
641% italics, and won't get funky in code fragments when we play around
Fred Drakefa1cceb1998-11-30 14:42:59 +0000642% with fonts. This also works directly in math mode.
643\newcommand{\var}[1]{%
644 \ifmmode%
645 \hbox{\normalsize\textrm{\textit{#1\/}}}%
646 \else%
647 \normalsize\textrm{\textit{#1\/}}%
648 \fi%
649}
Fred Drake24340ea1998-04-28 18:30:34 +0000650\renewcommand{\emph}[1]{{\em #1}}
Fred Drake6659c301998-03-03 22:02:19 +0000651\newcommand{\dfn}[1]{\emph{#1}}
652\newcommand{\strong}[1]{{\bf #1}}
653% let's experiment with a new font:
Fred Drake0ee9f721998-03-12 06:41:40 +0000654\newcommand{\file}[1]{`{\small\textsf{#1}}'}
Fred Drake6659c301998-03-03 22:02:19 +0000655
656% Use this def/redef approach for \url{} since hyperref defined this already,
657% but only if we actually used hyperref:
Fred Drake6cb71491998-03-27 05:22:53 +0000658\@ifundefined{pdfannotlink}{
Fred Drakea2c2a831998-04-15 17:50:01 +0000659 \newcommand{\py@url}[1]{\mbox{\small\textsf{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000660}{
Fred Drakea2c2a831998-04-15 17:50:01 +0000661 \newcommand{\py@url}[1]{{%
Fred Drake6659c301998-03-03 22:02:19 +0000662 \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}%
Fred Drake24340ea1998-04-28 18:30:34 +0000663 \py@LinkColor% color of the link text
664 \mbox{\small\textsf{#1}}%
665 \py@NormalColor% Turn it back off; these are declarative
Fred Drake6659c301998-03-03 22:02:19 +0000666 \pdfendlink}% and don't appear bound to the current
667 }% formatting "box".
668}
Fred Drakea2c2a831998-04-15 17:50:01 +0000669\let\url=\py@url
Fred Drake0ee9f721998-03-12 06:41:40 +0000670\newcommand{\email}[1]{{\small\textsf{#1}}}
Fred Drake454a4fb1998-04-01 22:20:14 +0000671\newcommand{\newsgroup}[1]{{\small\textsf{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000672
Fred Drake300775d1998-04-17 02:17:00 +0000673\newcommand{\py@varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}}
Fred Drake24340ea1998-04-28 18:30:34 +0000674% let's see if this breaks anything now; we may be able to simplify...
675\renewcommand{\py@varvars}[1]{\var{#1}}
Fred Drake6659c301998-03-03 22:02:19 +0000676
Fred Drake24340ea1998-04-28 18:30:34 +0000677% I'd really like to get rid of this!
Fred Drake6659c301998-03-03 22:02:19 +0000678\newif\iftexi\texifalse
Fred Drake6659c301998-03-03 22:02:19 +0000679
Fred Drake1e4973b1998-07-28 21:52:17 +0000680% This is used to get l2h to put the copyright and abstract on
681% a separate HTML page.
682\newif\ifhtml\htmlfalse
683
684
Fred Drake6659c301998-03-03 22:02:19 +0000685% These should be used for all references to identifiers which are
686% used to refer to instances of specific language constructs. See the
687% names for specific semantic assignments.
688%
689% For now, don't do anything really fancy with them; just use them as
690% logical markup. This might change in the future.
691%
Fred Drake24340ea1998-04-28 18:30:34 +0000692\newcommand{\module}[1]{\texttt{#1}}
693\newcommand{\keyword}[1]{\texttt{#1}}
694\newcommand{\exception}[1]{\texttt{#1}}
695\newcommand{\class}[1]{\texttt{#1}}
696\newcommand{\function}[1]{\texttt{#1}}
697\newcommand{\member}[1]{\texttt{#1}}
698\newcommand{\method}[1]{\texttt{#1}}
Fred Drake6659c301998-03-03 22:02:19 +0000699
Fred Drake53714971998-04-02 22:33:16 +0000700\newcommand{\pytype}[1]{#1} % built-in Python type
701
Fred Drake24340ea1998-04-28 18:30:34 +0000702\newcommand{\cfunction}[1]{\texttt{#1}}
703\newcommand{\ctype}[1]{\texttt{#1}} % C struct or typedef name
704\newcommand{\cdata}[1]{\texttt{#1}} % C variable, typically global
Fred Drake6659c301998-03-03 22:02:19 +0000705
Fred Drake0ee9f721998-03-12 06:41:40 +0000706\newcommand{\mimetype}[1]{{\small\textsf{#1}}}
Fred Drake94fac131998-03-12 19:37:03 +0000707% The \! is a "negative thin space" in math mode.
708\newcommand{\regexp}[1]{%
709 {\tiny$^{^\lceil}\!\!$%
710 {\normalsize\code{#1}}%
Fred Drake47cfd031998-04-03 21:22:31 +0000711 $\!\rfloor\!$%
Fred Drake94fac131998-03-12 19:37:03 +0000712 }}
Fred Drake0ee9f721998-03-12 06:41:40 +0000713\newcommand{\envvar}[1]{%
Fred Drake94fac131998-03-12 19:37:03 +0000714 \$#1% $ <-- bow to font-lock 3 times!
715 \index{#1@{\$#1}}% $
716 \index{environment variables!{\$#1}}% $
Fred Drake0ee9f721998-03-12 06:41:40 +0000717}
Fred Drake24340ea1998-04-28 18:30:34 +0000718\newcommand{\makevar}[1]{#1} % variable in a Makefile
719\newcommand{\character}[1]{\samp{#1}}
Fred Drake0ee9f721998-03-12 06:41:40 +0000720
Fred Drake6659c301998-03-03 22:02:19 +0000721% constants defined in Python modules or C headers, not language constants:
Fred Drake24340ea1998-04-28 18:30:34 +0000722\newcommand{\constant}[1]{\code{#1}} % manifest constant, not syntactic
Fred Drake6659c301998-03-03 22:02:19 +0000723
724\newcommand{\manpage}[2]{{\emph{#1}(#2)}}
725\newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}}
726\newcommand{\program}[1]{\strong{#1}}
727
728
729% Deprecation stuff.
730% Should be extended to allow an index / list of deprecated stuff. But
731% there's a lot of stuff that needs to be done to make that automatable.
732%
733% First parameter is the release number that deprecates the feature, the
734% second is the action the should be taken by users of the feature.
735%
736% Example:
Fred Drake24340ea1998-04-28 18:30:34 +0000737% \deprecated{1.5.1}{Use \method{frobnicate()} instead.}
Fred Drake6659c301998-03-03 22:02:19 +0000738%
739\newcommand{\deprecated}[2]{%
740 \strong{Deprecated since release #1.} #2\par}
741
Fred Drakeaf958c71998-07-27 20:32:33 +0000742% New stuff.
743% This should be used to mark things which have been added to the
744% development tree but that aren't in the release, but are documented.
745% This allows release of documentation that already includes updated
746% descriptions.
747%
748% Example:
749% \versionadded{1.5.2}
750%
751\newcommand{\versionadded}[1]{%
752 \strong{New in version #1.}\par}
753\newcommand{\versionchanged}[1]{%
754 \strong{Changed in version #1.}\par}
Fred Drake6659c301998-03-03 22:02:19 +0000755
Fred Drakeaf958c71998-07-27 20:32:33 +0000756
757% Tables.
758%
Fred Drake6659c301998-03-03 22:02:19 +0000759\newenvironment{tableii}[4]{%
760 \begin{center}%
761 \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
Fred Drakeee601911998-04-11 20:53:03 +0000762 \begin{tabular}{#1}\strong{#3}&\strong{#4} \\ \hline%
Fred Drake6659c301998-03-03 22:02:19 +0000763}{%
Fred Drake6659c301998-03-03 22:02:19 +0000764 \end{tabular}%
765 \end{center}%
766}
767
768\newenvironment{tableiii}[5]{%
769 \begin{center}%
770 \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
Fred Drakeee601911998-04-11 20:53:03 +0000771 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5} \\ \hline%
Fred Drake6659c301998-03-03 22:02:19 +0000772}{%
Fred Drake6659c301998-03-03 22:02:19 +0000773 \end{tabular}%
774 \end{center}%
775}
776
Fred Drake30e52651998-07-24 22:11:29 +0000777\newenvironment{tableiv}[6]{%
778 \begin{center}%
779 \def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}%
780 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6} \\%
781 \hline%
782}{%
783 \end{tabular}%
784 \end{center}%
785}
786
Fred Drake24340ea1998-04-28 18:30:34 +0000787% Cross-referencing (AMK, new impl. FLD)
Fred Drake6659c301998-03-03 22:02:19 +0000788% Sample usage:
789% \begin{seealso}
790% \seemodule{rand}{Uniform random number generator}; % Module xref
791% \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book
Fred Drakeebcb6581998-03-06 21:25:17 +0000792%
793% % A funky case: module name contains '_'; have to supply an optional key
794% \seemodule[copyreg]{copy_reg}{pickle interface constructor registration}
795%
Fred Drake6659c301998-03-03 22:02:19 +0000796% \end{seealso}
797
Fred Drake1c8d0e01998-03-07 05:29:15 +0000798\@ifundefined{pdfannotlink}{%
Fred Drake24340ea1998-04-28 18:30:34 +0000799 \newcommand{\py@seemodule}[3][\py@modulebadkey]{%
Fred Drakeda943741999-01-13 17:09:06 +0000800 \par%
Fred Drake24340ea1998-04-28 18:30:34 +0000801 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
802 \ref{module-\py@modulekey}:\quad %
Fred Drakeebcb6581998-03-06 21:25:17 +0000803 Module \module{#2}%
804 \quad (#3)%
805 }
Fred Drake24340ea1998-04-28 18:30:34 +0000806}{\newcommand{\py@seemodule}[3][\py@modulebadkey]{%
Fred Drakeda943741999-01-13 17:09:06 +0000807 \par%
Fred Drake24340ea1998-04-28 18:30:34 +0000808 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
809 \ref{module-\py@modulekey}:\quad %
810 {\pdfannotlink attr{/Border [0 0 0]} goto name{label-module-\py@modulekey}%
811 \py@LinkColor Module \module{#2} \py@NormalColor%
Fred Drakeebcb6581998-03-06 21:25:17 +0000812 \pdfendlink%
813 }%
814 \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}