blob: d37682e5920de7c5c8b152b2dbf9a010dbdc36de [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}
178
Fred Drake6659c301998-03-03 22:02:19 +0000179% Variable used by begin code command
Fred Drake24340ea1998-04-28 18:30:34 +0000180\newlength{\py@codewidth}
Fred Drake6659c301998-03-03 22:02:19 +0000181
Fred Drake6659c301998-03-03 22:02:19 +0000182\renewcommand{\verbatim}{%
Fred Drake9466b9a1999-03-18 16:18:27 +0000183 \setlength{\parindent}{1cm}%
Fred Drake6659c301998-03-03 22:02:19 +0000184 % Calculate the text width for the minipage:
Fred Drake24340ea1998-04-28 18:30:34 +0000185 \setlength{\py@codewidth}{\linewidth}%
186 \addtolength{\py@codewidth}{-\parindent}%
Fred Drake6659c301998-03-03 22:02:19 +0000187 %
Fred Drake9466b9a1999-03-18 16:18:27 +0000188 \par\indent%
Fred Drake24340ea1998-04-28 18:30:34 +0000189 \begin{minipage}[t]{\py@codewidth}%
Fred Drake6659c301998-03-03 22:02:19 +0000190 \small%
Fred Drake24340ea1998-04-28 18:30:34 +0000191 \py@OldVerbatim%
Fred Drake6659c301998-03-03 22:02:19 +0000192}
193\renewcommand{\endverbatim}{%
Fred Drake24340ea1998-04-28 18:30:34 +0000194 \py@OldEndVerbatim%
Fred Drake6659c301998-03-03 22:02:19 +0000195 \end{minipage}%
Fred Drake6659c301998-03-03 22:02:19 +0000196}
197
Fred Drakeb5309a92001-04-10 15:53:06 +0000198% This does a similar thing for the {alltt} environment:
199\RequirePackage{alltt}
200\let\py@OldAllTT=\alltt
201\let\py@OldEndAllTT=\endalltt
202
203\renewcommand{\alltt}{%
204 \setlength{\parindent}{1cm}%
205 % Calculate the text width for the minipage:
206 \setlength{\py@codewidth}{\linewidth}%
207 \addtolength{\py@codewidth}{-\parindent}%
208 %
209 \par\indent%
210 \begin{minipage}[t]{\py@codewidth}%
211 \small%
212 \py@OldAllTT%
213}
214\renewcommand{\endalltt}{%
215 \py@OldEndAllTT%
216 \end{minipage}%
217}
218
Fred Drake6cb71491998-03-27 05:22:53 +0000219
Fred Drakea488f301998-07-23 17:50:45 +0000220\newcommand{\py@modulebadkey}{{--just-some-junk--}}
Fred Drake6659c301998-03-03 22:02:19 +0000221
Fred Drake6659c301998-03-03 22:02:19 +0000222
223%% Lots of index-entry generation support.
224
225% Command to wrap around stuff that refers to function / module /
226% attribute names in the index. Default behavior: like \code{}. To
227% just keep the index entries in the roman font, uncomment the second
Fred Drakea488f301998-07-23 17:50:45 +0000228% definition; it matches O'Reilly style more.
Fred Drake6659c301998-03-03 22:02:19 +0000229%
Fred Drake24340ea1998-04-28 18:30:34 +0000230\newcommand{\py@idxcode}[1]{\texttt{#1}}
231%\renewcommand{\py@idxcode}[1]{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000232
233% Command to generate two index entries (using subentries)
234\newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}}
235
236% And three entries (using only one level of subentries)
237\newcommand{\indexiii}[3]{\index{#1!#2 #3}\index{#2!#3, #1}\index{#3!#1 #2}}
238
239% And four (again, using only one level of subentries)
240\newcommand{\indexiv}[4]{
241\index{#1!#2 #3 #4}
242\index{#2!#3 #4, #1}
243\index{#3!#4, #1 #2}
244\index{#4!#1 #2 #3}
245}
246
247% Command to generate a reference to a function, statement, keyword,
248% operator.
Fred Drake0cabff91998-05-06 19:36:01 +0000249\newcommand{\kwindex}[1]{\indexii{keyword}{#1@{\py@idxcode{#1}}}}
Fred Drake24340ea1998-04-28 18:30:34 +0000250\newcommand{\stindex}[1]{\indexii{statement}{#1@{\py@idxcode{#1}}}}
251\newcommand{\opindex}[1]{\indexii{operator}{#1@{\py@idxcode{#1}}}}
252\newcommand{\exindex}[1]{\indexii{exception}{#1@{\py@idxcode{#1}}}}
Fred Drake6659c301998-03-03 22:02:19 +0000253\newcommand{\obindex}[1]{\indexii{object}{#1}}
Fred Drakea33c5662000-10-29 05:19:16 +0000254\newcommand{\bifuncindex}[1]{%
255 \index{#1@{\py@idxcode{#1()}} (built-in function)}}
Fred Drake6659c301998-03-03 22:02:19 +0000256
257% Add an index entry for a module
Fred Drake24340ea1998-04-28 18:30:34 +0000258\newcommand{\py@refmodule}[2]{\index{#1@{\py@idxcode{#1}} (#2module)}}
259\newcommand{\refmodindex}[1]{\py@refmodule{#1}{}}
260\newcommand{\refbimodindex}[1]{\py@refmodule{#1}{built-in }}
261\newcommand{\refexmodindex}[1]{\py@refmodule{#1}{extension }}
262\newcommand{\refstmodindex}[1]{\py@refmodule{#1}{standard }}
Fred Drake6659c301998-03-03 22:02:19 +0000263
Fred Drakeda943741999-01-13 17:09:06 +0000264% Refer to a module's documentation using a hyperlink of the module's
265% name, at least if we're building PDF:
Fred Drakee59feb52001-10-29 21:02:28 +0000266\ifpdf
Fred Drakeaa2aea01999-01-27 17:37:36 +0000267 \newcommand{\refmodule}[2][\py@modulebadkey]{%
Fred Drakeda943741999-01-13 17:09:06 +0000268 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
Fred Drakeaa2aea01999-01-27 17:37:36 +0000269 \py@linkToName{label-module-\py@modulekey}{\module{#2}}%
Fred Drakeda943741999-01-13 17:09:06 +0000270 }
Fred Drakee59feb52001-10-29 21:02:28 +0000271\else
272 \newcommand{\refmodule}[2][\py@modulebadkey]{\module{#2}}
273\fi
Fred Drakeda943741999-01-13 17:09:06 +0000274
Fred Drake6659c301998-03-03 22:02:19 +0000275% support for the module index
Fred Drake24340ea1998-04-28 18:30:34 +0000276\newif\ifpy@UseModuleIndex
277\py@UseModuleIndexfalse
Fred Drakeb390daf1998-03-09 16:35:36 +0000278
Fred Drakeb390daf1998-03-09 16:35:36 +0000279\newcommand{\makemodindex}{
280 \newwrite\modindexfile
281 \openout\modindexfile=mod\jobname.idx
Fred Drake24340ea1998-04-28 18:30:34 +0000282 \py@UseModuleIndextrue
Fred Drakeb390daf1998-03-09 16:35:36 +0000283}
284
Fred Drake0ee9f721998-03-12 06:41:40 +0000285% Add the defining entry for a module
Fred Drake24340ea1998-04-28 18:30:34 +0000286\newcommand{\py@modindex}[2]{%
Fred Drakea488f301998-07-23 17:50:45 +0000287 \renewcommand{\py@thismodule}{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000288 \setindexsubitem{(in module #1)}%
Fred Drake24340ea1998-04-28 18:30:34 +0000289 \index{#1@{\py@idxcode{#1}} (#2module)|textbf}%
290 \ifpy@UseModuleIndex%
Fred Drake0c275fa1999-03-02 16:17:44 +0000291 \@ifundefined{py@modplat@\py@thismodulekey}{
292 \write\modindexfile{\protect\indexentry{#1@{\texttt{#1}}}{\thepage}}%
293 }{\write\modindexfile{\protect\indexentry{#1@{\texttt{#1} %
Fred Drake9466b9a1999-03-18 16:18:27 +0000294 \emph{(\py@platformof[\py@thismodulekey]{})}}}{\thepage}}%
Fred Drake0c275fa1999-03-02 16:17:44 +0000295 }
Fred Drake0ee9f721998-03-12 06:41:40 +0000296 \fi%
297}
298
Fred Drake9466b9a1999-03-18 16:18:27 +0000299% *** XXX *** THE NEXT FOUR MACROS ARE NOW OBSOLETE !!! ***
300
Fred Drake6659c301998-03-03 22:02:19 +0000301% built-in & Python modules in the main distribution
Fred Drake9466b9a1999-03-18 16:18:27 +0000302\newcommand{\bimodindex}[1]{\py@modindex{#1}{built-in }%
303 \typeout{*** MACRO bimodindex IS OBSOLETE -- USE declaremodule INSTEAD!}}
304\newcommand{\stmodindex}[1]{\py@modindex{#1}{standard }%
305 \typeout{*** MACRO stmodindex IS OBSOLETE -- USE declaremodule INSTEAD!}}
Fred Drake6659c301998-03-03 22:02:19 +0000306
307% Python & extension modules outside the main distribution
Fred Drake9466b9a1999-03-18 16:18:27 +0000308\newcommand{\modindex}[1]{\py@modindex{#1}{}%
309 \typeout{*** MACRO modindex IS OBSOLETE -- USE declaremodule INSTEAD!}}
310\newcommand{\exmodindex}[1]{\py@modindex{#1}{extension }%
311 \typeout{*** MACRO exmodindex IS OBSOLETE -- USE declaremodule INSTEAD!}}
Fred Drake6659c301998-03-03 22:02:19 +0000312
313% Additional string for an index entry
Fred Drakeba828782000-04-03 04:19:14 +0000314\newif\ifpy@usingsubitem\py@usingsubitemfalse
315\newcommand{\py@indexsubitem}{}
316\newcommand{\setindexsubitem}[1]{\renewcommand{\py@indexsubitem}{ #1}%
317 \py@usingsubitemtrue}
318\newcommand{\ttindex}[1]{%
319 \ifpy@usingsubitem
320 \index{#1@{\py@idxcode{#1}}\py@indexsubitem}%
321 \else%
322 \index{#1@{\py@idxcode{#1}}}%
323 \fi%
324}
Fred Drake0ee9f721998-03-12 06:41:40 +0000325\newcommand{\withsubitem}[2]{%
326 \begingroup%
Fred Drakeec77e652000-10-30 06:22:22 +0000327 \def\ttindex##1{\index{##1@{\py@idxcode{##1}} #1}}%
328 #2%
Fred Drake0ee9f721998-03-12 06:41:40 +0000329 \endgroup%
330}
Fred Drake6659c301998-03-03 22:02:19 +0000331
Fred Drake53714971998-04-02 22:33:16 +0000332
Fred Drakea488f301998-07-23 17:50:45 +0000333% Module synopsis processing -----------------------------------------------
334%
Fred Drake0c275fa1999-03-02 16:17:44 +0000335\newcommand{\py@thisclass}{}
336\newcommand{\py@thismodule}{}
337\newcommand{\py@thismodulekey}{}
338\newcommand{\py@thismoduletype}{}
339
Fred Drake9466b9a1999-03-18 16:18:27 +0000340\newcommand{\py@standardIndexModule}[1]{\py@modindex{#1}{standard }}
341\newcommand{\py@builtinIndexModule}[1]{\py@modindex{#1}{built-in }}
342\newcommand{\py@extensionIndexModule}[1]{\py@modindex{#1}{extension }}
343\newcommand{\py@IndexModule}[1]{\py@modindex{#1}{}}
Fred Drakea488f301998-07-23 17:50:45 +0000344
Fred Drake0c275fa1999-03-02 16:17:44 +0000345\newif\ifpy@HaveModSynopsis \py@HaveModSynopsisfalse
346\newif\ifpy@ModSynopsisFileIsOpen \py@ModSynopsisFileIsOpenfalse
347\newif\ifpy@HaveModPlatform \py@HaveModPlatformfalse
Fred Drakea488f301998-07-23 17:50:45 +0000348
349% \declaremodule[key]{type}{name}
350\newcommand{\declaremodule}[3][\py@modulebadkey]{
351 \py@openModSynopsisFile
352 \renewcommand{\py@thismoduletype}{#2}
Fred Drakea488f301998-07-23 17:50:45 +0000353 \ifx\py@modulebadkey#1
354 \renewcommand{\py@thismodulekey}{#3}
355 \else
356 \renewcommand{\py@thismodulekey}{#1}
357 \fi
Fred Drake5bc8d991999-05-17 14:47:10 +0000358 \@ifundefined{py@#2IndexModule}{%
359 \typeout{*** MACRO declaremodule called with unknown module type: `#2'}
Fred Drake66823021999-05-17 14:57:26 +0000360 \py@IndexModule{#3}%
Fred Drake5bc8d991999-05-17 14:47:10 +0000361 }{%
362 \csname py@#2IndexModule\endcsname{#3}%
363 }
Fred Drakea488f301998-07-23 17:50:45 +0000364 \label{module-\py@thismodulekey}
Fred Drakea488f301998-07-23 17:50:45 +0000365}
Fred Drake0c275fa1999-03-02 16:17:44 +0000366\newif\ifpy@ModPlatformFileIsOpen \py@ModPlatformFileIsOpenfalse
367\newcommand{\py@ModPlatformFilename}{\jobname.pla}
368\newcommand{\platform}[1]{
369 \ifpy@ModPlatformFileIsOpen\else
370 \newwrite\py@ModPlatformFile
371 \openout\py@ModPlatformFile=\py@ModPlatformFilename
372 \py@ModPlatformFileIsOpentrue
373 \fi
Fred Drake0c275fa1999-03-02 16:17:44 +0000374}
375\InputIfFileExists{\jobname.pla}{}{}
Fred Drake9466b9a1999-03-18 16:18:27 +0000376\newcommand{\py@platformof}[2][\py@modulebadkey]{%
Fred Drake0c275fa1999-03-02 16:17:44 +0000377 \ifx\py@modulebadkey#1 \def\py@key{#2}%
378 \else \def\py@key{#1}%
379 \fi%
380 \csname py@modplat@\py@key\endcsname%
381}
382\newcommand{\ignorePlatformAnnotation}[1]{}
Fred Drakea488f301998-07-23 17:50:45 +0000383
Fred Drakeb75c6151998-08-10 18:41:43 +0000384% \moduleauthor{name}{email}
385\newcommand{\moduleauthor}[2]{}
386
387% \sectionauthor{name}{email}
388\newcommand{\sectionauthor}[2]{}
389
Fred Drakea488f301998-07-23 17:50:45 +0000390
391\newcommand{\py@defsynopsis}{Module has no synopsis.}
392\newcommand{\py@modulesynopsis}{\py@defsynopsis}
393\newcommand{\modulesynopsis}[1]{
Fred Drake0c275fa1999-03-02 16:17:44 +0000394 \py@HaveModSynopsistrue
Fred Drakea488f301998-07-23 17:50:45 +0000395 \renewcommand{\py@modulesynopsis}{#1}
396}
397
398% define the file
399\newwrite\py@ModSynopsisFile
400
401% hacked from \addtocontents from latex.ltx:
402\long\def\py@writeModSynopsisFile#1{%
403 \protected@write\py@ModSynopsisFile%
404 {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
405 {\string#1}%
406}
407\newcommand{\py@closeModSynopsisFile}{
408 \ifpy@ModSynopsisFileIsOpen
409 \closeout\py@ModSynopsisFile
410 \py@ModSynopsisFileIsOpenfalse
411 \fi
412}
413\newcommand{\py@openModSynopsisFile}{
414 \ifpy@ModSynopsisFileIsOpen\else
415 \openout\py@ModSynopsisFile=\py@ModSynopsisFilename
416 \py@ModSynopsisFileIsOpentrue
417 \fi
418}
419
420\newcommand{\py@ProcessModSynopsis}{
421 \ifpy@HaveModSynopsis
422 \py@writeModSynopsisFile{\modulesynopsis%
423 {\py@thismodulekey}{\py@thismodule}%
424 {\py@thismoduletype}{\py@modulesynopsis}}%
425 \py@HaveModSynopsisfalse
426 \fi
427 \renewcommand{\py@modulesynopsis}{\py@defsynopsis}
428}
429\AtEndDocument{\py@ProcessModSynopsis\py@closeModSynopsisFile}
430
Fred Drake0c275fa1999-03-02 16:17:44 +0000431
432\long\def\py@writeModPlatformFile#1{%
433 \protected@write\py@ModPlatformFile%
434 {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
435 {\string#1}%
436}
437
438
Fred Drakea488f301998-07-23 17:50:45 +0000439\newcommand{\localmoduletable}{
440 \IfFileExists{\py@ModSynopsisFilename}{
441 \begin{synopsistable}
442 \input{\py@ModSynopsisFilename}
443 \end{synopsistable}
444 }{}
445}
446
Fred Drakee59feb52001-10-29 21:02:28 +0000447\ifpdf
Fred Drakeaa2aea01999-01-27 17:37:36 +0000448 \newcommand{\py@ModSynopsisSummary}[4]{%
449 \py@linkToName{label-module-#1}{\bfcode{#2}} & #4\\
450 }
Fred Drakee59feb52001-10-29 21:02:28 +0000451\else
452 \newcommand{\py@ModSynopsisSummary}[4]{\bfcode{#2} & #4\\}
453\fi
Fred Drakea488f301998-07-23 17:50:45 +0000454\newenvironment{synopsistable}{
455 % key, name, type, synopsis
456 \let\modulesynopsis=\py@ModSynopsisSummary
457 \begin{tabular}{ll}
458}{
459 \end{tabular}
460}
461%
462% --------------------------------------------------------------------------
463
464
Fred Drakea488f301998-07-23 17:50:45 +0000465\newcommand{\py@reset}{
Fred Drakeba828782000-04-03 04:19:14 +0000466 \py@usingsubitemfalse
Fred Drakea488f301998-07-23 17:50:45 +0000467 \py@ProcessModSynopsis
468 \renewcommand{\py@thisclass}{}
469 \renewcommand{\py@thismodule}{}
470 \renewcommand{\py@thismodulekey}{}
471 \renewcommand{\py@thismoduletype}{}
472}
473
474% Augment the sectioning commands used to get our own font family in place,
475% and reset some internal data items:
476\renewcommand{\section}{\py@reset%
477 \@startsection{section}{1}{\z@}%
478 {-3.5ex \@plus -1ex \@minus -.2ex}%
479 {2.3ex \@plus.2ex}%
480 {\reset@font\Large\py@HeaderFamily}}
481\renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}%
482 {-3.25ex\@plus -1ex \@minus -.2ex}%
483 {1.5ex \@plus .2ex}%
484 {\reset@font\large\py@HeaderFamily}}
485\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}%
486 {-3.25ex\@plus -1ex \@minus -.2ex}%
487 {1.5ex \@plus .2ex}%
488 {\reset@font\normalsize\py@HeaderFamily}}
489\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}%
490 {3.25ex \@plus1ex \@minus.2ex}%
491 {-1em}%
492 {\reset@font\normalsize\py@HeaderFamily}}
493\renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}%
494 {3.25ex \@plus1ex \@minus .2ex}%
495 {-1em}%
496 {\reset@font\normalsize\py@HeaderFamily}}
497
498
Fred Drake5420f331998-07-23 21:41:02 +0000499% This gets the underscores closer to the right width; the only change
500% from standard LaTeX is the width specified.
501
502\DeclareTextCommandDefault{\textunderscore}{%
503 \leavevmode \kern.06em\vbox{\hrule\@width.55em}}
504
Fred Drakea488f301998-07-23 17:50:45 +0000505% Underscore hack (only act like subscript operator if in math mode)
506%
507% The following is due to Mark Wooding (the old version didn't work with
508% Latex 2e.
509
510\DeclareRobustCommand\hackscore{%
511 \ifmmode_\else\textunderscore\fi%
512}
513\begingroup
514\catcode`\_\active
515\def\next{%
516 \AtBeginDocument{\catcode`\_\active\def_{\hackscore{}}}%
517}
518\expandafter\endgroup\next
519
520
Fred Drake53714971998-04-02 22:33:16 +0000521% Now for a lot of semantically-loaded environments that do a ton of magical
522% things to get the right formatting and index entries for the stuff in
523% Python modules and C API.
524
525
Fred Drake6659c301998-03-03 22:02:19 +0000526% {fulllineitems} is used in one place in libregex.tex, but is really for
527% internal use in this file.
528%
Fred Drakef9acc591998-09-09 15:27:43 +0000529\newcommand{\py@itemnewline}[1]{%
530 \@tempdima\linewidth%
531 \advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}%
532}
533
Fred Drake6659c301998-03-03 22:02:19 +0000534\newenvironment{fulllineitems}{
535 \begin{list}{}{\labelwidth \leftmargin \labelsep 0pt
536 \rightmargin 0pt \topsep -\parskip \partopsep \parskip
537 \itemsep -\parsep
Fred Drakef9acc591998-09-09 15:27:43 +0000538 \let\makelabel=\py@itemnewline}
Fred Drake6659c301998-03-03 22:02:19 +0000539}{\end{list}}
540
Fred Drake6cb71491998-03-27 05:22:53 +0000541% \optional is mostly for use in the arguments parameters to the various
542% {*desc} environments defined below, but may be used elsewhere. Known to
543% be used in the debugger chapter.
Fred Drake24340ea1998-04-28 18:30:34 +0000544%
545% Typical usage:
546%
547% \begin{funcdesc}{myfunc}{reqparm\optional{, optparm}}
548% ^^^ ^^^
549% No space here No space here
550%
551% When a function has multiple optional parameters, \optional should be
552% nested, not chained. This is right:
553%
554% \begin{funcdesc}{myfunc}{\optional{parm1\optional{, parm2}}}
555%
Fred Drakeba828782000-04-03 04:19:14 +0000556\let\py@badkey=\@undefined
557
Fred Drake6659c301998-03-03 22:02:19 +0000558\newcommand{\optional}[1]{%
559 {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
560
Fred Drakeba828782000-04-03 04:19:14 +0000561% This can be used when a function or method accepts an varying number
562% of arguments, such as by using the *args syntax in the parameter list.
563\newcommand{\py@moreargs}{...}
564
565% This can be used when you don't want to document the parameters to a
566% function or method, but simply state that it's an alias for
567% something else.
568\newcommand{\py@unspecified}{...}
569
Fred Drake6cb71491998-03-27 05:22:53 +0000570% C functions ------------------------------------------------------------
Fred Drakeba828782000-04-03 04:19:14 +0000571% \begin{cfuncdesc}[refcount]{type}{name}{arglist}
572% Note that the [refcount] slot should only be filled in by
573% tools/anno-api.py; it pulls the value from the refcounts database.
574\newenvironment{cfuncdesc}[4][\py@badkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000575 \begin{fulllineitems}
Fred Drakeba828782000-04-03 04:19:14 +0000576 \item[\code{#2 \bfcode{#3}(\py@varvars{#4})}\index{#3@{\py@idxcode{#3()}}}]
577 \ifx#1\@undefined\else%
Fred Drake0a863da2000-04-10 18:21:38 +0000578 \emph{Return value: \textbf{#1}.}\\
Fred Drakeba828782000-04-03 04:19:14 +0000579 \fi
Fred Drake6cb71491998-03-27 05:22:53 +0000580}{\end{fulllineitems}}
581
582% C variables ------------------------------------------------------------
583% \begin{cvardesc}{type}{name}
584\newenvironment{cvardesc}[2]{
585 \begin{fulllineitems}
Fred Drake24340ea1998-04-28 18:30:34 +0000586 \item[\code{#1 \bfcode{#2}}\index{#2@{\py@idxcode{#2}}}]
Fred Drake6cb71491998-03-27 05:22:53 +0000587}{\end{fulllineitems}}
588
589% C data types -----------------------------------------------------------
Fred Drakeba828782000-04-03 04:19:14 +0000590% \begin{ctypedesc}[index name]{typedef name}
591\newenvironment{ctypedesc}[2][\py@badkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000592 \begin{fulllineitems}
Fred Drakeba828782000-04-03 04:19:14 +0000593 \item[\bfcode{#2}%
594 \ifx#1\@undefined%
Fred Drakea33c5662000-10-29 05:19:16 +0000595 \index{#2@{\py@idxcode{#2}} (C type)}
Fred Drakeba828782000-04-03 04:19:14 +0000596 \else%
Fred Drakea33c5662000-10-29 05:19:16 +0000597 \index{#2@{\py@idxcode{#1}} (C type)}
Fred Drakeba828782000-04-03 04:19:14 +0000598 \fi]
599}{\end{fulllineitems}}
600
601% Funky macros -----------------------------------------------------------
602% \begin{csimplemacro}{name}
603% -- "simple" because it has no args; NOT for constant definitions!
604\newenvironment{csimplemacrodesc}[1]{
605 \begin{fulllineitems}
Fred Drakea33c5662000-10-29 05:19:16 +0000606 \item[\bfcode{#1}\index{#1@{\py@idxcode{#1}} (macro)}]
Fred Drake6cb71491998-03-27 05:22:53 +0000607}{\end{fulllineitems}}
608
609% simple functions (not methods) -----------------------------------------
610% \begin{funcdesc}{name}{args}
Fred Drakeec77e652000-10-30 06:22:22 +0000611\newcommand{\funcline}[2]{%
612 \funclineni{#1}{#2}%
613 \index{#1@{\py@idxcode{#1()}} (in module \py@thismodule)}}
Fred Drake6cb71491998-03-27 05:22:53 +0000614\newenvironment{funcdesc}[2]{
615 \begin{fulllineitems}
616 \funcline{#1}{#2}
617}{\end{fulllineitems}}
618
Fred Drake6659c301998-03-03 22:02:19 +0000619% similar to {funcdesc}, but doesn't add to the index
Fred Drake300775d1998-04-17 02:17:00 +0000620\newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(\py@varvars{#2})}]}
Fred Drake6cb71491998-03-27 05:22:53 +0000621\newenvironment{funcdescni}[2]{
622 \begin{fulllineitems}
623 \funclineni{#1}{#2}
Fred Drake6659c301998-03-03 22:02:19 +0000624}{\end{fulllineitems}}
625
Fred Drake6cb71491998-03-27 05:22:53 +0000626% classes ----------------------------------------------------------------
627% \begin{classdesc}{name}{constructor args}
628\newenvironment{classdesc}[2]{
Fred Drake1cbd1961998-11-25 17:13:28 +0000629 % Using \renewcommand doesn't work for this, for unknown reasons:
630 \global\def\py@thisclass{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000631 \begin{fulllineitems}
Fred Drakeab357ec2001-03-02 18:57:05 +0000632 \item[\strong{class }\code{\bfcode{#1}(\py@varvars{#2})}%
Fred Drakea33c5662000-10-29 05:19:16 +0000633 \index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}]
Fred Drake6659c301998-03-03 22:02:19 +0000634}{\end{fulllineitems}}
635
Fred Drake06a01e82001-05-11 01:00:30 +0000636% \begin{classdesc*}{name}
637\newenvironment{classdesc*}[1]{
638 % Using \renewcommand doesn't work for this, for unknown reasons:
639 \global\def\py@thisclass{#1}
640 \begin{fulllineitems}
641 \item[\strong{class }\code{\bfcode{#1}}%
642 \index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}]
643}{\end{fulllineitems}}
644
Fred Drake4e607962000-09-09 06:01:25 +0000645% \begin{excclassdesc}{name}{constructor args}
646% but indexes as an exception
647\newenvironment{excclassdesc}[2]{
648 % Using \renewcommand doesn't work for this, for unknown reasons:
649 \global\def\py@thisclass{#1}
650 \begin{fulllineitems}
Fred Drakeab357ec2001-03-02 18:57:05 +0000651 \item[\strong{exception }\code{\bfcode{#1}(\py@varvars{#2})}%
Fred Drakea33c5662000-10-29 05:19:16 +0000652 \index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}]
Fred Drake4e607962000-09-09 06:01:25 +0000653}{\end{fulllineitems}}
654
Fred Drake06a01e82001-05-11 01:00:30 +0000655% There is no corresponding {excclassdesc*} environment. To describe
656% a class exception without parameters, use the {excdesc} environment.
657
Fred Drake6cb71491998-03-27 05:22:53 +0000658
Fred Drake24340ea1998-04-28 18:30:34 +0000659\let\py@classbadkey=\@undefined
Fred Drake6cb71491998-03-27 05:22:53 +0000660
661% object method ----------------------------------------------------------
662% \begin{methoddesc}[classname]{methodname}{args}
Fred Drakea33c5662000-10-29 05:19:16 +0000663\newcommand{\methodline}[3][\@undefined]{
Fred Drake6cb71491998-03-27 05:22:53 +0000664 \methodlineni{#2}{#3}
665 \ifx#1\@undefined
Fred Drakea33c5662000-10-29 05:19:16 +0000666 \index{#2@{\py@idxcode{#2()}} (\py@thisclass\ method)}
Fred Drake6cb71491998-03-27 05:22:53 +0000667 \else
Fred Drakea33c5662000-10-29 05:19:16 +0000668 \index{#2@{\py@idxcode{#2()}} (#1 method)}
Fred Drake6cb71491998-03-27 05:22:53 +0000669 \fi
670}
Fred Drakea33c5662000-10-29 05:19:16 +0000671\newenvironment{methoddesc}[3][\@undefined]{
Fred Drake6cb71491998-03-27 05:22:53 +0000672 \begin{fulllineitems}
673 \ifx#1\@undefined
674 \methodline{#2}{#3}
675 \else
Fred Drake24340ea1998-04-28 18:30:34 +0000676 \def\py@thisclass{#1}
Fred Drakea33c5662000-10-29 05:19:16 +0000677 \methodline{#2}{#3}
Fred Drake6cb71491998-03-27 05:22:53 +0000678 \fi
Fred Drake6659c301998-03-03 22:02:19 +0000679}{\end{fulllineitems}}
680
Fred Drake6cb71491998-03-27 05:22:53 +0000681% similar to {methoddesc}, but doesn't add to the index
682% (never actually uses the optional argument)
Fred Drake24340ea1998-04-28 18:30:34 +0000683\newcommand{\methodlineni}[3][\py@classbadkey]{%
Fred Drake300775d1998-04-17 02:17:00 +0000684 \item[\code{\bfcode{#2}(\py@varvars{#3})}]}
Fred Drake24340ea1998-04-28 18:30:34 +0000685\newenvironment{methoddescni}[3][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000686 \begin{fulllineitems}
687 \methodlineni{#2}{#3}
688}{\end{fulllineitems}}
689
690% object data attribute --------------------------------------------------
691% \begin{memberdesc}[classname]{membername}
Fred Drake24340ea1998-04-28 18:30:34 +0000692\newcommand{\memberline}[2][\py@classbadkey]{%
Fred Drake6cb71491998-03-27 05:22:53 +0000693 \ifx#1\@undefined
694 \memberlineni{#2}
Fred Drakea33c5662000-10-29 05:19:16 +0000695 \index{#2@{\py@idxcode{#2}} (\py@thisclass\ attribute)}
Fred Drake6cb71491998-03-27 05:22:53 +0000696 \else
697 \memberlineni{#2}
Fred Drakea33c5662000-10-29 05:19:16 +0000698 \index{#2@{\py@idxcode{#2}} (#1 attribute)}
Fred Drake6cb71491998-03-27 05:22:53 +0000699 \fi
700}
Fred Drake24340ea1998-04-28 18:30:34 +0000701\newenvironment{memberdesc}[2][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000702 \begin{fulllineitems}
703 \ifx#1\@undefined
704 \memberline{#2}
705 \else
Fred Drake24340ea1998-04-28 18:30:34 +0000706 \def\py@thisclass{#1}
Fred Drakea33c5662000-10-29 05:19:16 +0000707 \memberline{#2}
Fred Drake6cb71491998-03-27 05:22:53 +0000708 \fi
709}{\end{fulllineitems}}
710
711% similar to {memberdesc}, but doesn't add to the index
712% (never actually uses the optional argument)
Fred Drake24340ea1998-04-28 18:30:34 +0000713\newcommand{\memberlineni}[2][\py@classbadkey]{\item[\bfcode{#2}]}
714\newenvironment{memberdescni}[2][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000715 \begin{fulllineitems}
716 \memberlineni{#2}
717}{\end{fulllineitems}}
718
719% For exceptions: --------------------------------------------------------
720% \begin{excdesc}{name}
Fred Drakea33c5662000-10-29 05:19:16 +0000721% -- for constructor information, use excclassdesc instead
Fred Drake6cb71491998-03-27 05:22:53 +0000722\newenvironment{excdesc}[1]{
723 \begin{fulllineitems}
Fred Drakeab357ec2001-03-02 18:57:05 +0000724 \item[\strong{exception }\bfcode{#1}%
Fred Drakea33c5662000-10-29 05:19:16 +0000725 \index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}]
Fred Drake6cb71491998-03-27 05:22:53 +0000726}{\end{fulllineitems}}
727
728% Module data or constants: ----------------------------------------------
729% \begin{datadesc}{name}
Fred Drakea33c5662000-10-29 05:19:16 +0000730\newcommand{\dataline}[1]{%
731 \datalineni{#1}\index{#1@{\py@idxcode{#1}} (data in \py@thismodule)}}
Fred Drake6cb71491998-03-27 05:22:53 +0000732\newenvironment{datadesc}[1]{
733 \begin{fulllineitems}
734 \dataline{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000735}{\end{fulllineitems}}
736
737% similar to {datadesc}, but doesn't add to the index
Fred Drake6cb71491998-03-27 05:22:53 +0000738\newcommand{\datalineni}[1]{\item[\bfcode{#1}]\nopagebreak}
739\newenvironment{datadescni}[1]{
740 \begin{fulllineitems}
741 \datalineni{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000742}{\end{fulllineitems}}
743
Fred Drake6cb71491998-03-27 05:22:53 +0000744% bytecode instruction ---------------------------------------------------
745% \begin{opcodedesc}{name}{var}
746% -- {var} may be {}
747\newenvironment{opcodedesc}[2]{
748 \begin{fulllineitems}
749 \item[\bfcode{#1}\quad\var{#2}]
Fred Drake6659c301998-03-03 22:02:19 +0000750}{\end{fulllineitems}}
751
752
Fred Drake24340ea1998-04-28 18:30:34 +0000753\newcommand{\nodename}[1]{\label{#1}}
Fred Drake55730311998-03-25 15:41:23 +0000754
Fred Drake6659c301998-03-03 22:02:19 +0000755% For these commands, use \command{} to get the typography right, not
756% {\command}. This works better with the texinfo translation.
757\newcommand{\ABC}{{\sc abc}}
758\newcommand{\UNIX}{{\sc Unix}}
759\newcommand{\POSIX}{POSIX}
760\newcommand{\ASCII}{{\sc ascii}}
761\newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}}
762\newcommand{\C}{C}
763\newcommand{\EOF}{{\sc eof}}
Fred Drake24340ea1998-04-28 18:30:34 +0000764\newcommand{\NULL}{\constant{NULL}}
Fred Drake5445e5e2001-06-23 03:11:45 +0000765\newcommand{\infinity}{\ensuremath{\infty}}
766\newcommand{\plusminus}{\ensuremath{\pm}}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000767\newcommand{\menuselection}[1]{{\def\sub{ \ensuremath{>} }#1}}
Fred Drake6659c301998-03-03 22:02:19 +0000768
Fred Drake53714971998-04-02 22:33:16 +0000769% Also for consistency: spell Python "Python", not "python"!
770
Fred Drake6659c301998-03-03 22:02:19 +0000771% code is the most difficult one...
Fred Drake46346ec2000-06-30 17:57:05 +0000772\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 +0000773\texttt{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000774
775\newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font
Fred Drake8e54abe1998-07-01 14:49:25 +0000776\newcommand{\kbd}[1]{\code{#1}}
Fred Drake24340ea1998-04-28 18:30:34 +0000777\newcommand{\samp}[1]{`\code{#1}'}
Fred Drake6659c301998-03-03 22:02:19 +0000778% This weird definition of \var{} allows it to always appear in roman
779% italics, and won't get funky in code fragments when we play around
Fred Drakefa1cceb1998-11-30 14:42:59 +0000780% with fonts. This also works directly in math mode.
781\newcommand{\var}[1]{%
782 \ifmmode%
783 \hbox{\normalsize\textrm{\textit{#1\/}}}%
784 \else%
785 \normalsize\textrm{\textit{#1\/}}%
786 \fi%
787}
Fred Drake24340ea1998-04-28 18:30:34 +0000788\renewcommand{\emph}[1]{{\em #1}}
Fred Drake6659c301998-03-03 22:02:19 +0000789\newcommand{\dfn}[1]{\emph{#1}}
790\newcommand{\strong}[1]{{\bf #1}}
791% let's experiment with a new font:
Fred Drake0ee9f721998-03-12 06:41:40 +0000792\newcommand{\file}[1]{`{\small\textsf{#1}}'}
Fred Drake0a0fd591999-04-28 14:59:44 +0000793\newcommand{\filenq}[1]{{\small\textsf{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000794
795% Use this def/redef approach for \url{} since hyperref defined this already,
796% but only if we actually used hyperref:
Fred Drakee59feb52001-10-29 21:02:28 +0000797\ifpdf
798 \newcommand{\url}[1]{{%
Fred Drake53815882002-03-15 23:21:37 +0000799 \pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}%
Fred Drakeab357ec2001-03-02 18:57:05 +0000800 \py@LinkColor% color of the link text
Fred Drakee59feb52001-10-29 21:02:28 +0000801 \small\sf #1%
Fred Drakeab357ec2001-03-02 18:57:05 +0000802 \py@NormalColor% Turn it back off; these are declarative
803 \pdfendlink}% and don't appear bound to the current
804 }% formatting "box".
Fred Drakee59feb52001-10-29 21:02:28 +0000805\else
806 \newcommand{\url}[1]{\mbox{\small\textsf{#1}}}
807\fi
Fred Drake0ee9f721998-03-12 06:41:40 +0000808\newcommand{\email}[1]{{\small\textsf{#1}}}
Fred Drake454a4fb1998-04-01 22:20:14 +0000809\newcommand{\newsgroup}[1]{{\small\textsf{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000810
Fred Drakecc2b81e2000-08-03 17:38:30 +0000811\newcommand{\py@varvars}[1]{{%
Fred Drakeba828782000-04-03 04:19:14 +0000812 {\let\unspecified=\py@unspecified%
813 \let\moreargs=\py@moreargs%
Fred Drakecc2b81e2000-08-03 17:38:30 +0000814 \var{#1}}}}
Fred Drake6659c301998-03-03 22:02:19 +0000815
Fred Drake24340ea1998-04-28 18:30:34 +0000816% I'd really like to get rid of this!
Fred Drake6659c301998-03-03 22:02:19 +0000817\newif\iftexi\texifalse
Fred Drake6659c301998-03-03 22:02:19 +0000818
Fred Drake1e4973b1998-07-28 21:52:17 +0000819% This is used to get l2h to put the copyright and abstract on
820% a separate HTML page.
821\newif\ifhtml\htmlfalse
822
823
Fred Drake6659c301998-03-03 22:02:19 +0000824% These should be used for all references to identifiers which are
825% used to refer to instances of specific language constructs. See the
826% names for specific semantic assignments.
827%
828% For now, don't do anything really fancy with them; just use them as
829% logical markup. This might change in the future.
830%
Fred Drake24340ea1998-04-28 18:30:34 +0000831\newcommand{\module}[1]{\texttt{#1}}
832\newcommand{\keyword}[1]{\texttt{#1}}
833\newcommand{\exception}[1]{\texttt{#1}}
834\newcommand{\class}[1]{\texttt{#1}}
835\newcommand{\function}[1]{\texttt{#1}}
836\newcommand{\member}[1]{\texttt{#1}}
837\newcommand{\method}[1]{\texttt{#1}}
Fred Drake6659c301998-03-03 22:02:19 +0000838
Fred Drakeab357ec2001-03-02 18:57:05 +0000839\newcommand{\pytype}[1]{#1} % built-in Python type
Fred Drake53714971998-04-02 22:33:16 +0000840
Fred Drake24340ea1998-04-28 18:30:34 +0000841\newcommand{\cfunction}[1]{\texttt{#1}}
Fred Drakeab357ec2001-03-02 18:57:05 +0000842\newcommand{\ctype}[1]{\texttt{#1}} % C struct or typedef name
843\newcommand{\cdata}[1]{\texttt{#1}} % C variable, typically global
Fred Drake6659c301998-03-03 22:02:19 +0000844
Fred Drake479384e2001-09-26 18:46:36 +0000845\newcommand{\mailheader}[1]{{\small\textsf{#1:}}}
Fred Drake0ee9f721998-03-12 06:41:40 +0000846\newcommand{\mimetype}[1]{{\small\textsf{#1}}}
Fred Drake94fac131998-03-12 19:37:03 +0000847% The \! is a "negative thin space" in math mode.
848\newcommand{\regexp}[1]{%
849 {\tiny$^{^\lceil}\!\!$%
850 {\normalsize\code{#1}}%
Fred Drake47cfd031998-04-03 21:22:31 +0000851 $\!\rfloor\!$%
Fred Drake94fac131998-03-12 19:37:03 +0000852 }}
Fred Drake0ee9f721998-03-12 06:41:40 +0000853\newcommand{\envvar}[1]{%
Fred Drake31ab2982001-01-22 17:50:42 +0000854 #1%
Fred Drakee59feb52001-10-29 21:02:28 +0000855 \index{#1}%
Fred Drake31ab2982001-01-22 17:50:42 +0000856 \index{environment variables!{#1}}%
Fred Drake0ee9f721998-03-12 06:41:40 +0000857}
Fred Drakeab357ec2001-03-02 18:57:05 +0000858\newcommand{\makevar}[1]{#1} % variable in a Makefile
Fred Drake24340ea1998-04-28 18:30:34 +0000859\newcommand{\character}[1]{\samp{#1}}
Fred Drake0ee9f721998-03-12 06:41:40 +0000860
Fred Drake6659c301998-03-03 22:02:19 +0000861% constants defined in Python modules or C headers, not language constants:
Fred Drakeab357ec2001-03-02 18:57:05 +0000862\newcommand{\constant}[1]{\code{#1}} % manifest constant, not syntactic
Fred Drake6659c301998-03-03 22:02:19 +0000863
864\newcommand{\manpage}[2]{{\emph{#1}(#2)}}
Fred Drake4e607962000-09-09 06:01:25 +0000865\newcommand{\pep}[1]{PEP #1\index{Python Enhancement Proposals!PEP #1}}
Fred Drake6659c301998-03-03 22:02:19 +0000866\newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}}
867\newcommand{\program}[1]{\strong{#1}}
Fred Drake7b8195a1999-11-09 17:02:11 +0000868\newcommand{\programopt}[1]{\strong{#1}}
Fred Drake49362492000-04-11 18:47:59 +0000869% Note that \longprogramopt provides the '--'!
870\newcommand{\longprogramopt}[1]{\strong{-{}-#1}}
Fred Drakee59feb52001-10-29 21:02:28 +0000871
Fred Drakeb4b64da2001-07-06 22:44:48 +0000872% \ulink{link text}{URL}
Fred Drakee59feb52001-10-29 21:02:28 +0000873\ifpdf
874 % The \noindent here is a hack -- we're forcing pdfTeX into
Fred Drake53815882002-03-15 23:21:37 +0000875 % horizontal mode since \pdfstartlink requires that.
Fred Drakee59feb52001-10-29 21:02:28 +0000876 \newcommand{\ulink}[2]{\noindent{%
Fred Drake53815882002-03-15 23:21:37 +0000877 \pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#2)}%
Fred Drakee59feb52001-10-29 21:02:28 +0000878 \py@LinkColor% color of the link text
879 #1%
880 \py@NormalColor% Turn it back off; these are declarative
881 \pdfendlink}% and don't appear bound to the current
882 }% formatting "box".
883\else
884 \newcommand{\ulink}[2]{#1}
885\fi
Fred Drake7b8195a1999-11-09 17:02:11 +0000886
887% cited titles: \citetitle{Title of Work}
888% online: \citetitle[url-to-resource]{Title of Work}
Fred Drakee59feb52001-10-29 21:02:28 +0000889\ifpdf
890 \newcommand{\citetitle}[2][\py@modulebadkey]{%
891 \ifx\py@modulebadkey#1\emph{#2}\else\ulink{\emph{#2}}{#1}\fi%
892 }
893\else
Fred Drake622087a2001-11-02 20:53:19 +0000894 \newcommand{\citetitle}[2][URL]{\emph{#2}}
Fred Drakee59feb52001-10-29 21:02:28 +0000895\fi
896
Fred Drake6659c301998-03-03 22:02:19 +0000897
898
Fred Drakec82bd722001-12-11 18:47:36 +0000899% This version is being checked in for the historical record; it shows
900% how I've managed to get some aspects of this to work. It will not
901% be used in practice, so a subsequent revision will change things
902% again. This version has problems, but shows how to do something
903% that proved more tedious than I'd expected, so I don't want to lose
904% the example completely.
905%
Fred Drake16bb4192001-08-20 21:36:38 +0000906\newcommand{\grammartoken}[1]{\texttt{#1}}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000907\newenvironment{productionlist}[1][\py@badkey]{
908 \def\optional##1{{\Large[}##1{\Large]}}
909 \def\production##1##2{\code{##1}&::=&\code{##2}\\}
Fred Drake53815882002-03-15 23:21:37 +0000910 \def\productioncont##1{& &\code{##1}\\}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000911 \def\token##1{##1}
Fred Drake16bb4192001-08-20 21:36:38 +0000912 \let\grammartoken=\token
Fred Drakec82bd722001-12-11 18:47:36 +0000913 \parindent=2em
914 \indent
915 \begin{tabular}{lcl}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000916}{%
Fred Drakec82bd722001-12-11 18:47:36 +0000917 \end{tabular}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000918}
919
Fred Drake6ca33772001-12-14 22:50:06 +0000920\newcommand{\py@noticelabel@note}{Note:}
921\newcommand{\py@noticelabel@warning}{Warning:}
922\newenvironment{notice}[1][note]{
923 \par\strong{\csname py@noticelabel@#1\endcsname}
924}{}
925\newcommand{\note}[1]{\strong{\py@noticelabel@note} #1}
926\newcommand{\warning}[1]{\strong{\py@noticelabel@warning} #1}
Fred Drake92350b32001-10-09 18:01:23 +0000927
Fred Drake6659c301998-03-03 22:02:19 +0000928% Deprecation stuff.
929% Should be extended to allow an index / list of deprecated stuff. But
930% there's a lot of stuff that needs to be done to make that automatable.
931%
932% First parameter is the release number that deprecates the feature, the
933% second is the action the should be taken by users of the feature.
934%
935% Example:
Fred Drake24340ea1998-04-28 18:30:34 +0000936% \deprecated{1.5.1}{Use \method{frobnicate()} instead.}
Fred Drake6659c301998-03-03 22:02:19 +0000937%
938\newcommand{\deprecated}[2]{%
939 \strong{Deprecated since release #1.} #2\par}
940
Fred Drakeaf958c71998-07-27 20:32:33 +0000941% New stuff.
942% This should be used to mark things which have been added to the
943% development tree but that aren't in the release, but are documented.
944% This allows release of documentation that already includes updated
Fred Drake2116d981999-02-02 18:02:48 +0000945% descriptions. Place at end of descriptor environment.
Fred Drakeaf958c71998-07-27 20:32:33 +0000946%
947% Example:
948% \versionadded{1.5.2}
Fred Drake46346ec2000-06-30 17:57:05 +0000949% \versionchanged[short explanation]{2.0}
Fred Drakeaf958c71998-07-27 20:32:33 +0000950%
Fred Drakefdfb05b2001-04-18 03:08:54 +0000951\newcommand{\versionadded}[2][\py@badkey]{%
952 \ifx#1\@undefined%
953 { New in version #2. }%
954 \else%
955 { New in version #2:\ #1. }%
956 \fi%
957}
Fred Drakea6e83392000-05-02 17:28:36 +0000958\newcommand{\versionchanged}[2][\py@badkey]{%
959 \ifx#1\@undefined%
960 { Changed in version #2. }%
961 \else%
962 { Changed in version #2:\ #1. }%
963 \fi%
964}
Fred Drake6659c301998-03-03 22:02:19 +0000965
Fred Drakeaf958c71998-07-27 20:32:33 +0000966
967% Tables.
968%
Fred Drake6659c301998-03-03 22:02:19 +0000969\newenvironment{tableii}[4]{%
970 \begin{center}%
971 \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
Fred Drakef61eac42000-10-24 02:18:30 +0000972 \begin{tabular}{#1}\strong{#3}&\strong{#4} \\* \hline%
Fred Drake6659c301998-03-03 22:02:19 +0000973}{%
Fred Drake6659c301998-03-03 22:02:19 +0000974 \end{tabular}%
975 \end{center}%
976}
977
Fred Drakeda72b932000-09-21 15:58:02 +0000978\newenvironment{longtableii}[4]{%
979 \begin{center}%
980 \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
Fred Drakef61eac42000-10-24 02:18:30 +0000981 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4} \\* \hline\endhead%
Fred Drakeda72b932000-09-21 15:58:02 +0000982}{%
983 \end{longtable}%
984 \end{center}%
985}
986
Fred Drake6659c301998-03-03 22:02:19 +0000987\newenvironment{tableiii}[5]{%
988 \begin{center}%
989 \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
Fred Drakeda72b932000-09-21 15:58:02 +0000990 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5} \\%
Fred Drakef61eac42000-10-24 02:18:30 +0000991 \hline%
Fred Drake6659c301998-03-03 22:02:19 +0000992}{%
Fred Drake6659c301998-03-03 22:02:19 +0000993 \end{tabular}%
994 \end{center}%
995}
996
Fred Drakeda72b932000-09-21 15:58:02 +0000997\newenvironment{longtableiii}[5]{%
998 \begin{center}%
999 \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
1000 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5} \\%
Fred Drakef61eac42000-10-24 02:18:30 +00001001 \hline\endhead%
Fred Drakeda72b932000-09-21 15:58:02 +00001002}{%
1003 \end{longtable}%
1004 \end{center}%
1005}
1006
Fred Drake30e52651998-07-24 22:11:29 +00001007\newenvironment{tableiv}[6]{%
1008 \begin{center}%
1009 \def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}%
1010 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6} \\%
Fred Drakef61eac42000-10-24 02:18:30 +00001011 \hline%
Fred Drake30e52651998-07-24 22:11:29 +00001012}{%
1013 \end{tabular}%
1014 \end{center}%
1015}
1016
Fred Drakeda72b932000-09-21 15:58:02 +00001017\newenvironment{longtableiv}[6]{%
1018 \begin{center}%
1019 \def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}%
1020 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}%
1021 \\%
Fred Drakef61eac42000-10-24 02:18:30 +00001022 \hline\endhead%
Fred Drakeda72b932000-09-21 15:58:02 +00001023}{%
1024 \end{longtable}%
1025 \end{center}%
1026}
1027
Fred Drakef269e592001-07-17 23:05:57 +00001028\newenvironment{tablev}[7]{%
1029 \begin{center}%
1030 \def\linev##1##2##3##4##5{\csname#2\endcsname{##1}&##2&##3&##4&##5\\}%
1031 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}&\strong{#7} \\%
1032 \hline%
1033}{%
1034 \end{tabular}%
1035 \end{center}%
1036}
1037
1038\newenvironment{longtablev}[7]{%
1039 \begin{center}%
1040 \def\linev##1##2##3##4##5{\csname#2\endcsname{##1}&##2&##3&##4&##5\\}%
1041 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}&\strong{#7}%
1042 \\%
1043 \hline\endhead%
1044}{%
1045 \end{longtable}%
1046 \end{center}%
1047}
1048
Fred Drake24340ea1998-04-28 18:30:34 +00001049% Cross-referencing (AMK, new impl. FLD)
Fred Drake6659c301998-03-03 22:02:19 +00001050% Sample usage:
1051% \begin{seealso}
Fred Drake84bd6f31999-05-11 15:42:51 +00001052% \seemodule{rand}{Uniform random number generator.}; % Module xref
1053% \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book
Fred Drakeebcb6581998-03-06 21:25:17 +00001054%
1055% % A funky case: module name contains '_'; have to supply an optional key
Fred Drake84bd6f31999-05-11 15:42:51 +00001056% \seemodule[copyreg]{copy_reg}{Interface constructor registration for
1057% \module{pickle}.}
Fred Drake6659c301998-03-03 22:02:19 +00001058% \end{seealso}
Fred Drake84bd6f31999-05-11 15:42:51 +00001059%
1060% Note that the last parameter for \seemodule and \seetext should be complete
1061% sentences and be terminated with the proper punctuation.
Fred Drake6659c301998-03-03 22:02:19 +00001062
Fred Drakee59feb52001-10-29 21:02:28 +00001063\ifpdf
Fred Drake24340ea1998-04-28 18:30:34 +00001064 \newcommand{\py@seemodule}[3][\py@modulebadkey]{%
Fred Drakeda943741999-01-13 17:09:06 +00001065 \par%
Fred Drake24340ea1998-04-28 18:30:34 +00001066 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
Fred Drake84bd6f31999-05-11 15:42:51 +00001067 \begin{fulllineitems}
Fred Drake84bd6f31999-05-11 15:42:51 +00001068 \item[\py@linkToName{label-module-\py@modulekey}{Module \module{#2}}
1069 (section \ref{module-\py@modulekey}):]
1070 #3
1071 \end{fulllineitems}
Fred Drakeebcb6581998-03-06 21:25:17 +00001072 }
Fred Drakee59feb52001-10-29 21:02:28 +00001073\else
1074 \newcommand{\py@seemodule}[3][\py@modulebadkey]{%
1075 \par%
1076 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
1077 \begin{fulllineitems}
1078 \item[Module \module{#2} (section \ref{module-\py@modulekey}):]
1079 #3
1080 \end{fulllineitems}
1081 }
1082\fi
1083
Fred Drake48449982000-09-12 17:52:33 +00001084% \seetitle[url]{title}{why it's interesting}
1085\newcommand{\py@seetitle}[3][\py@modulebadkey]{%
1086 \par
1087 \begin{fulllineitems}
1088 \item[\citetitle{#2}]
1089 \ifx\py@modulebadkey#1\else
1090 \item[{\small{(\url{#1})}}]
1091 \fi
1092 #3
1093 \end{fulllineitems}
1094}
Fred Drake4e607962000-09-09 06:01:25 +00001095% \seepep{number}{title}{why it's interesting}
1096\newcommand{\py@seepep}[3]{%
1097 \par%
1098 \begin{fulllineitems}
1099 \item[\pep{#1}, ``\emph{#2}'']
1100 #3
1101 \end{fulllineitems}
1102}
Fred Drake64b72b62000-04-26 18:13:58 +00001103% \seerfc{number}{title}{why it's interesting}
1104\newcommand{\py@seerfc}[3]{%
1105 \par%
1106 \begin{fulllineitems}
1107 \item[\rfc{#1}, ``\emph{#2}'']
1108 #3
1109 \end{fulllineitems}
1110}
Fred Drake51313f12000-05-09 16:18:44 +00001111% \seeurl{url}{why it's interesting}
1112\newcommand{\py@seeurl}[2]{%
1113 \par%
1114 \begin{fulllineitems}
1115 \item[\url{#1}]
1116 #2
1117 \end{fulllineitems}
1118}
Fred Drake5ed35fd2001-11-30 18:09:54 +00001119
1120\newenvironment{seealso*}{
Fred Drake9466b9a1999-03-18 16:18:27 +00001121 \par
Fred Drake6659c301998-03-03 22:02:19 +00001122 \def\seetext##1{\par{##1}}
Fred Drake24340ea1998-04-28 18:30:34 +00001123 \let\seemodule=\py@seemodule
Fred Drake48449982000-09-12 17:52:33 +00001124 \let\seepep=\py@seepep
Fred Drake64b72b62000-04-26 18:13:58 +00001125 \let\seerfc=\py@seerfc
Fred Drake48449982000-09-12 17:52:33 +00001126 \let\seetitle=\py@seetitle
Fred Drake51313f12000-05-09 16:18:44 +00001127 \let\seeurl=\py@seeurl
Fred Drake6659c301998-03-03 22:02:19 +00001128}{\par}
Fred Drake5ed35fd2001-11-30 18:09:54 +00001129\newenvironment{seealso}{
1130 \par
1131 \strong{See Also:}
1132 \par
1133 \def\seetext##1{\par{##1}}
1134 \let\seemodule=\py@seemodule
1135 \let\seepep=\py@seepep
1136 \let\seerfc=\py@seerfc
1137 \let\seetitle=\py@seetitle
1138 \let\seeurl=\py@seeurl
1139}{\par}
Fred Drake6659c301998-03-03 22:02:19 +00001140
Fred Drakeaf958c71998-07-27 20:32:33 +00001141% Allow the Python release number to be specified independently of the
Fred Drake6659c301998-03-03 22:02:19 +00001142% \date{}. This allows the date to reflect the document's date and
1143% release to specify the Python release that is documented.
1144%
Fred Drake24340ea1998-04-28 18:30:34 +00001145\newcommand{\py@release}{}
Fred Drake6659c301998-03-03 22:02:19 +00001146\newcommand{\version}{}
Fred Drakeaf2b7142000-09-14 20:11:05 +00001147\newcommand{\shortversion}{}
Fred Drakec65218e2001-06-20 21:17:09 +00001148\newcommand{\releaseinfo}{}
Fred Drake6659c301998-03-03 22:02:19 +00001149\newcommand{\releasename}{Release}
1150\newcommand{\release}[1]{%
Fred Drake24340ea1998-04-28 18:30:34 +00001151 \renewcommand{\py@release}{\releasename\space\version}%
Fred Drake6659c301998-03-03 22:02:19 +00001152 \renewcommand{\version}{#1}}
Fred Drakeaf2b7142000-09-14 20:11:05 +00001153\newcommand{\setshortversion}[1]{%
1154 \renewcommand{\shortversion}{#1}}
Fred Drakec65218e2001-06-20 21:17:09 +00001155\newcommand{\setreleaseinfo}[1]{%
1156 \renewcommand{\releaseinfo}{#1}}
Fred Drake6659c301998-03-03 22:02:19 +00001157
1158% Allow specification of the author's address separately from the
1159% author's name. This can be used to format them differently, which
1160% is a good thing.
1161%
Fred Drake24340ea1998-04-28 18:30:34 +00001162\newcommand{\py@authoraddress}{}
1163\newcommand{\authoraddress}[1]{\renewcommand{\py@authoraddress}{#1}}
Fred Drake6df93ef1998-05-14 20:56:31 +00001164\let\developersaddress=\authoraddress
1165\let\developer=\author
1166\let\developers=\author
Fred Drake6659c301998-03-03 22:02:19 +00001167
Fred Drake6659c301998-03-03 22:02:19 +00001168% This sets up the fancy chapter headings that make the documents look
1169% at least a little better than the usual LaTeX output.
1170%
Fred Drake1c8d0e01998-03-07 05:29:15 +00001171\@ifundefined{ChTitleVar}{}{
Fred Drake24340ea1998-04-28 18:30:34 +00001172 \ChNameVar{\raggedleft\normalsize\py@HeaderFamily}
1173 \ChNumVar{\raggedleft \bfseries\Large\py@HeaderFamily}
1174 \ChTitleVar{\raggedleft \rm\Huge\py@HeaderFamily}
Fred Drake6659c301998-03-03 22:02:19 +00001175 % This creates chapter heads without the leading \vspace*{}:
Fred Drake1c8d0e01998-03-07 05:29:15 +00001176 \def\@makechapterhead#1{%
1177 {\parindent \z@ \raggedright \normalfont
1178 \ifnum \c@secnumdepth >\m@ne
Fred Drake6659c301998-03-03 22:02:19 +00001179 \DOCH
1180 \fi
Fred Drake1c8d0e01998-03-07 05:29:15 +00001181 \interlinepenalty\@M
Fred Drake6659c301998-03-03 22:02:19 +00001182 \DOTI{#1}
1183 }
1184 }
Fred Drake6659c301998-03-03 22:02:19 +00001185}
1186
Fred Drake3bf78651998-05-20 17:42:17 +00001187
1188% Definition lists; requested by AMK for HOWTO documents. Probably useful
1189% elsewhere as well, so keep in in the general style support.
1190%
1191\newenvironment{definitions}{%
1192 \begin{description}%
Fred Drakef9acc591998-09-09 15:27:43 +00001193 \def\term##1{\item[##1]\mbox{}\\*[0mm]}
Fred Drake3bf78651998-05-20 17:42:17 +00001194}{%
1195 \end{description}%
1196}
1197
Fred Drake6659c301998-03-03 22:02:19 +00001198% Tell TeX about pathological hyphenation cases:
1199\hyphenation{Base-HTTP-Re-quest-Hand-ler}