blob: 021ba5c6e1215ca5d709f9c6fe77aad2118695ad [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 %
51 % Macro that takes two args: the name to link to and the content of
52 % the link. This takes care of the PDF magic, getting the colors
53 % the same for each link, and avoids having lots of garbage all over
54 % this style file.
55 \newcommand{\py@linkToName}[2]{%
56 \pdfannotlink attr{/Border [0 0 0]} goto name{#1}%
57 \py@LinkColor#2\py@NormalColor%
58 \pdfendlink%
59 }
Fred Drakea2c2a831998-04-15 17:50:01 +000060 % Compute the padded page number separately since we end up with a pair of
61 % \relax tokens; this gets the right string computed and works.
Fred Drake6659c301998-03-03 22:02:19 +000062 \renewcommand{\contentsline}[3]{%
Fred Drakea2c2a831998-04-15 17:50:01 +000063 \def\my@pageno{\py@targetno{#3}}%
Fred Drakeaa2aea01999-01-27 17:37:36 +000064 \py@OldContentsline{#1}{\py@linkToName{page\my@pageno}{#2}}{#3}%
Fred Drake6659c301998-03-03 22:02:19 +000065 }
Fred Drakeebcb6581998-03-06 21:25:17 +000066 \AtEndDocument{
Fred Drakec0b2e451998-03-25 14:53:43 +000067 \InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{}
Fred Drakeebcb6581998-03-06 21:25:17 +000068 }
Fred Drakea2c2a831998-04-15 17:50:01 +000069 \newcommand{\py@target}[1]{%
Fred Drake24340ea1998-04-28 18:30:34 +000070 \ifpy@doing@page@targets%
Fred Drake9b8afde1999-03-24 14:16:17 +000071 {\pdfdest name{#1} xyz}%
Fred Drakea2c2a831998-04-15 17:50:01 +000072 \fi%
73 }
Fred Drake24340ea1998-04-28 18:30:34 +000074 \let\py@OldLabel=\label
Fred Drake6659c301998-03-03 22:02:19 +000075 \renewcommand{\label}[1]{%
Fred Drake24340ea1998-04-28 18:30:34 +000076 \py@OldLabel{#1}%
Fred Drakea2c2a831998-04-15 17:50:01 +000077 \py@target{label-#1}%
Fred Drake6659c301998-03-03 22:02:19 +000078 }
Fred Drakeba1700c1998-05-11 20:42:54 +000079 % This stuff adds a page# destination to every PDF page, where # is three
80 % digits wide, padded with leading zeros. This doesn't really help with
81 % the frontmatter, but does fine with the body.
Fred Drake6659c301998-03-03 22:02:19 +000082 %
83 % This is *heavily* based on the hyperref package.
84 %
Fred Drake1c8d0e01998-03-07 05:29:15 +000085 \def\@begindvi{%
86 \unvbox \@begindvibox
87 \@hyperfixhead
Fred Drake6659c301998-03-03 22:02:19 +000088 }
Fred Drake1c8d0e01998-03-07 05:29:15 +000089 \def\@hyperfixhead{%
90 \let\H@old@thehead\@thehead
Fred Drakea2c2a831998-04-15 17:50:01 +000091 \global\def\@foo{\py@target{page\py@pageno}}%
Fred Drake1c8d0e01998-03-07 05:29:15 +000092 \expandafter\ifx\expandafter\@empty\H@old@thehead
93 \def\H@old@thehead{\hfil}\fi
94 \def\@thehead{\@foo\relax\H@old@thehead}%
Fred Drake6659c301998-03-03 22:02:19 +000095 }
Fred Drakec0b2e451998-03-25 14:53:43 +000096\fi\fi
Fred Drake6659c301998-03-03 22:02:19 +000097
98% Increase printable page size (copied from fullpage.sty)
99\topmargin 0pt
100\advance \topmargin by -\headheight
101\advance \topmargin by -\headsep
102
103% attempt to work a little better for A4 users
Fred Drake9466b9a1999-03-18 16:18:27 +0000104\textheight \paperheight
105\advance\textheight by -2in
Fred Drake6659c301998-03-03 22:02:19 +0000106
107\oddsidemargin 0pt
Fred Drake9466b9a1999-03-18 16:18:27 +0000108\evensidemargin 0pt
109%\evensidemargin -.25in % for ``manual size'' documents
Fred Drake6659c301998-03-03 22:02:19 +0000110\marginparwidth 0.5in
111
Fred Drake9466b9a1999-03-18 16:18:27 +0000112\textwidth \paperwidth
113\advance\textwidth by -2in
Fred Drake6659c301998-03-03 22:02:19 +0000114
115
116% Style parameters and macros used by most documents here
117\raggedbottom
118\sloppy
119\parindent = 0mm
Fred Drake24340ea1998-04-28 18:30:34 +0000120\parskip = 2mm
Fred Drakeab357ec2001-03-02 18:57:05 +0000121\hbadness = 5000 % don't print trivial gripes
Fred Drake6659c301998-03-03 22:02:19 +0000122
Fred Drakeab357ec2001-03-02 18:57:05 +0000123\pagestyle{empty} % start this way; change for
124\pagenumbering{roman} % ToC & chapters
Fred Drake6659c301998-03-03 22:02:19 +0000125
126% Use this to set the font family for headers and other decor:
Fred Drake24340ea1998-04-28 18:30:34 +0000127\newcommand{\py@HeaderFamily}{\sffamily}
Fred Drake6659c301998-03-03 22:02:19 +0000128
129% Redefine the 'normal' header/footer style when using "fancyhdr" package:
Fred Drake1c8d0e01998-03-07 05:29:15 +0000130\@ifundefined{fancyhf}{}{
Fred Drake6659c301998-03-03 22:02:19 +0000131 % Use \pagestyle{normal} as the primary pagestyle for text.
132 \fancypagestyle{normal}{
133 \fancyhf{}
Fred Drake24340ea1998-04-28 18:30:34 +0000134 \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
135 \fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}}
136 \fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}}
Fred Drake6659c301998-03-03 22:02:19 +0000137 \renewcommand{\headrulewidth}{0pt}
138 \renewcommand{\footrulewidth}{0.4pt}
139 }
140 % Update the plain style so we get the page number & footer line,
141 % but not a chapter or section title. This is to keep the first
142 % page of a chapter and the blank page between chapters `clean.'
143 \fancypagestyle{plain}{
144 \fancyhf{}
Fred Drake24340ea1998-04-28 18:30:34 +0000145 \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
Fred Drake6659c301998-03-03 22:02:19 +0000146 \renewcommand{\headrulewidth}{0pt}
147 \renewcommand{\footrulewidth}{0.4pt}
148 }
149 % Redefine \cleardoublepage so that the blank page between chapters
150 % gets the plain style and not the fancy style. This is described
151 % in the documentation for the fancyhdr package by Piet von Oostrum.
Fred Drake1c8d0e01998-03-07 05:29:15 +0000152 \@ifundefined{chapter}{}{
Fred Drake28f13911998-03-04 21:47:59 +0000153 \renewcommand{\cleardoublepage}{
Fred Drake1c8d0e01998-03-07 05:29:15 +0000154 \clearpage\if@openright \ifodd\c@page\else
Fred Drake28f13911998-03-04 21:47:59 +0000155 \hbox{}
156 \thispagestyle{plain}
157 \newpage
Fred Drake1c8d0e01998-03-07 05:29:15 +0000158 \if@twocolumn\hbox{}\newpage\fi\fi\fi
Fred Drake28f13911998-03-04 21:47:59 +0000159 }
160 }
Fred Drake6659c301998-03-03 22:02:19 +0000161}
162
Fred Drake6659c301998-03-03 22:02:19 +0000163% This sets up the {verbatim} environment to be indented and a minipage,
164% and to have all the other mostly nice properties that we want for
165% code samples.
166
Fred Drake9466b9a1999-03-18 16:18:27 +0000167\let\py@OldVerbatim=\verbatim
168\let\py@OldEndVerbatim=\endverbatim
169\RequirePackage{verbatim}
170
Fred Drake6659c301998-03-03 22:02:19 +0000171% Variable used by begin code command
Fred Drake24340ea1998-04-28 18:30:34 +0000172\newlength{\py@codewidth}
Fred Drake6659c301998-03-03 22:02:19 +0000173
Fred Drake6659c301998-03-03 22:02:19 +0000174\renewcommand{\verbatim}{%
Fred Drake9466b9a1999-03-18 16:18:27 +0000175 \setlength{\parindent}{1cm}%
Fred Drake6659c301998-03-03 22:02:19 +0000176 % Calculate the text width for the minipage:
Fred Drake24340ea1998-04-28 18:30:34 +0000177 \setlength{\py@codewidth}{\linewidth}%
178 \addtolength{\py@codewidth}{-\parindent}%
Fred Drake6659c301998-03-03 22:02:19 +0000179 %
Fred Drake9466b9a1999-03-18 16:18:27 +0000180 \par\indent%
Fred Drake24340ea1998-04-28 18:30:34 +0000181 \begin{minipage}[t]{\py@codewidth}%
Fred Drake6659c301998-03-03 22:02:19 +0000182 \small%
Fred Drake24340ea1998-04-28 18:30:34 +0000183 \py@OldVerbatim%
Fred Drake6659c301998-03-03 22:02:19 +0000184}
185\renewcommand{\endverbatim}{%
Fred Drake24340ea1998-04-28 18:30:34 +0000186 \py@OldEndVerbatim%
Fred Drake6659c301998-03-03 22:02:19 +0000187 \end{minipage}%
Fred Drake6659c301998-03-03 22:02:19 +0000188}
189
Fred Drakeb5309a92001-04-10 15:53:06 +0000190% This does a similar thing for the {alltt} environment:
191\RequirePackage{alltt}
192\let\py@OldAllTT=\alltt
193\let\py@OldEndAllTT=\endalltt
194
195\renewcommand{\alltt}{%
196 \setlength{\parindent}{1cm}%
197 % Calculate the text width for the minipage:
198 \setlength{\py@codewidth}{\linewidth}%
199 \addtolength{\py@codewidth}{-\parindent}%
200 %
201 \par\indent%
202 \begin{minipage}[t]{\py@codewidth}%
203 \small%
204 \py@OldAllTT%
205}
206\renewcommand{\endalltt}{%
207 \py@OldEndAllTT%
208 \end{minipage}%
209}
210
Fred Drake6cb71491998-03-27 05:22:53 +0000211
Fred Drakea488f301998-07-23 17:50:45 +0000212\newcommand{\py@modulebadkey}{{--just-some-junk--}}
Fred Drake6659c301998-03-03 22:02:19 +0000213
Fred Drake6659c301998-03-03 22:02:19 +0000214
215%% Lots of index-entry generation support.
216
217% Command to wrap around stuff that refers to function / module /
218% attribute names in the index. Default behavior: like \code{}. To
219% just keep the index entries in the roman font, uncomment the second
Fred Drakea488f301998-07-23 17:50:45 +0000220% definition; it matches O'Reilly style more.
Fred Drake6659c301998-03-03 22:02:19 +0000221%
Fred Drake24340ea1998-04-28 18:30:34 +0000222\newcommand{\py@idxcode}[1]{\texttt{#1}}
223%\renewcommand{\py@idxcode}[1]{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000224
225% Command to generate two index entries (using subentries)
226\newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}}
227
228% And three entries (using only one level of subentries)
229\newcommand{\indexiii}[3]{\index{#1!#2 #3}\index{#2!#3, #1}\index{#3!#1 #2}}
230
231% And four (again, using only one level of subentries)
232\newcommand{\indexiv}[4]{
233\index{#1!#2 #3 #4}
234\index{#2!#3 #4, #1}
235\index{#3!#4, #1 #2}
236\index{#4!#1 #2 #3}
237}
238
239% Command to generate a reference to a function, statement, keyword,
240% operator.
Fred Drake0cabff91998-05-06 19:36:01 +0000241\newcommand{\kwindex}[1]{\indexii{keyword}{#1@{\py@idxcode{#1}}}}
Fred Drake24340ea1998-04-28 18:30:34 +0000242\newcommand{\stindex}[1]{\indexii{statement}{#1@{\py@idxcode{#1}}}}
243\newcommand{\opindex}[1]{\indexii{operator}{#1@{\py@idxcode{#1}}}}
244\newcommand{\exindex}[1]{\indexii{exception}{#1@{\py@idxcode{#1}}}}
Fred Drake6659c301998-03-03 22:02:19 +0000245\newcommand{\obindex}[1]{\indexii{object}{#1}}
Fred Drakea33c5662000-10-29 05:19:16 +0000246\newcommand{\bifuncindex}[1]{%
247 \index{#1@{\py@idxcode{#1()}} (built-in function)}}
Fred Drake6659c301998-03-03 22:02:19 +0000248
249% Add an index entry for a module
Fred Drake24340ea1998-04-28 18:30:34 +0000250\newcommand{\py@refmodule}[2]{\index{#1@{\py@idxcode{#1}} (#2module)}}
251\newcommand{\refmodindex}[1]{\py@refmodule{#1}{}}
252\newcommand{\refbimodindex}[1]{\py@refmodule{#1}{built-in }}
253\newcommand{\refexmodindex}[1]{\py@refmodule{#1}{extension }}
254\newcommand{\refstmodindex}[1]{\py@refmodule{#1}{standard }}
Fred Drake6659c301998-03-03 22:02:19 +0000255
Fred Drakeda943741999-01-13 17:09:06 +0000256% Refer to a module's documentation using a hyperlink of the module's
257% name, at least if we're building PDF:
Fred Drakee59feb52001-10-29 21:02:28 +0000258\ifpdf
Fred Drakeaa2aea01999-01-27 17:37:36 +0000259 \newcommand{\refmodule}[2][\py@modulebadkey]{%
Fred Drakeda943741999-01-13 17:09:06 +0000260 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
Fred Drakeaa2aea01999-01-27 17:37:36 +0000261 \py@linkToName{label-module-\py@modulekey}{\module{#2}}%
Fred Drakeda943741999-01-13 17:09:06 +0000262 }
Fred Drakee59feb52001-10-29 21:02:28 +0000263\else
264 \newcommand{\refmodule}[2][\py@modulebadkey]{\module{#2}}
265\fi
Fred Drakeda943741999-01-13 17:09:06 +0000266
Fred Drake6659c301998-03-03 22:02:19 +0000267% support for the module index
Fred Drake24340ea1998-04-28 18:30:34 +0000268\newif\ifpy@UseModuleIndex
269\py@UseModuleIndexfalse
Fred Drakeb390daf1998-03-09 16:35:36 +0000270
Fred Drakeb390daf1998-03-09 16:35:36 +0000271\newcommand{\makemodindex}{
272 \newwrite\modindexfile
273 \openout\modindexfile=mod\jobname.idx
Fred Drake24340ea1998-04-28 18:30:34 +0000274 \py@UseModuleIndextrue
Fred Drakeb390daf1998-03-09 16:35:36 +0000275}
276
Fred Drake0ee9f721998-03-12 06:41:40 +0000277% Add the defining entry for a module
Fred Drake24340ea1998-04-28 18:30:34 +0000278\newcommand{\py@modindex}[2]{%
Fred Drakea488f301998-07-23 17:50:45 +0000279 \renewcommand{\py@thismodule}{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000280 \setindexsubitem{(in module #1)}%
Fred Drake24340ea1998-04-28 18:30:34 +0000281 \index{#1@{\py@idxcode{#1}} (#2module)|textbf}%
282 \ifpy@UseModuleIndex%
Fred Drake0c275fa1999-03-02 16:17:44 +0000283 \@ifundefined{py@modplat@\py@thismodulekey}{
284 \write\modindexfile{\protect\indexentry{#1@{\texttt{#1}}}{\thepage}}%
285 }{\write\modindexfile{\protect\indexentry{#1@{\texttt{#1} %
Fred Drake9466b9a1999-03-18 16:18:27 +0000286 \emph{(\py@platformof[\py@thismodulekey]{})}}}{\thepage}}%
Fred Drake0c275fa1999-03-02 16:17:44 +0000287 }
Fred Drake0ee9f721998-03-12 06:41:40 +0000288 \fi%
289}
290
Fred Drake9466b9a1999-03-18 16:18:27 +0000291% *** XXX *** THE NEXT FOUR MACROS ARE NOW OBSOLETE !!! ***
292
Fred Drake6659c301998-03-03 22:02:19 +0000293% built-in & Python modules in the main distribution
Fred Drake9466b9a1999-03-18 16:18:27 +0000294\newcommand{\bimodindex}[1]{\py@modindex{#1}{built-in }%
295 \typeout{*** MACRO bimodindex IS OBSOLETE -- USE declaremodule INSTEAD!}}
296\newcommand{\stmodindex}[1]{\py@modindex{#1}{standard }%
297 \typeout{*** MACRO stmodindex IS OBSOLETE -- USE declaremodule INSTEAD!}}
Fred Drake6659c301998-03-03 22:02:19 +0000298
299% Python & extension modules outside the main distribution
Fred Drake9466b9a1999-03-18 16:18:27 +0000300\newcommand{\modindex}[1]{\py@modindex{#1}{}%
301 \typeout{*** MACRO modindex IS OBSOLETE -- USE declaremodule INSTEAD!}}
302\newcommand{\exmodindex}[1]{\py@modindex{#1}{extension }%
303 \typeout{*** MACRO exmodindex IS OBSOLETE -- USE declaremodule INSTEAD!}}
Fred Drake6659c301998-03-03 22:02:19 +0000304
305% Additional string for an index entry
Fred Drakeba828782000-04-03 04:19:14 +0000306\newif\ifpy@usingsubitem\py@usingsubitemfalse
307\newcommand{\py@indexsubitem}{}
308\newcommand{\setindexsubitem}[1]{\renewcommand{\py@indexsubitem}{ #1}%
309 \py@usingsubitemtrue}
310\newcommand{\ttindex}[1]{%
311 \ifpy@usingsubitem
312 \index{#1@{\py@idxcode{#1}}\py@indexsubitem}%
313 \else%
314 \index{#1@{\py@idxcode{#1}}}%
315 \fi%
316}
Fred Drake0ee9f721998-03-12 06:41:40 +0000317\newcommand{\withsubitem}[2]{%
318 \begingroup%
Fred Drakeec77e652000-10-30 06:22:22 +0000319 \def\ttindex##1{\index{##1@{\py@idxcode{##1}} #1}}%
320 #2%
Fred Drake0ee9f721998-03-12 06:41:40 +0000321 \endgroup%
322}
Fred Drake6659c301998-03-03 22:02:19 +0000323
Fred Drake53714971998-04-02 22:33:16 +0000324
Fred Drakea488f301998-07-23 17:50:45 +0000325% Module synopsis processing -----------------------------------------------
326%
Fred Drake0c275fa1999-03-02 16:17:44 +0000327\newcommand{\py@thisclass}{}
328\newcommand{\py@thismodule}{}
329\newcommand{\py@thismodulekey}{}
330\newcommand{\py@thismoduletype}{}
331
Fred Drake9466b9a1999-03-18 16:18:27 +0000332\newcommand{\py@standardIndexModule}[1]{\py@modindex{#1}{standard }}
333\newcommand{\py@builtinIndexModule}[1]{\py@modindex{#1}{built-in }}
334\newcommand{\py@extensionIndexModule}[1]{\py@modindex{#1}{extension }}
335\newcommand{\py@IndexModule}[1]{\py@modindex{#1}{}}
Fred Drakea488f301998-07-23 17:50:45 +0000336
Fred Drake0c275fa1999-03-02 16:17:44 +0000337\newif\ifpy@HaveModSynopsis \py@HaveModSynopsisfalse
338\newif\ifpy@ModSynopsisFileIsOpen \py@ModSynopsisFileIsOpenfalse
339\newif\ifpy@HaveModPlatform \py@HaveModPlatformfalse
Fred Drakea488f301998-07-23 17:50:45 +0000340
341% \declaremodule[key]{type}{name}
342\newcommand{\declaremodule}[3][\py@modulebadkey]{
343 \py@openModSynopsisFile
344 \renewcommand{\py@thismoduletype}{#2}
Fred Drakea488f301998-07-23 17:50:45 +0000345 \ifx\py@modulebadkey#1
346 \renewcommand{\py@thismodulekey}{#3}
347 \else
348 \renewcommand{\py@thismodulekey}{#1}
349 \fi
Fred Drake5bc8d991999-05-17 14:47:10 +0000350 \@ifundefined{py@#2IndexModule}{%
351 \typeout{*** MACRO declaremodule called with unknown module type: `#2'}
Fred Drake66823021999-05-17 14:57:26 +0000352 \py@IndexModule{#3}%
Fred Drake5bc8d991999-05-17 14:47:10 +0000353 }{%
354 \csname py@#2IndexModule\endcsname{#3}%
355 }
Fred Drakea488f301998-07-23 17:50:45 +0000356 \label{module-\py@thismodulekey}
Fred Drakea488f301998-07-23 17:50:45 +0000357}
Fred Drake0c275fa1999-03-02 16:17:44 +0000358\newif\ifpy@ModPlatformFileIsOpen \py@ModPlatformFileIsOpenfalse
359\newcommand{\py@ModPlatformFilename}{\jobname.pla}
360\newcommand{\platform}[1]{
361 \ifpy@ModPlatformFileIsOpen\else
362 \newwrite\py@ModPlatformFile
363 \openout\py@ModPlatformFile=\py@ModPlatformFilename
364 \py@ModPlatformFileIsOpentrue
365 \fi
Fred Drake0c275fa1999-03-02 16:17:44 +0000366}
367\InputIfFileExists{\jobname.pla}{}{}
Fred Drake9466b9a1999-03-18 16:18:27 +0000368\newcommand{\py@platformof}[2][\py@modulebadkey]{%
Fred Drake0c275fa1999-03-02 16:17:44 +0000369 \ifx\py@modulebadkey#1 \def\py@key{#2}%
370 \else \def\py@key{#1}%
371 \fi%
372 \csname py@modplat@\py@key\endcsname%
373}
374\newcommand{\ignorePlatformAnnotation}[1]{}
Fred Drakea488f301998-07-23 17:50:45 +0000375
Fred Drakeb75c6151998-08-10 18:41:43 +0000376% \moduleauthor{name}{email}
377\newcommand{\moduleauthor}[2]{}
378
379% \sectionauthor{name}{email}
380\newcommand{\sectionauthor}[2]{}
381
Fred Drakea488f301998-07-23 17:50:45 +0000382
383\newcommand{\py@defsynopsis}{Module has no synopsis.}
384\newcommand{\py@modulesynopsis}{\py@defsynopsis}
385\newcommand{\modulesynopsis}[1]{
Fred Drake0c275fa1999-03-02 16:17:44 +0000386 \py@HaveModSynopsistrue
Fred Drakea488f301998-07-23 17:50:45 +0000387 \renewcommand{\py@modulesynopsis}{#1}
388}
389
390% define the file
391\newwrite\py@ModSynopsisFile
392
393% hacked from \addtocontents from latex.ltx:
394\long\def\py@writeModSynopsisFile#1{%
395 \protected@write\py@ModSynopsisFile%
396 {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
397 {\string#1}%
398}
399\newcommand{\py@closeModSynopsisFile}{
400 \ifpy@ModSynopsisFileIsOpen
401 \closeout\py@ModSynopsisFile
402 \py@ModSynopsisFileIsOpenfalse
403 \fi
404}
405\newcommand{\py@openModSynopsisFile}{
406 \ifpy@ModSynopsisFileIsOpen\else
407 \openout\py@ModSynopsisFile=\py@ModSynopsisFilename
408 \py@ModSynopsisFileIsOpentrue
409 \fi
410}
411
412\newcommand{\py@ProcessModSynopsis}{
413 \ifpy@HaveModSynopsis
414 \py@writeModSynopsisFile{\modulesynopsis%
415 {\py@thismodulekey}{\py@thismodule}%
416 {\py@thismoduletype}{\py@modulesynopsis}}%
417 \py@HaveModSynopsisfalse
418 \fi
419 \renewcommand{\py@modulesynopsis}{\py@defsynopsis}
420}
421\AtEndDocument{\py@ProcessModSynopsis\py@closeModSynopsisFile}
422
Fred Drake0c275fa1999-03-02 16:17:44 +0000423
424\long\def\py@writeModPlatformFile#1{%
425 \protected@write\py@ModPlatformFile%
426 {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
427 {\string#1}%
428}
429
430
Fred Drakea488f301998-07-23 17:50:45 +0000431\newcommand{\localmoduletable}{
432 \IfFileExists{\py@ModSynopsisFilename}{
433 \begin{synopsistable}
434 \input{\py@ModSynopsisFilename}
435 \end{synopsistable}
436 }{}
437}
438
Fred Drakee59feb52001-10-29 21:02:28 +0000439\ifpdf
Fred Drakeaa2aea01999-01-27 17:37:36 +0000440 \newcommand{\py@ModSynopsisSummary}[4]{%
441 \py@linkToName{label-module-#1}{\bfcode{#2}} & #4\\
442 }
Fred Drakee59feb52001-10-29 21:02:28 +0000443\else
444 \newcommand{\py@ModSynopsisSummary}[4]{\bfcode{#2} & #4\\}
445\fi
Fred Drakea488f301998-07-23 17:50:45 +0000446\newenvironment{synopsistable}{
447 % key, name, type, synopsis
448 \let\modulesynopsis=\py@ModSynopsisSummary
449 \begin{tabular}{ll}
450}{
451 \end{tabular}
452}
453%
454% --------------------------------------------------------------------------
455
456
Fred Drakea488f301998-07-23 17:50:45 +0000457\newcommand{\py@reset}{
Fred Drakeba828782000-04-03 04:19:14 +0000458 \py@usingsubitemfalse
Fred Drakea488f301998-07-23 17:50:45 +0000459 \py@ProcessModSynopsis
460 \renewcommand{\py@thisclass}{}
461 \renewcommand{\py@thismodule}{}
462 \renewcommand{\py@thismodulekey}{}
463 \renewcommand{\py@thismoduletype}{}
464}
465
466% Augment the sectioning commands used to get our own font family in place,
467% and reset some internal data items:
468\renewcommand{\section}{\py@reset%
469 \@startsection{section}{1}{\z@}%
470 {-3.5ex \@plus -1ex \@minus -.2ex}%
471 {2.3ex \@plus.2ex}%
472 {\reset@font\Large\py@HeaderFamily}}
473\renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}%
474 {-3.25ex\@plus -1ex \@minus -.2ex}%
475 {1.5ex \@plus .2ex}%
476 {\reset@font\large\py@HeaderFamily}}
477\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}%
478 {-3.25ex\@plus -1ex \@minus -.2ex}%
479 {1.5ex \@plus .2ex}%
480 {\reset@font\normalsize\py@HeaderFamily}}
481\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}%
482 {3.25ex \@plus1ex \@minus.2ex}%
483 {-1em}%
484 {\reset@font\normalsize\py@HeaderFamily}}
485\renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}%
486 {3.25ex \@plus1ex \@minus .2ex}%
487 {-1em}%
488 {\reset@font\normalsize\py@HeaderFamily}}
489
490
Fred Drake5420f331998-07-23 21:41:02 +0000491% This gets the underscores closer to the right width; the only change
492% from standard LaTeX is the width specified.
493
494\DeclareTextCommandDefault{\textunderscore}{%
495 \leavevmode \kern.06em\vbox{\hrule\@width.55em}}
496
Fred Drakea488f301998-07-23 17:50:45 +0000497% Underscore hack (only act like subscript operator if in math mode)
498%
499% The following is due to Mark Wooding (the old version didn't work with
500% Latex 2e.
501
502\DeclareRobustCommand\hackscore{%
503 \ifmmode_\else\textunderscore\fi%
504}
505\begingroup
506\catcode`\_\active
507\def\next{%
508 \AtBeginDocument{\catcode`\_\active\def_{\hackscore{}}}%
509}
510\expandafter\endgroup\next
511
512
Fred Drake53714971998-04-02 22:33:16 +0000513% Now for a lot of semantically-loaded environments that do a ton of magical
514% things to get the right formatting and index entries for the stuff in
515% Python modules and C API.
516
517
Fred Drake6659c301998-03-03 22:02:19 +0000518% {fulllineitems} is used in one place in libregex.tex, but is really for
519% internal use in this file.
520%
Fred Drakef9acc591998-09-09 15:27:43 +0000521\newcommand{\py@itemnewline}[1]{%
522 \@tempdima\linewidth%
523 \advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}%
524}
525
Fred Drake6659c301998-03-03 22:02:19 +0000526\newenvironment{fulllineitems}{
527 \begin{list}{}{\labelwidth \leftmargin \labelsep 0pt
528 \rightmargin 0pt \topsep -\parskip \partopsep \parskip
529 \itemsep -\parsep
Fred Drakef9acc591998-09-09 15:27:43 +0000530 \let\makelabel=\py@itemnewline}
Fred Drake6659c301998-03-03 22:02:19 +0000531}{\end{list}}
532
Fred Drake6cb71491998-03-27 05:22:53 +0000533% \optional is mostly for use in the arguments parameters to the various
534% {*desc} environments defined below, but may be used elsewhere. Known to
535% be used in the debugger chapter.
Fred Drake24340ea1998-04-28 18:30:34 +0000536%
537% Typical usage:
538%
539% \begin{funcdesc}{myfunc}{reqparm\optional{, optparm}}
540% ^^^ ^^^
541% No space here No space here
542%
543% When a function has multiple optional parameters, \optional should be
544% nested, not chained. This is right:
545%
546% \begin{funcdesc}{myfunc}{\optional{parm1\optional{, parm2}}}
547%
Fred Drakeba828782000-04-03 04:19:14 +0000548\let\py@badkey=\@undefined
549
Fred Drake6659c301998-03-03 22:02:19 +0000550\newcommand{\optional}[1]{%
551 {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
552
Fred Drakeba828782000-04-03 04:19:14 +0000553% This can be used when a function or method accepts an varying number
554% of arguments, such as by using the *args syntax in the parameter list.
555\newcommand{\py@moreargs}{...}
556
557% This can be used when you don't want to document the parameters to a
558% function or method, but simply state that it's an alias for
559% something else.
560\newcommand{\py@unspecified}{...}
561
Fred Drake6cb71491998-03-27 05:22:53 +0000562% C functions ------------------------------------------------------------
Fred Drakeba828782000-04-03 04:19:14 +0000563% \begin{cfuncdesc}[refcount]{type}{name}{arglist}
564% Note that the [refcount] slot should only be filled in by
565% tools/anno-api.py; it pulls the value from the refcounts database.
566\newenvironment{cfuncdesc}[4][\py@badkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000567 \begin{fulllineitems}
Fred Drakeba828782000-04-03 04:19:14 +0000568 \item[\code{#2 \bfcode{#3}(\py@varvars{#4})}\index{#3@{\py@idxcode{#3()}}}]
569 \ifx#1\@undefined\else%
Fred Drake0a863da2000-04-10 18:21:38 +0000570 \emph{Return value: \textbf{#1}.}\\
Fred Drakeba828782000-04-03 04:19:14 +0000571 \fi
Fred Drake6cb71491998-03-27 05:22:53 +0000572}{\end{fulllineitems}}
573
574% C variables ------------------------------------------------------------
575% \begin{cvardesc}{type}{name}
576\newenvironment{cvardesc}[2]{
577 \begin{fulllineitems}
Fred Drake24340ea1998-04-28 18:30:34 +0000578 \item[\code{#1 \bfcode{#2}}\index{#2@{\py@idxcode{#2}}}]
Fred Drake6cb71491998-03-27 05:22:53 +0000579}{\end{fulllineitems}}
580
581% C data types -----------------------------------------------------------
Fred Drakeba828782000-04-03 04:19:14 +0000582% \begin{ctypedesc}[index name]{typedef name}
583\newenvironment{ctypedesc}[2][\py@badkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000584 \begin{fulllineitems}
Fred Drakeba828782000-04-03 04:19:14 +0000585 \item[\bfcode{#2}%
586 \ifx#1\@undefined%
Fred Drakea33c5662000-10-29 05:19:16 +0000587 \index{#2@{\py@idxcode{#2}} (C type)}
Fred Drakeba828782000-04-03 04:19:14 +0000588 \else%
Fred Drakea33c5662000-10-29 05:19:16 +0000589 \index{#2@{\py@idxcode{#1}} (C type)}
Fred Drakeba828782000-04-03 04:19:14 +0000590 \fi]
591}{\end{fulllineitems}}
592
593% Funky macros -----------------------------------------------------------
594% \begin{csimplemacro}{name}
595% -- "simple" because it has no args; NOT for constant definitions!
596\newenvironment{csimplemacrodesc}[1]{
597 \begin{fulllineitems}
Fred Drakea33c5662000-10-29 05:19:16 +0000598 \item[\bfcode{#1}\index{#1@{\py@idxcode{#1}} (macro)}]
Fred Drake6cb71491998-03-27 05:22:53 +0000599}{\end{fulllineitems}}
600
601% simple functions (not methods) -----------------------------------------
602% \begin{funcdesc}{name}{args}
Fred Drakeec77e652000-10-30 06:22:22 +0000603\newcommand{\funcline}[2]{%
604 \funclineni{#1}{#2}%
605 \index{#1@{\py@idxcode{#1()}} (in module \py@thismodule)}}
Fred Drake6cb71491998-03-27 05:22:53 +0000606\newenvironment{funcdesc}[2]{
607 \begin{fulllineitems}
608 \funcline{#1}{#2}
609}{\end{fulllineitems}}
610
Fred Drake6659c301998-03-03 22:02:19 +0000611% similar to {funcdesc}, but doesn't add to the index
Fred Drake300775d1998-04-17 02:17:00 +0000612\newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(\py@varvars{#2})}]}
Fred Drake6cb71491998-03-27 05:22:53 +0000613\newenvironment{funcdescni}[2]{
614 \begin{fulllineitems}
615 \funclineni{#1}{#2}
Fred Drake6659c301998-03-03 22:02:19 +0000616}{\end{fulllineitems}}
617
Fred Drake6cb71491998-03-27 05:22:53 +0000618% classes ----------------------------------------------------------------
619% \begin{classdesc}{name}{constructor args}
620\newenvironment{classdesc}[2]{
Fred Drake1cbd1961998-11-25 17:13:28 +0000621 % Using \renewcommand doesn't work for this, for unknown reasons:
622 \global\def\py@thisclass{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000623 \begin{fulllineitems}
Fred Drakeab357ec2001-03-02 18:57:05 +0000624 \item[\strong{class }\code{\bfcode{#1}(\py@varvars{#2})}%
Fred Drakea33c5662000-10-29 05:19:16 +0000625 \index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}]
Fred Drake6659c301998-03-03 22:02:19 +0000626}{\end{fulllineitems}}
627
Fred Drake06a01e82001-05-11 01:00:30 +0000628% \begin{classdesc*}{name}
629\newenvironment{classdesc*}[1]{
630 % Using \renewcommand doesn't work for this, for unknown reasons:
631 \global\def\py@thisclass{#1}
632 \begin{fulllineitems}
633 \item[\strong{class }\code{\bfcode{#1}}%
634 \index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}]
635}{\end{fulllineitems}}
636
Fred Drake4e607962000-09-09 06:01:25 +0000637% \begin{excclassdesc}{name}{constructor args}
638% but indexes as an exception
639\newenvironment{excclassdesc}[2]{
640 % Using \renewcommand doesn't work for this, for unknown reasons:
641 \global\def\py@thisclass{#1}
642 \begin{fulllineitems}
Fred Drakeab357ec2001-03-02 18:57:05 +0000643 \item[\strong{exception }\code{\bfcode{#1}(\py@varvars{#2})}%
Fred Drakea33c5662000-10-29 05:19:16 +0000644 \index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}]
Fred Drake4e607962000-09-09 06:01:25 +0000645}{\end{fulllineitems}}
646
Fred Drake06a01e82001-05-11 01:00:30 +0000647% There is no corresponding {excclassdesc*} environment. To describe
648% a class exception without parameters, use the {excdesc} environment.
649
Fred Drake6cb71491998-03-27 05:22:53 +0000650
Fred Drake24340ea1998-04-28 18:30:34 +0000651\let\py@classbadkey=\@undefined
Fred Drake6cb71491998-03-27 05:22:53 +0000652
653% object method ----------------------------------------------------------
654% \begin{methoddesc}[classname]{methodname}{args}
Fred Drakea33c5662000-10-29 05:19:16 +0000655\newcommand{\methodline}[3][\@undefined]{
Fred Drake6cb71491998-03-27 05:22:53 +0000656 \methodlineni{#2}{#3}
657 \ifx#1\@undefined
Fred Drakea33c5662000-10-29 05:19:16 +0000658 \index{#2@{\py@idxcode{#2()}} (\py@thisclass\ method)}
Fred Drake6cb71491998-03-27 05:22:53 +0000659 \else
Fred Drakea33c5662000-10-29 05:19:16 +0000660 \index{#2@{\py@idxcode{#2()}} (#1 method)}
Fred Drake6cb71491998-03-27 05:22:53 +0000661 \fi
662}
Fred Drakea33c5662000-10-29 05:19:16 +0000663\newenvironment{methoddesc}[3][\@undefined]{
Fred Drake6cb71491998-03-27 05:22:53 +0000664 \begin{fulllineitems}
665 \ifx#1\@undefined
666 \methodline{#2}{#3}
667 \else
Fred Drake24340ea1998-04-28 18:30:34 +0000668 \def\py@thisclass{#1}
Fred Drakea33c5662000-10-29 05:19:16 +0000669 \methodline{#2}{#3}
Fred Drake6cb71491998-03-27 05:22:53 +0000670 \fi
Fred Drake6659c301998-03-03 22:02:19 +0000671}{\end{fulllineitems}}
672
Fred Drake6cb71491998-03-27 05:22:53 +0000673% similar to {methoddesc}, but doesn't add to the index
674% (never actually uses the optional argument)
Fred Drake24340ea1998-04-28 18:30:34 +0000675\newcommand{\methodlineni}[3][\py@classbadkey]{%
Fred Drake300775d1998-04-17 02:17:00 +0000676 \item[\code{\bfcode{#2}(\py@varvars{#3})}]}
Fred Drake24340ea1998-04-28 18:30:34 +0000677\newenvironment{methoddescni}[3][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000678 \begin{fulllineitems}
679 \methodlineni{#2}{#3}
680}{\end{fulllineitems}}
681
682% object data attribute --------------------------------------------------
683% \begin{memberdesc}[classname]{membername}
Fred Drake24340ea1998-04-28 18:30:34 +0000684\newcommand{\memberline}[2][\py@classbadkey]{%
Fred Drake6cb71491998-03-27 05:22:53 +0000685 \ifx#1\@undefined
686 \memberlineni{#2}
Fred Drakea33c5662000-10-29 05:19:16 +0000687 \index{#2@{\py@idxcode{#2}} (\py@thisclass\ attribute)}
Fred Drake6cb71491998-03-27 05:22:53 +0000688 \else
689 \memberlineni{#2}
Fred Drakea33c5662000-10-29 05:19:16 +0000690 \index{#2@{\py@idxcode{#2}} (#1 attribute)}
Fred Drake6cb71491998-03-27 05:22:53 +0000691 \fi
692}
Fred Drake24340ea1998-04-28 18:30:34 +0000693\newenvironment{memberdesc}[2][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000694 \begin{fulllineitems}
695 \ifx#1\@undefined
696 \memberline{#2}
697 \else
Fred Drake24340ea1998-04-28 18:30:34 +0000698 \def\py@thisclass{#1}
Fred Drakea33c5662000-10-29 05:19:16 +0000699 \memberline{#2}
Fred Drake6cb71491998-03-27 05:22:53 +0000700 \fi
701}{\end{fulllineitems}}
702
703% similar to {memberdesc}, but doesn't add to the index
704% (never actually uses the optional argument)
Fred Drake24340ea1998-04-28 18:30:34 +0000705\newcommand{\memberlineni}[2][\py@classbadkey]{\item[\bfcode{#2}]}
706\newenvironment{memberdescni}[2][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000707 \begin{fulllineitems}
708 \memberlineni{#2}
709}{\end{fulllineitems}}
710
711% For exceptions: --------------------------------------------------------
712% \begin{excdesc}{name}
Fred Drakea33c5662000-10-29 05:19:16 +0000713% -- for constructor information, use excclassdesc instead
Fred Drake6cb71491998-03-27 05:22:53 +0000714\newenvironment{excdesc}[1]{
715 \begin{fulllineitems}
Fred Drakeab357ec2001-03-02 18:57:05 +0000716 \item[\strong{exception }\bfcode{#1}%
Fred Drakea33c5662000-10-29 05:19:16 +0000717 \index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}]
Fred Drake6cb71491998-03-27 05:22:53 +0000718}{\end{fulllineitems}}
719
720% Module data or constants: ----------------------------------------------
721% \begin{datadesc}{name}
Fred Drakea33c5662000-10-29 05:19:16 +0000722\newcommand{\dataline}[1]{%
723 \datalineni{#1}\index{#1@{\py@idxcode{#1}} (data in \py@thismodule)}}
Fred Drake6cb71491998-03-27 05:22:53 +0000724\newenvironment{datadesc}[1]{
725 \begin{fulllineitems}
726 \dataline{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000727}{\end{fulllineitems}}
728
729% similar to {datadesc}, but doesn't add to the index
Fred Drake6cb71491998-03-27 05:22:53 +0000730\newcommand{\datalineni}[1]{\item[\bfcode{#1}]\nopagebreak}
731\newenvironment{datadescni}[1]{
732 \begin{fulllineitems}
733 \datalineni{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000734}{\end{fulllineitems}}
735
Fred Drake6cb71491998-03-27 05:22:53 +0000736% bytecode instruction ---------------------------------------------------
737% \begin{opcodedesc}{name}{var}
738% -- {var} may be {}
739\newenvironment{opcodedesc}[2]{
740 \begin{fulllineitems}
741 \item[\bfcode{#1}\quad\var{#2}]
Fred Drake6659c301998-03-03 22:02:19 +0000742}{\end{fulllineitems}}
743
744
Fred Drake24340ea1998-04-28 18:30:34 +0000745\newcommand{\nodename}[1]{\label{#1}}
Fred Drake55730311998-03-25 15:41:23 +0000746
Fred Drake6659c301998-03-03 22:02:19 +0000747% For these commands, use \command{} to get the typography right, not
748% {\command}. This works better with the texinfo translation.
749\newcommand{\ABC}{{\sc abc}}
750\newcommand{\UNIX}{{\sc Unix}}
751\newcommand{\POSIX}{POSIX}
752\newcommand{\ASCII}{{\sc ascii}}
753\newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}}
754\newcommand{\C}{C}
755\newcommand{\EOF}{{\sc eof}}
Fred Drake24340ea1998-04-28 18:30:34 +0000756\newcommand{\NULL}{\constant{NULL}}
Fred Drake5445e5e2001-06-23 03:11:45 +0000757\newcommand{\infinity}{\ensuremath{\infty}}
758\newcommand{\plusminus}{\ensuremath{\pm}}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000759\newcommand{\menuselection}[1]{{\def\sub{ \ensuremath{>} }#1}}
Fred Drake6659c301998-03-03 22:02:19 +0000760
Fred Drake53714971998-04-02 22:33:16 +0000761% Also for consistency: spell Python "Python", not "python"!
762
Fred Drake6659c301998-03-03 22:02:19 +0000763% code is the most difficult one...
Fred Drake46346ec2000-06-30 17:57:05 +0000764\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 +0000765\texttt{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000766
767\newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font
Fred Drake8e54abe1998-07-01 14:49:25 +0000768\newcommand{\kbd}[1]{\code{#1}}
Fred Drake24340ea1998-04-28 18:30:34 +0000769\newcommand{\samp}[1]{`\code{#1}'}
Fred Drake6659c301998-03-03 22:02:19 +0000770% This weird definition of \var{} allows it to always appear in roman
771% italics, and won't get funky in code fragments when we play around
Fred Drakefa1cceb1998-11-30 14:42:59 +0000772% with fonts. This also works directly in math mode.
773\newcommand{\var}[1]{%
774 \ifmmode%
775 \hbox{\normalsize\textrm{\textit{#1\/}}}%
776 \else%
777 \normalsize\textrm{\textit{#1\/}}%
778 \fi%
779}
Fred Drake24340ea1998-04-28 18:30:34 +0000780\renewcommand{\emph}[1]{{\em #1}}
Fred Drake6659c301998-03-03 22:02:19 +0000781\newcommand{\dfn}[1]{\emph{#1}}
782\newcommand{\strong}[1]{{\bf #1}}
783% let's experiment with a new font:
Fred Drake0ee9f721998-03-12 06:41:40 +0000784\newcommand{\file}[1]{`{\small\textsf{#1}}'}
Fred Drake0a0fd591999-04-28 14:59:44 +0000785\newcommand{\filenq}[1]{{\small\textsf{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000786
787% Use this def/redef approach for \url{} since hyperref defined this already,
788% but only if we actually used hyperref:
Fred Drakee59feb52001-10-29 21:02:28 +0000789\ifpdf
790 \newcommand{\url}[1]{{%
Fred Drake6659c301998-03-03 22:02:19 +0000791 \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}%
Fred Drakeab357ec2001-03-02 18:57:05 +0000792 \py@LinkColor% color of the link text
Fred Drakee59feb52001-10-29 21:02:28 +0000793 \small\sf #1%
Fred Drakeab357ec2001-03-02 18:57:05 +0000794 \py@NormalColor% Turn it back off; these are declarative
795 \pdfendlink}% and don't appear bound to the current
796 }% formatting "box".
Fred Drakee59feb52001-10-29 21:02:28 +0000797\else
798 \newcommand{\url}[1]{\mbox{\small\textsf{#1}}}
799\fi
Fred Drake0ee9f721998-03-12 06:41:40 +0000800\newcommand{\email}[1]{{\small\textsf{#1}}}
Fred Drake454a4fb1998-04-01 22:20:14 +0000801\newcommand{\newsgroup}[1]{{\small\textsf{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000802
Fred Drakecc2b81e2000-08-03 17:38:30 +0000803\newcommand{\py@varvars}[1]{{%
Fred Drakeba828782000-04-03 04:19:14 +0000804 {\let\unspecified=\py@unspecified%
805 \let\moreargs=\py@moreargs%
Fred Drakecc2b81e2000-08-03 17:38:30 +0000806 \var{#1}}}}
Fred Drake6659c301998-03-03 22:02:19 +0000807
Fred Drake24340ea1998-04-28 18:30:34 +0000808% I'd really like to get rid of this!
Fred Drake6659c301998-03-03 22:02:19 +0000809\newif\iftexi\texifalse
Fred Drake6659c301998-03-03 22:02:19 +0000810
Fred Drake1e4973b1998-07-28 21:52:17 +0000811% This is used to get l2h to put the copyright and abstract on
812% a separate HTML page.
813\newif\ifhtml\htmlfalse
814
815
Fred Drake6659c301998-03-03 22:02:19 +0000816% These should be used for all references to identifiers which are
817% used to refer to instances of specific language constructs. See the
818% names for specific semantic assignments.
819%
820% For now, don't do anything really fancy with them; just use them as
821% logical markup. This might change in the future.
822%
Fred Drake24340ea1998-04-28 18:30:34 +0000823\newcommand{\module}[1]{\texttt{#1}}
824\newcommand{\keyword}[1]{\texttt{#1}}
825\newcommand{\exception}[1]{\texttt{#1}}
826\newcommand{\class}[1]{\texttt{#1}}
827\newcommand{\function}[1]{\texttt{#1}}
828\newcommand{\member}[1]{\texttt{#1}}
829\newcommand{\method}[1]{\texttt{#1}}
Fred Drake6659c301998-03-03 22:02:19 +0000830
Fred Drakeab357ec2001-03-02 18:57:05 +0000831\newcommand{\pytype}[1]{#1} % built-in Python type
Fred Drake53714971998-04-02 22:33:16 +0000832
Fred Drake24340ea1998-04-28 18:30:34 +0000833\newcommand{\cfunction}[1]{\texttt{#1}}
Fred Drakeab357ec2001-03-02 18:57:05 +0000834\newcommand{\ctype}[1]{\texttt{#1}} % C struct or typedef name
835\newcommand{\cdata}[1]{\texttt{#1}} % C variable, typically global
Fred Drake6659c301998-03-03 22:02:19 +0000836
Fred Drake479384e2001-09-26 18:46:36 +0000837\newcommand{\mailheader}[1]{{\small\textsf{#1:}}}
Fred Drake0ee9f721998-03-12 06:41:40 +0000838\newcommand{\mimetype}[1]{{\small\textsf{#1}}}
Fred Drake94fac131998-03-12 19:37:03 +0000839% The \! is a "negative thin space" in math mode.
840\newcommand{\regexp}[1]{%
841 {\tiny$^{^\lceil}\!\!$%
842 {\normalsize\code{#1}}%
Fred Drake47cfd031998-04-03 21:22:31 +0000843 $\!\rfloor\!$%
Fred Drake94fac131998-03-12 19:37:03 +0000844 }}
Fred Drake0ee9f721998-03-12 06:41:40 +0000845\newcommand{\envvar}[1]{%
Fred Drake31ab2982001-01-22 17:50:42 +0000846 #1%
Fred Drakee59feb52001-10-29 21:02:28 +0000847 \index{#1}%
Fred Drake31ab2982001-01-22 17:50:42 +0000848 \index{environment variables!{#1}}%
Fred Drake0ee9f721998-03-12 06:41:40 +0000849}
Fred Drakeab357ec2001-03-02 18:57:05 +0000850\newcommand{\makevar}[1]{#1} % variable in a Makefile
Fred Drake24340ea1998-04-28 18:30:34 +0000851\newcommand{\character}[1]{\samp{#1}}
Fred Drake0ee9f721998-03-12 06:41:40 +0000852
Fred Drake6659c301998-03-03 22:02:19 +0000853% constants defined in Python modules or C headers, not language constants:
Fred Drakeab357ec2001-03-02 18:57:05 +0000854\newcommand{\constant}[1]{\code{#1}} % manifest constant, not syntactic
Fred Drake6659c301998-03-03 22:02:19 +0000855
856\newcommand{\manpage}[2]{{\emph{#1}(#2)}}
Fred Drake4e607962000-09-09 06:01:25 +0000857\newcommand{\pep}[1]{PEP #1\index{Python Enhancement Proposals!PEP #1}}
Fred Drake6659c301998-03-03 22:02:19 +0000858\newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}}
859\newcommand{\program}[1]{\strong{#1}}
Fred Drake7b8195a1999-11-09 17:02:11 +0000860\newcommand{\programopt}[1]{\strong{#1}}
Fred Drake49362492000-04-11 18:47:59 +0000861% Note that \longprogramopt provides the '--'!
862\newcommand{\longprogramopt}[1]{\strong{-{}-#1}}
Fred Drakee59feb52001-10-29 21:02:28 +0000863
Fred Drakeb4b64da2001-07-06 22:44:48 +0000864% \ulink{link text}{URL}
Fred Drakee59feb52001-10-29 21:02:28 +0000865\ifpdf
866 % The \noindent here is a hack -- we're forcing pdfTeX into
867 % horizontal mode since \pdfannotlink requires that.
868 \newcommand{\ulink}[2]{\noindent{%
869 \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#2)}%
870 \py@LinkColor% color of the link text
871 #1%
872 \py@NormalColor% Turn it back off; these are declarative
873 \pdfendlink}% and don't appear bound to the current
874 }% formatting "box".
875\else
876 \newcommand{\ulink}[2]{#1}
877\fi
Fred Drake7b8195a1999-11-09 17:02:11 +0000878
879% cited titles: \citetitle{Title of Work}
880% online: \citetitle[url-to-resource]{Title of Work}
Fred Drakee59feb52001-10-29 21:02:28 +0000881\ifpdf
882 \newcommand{\citetitle}[2][\py@modulebadkey]{%
883 \ifx\py@modulebadkey#1\emph{#2}\else\ulink{\emph{#2}}{#1}\fi%
884 }
885\else
Fred Drake622087a2001-11-02 20:53:19 +0000886 \newcommand{\citetitle}[2][URL]{\emph{#2}}
Fred Drakee59feb52001-10-29 21:02:28 +0000887\fi
888
Fred Drake6659c301998-03-03 22:02:19 +0000889
890
Fred Drakec82bd722001-12-11 18:47:36 +0000891% This version is being checked in for the historical record; it shows
892% how I've managed to get some aspects of this to work. It will not
893% be used in practice, so a subsequent revision will change things
894% again. This version has problems, but shows how to do something
895% that proved more tedious than I'd expected, so I don't want to lose
896% the example completely.
897%
Fred Drake16bb4192001-08-20 21:36:38 +0000898\newcommand{\grammartoken}[1]{\texttt{#1}}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000899\newenvironment{productionlist}[1][\py@badkey]{
900 \def\optional##1{{\Large[}##1{\Large]}}
901 \def\production##1##2{\code{##1}&::=&\code{##2}\\}
Fred Drakec82bd722001-12-11 18:47:36 +0000902 \def\orgroup##1{{\def\oritem{\textbar\ }##1}}
903 \def\orgroup*##1{{
904 \def\oritem{\\ \textbar&}
905 % This uses math mode's ``negative thin space'' to avoid a weird
906 % indentation that I've not been able to figure out, but
907 % probably relates to nesting tabular environments.
908 $\!\!\!\!\!\!\!\!\!\!$%
909 \begin{tabular}[t]{ll}
910 \ & ##1
911 \end{tabular}
912 }}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000913 \def\token##1{##1}
Fred Drake16bb4192001-08-20 21:36:38 +0000914 \let\grammartoken=\token
Fred Drakec82bd722001-12-11 18:47:36 +0000915 \parindent=2em
916 \indent
917 \begin{tabular}{lcl}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000918}{%
Fred Drakec82bd722001-12-11 18:47:36 +0000919 \end{tabular}
Fred Drakeb4b64da2001-07-06 22:44:48 +0000920}
921
Fred Drake6ca33772001-12-14 22:50:06 +0000922\newcommand{\py@noticelabel@note}{Note:}
923\newcommand{\py@noticelabel@warning}{Warning:}
924\newenvironment{notice}[1][note]{
925 \par\strong{\csname py@noticelabel@#1\endcsname}
926}{}
927\newcommand{\note}[1]{\strong{\py@noticelabel@note} #1}
928\newcommand{\warning}[1]{\strong{\py@noticelabel@warning} #1}
Fred Drake92350b32001-10-09 18:01:23 +0000929
Fred Drake6659c301998-03-03 22:02:19 +0000930% Deprecation stuff.
931% Should be extended to allow an index / list of deprecated stuff. But
932% there's a lot of stuff that needs to be done to make that automatable.
933%
934% First parameter is the release number that deprecates the feature, the
935% second is the action the should be taken by users of the feature.
936%
937% Example:
Fred Drake24340ea1998-04-28 18:30:34 +0000938% \deprecated{1.5.1}{Use \method{frobnicate()} instead.}
Fred Drake6659c301998-03-03 22:02:19 +0000939%
940\newcommand{\deprecated}[2]{%
941 \strong{Deprecated since release #1.} #2\par}
942
Fred Drakeaf958c71998-07-27 20:32:33 +0000943% New stuff.
944% This should be used to mark things which have been added to the
945% development tree but that aren't in the release, but are documented.
946% This allows release of documentation that already includes updated
Fred Drake2116d981999-02-02 18:02:48 +0000947% descriptions. Place at end of descriptor environment.
Fred Drakeaf958c71998-07-27 20:32:33 +0000948%
949% Example:
950% \versionadded{1.5.2}
Fred Drake46346ec2000-06-30 17:57:05 +0000951% \versionchanged[short explanation]{2.0}
Fred Drakeaf958c71998-07-27 20:32:33 +0000952%
Fred Drakefdfb05b2001-04-18 03:08:54 +0000953\newcommand{\versionadded}[2][\py@badkey]{%
954 \ifx#1\@undefined%
955 { New in version #2. }%
956 \else%
957 { New in version #2:\ #1. }%
958 \fi%
959}
Fred Drakea6e83392000-05-02 17:28:36 +0000960\newcommand{\versionchanged}[2][\py@badkey]{%
961 \ifx#1\@undefined%
962 { Changed in version #2. }%
963 \else%
964 { Changed in version #2:\ #1. }%
965 \fi%
966}
Fred Drake6659c301998-03-03 22:02:19 +0000967
Fred Drakeaf958c71998-07-27 20:32:33 +0000968
969% Tables.
970%
Fred Drake6659c301998-03-03 22:02:19 +0000971\newenvironment{tableii}[4]{%
972 \begin{center}%
973 \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
Fred Drakef61eac42000-10-24 02:18:30 +0000974 \begin{tabular}{#1}\strong{#3}&\strong{#4} \\* \hline%
Fred Drake6659c301998-03-03 22:02:19 +0000975}{%
Fred Drake6659c301998-03-03 22:02:19 +0000976 \end{tabular}%
977 \end{center}%
978}
979
Fred Drakeda72b932000-09-21 15:58:02 +0000980\newenvironment{longtableii}[4]{%
981 \begin{center}%
982 \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
Fred Drakef61eac42000-10-24 02:18:30 +0000983 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4} \\* \hline\endhead%
Fred Drakeda72b932000-09-21 15:58:02 +0000984}{%
985 \end{longtable}%
986 \end{center}%
987}
988
Fred Drake6659c301998-03-03 22:02:19 +0000989\newenvironment{tableiii}[5]{%
990 \begin{center}%
991 \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
Fred Drakeda72b932000-09-21 15:58:02 +0000992 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5} \\%
Fred Drakef61eac42000-10-24 02:18:30 +0000993 \hline%
Fred Drake6659c301998-03-03 22:02:19 +0000994}{%
Fred Drake6659c301998-03-03 22:02:19 +0000995 \end{tabular}%
996 \end{center}%
997}
998
Fred Drakeda72b932000-09-21 15:58:02 +0000999\newenvironment{longtableiii}[5]{%
1000 \begin{center}%
1001 \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
1002 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5} \\%
Fred Drakef61eac42000-10-24 02:18:30 +00001003 \hline\endhead%
Fred Drakeda72b932000-09-21 15:58:02 +00001004}{%
1005 \end{longtable}%
1006 \end{center}%
1007}
1008
Fred Drake30e52651998-07-24 22:11:29 +00001009\newenvironment{tableiv}[6]{%
1010 \begin{center}%
1011 \def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}%
1012 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6} \\%
Fred Drakef61eac42000-10-24 02:18:30 +00001013 \hline%
Fred Drake30e52651998-07-24 22:11:29 +00001014}{%
1015 \end{tabular}%
1016 \end{center}%
1017}
1018
Fred Drakeda72b932000-09-21 15:58:02 +00001019\newenvironment{longtableiv}[6]{%
1020 \begin{center}%
1021 \def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}%
1022 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}%
1023 \\%
Fred Drakef61eac42000-10-24 02:18:30 +00001024 \hline\endhead%
Fred Drakeda72b932000-09-21 15:58:02 +00001025}{%
1026 \end{longtable}%
1027 \end{center}%
1028}
1029
Fred Drakef269e592001-07-17 23:05:57 +00001030\newenvironment{tablev}[7]{%
1031 \begin{center}%
1032 \def\linev##1##2##3##4##5{\csname#2\endcsname{##1}&##2&##3&##4&##5\\}%
1033 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}&\strong{#7} \\%
1034 \hline%
1035}{%
1036 \end{tabular}%
1037 \end{center}%
1038}
1039
1040\newenvironment{longtablev}[7]{%
1041 \begin{center}%
1042 \def\linev##1##2##3##4##5{\csname#2\endcsname{##1}&##2&##3&##4&##5\\}%
1043 \begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}&\strong{#7}%
1044 \\%
1045 \hline\endhead%
1046}{%
1047 \end{longtable}%
1048 \end{center}%
1049}
1050
Fred Drake24340ea1998-04-28 18:30:34 +00001051% Cross-referencing (AMK, new impl. FLD)
Fred Drake6659c301998-03-03 22:02:19 +00001052% Sample usage:
1053% \begin{seealso}
Fred Drake84bd6f31999-05-11 15:42:51 +00001054% \seemodule{rand}{Uniform random number generator.}; % Module xref
1055% \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book
Fred Drakeebcb6581998-03-06 21:25:17 +00001056%
1057% % A funky case: module name contains '_'; have to supply an optional key
Fred Drake84bd6f31999-05-11 15:42:51 +00001058% \seemodule[copyreg]{copy_reg}{Interface constructor registration for
1059% \module{pickle}.}
Fred Drake6659c301998-03-03 22:02:19 +00001060% \end{seealso}
Fred Drake84bd6f31999-05-11 15:42:51 +00001061%
1062% Note that the last parameter for \seemodule and \seetext should be complete
1063% sentences and be terminated with the proper punctuation.
Fred Drake6659c301998-03-03 22:02:19 +00001064
Fred Drakee59feb52001-10-29 21:02:28 +00001065\ifpdf
Fred Drake24340ea1998-04-28 18:30:34 +00001066 \newcommand{\py@seemodule}[3][\py@modulebadkey]{%
Fred Drakeda943741999-01-13 17:09:06 +00001067 \par%
Fred Drake24340ea1998-04-28 18:30:34 +00001068 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
Fred Drake84bd6f31999-05-11 15:42:51 +00001069 \begin{fulllineitems}
Fred Drake84bd6f31999-05-11 15:42:51 +00001070 \item[\py@linkToName{label-module-\py@modulekey}{Module \module{#2}}
1071 (section \ref{module-\py@modulekey}):]
1072 #3
1073 \end{fulllineitems}
Fred Drakeebcb6581998-03-06 21:25:17 +00001074 }
Fred Drakee59feb52001-10-29 21:02:28 +00001075\else
1076 \newcommand{\py@seemodule}[3][\py@modulebadkey]{%
1077 \par%
1078 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
1079 \begin{fulllineitems}
1080 \item[Module \module{#2} (section \ref{module-\py@modulekey}):]
1081 #3
1082 \end{fulllineitems}
1083 }
1084\fi
1085
Fred Drake48449982000-09-12 17:52:33 +00001086% \seetitle[url]{title}{why it's interesting}
1087\newcommand{\py@seetitle}[3][\py@modulebadkey]{%
1088 \par
1089 \begin{fulllineitems}
1090 \item[\citetitle{#2}]
1091 \ifx\py@modulebadkey#1\else
1092 \item[{\small{(\url{#1})}}]
1093 \fi
1094 #3
1095 \end{fulllineitems}
1096}
Fred Drake4e607962000-09-09 06:01:25 +00001097% \seepep{number}{title}{why it's interesting}
1098\newcommand{\py@seepep}[3]{%
1099 \par%
1100 \begin{fulllineitems}
1101 \item[\pep{#1}, ``\emph{#2}'']
1102 #3
1103 \end{fulllineitems}
1104}
Fred Drake64b72b62000-04-26 18:13:58 +00001105% \seerfc{number}{title}{why it's interesting}
1106\newcommand{\py@seerfc}[3]{%
1107 \par%
1108 \begin{fulllineitems}
1109 \item[\rfc{#1}, ``\emph{#2}'']
1110 #3
1111 \end{fulllineitems}
1112}
Fred Drake51313f12000-05-09 16:18:44 +00001113% \seeurl{url}{why it's interesting}
1114\newcommand{\py@seeurl}[2]{%
1115 \par%
1116 \begin{fulllineitems}
1117 \item[\url{#1}]
1118 #2
1119 \end{fulllineitems}
1120}
Fred Drake5ed35fd2001-11-30 18:09:54 +00001121
1122\newenvironment{seealso*}{
Fred Drake9466b9a1999-03-18 16:18:27 +00001123 \par
Fred Drake6659c301998-03-03 22:02:19 +00001124 \def\seetext##1{\par{##1}}
Fred Drake24340ea1998-04-28 18:30:34 +00001125 \let\seemodule=\py@seemodule
Fred Drake48449982000-09-12 17:52:33 +00001126 \let\seepep=\py@seepep
Fred Drake64b72b62000-04-26 18:13:58 +00001127 \let\seerfc=\py@seerfc
Fred Drake48449982000-09-12 17:52:33 +00001128 \let\seetitle=\py@seetitle
Fred Drake51313f12000-05-09 16:18:44 +00001129 \let\seeurl=\py@seeurl
Fred Drake6659c301998-03-03 22:02:19 +00001130}{\par}
Fred Drake5ed35fd2001-11-30 18:09:54 +00001131\newenvironment{seealso}{
1132 \par
1133 \strong{See Also:}
1134 \par
1135 \def\seetext##1{\par{##1}}
1136 \let\seemodule=\py@seemodule
1137 \let\seepep=\py@seepep
1138 \let\seerfc=\py@seerfc
1139 \let\seetitle=\py@seetitle
1140 \let\seeurl=\py@seeurl
1141}{\par}
Fred Drake6659c301998-03-03 22:02:19 +00001142
Fred Drakeaf958c71998-07-27 20:32:33 +00001143% Allow the Python release number to be specified independently of the
Fred Drake6659c301998-03-03 22:02:19 +00001144% \date{}. This allows the date to reflect the document's date and
1145% release to specify the Python release that is documented.
1146%
Fred Drake24340ea1998-04-28 18:30:34 +00001147\newcommand{\py@release}{}
Fred Drake6659c301998-03-03 22:02:19 +00001148\newcommand{\version}{}
Fred Drakeaf2b7142000-09-14 20:11:05 +00001149\newcommand{\shortversion}{}
Fred Drakec65218e2001-06-20 21:17:09 +00001150\newcommand{\releaseinfo}{}
Fred Drake6659c301998-03-03 22:02:19 +00001151\newcommand{\releasename}{Release}
1152\newcommand{\release}[1]{%
Fred Drake24340ea1998-04-28 18:30:34 +00001153 \renewcommand{\py@release}{\releasename\space\version}%
Fred Drake6659c301998-03-03 22:02:19 +00001154 \renewcommand{\version}{#1}}
Fred Drakeaf2b7142000-09-14 20:11:05 +00001155\newcommand{\setshortversion}[1]{%
1156 \renewcommand{\shortversion}{#1}}
Fred Drakec65218e2001-06-20 21:17:09 +00001157\newcommand{\setreleaseinfo}[1]{%
1158 \renewcommand{\releaseinfo}{#1}}
Fred Drake6659c301998-03-03 22:02:19 +00001159
1160% Allow specification of the author's address separately from the
1161% author's name. This can be used to format them differently, which
1162% is a good thing.
1163%
Fred Drake24340ea1998-04-28 18:30:34 +00001164\newcommand{\py@authoraddress}{}
1165\newcommand{\authoraddress}[1]{\renewcommand{\py@authoraddress}{#1}}
Fred Drake6df93ef1998-05-14 20:56:31 +00001166\let\developersaddress=\authoraddress
1167\let\developer=\author
1168\let\developers=\author
Fred Drake6659c301998-03-03 22:02:19 +00001169
Fred Drake6659c301998-03-03 22:02:19 +00001170% This sets up the fancy chapter headings that make the documents look
1171% at least a little better than the usual LaTeX output.
1172%
Fred Drake1c8d0e01998-03-07 05:29:15 +00001173\@ifundefined{ChTitleVar}{}{
Fred Drake24340ea1998-04-28 18:30:34 +00001174 \ChNameVar{\raggedleft\normalsize\py@HeaderFamily}
1175 \ChNumVar{\raggedleft \bfseries\Large\py@HeaderFamily}
1176 \ChTitleVar{\raggedleft \rm\Huge\py@HeaderFamily}
Fred Drake6659c301998-03-03 22:02:19 +00001177 % This creates chapter heads without the leading \vspace*{}:
Fred Drake1c8d0e01998-03-07 05:29:15 +00001178 \def\@makechapterhead#1{%
1179 {\parindent \z@ \raggedright \normalfont
1180 \ifnum \c@secnumdepth >\m@ne
Fred Drake6659c301998-03-03 22:02:19 +00001181 \DOCH
1182 \fi
Fred Drake1c8d0e01998-03-07 05:29:15 +00001183 \interlinepenalty\@M
Fred Drake6659c301998-03-03 22:02:19 +00001184 \DOTI{#1}
1185 }
1186 }
Fred Drake6659c301998-03-03 22:02:19 +00001187}
1188
Fred Drake3bf78651998-05-20 17:42:17 +00001189
1190% Definition lists; requested by AMK for HOWTO documents. Probably useful
1191% elsewhere as well, so keep in in the general style support.
1192%
1193\newenvironment{definitions}{%
1194 \begin{description}%
Fred Drakef9acc591998-09-09 15:27:43 +00001195 \def\term##1{\item[##1]\mbox{}\\*[0mm]}
Fred Drake3bf78651998-05-20 17:42:17 +00001196}{%
1197 \end{description}%
1198}
1199
Fred Drake6659c301998-03-03 22:02:19 +00001200% Tell TeX about pathological hyphenation cases:
1201\hyphenation{Base-HTTP-Re-quest-Hand-ler}