blob: e2c9dbb88346888b4843113e14cf40eb7caba2f7 [file] [log] [blame]
Fred Drake6659c301998-03-03 22:02:19 +00001%
Fred Drake6663b221998-03-06 22:33:06 +00002% python.sty for the Python docummentation [works only with with Latex2e]
Fred Drake6659c301998-03-03 22:02:19 +00003%
4
5\NeedsTeXFormat{LaTeX2e}[1995/12/01]
6\ProvidesPackage{python}
Fred Drakec0b2e451998-03-25 14:53:43 +00007 [1998/01/11 LaTeX package (Python markup)]
Fred Drake6659c301998-03-03 22:02:19 +00008
Fred Drake454a4fb1998-04-01 22:20:14 +00009% These packages can be used to add marginal annotations which indicate
10% index entries and labels; useful for reviewing this messy documentation!
11%
12%\RequirePackage{showkeys}
13%\RequirePackage{showidx}
14
Fred Drakec0b2e451998-03-25 14:53:43 +000015% for PDF output, use maximal compression & a lot of other stuff
16% (test for PDF recommended by Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov>)
17%
Fred Drake24340ea1998-04-28 18:30:34 +000018\newif\ifpy@doing@page@targets
19\py@doing@page@targetsfalse
Fred Drake6cb71491998-03-27 05:22:53 +000020
Fred Drakec0b2e451998-03-25 14:53:43 +000021\ifx\pdfoutput\undefined\else\ifcase\pdfoutput
Fred Drakec0b2e451998-03-25 14:53:43 +000022\else
Fred Drake6659c301998-03-03 22:02:19 +000023 \input{pdfcolor}
Fred Drake24340ea1998-04-28 18:30:34 +000024 \let\py@LinkColor=\NavyBlue
25 \let\py@NormalColor=\Black
Fred Drake6659c301998-03-03 22:02:19 +000026 \pdfcompresslevel=9
Fred Drakeba1700c1998-05-11 20:42:54 +000027 \pdfpagewidth=\paperwidth % page width of PDF output
28 \pdfpageheight=\paperheight % page height of PDF output
Fred Drakeebcb6581998-03-06 21:25:17 +000029 %
Fred Drakea2c2a831998-04-15 17:50:01 +000030 % Pad the number with '0' to 3 digits wide so no page name is a prefix
31 % of any other.
32 %
Fred Drakea488f301998-07-23 17:50:45 +000033 \newcommand{\py@targetno}[1]{\ifnum#1<100 0\fi\ifnum#1<10 0\fi#1}
34 \newcommand{\py@pageno}{\py@targetno\thepage}
Fred Drakea2c2a831998-04-15 17:50:01 +000035 %
Fred Drakeebcb6581998-03-06 21:25:17 +000036 % This definition allows the entries in the page-view of the ToC to be
37 % active links. Some work, some don't.
38 %
Fred Drake24340ea1998-04-28 18:30:34 +000039 \let\py@OldContentsline=\contentsline
Fred Drakeaa2aea01999-01-27 17:37:36 +000040 %
41 % Macro that takes two args: the name to link to and the content of
42 % the link. This takes care of the PDF magic, getting the colors
43 % the same for each link, and avoids having lots of garbage all over
44 % this style file.
45 \newcommand{\py@linkToName}[2]{%
46 \pdfannotlink attr{/Border [0 0 0]} goto name{#1}%
47 \py@LinkColor#2\py@NormalColor%
48 \pdfendlink%
49 }
Fred Drakea2c2a831998-04-15 17:50:01 +000050 % Compute the padded page number separately since we end up with a pair of
51 % \relax tokens; this gets the right string computed and works.
Fred Drake6659c301998-03-03 22:02:19 +000052 \renewcommand{\contentsline}[3]{%
Fred Drakea2c2a831998-04-15 17:50:01 +000053 \def\my@pageno{\py@targetno{#3}}%
Fred Drakeaa2aea01999-01-27 17:37:36 +000054 \py@OldContentsline{#1}{\py@linkToName{page\my@pageno}{#2}}{#3}%
Fred Drake6659c301998-03-03 22:02:19 +000055 }
Fred Drakeebcb6581998-03-06 21:25:17 +000056 \AtEndDocument{
Fred Drakec0b2e451998-03-25 14:53:43 +000057 \InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{}
Fred Drakeebcb6581998-03-06 21:25:17 +000058 }
Fred Drakea2c2a831998-04-15 17:50:01 +000059 \newcommand{\py@target}[1]{%
Fred Drake24340ea1998-04-28 18:30:34 +000060 \ifpy@doing@page@targets%
Fred Drakea2c2a831998-04-15 17:50:01 +000061 {\pdfdest name{#1} fit}%
62 \fi%
63 }
Fred Drake24340ea1998-04-28 18:30:34 +000064 \let\py@OldLabel=\label
Fred Drake6659c301998-03-03 22:02:19 +000065 \renewcommand{\label}[1]{%
Fred Drake24340ea1998-04-28 18:30:34 +000066 \py@OldLabel{#1}%
Fred Drakea2c2a831998-04-15 17:50:01 +000067 \py@target{label-#1}%
Fred Drake6659c301998-03-03 22:02:19 +000068 }
Fred Drakeba1700c1998-05-11 20:42:54 +000069 % This stuff adds a page# destination to every PDF page, where # is three
70 % digits wide, padded with leading zeros. This doesn't really help with
71 % the frontmatter, but does fine with the body.
Fred Drake6659c301998-03-03 22:02:19 +000072 %
73 % This is *heavily* based on the hyperref package.
74 %
Fred Drake1c8d0e01998-03-07 05:29:15 +000075 \def\@begindvi{%
76 \unvbox \@begindvibox
77 \@hyperfixhead
Fred Drake6659c301998-03-03 22:02:19 +000078 }
Fred Drake1c8d0e01998-03-07 05:29:15 +000079 \def\@hyperfixhead{%
80 \let\H@old@thehead\@thehead
Fred Drakea2c2a831998-04-15 17:50:01 +000081 \global\def\@foo{\py@target{page\py@pageno}}%
Fred Drake1c8d0e01998-03-07 05:29:15 +000082 \expandafter\ifx\expandafter\@empty\H@old@thehead
83 \def\H@old@thehead{\hfil}\fi
84 \def\@thehead{\@foo\relax\H@old@thehead}%
Fred Drake6659c301998-03-03 22:02:19 +000085 }
Fred Drakec0b2e451998-03-25 14:53:43 +000086\fi\fi
Fred Drake6659c301998-03-03 22:02:19 +000087
88% Increase printable page size (copied from fullpage.sty)
89\topmargin 0pt
90\advance \topmargin by -\headheight
91\advance \topmargin by -\headsep
92
93% attempt to work a little better for A4 users
Fred Drake1c8d0e01998-03-07 05:29:15 +000094\@ifundefined{paperheight}{
Fred Drake6659c301998-03-03 22:02:19 +000095 \textheight 9in
96}{
97 \textheight \paperheight
98 \advance\textheight by -2in
99}
100
101\oddsidemargin 0pt
102\evensidemargin \oddsidemargin
103\marginparwidth 0.5in
104
Fred Drake1c8d0e01998-03-07 05:29:15 +0000105\@ifundefined{paperwidth}{
Fred Drake6659c301998-03-03 22:02:19 +0000106 \textwidth 6.5in
107}{
108 \textwidth \paperwidth
109 \advance\textwidth by -2in
110}
111
112
113% Style parameters and macros used by most documents here
114\raggedbottom
115\sloppy
116\parindent = 0mm
Fred Drake24340ea1998-04-28 18:30:34 +0000117\parskip = 2mm
Fred Drake6659c301998-03-03 22:02:19 +0000118\hbadness = 5000 % don't print trivial gripes
119
120\pagestyle{empty} % start this way; change for
121\pagenumbering{roman} % ToC & chapters
122\setcounter{secnumdepth}{1}
123
124% Use this to set the font family for headers and other decor:
Fred Drake24340ea1998-04-28 18:30:34 +0000125\newcommand{\py@HeaderFamily}{\sffamily}
Fred Drake6659c301998-03-03 22:02:19 +0000126
127% Redefine the 'normal' header/footer style when using "fancyhdr" package:
Fred Drake1c8d0e01998-03-07 05:29:15 +0000128\@ifundefined{fancyhf}{}{
Fred Drake6659c301998-03-03 22:02:19 +0000129 % Use \pagestyle{normal} as the primary pagestyle for text.
130 \fancypagestyle{normal}{
131 \fancyhf{}
Fred Drake24340ea1998-04-28 18:30:34 +0000132 \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
133 \fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}}
134 \fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}}
Fred Drake6659c301998-03-03 22:02:19 +0000135 \renewcommand{\headrulewidth}{0pt}
136 \renewcommand{\footrulewidth}{0.4pt}
137 }
138 % Update the plain style so we get the page number & footer line,
139 % but not a chapter or section title. This is to keep the first
140 % page of a chapter and the blank page between chapters `clean.'
141 \fancypagestyle{plain}{
142 \fancyhf{}
Fred Drake24340ea1998-04-28 18:30:34 +0000143 \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
Fred Drake6659c301998-03-03 22:02:19 +0000144 \renewcommand{\headrulewidth}{0pt}
145 \renewcommand{\footrulewidth}{0.4pt}
146 }
147 % Redefine \cleardoublepage so that the blank page between chapters
148 % gets the plain style and not the fancy style. This is described
149 % in the documentation for the fancyhdr package by Piet von Oostrum.
Fred Drake1c8d0e01998-03-07 05:29:15 +0000150 \@ifundefined{chapter}{}{
Fred Drake28f13911998-03-04 21:47:59 +0000151 \renewcommand{\cleardoublepage}{
Fred Drake1c8d0e01998-03-07 05:29:15 +0000152 \clearpage\if@openright \ifodd\c@page\else
Fred Drake28f13911998-03-04 21:47:59 +0000153 \hbox{}
154 \thispagestyle{plain}
155 \newpage
Fred Drake1c8d0e01998-03-07 05:29:15 +0000156 \if@twocolumn\hbox{}\newpage\fi\fi\fi
Fred Drake28f13911998-03-04 21:47:59 +0000157 }
158 }
Fred Drake6659c301998-03-03 22:02:19 +0000159}
160
Fred Drake6659c301998-03-03 22:02:19 +0000161% This sets up the {verbatim} environment to be indented and a minipage,
162% and to have all the other mostly nice properties that we want for
163% code samples.
164
165% Variable used by begin code command
Fred Drake24340ea1998-04-28 18:30:34 +0000166\newlength{\py@codewidth}
Fred Drake6659c301998-03-03 22:02:19 +0000167
Fred Drake24340ea1998-04-28 18:30:34 +0000168\newcommand{\py@examplevspace}{2mm}
169\newcommand{\py@exampleindent}{1cm}
Fred Drake6659c301998-03-03 22:02:19 +0000170
Fred Drake24340ea1998-04-28 18:30:34 +0000171\let\py@OldVerbatim=\verbatim
172\let\py@OldEndVerbatim=\endverbatim
Fred Drake6659c301998-03-03 22:02:19 +0000173\renewcommand{\verbatim}{%
174 \begingroup%
Fred Drake24340ea1998-04-28 18:30:34 +0000175 \setlength{\parindent}\py@exampleindent%
Fred Drake6659c301998-03-03 22:02:19 +0000176 % Calculate the text width for the minipage:
Fred Drake24340ea1998-04-28 18:30:34 +0000177 \setlength{\py@codewidth}{\linewidth}%
178 \addtolength{\py@codewidth}{-\parindent}%
Fred Drake6659c301998-03-03 22:02:19 +0000179 %
180 \par%
Fred Drake24340ea1998-04-28 18:30:34 +0000181 \vspace\py@examplevspace%
Fred Drake6659c301998-03-03 22:02:19 +0000182 \indent%
Fred Drake24340ea1998-04-28 18:30:34 +0000183 \begin{minipage}[t]{\py@codewidth}%
Fred Drake6659c301998-03-03 22:02:19 +0000184 \small%
Fred Drake24340ea1998-04-28 18:30:34 +0000185 \py@OldVerbatim%
Fred Drake6659c301998-03-03 22:02:19 +0000186}
187\renewcommand{\endverbatim}{%
Fred Drake24340ea1998-04-28 18:30:34 +0000188 \py@OldEndVerbatim%
Fred Drake6659c301998-03-03 22:02:19 +0000189 \end{minipage}%
190 \endgroup%
191}
192
Fred Drake6cb71491998-03-27 05:22:53 +0000193
Fred Drakea488f301998-07-23 17:50:45 +0000194\newcommand{\py@modulebadkey}{{--just-some-junk--}}
Fred Drake6659c301998-03-03 22:02:19 +0000195
Fred Drake6659c301998-03-03 22:02:19 +0000196
197%% Lots of index-entry generation support.
198
199% Command to wrap around stuff that refers to function / module /
200% attribute names in the index. Default behavior: like \code{}. To
201% just keep the index entries in the roman font, uncomment the second
Fred Drakea488f301998-07-23 17:50:45 +0000202% definition; it matches O'Reilly style more.
Fred Drake6659c301998-03-03 22:02:19 +0000203%
Fred Drake24340ea1998-04-28 18:30:34 +0000204\newcommand{\py@idxcode}[1]{\texttt{#1}}
205%\renewcommand{\py@idxcode}[1]{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000206
207% Command to generate two index entries (using subentries)
208\newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}}
209
210% And three entries (using only one level of subentries)
211\newcommand{\indexiii}[3]{\index{#1!#2 #3}\index{#2!#3, #1}\index{#3!#1 #2}}
212
213% And four (again, using only one level of subentries)
214\newcommand{\indexiv}[4]{
215\index{#1!#2 #3 #4}
216\index{#2!#3 #4, #1}
217\index{#3!#4, #1 #2}
218\index{#4!#1 #2 #3}
219}
220
221% Command to generate a reference to a function, statement, keyword,
222% operator.
Fred Drake0cabff91998-05-06 19:36:01 +0000223\newcommand{\kwindex}[1]{\indexii{keyword}{#1@{\py@idxcode{#1}}}}
Fred Drake24340ea1998-04-28 18:30:34 +0000224\newcommand{\stindex}[1]{\indexii{statement}{#1@{\py@idxcode{#1}}}}
225\newcommand{\opindex}[1]{\indexii{operator}{#1@{\py@idxcode{#1}}}}
226\newcommand{\exindex}[1]{\indexii{exception}{#1@{\py@idxcode{#1}}}}
Fred Drake6659c301998-03-03 22:02:19 +0000227\newcommand{\obindex}[1]{\indexii{object}{#1}}
Fred Drake2351c801998-04-02 18:48:32 +0000228\newcommand{\bifuncindex}[1]{\withsubitem{(built-in function)}{\ttindex{#1()}}}
Fred Drake6659c301998-03-03 22:02:19 +0000229
230% Add an index entry for a module
Fred Drake24340ea1998-04-28 18:30:34 +0000231\newcommand{\py@refmodule}[2]{\index{#1@{\py@idxcode{#1}} (#2module)}}
232\newcommand{\refmodindex}[1]{\py@refmodule{#1}{}}
233\newcommand{\refbimodindex}[1]{\py@refmodule{#1}{built-in }}
234\newcommand{\refexmodindex}[1]{\py@refmodule{#1}{extension }}
235\newcommand{\refstmodindex}[1]{\py@refmodule{#1}{standard }}
Fred Drake6659c301998-03-03 22:02:19 +0000236
Fred Drakeda943741999-01-13 17:09:06 +0000237% Refer to a module's documentation using a hyperlink of the module's
238% name, at least if we're building PDF:
239\@ifundefined{pdfannotlink}{%
240 \newcommand{\refmodule}[2][\py@modulebadkey]{\module{#2}}
Fred Drakeaa2aea01999-01-27 17:37:36 +0000241}{%
242 \newcommand{\refmodule}[2][\py@modulebadkey]{%
Fred Drakeda943741999-01-13 17:09:06 +0000243 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
Fred Drakeaa2aea01999-01-27 17:37:36 +0000244 \py@linkToName{label-module-\py@modulekey}{\module{#2}}%
Fred Drakeda943741999-01-13 17:09:06 +0000245 }
246}
247
Fred Drake6659c301998-03-03 22:02:19 +0000248% support for the module index
Fred Drake24340ea1998-04-28 18:30:34 +0000249\newif\ifpy@UseModuleIndex
250\py@UseModuleIndexfalse
Fred Drakeb390daf1998-03-09 16:35:36 +0000251
Fred Drakeb390daf1998-03-09 16:35:36 +0000252\newcommand{\makemodindex}{
253 \newwrite\modindexfile
254 \openout\modindexfile=mod\jobname.idx
Fred Drake24340ea1998-04-28 18:30:34 +0000255 \py@UseModuleIndextrue
Fred Drakeb390daf1998-03-09 16:35:36 +0000256}
257
Fred Drake0ee9f721998-03-12 06:41:40 +0000258% Add the defining entry for a module
Fred Drake24340ea1998-04-28 18:30:34 +0000259\newcommand{\py@modindex}[2]{%
Fred Drakea488f301998-07-23 17:50:45 +0000260 \renewcommand{\py@thismodule}{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000261 \setindexsubitem{(in module #1)}%
Fred Drake24340ea1998-04-28 18:30:34 +0000262 \index{#1@{\py@idxcode{#1}} (#2module)|textbf}%
263 \ifpy@UseModuleIndex%
Fred Drake0c275fa1999-03-02 16:17:44 +0000264 \@ifundefined{py@modplat@\py@thismodulekey}{
265 \write\modindexfile{\protect\indexentry{#1@{\texttt{#1}}}{\thepage}}%
266 }{\write\modindexfile{\protect\indexentry{#1@{\texttt{#1} %
267 \emph{(\platformof[\py@thismodulekey]{})}}}{\thepage}}%
268 }
Fred Drake0ee9f721998-03-12 06:41:40 +0000269 \fi%
270}
271
Fred Drake6659c301998-03-03 22:02:19 +0000272% built-in & Python modules in the main distribution
Fred Drake24340ea1998-04-28 18:30:34 +0000273\newcommand{\bimodindex}[1]{\py@modindex{#1}{built-in }}
274\newcommand{\stmodindex}[1]{\py@modindex{#1}{standard }}
Fred Drake6659c301998-03-03 22:02:19 +0000275
276% Python & extension modules outside the main distribution
Fred Drake24340ea1998-04-28 18:30:34 +0000277\newcommand{\modindex}[1]{\py@modindex{#1}{}}
278\newcommand{\exmodindex}[1]{\py@modindex{#1}{extension }}
Fred Drake6659c301998-03-03 22:02:19 +0000279
280% Additional string for an index entry
Fred Drake1c8d0e01998-03-07 05:29:15 +0000281\newcommand{\index@subitem}{}
282\newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}}
Fred Drake24340ea1998-04-28 18:30:34 +0000283\newcommand{\ttindex}[1]{\index{#1@{\py@idxcode{#1}} \index@subitem}}
Fred Drake6659c301998-03-03 22:02:19 +0000284
Fred Drake0ee9f721998-03-12 06:41:40 +0000285\newcommand{\withsubitem}[2]{%
286 \begingroup%
287 \def\index@subitem{#1}#2%
288 \endgroup%
289}
Fred Drake6659c301998-03-03 22:02:19 +0000290
Fred Drake53714971998-04-02 22:33:16 +0000291
Fred Drakea488f301998-07-23 17:50:45 +0000292% Module synopsis processing -----------------------------------------------
293%
Fred Drake0c275fa1999-03-02 16:17:44 +0000294\newcommand{\py@thisclass}{}
295\newcommand{\py@thismodule}{}
296\newcommand{\py@thismodulekey}{}
297\newcommand{\py@thismoduletype}{}
298
Fred Drakea488f301998-07-23 17:50:45 +0000299\newcommand{\py@standardIndexModule}[1]{\stmodindex{#1}}
300\newcommand{\py@builtinIndexModule}[1]{\bimodindex{#1}}
301\newcommand{\py@extensionIndexModule}[1]{\exmodindex{#1}}
302\newcommand{\py@IndexModule}[1]{\modindex{#1}}
303
Fred Drake0c275fa1999-03-02 16:17:44 +0000304\newif\ifpy@HaveModSynopsis \py@HaveModSynopsisfalse
305\newif\ifpy@ModSynopsisFileIsOpen \py@ModSynopsisFileIsOpenfalse
306\newif\ifpy@HaveModPlatform \py@HaveModPlatformfalse
Fred Drakea488f301998-07-23 17:50:45 +0000307
308% \declaremodule[key]{type}{name}
309\newcommand{\declaremodule}[3][\py@modulebadkey]{
310 \py@openModSynopsisFile
311 \renewcommand{\py@thismoduletype}{#2}
Fred Drakea488f301998-07-23 17:50:45 +0000312 \ifx\py@modulebadkey#1
313 \renewcommand{\py@thismodulekey}{#3}
314 \else
315 \renewcommand{\py@thismodulekey}{#1}
316 \fi
Fred Drake0c275fa1999-03-02 16:17:44 +0000317 \csname py@#2IndexModule\endcsname{#3}
Fred Drakea488f301998-07-23 17:50:45 +0000318 \label{module-\py@thismodulekey}
Fred Drakea488f301998-07-23 17:50:45 +0000319}
Fred Drake0c275fa1999-03-02 16:17:44 +0000320\newif\ifpy@ModPlatformFileIsOpen \py@ModPlatformFileIsOpenfalse
321\newcommand{\py@ModPlatformFilename}{\jobname.pla}
322\newcommand{\platform}[1]{
323 \ifpy@ModPlatformFileIsOpen\else
324 \newwrite\py@ModPlatformFile
325 \openout\py@ModPlatformFile=\py@ModPlatformFilename
326 \py@ModPlatformFileIsOpentrue
327 \fi
328 \@ifundefined{py@modplat@\py@thismodulekey}{
329 \py@writeModPlatformFile{%
330 \newcommand{\csname py@modplat@\py@thismodulekey\endcsname}{#1}}%
331 }{\py@writeModPlatformFile{%
332 \newcommand{\string\py@modplat@\py@thismodulekey}{#1}%
333 }
334 }
335}
336\InputIfFileExists{\jobname.pla}{}{}
337\newcommand{\platformof}[2][\py@modulebadkey]{%
338 \ifx\py@modulebadkey#1 \def\py@key{#2}%
339 \else \def\py@key{#1}%
340 \fi%
341 \csname py@modplat@\py@key\endcsname%
342}
343\newcommand{\ignorePlatformAnnotation}[1]{}
Fred Drakea488f301998-07-23 17:50:45 +0000344
Fred Drakeb75c6151998-08-10 18:41:43 +0000345% \moduleauthor{name}{email}
346\newcommand{\moduleauthor}[2]{}
347
348% \sectionauthor{name}{email}
349\newcommand{\sectionauthor}[2]{}
350
Fred Drakea488f301998-07-23 17:50:45 +0000351
352\newcommand{\py@defsynopsis}{Module has no synopsis.}
353\newcommand{\py@modulesynopsis}{\py@defsynopsis}
354\newcommand{\modulesynopsis}[1]{
Fred Drake0c275fa1999-03-02 16:17:44 +0000355 \py@HaveModSynopsistrue
Fred Drakea488f301998-07-23 17:50:45 +0000356 \renewcommand{\py@modulesynopsis}{#1}
357}
358
359% define the file
360\newwrite\py@ModSynopsisFile
361
362% hacked from \addtocontents from latex.ltx:
363\long\def\py@writeModSynopsisFile#1{%
364 \protected@write\py@ModSynopsisFile%
365 {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
366 {\string#1}%
367}
368\newcommand{\py@closeModSynopsisFile}{
369 \ifpy@ModSynopsisFileIsOpen
370 \closeout\py@ModSynopsisFile
371 \py@ModSynopsisFileIsOpenfalse
372 \fi
373}
374\newcommand{\py@openModSynopsisFile}{
375 \ifpy@ModSynopsisFileIsOpen\else
376 \openout\py@ModSynopsisFile=\py@ModSynopsisFilename
377 \py@ModSynopsisFileIsOpentrue
378 \fi
379}
380
381\newcommand{\py@ProcessModSynopsis}{
382 \ifpy@HaveModSynopsis
383 \py@writeModSynopsisFile{\modulesynopsis%
384 {\py@thismodulekey}{\py@thismodule}%
385 {\py@thismoduletype}{\py@modulesynopsis}}%
386 \py@HaveModSynopsisfalse
387 \fi
388 \renewcommand{\py@modulesynopsis}{\py@defsynopsis}
389}
390\AtEndDocument{\py@ProcessModSynopsis\py@closeModSynopsisFile}
391
Fred Drake0c275fa1999-03-02 16:17:44 +0000392
393\long\def\py@writeModPlatformFile#1{%
394 \protected@write\py@ModPlatformFile%
395 {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
396 {\string#1}%
397}
398
399
Fred Drakea488f301998-07-23 17:50:45 +0000400\newcommand{\localmoduletable}{
401 \IfFileExists{\py@ModSynopsisFilename}{
402 \begin{synopsistable}
403 \input{\py@ModSynopsisFilename}
404 \end{synopsistable}
405 }{}
406}
407
408\@ifundefined{pdfoutput}{
409 \newcommand{\py@ModSynopsisSummary}[4]{\bfcode{#2} & #4\\}
410}{
Fred Drakeaa2aea01999-01-27 17:37:36 +0000411 \newcommand{\py@ModSynopsisSummary}[4]{%
412 \py@linkToName{label-module-#1}{\bfcode{#2}} & #4\\
413 }
Fred Drakea488f301998-07-23 17:50:45 +0000414}
415\newenvironment{synopsistable}{
416 % key, name, type, synopsis
417 \let\modulesynopsis=\py@ModSynopsisSummary
418 \begin{tabular}{ll}
419}{
420 \end{tabular}
421}
422%
423% --------------------------------------------------------------------------
424
425
Fred Drakea488f301998-07-23 17:50:45 +0000426\newcommand{\py@reset}{
427 \py@ProcessModSynopsis
428 \renewcommand{\py@thisclass}{}
429 \renewcommand{\py@thismodule}{}
430 \renewcommand{\py@thismodulekey}{}
431 \renewcommand{\py@thismoduletype}{}
432}
433
434% Augment the sectioning commands used to get our own font family in place,
435% and reset some internal data items:
436\renewcommand{\section}{\py@reset%
437 \@startsection{section}{1}{\z@}%
438 {-3.5ex \@plus -1ex \@minus -.2ex}%
439 {2.3ex \@plus.2ex}%
440 {\reset@font\Large\py@HeaderFamily}}
441\renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}%
442 {-3.25ex\@plus -1ex \@minus -.2ex}%
443 {1.5ex \@plus .2ex}%
444 {\reset@font\large\py@HeaderFamily}}
445\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}%
446 {-3.25ex\@plus -1ex \@minus -.2ex}%
447 {1.5ex \@plus .2ex}%
448 {\reset@font\normalsize\py@HeaderFamily}}
449\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}%
450 {3.25ex \@plus1ex \@minus.2ex}%
451 {-1em}%
452 {\reset@font\normalsize\py@HeaderFamily}}
453\renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}%
454 {3.25ex \@plus1ex \@minus .2ex}%
455 {-1em}%
456 {\reset@font\normalsize\py@HeaderFamily}}
457
458
Fred Drake5420f331998-07-23 21:41:02 +0000459% This gets the underscores closer to the right width; the only change
460% from standard LaTeX is the width specified.
461
462\DeclareTextCommandDefault{\textunderscore}{%
463 \leavevmode \kern.06em\vbox{\hrule\@width.55em}}
464
Fred Drakea488f301998-07-23 17:50:45 +0000465% Underscore hack (only act like subscript operator if in math mode)
466%
467% The following is due to Mark Wooding (the old version didn't work with
468% Latex 2e.
469
470\DeclareRobustCommand\hackscore{%
471 \ifmmode_\else\textunderscore\fi%
472}
473\begingroup
474\catcode`\_\active
475\def\next{%
476 \AtBeginDocument{\catcode`\_\active\def_{\hackscore{}}}%
477}
478\expandafter\endgroup\next
479
480
Fred Drake53714971998-04-02 22:33:16 +0000481% Now for a lot of semantically-loaded environments that do a ton of magical
482% things to get the right formatting and index entries for the stuff in
483% Python modules and C API.
484
485
Fred Drake6659c301998-03-03 22:02:19 +0000486% {fulllineitems} is used in one place in libregex.tex, but is really for
487% internal use in this file.
488%
Fred Drakef9acc591998-09-09 15:27:43 +0000489\newcommand{\py@itemnewline}[1]{%
490 \@tempdima\linewidth%
491 \advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}%
492}
493
Fred Drake6659c301998-03-03 22:02:19 +0000494\newenvironment{fulllineitems}{
495 \begin{list}{}{\labelwidth \leftmargin \labelsep 0pt
496 \rightmargin 0pt \topsep -\parskip \partopsep \parskip
497 \itemsep -\parsep
Fred Drakef9acc591998-09-09 15:27:43 +0000498 \let\makelabel=\py@itemnewline}
Fred Drake6659c301998-03-03 22:02:19 +0000499}{\end{list}}
500
Fred Drake6cb71491998-03-27 05:22:53 +0000501% \optional is mostly for use in the arguments parameters to the various
502% {*desc} environments defined below, but may be used elsewhere. Known to
503% be used in the debugger chapter.
Fred Drake24340ea1998-04-28 18:30:34 +0000504%
505% Typical usage:
506%
507% \begin{funcdesc}{myfunc}{reqparm\optional{, optparm}}
508% ^^^ ^^^
509% No space here No space here
510%
511% When a function has multiple optional parameters, \optional should be
512% nested, not chained. This is right:
513%
514% \begin{funcdesc}{myfunc}{\optional{parm1\optional{, parm2}}}
515%
Fred Drake6659c301998-03-03 22:02:19 +0000516\newcommand{\optional}[1]{%
517 {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
518
Fred Drake6cb71491998-03-27 05:22:53 +0000519% C functions ------------------------------------------------------------
520% \begin{cfuncdesc}{type}{name}{arglist}
521\newenvironment{cfuncdesc}[3]{
522 \begin{fulllineitems}
Fred Drake24340ea1998-04-28 18:30:34 +0000523 \item[\code{#1 \bfcode{#2}(\py@varvars{#3})}\index{#2@{\py@idxcode{#2()}}}]
Fred Drake6cb71491998-03-27 05:22:53 +0000524}{\end{fulllineitems}}
525
526% C variables ------------------------------------------------------------
527% \begin{cvardesc}{type}{name}
528\newenvironment{cvardesc}[2]{
529 \begin{fulllineitems}
Fred Drake24340ea1998-04-28 18:30:34 +0000530 \item[\code{#1 \bfcode{#2}}\index{#2@{\py@idxcode{#2}}}]
Fred Drake6cb71491998-03-27 05:22:53 +0000531}{\end{fulllineitems}}
532
533% C data types -----------------------------------------------------------
534% \begin{ctypedesc}{typedef name}
535\newenvironment{ctypedesc}[1]{
536 \begin{fulllineitems}
537 \item[\bfcode{#1}\ttindex{#1}]
538}{\end{fulllineitems}}
539
540% simple functions (not methods) -----------------------------------------
541% \begin{funcdesc}{name}{args}
542\newcommand{\funcline}[2]{\funclineni{#1}{#2}\ttindex{#1()}}
543\newenvironment{funcdesc}[2]{
544 \begin{fulllineitems}
545 \funcline{#1}{#2}
546}{\end{fulllineitems}}
547
Fred Drake6659c301998-03-03 22:02:19 +0000548% similar to {funcdesc}, but doesn't add to the index
Fred Drake300775d1998-04-17 02:17:00 +0000549\newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(\py@varvars{#2})}]}
Fred Drake6cb71491998-03-27 05:22:53 +0000550\newenvironment{funcdescni}[2]{
551 \begin{fulllineitems}
552 \funclineni{#1}{#2}
Fred Drake6659c301998-03-03 22:02:19 +0000553}{\end{fulllineitems}}
554
Fred Drake6cb71491998-03-27 05:22:53 +0000555% classes ----------------------------------------------------------------
556% \begin{classdesc}{name}{constructor args}
557\newenvironment{classdesc}[2]{
Fred Drake1cbd1961998-11-25 17:13:28 +0000558 % Using \renewcommand doesn't work for this, for unknown reasons:
559 \global\def\py@thisclass{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000560 \begin{fulllineitems}
Fred Drake300775d1998-04-17 02:17:00 +0000561 \item[\code{\bfcode{#1}(\py@varvars{#2})}%
Fred Drake24340ea1998-04-28 18:30:34 +0000562 \withsubitem{(class in \py@thismodule)}{\ttindex{#1}}]
Fred Drake6659c301998-03-03 22:02:19 +0000563}{\end{fulllineitems}}
564
Fred Drake6cb71491998-03-27 05:22:53 +0000565
Fred Drake24340ea1998-04-28 18:30:34 +0000566\let\py@classbadkey=\@undefined
Fred Drake6cb71491998-03-27 05:22:53 +0000567
568% object method ----------------------------------------------------------
569% \begin{methoddesc}[classname]{methodname}{args}
Fred Drake24340ea1998-04-28 18:30:34 +0000570\newcommand{\methodline}[3][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000571 \methodlineni{#2}{#3}
572 \ifx#1\@undefined
Fred Drake24340ea1998-04-28 18:30:34 +0000573 \withsubitem{(\py@thisclass\ method)}{\ttindex{#2()}}
Fred Drake6cb71491998-03-27 05:22:53 +0000574 \else
575 \withsubitem{(#1 method)}{\ttindex{#2()}}
576 \fi
577}
Fred Drake24340ea1998-04-28 18:30:34 +0000578\newenvironment{methoddesc}[3][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000579 \begin{fulllineitems}
580 \ifx#1\@undefined
581 \methodline{#2}{#3}
582 \else
Fred Drake24340ea1998-04-28 18:30:34 +0000583 \def\py@thisclass{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000584 \methodline[#1]{#2}{#3}
585 \fi
Fred Drake6659c301998-03-03 22:02:19 +0000586}{\end{fulllineitems}}
587
Fred Drake6cb71491998-03-27 05:22:53 +0000588% similar to {methoddesc}, but doesn't add to the index
589% (never actually uses the optional argument)
Fred Drake24340ea1998-04-28 18:30:34 +0000590\newcommand{\methodlineni}[3][\py@classbadkey]{%
Fred Drake300775d1998-04-17 02:17:00 +0000591 \item[\code{\bfcode{#2}(\py@varvars{#3})}]}
Fred Drake24340ea1998-04-28 18:30:34 +0000592\newenvironment{methoddescni}[3][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000593 \begin{fulllineitems}
594 \methodlineni{#2}{#3}
595}{\end{fulllineitems}}
596
597% object data attribute --------------------------------------------------
598% \begin{memberdesc}[classname]{membername}
Fred Drake24340ea1998-04-28 18:30:34 +0000599\newcommand{\memberline}[2][\py@classbadkey]{%
Fred Drake6cb71491998-03-27 05:22:53 +0000600 \ifx#1\@undefined
601 \memberlineni{#2}
Fred Drake24340ea1998-04-28 18:30:34 +0000602 \withsubitem{(\py@thisclass\ attribute)}{\ttindex{#2}}
Fred Drake6cb71491998-03-27 05:22:53 +0000603 \else
604 \memberlineni{#2}
Fred Drake41565f61998-04-07 19:32:40 +0000605 \withsubitem{(#1 attribute)}{\ttindex{#2}}
Fred Drake6cb71491998-03-27 05:22:53 +0000606 \fi
607}
Fred Drake24340ea1998-04-28 18:30:34 +0000608\newenvironment{memberdesc}[2][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000609 \begin{fulllineitems}
610 \ifx#1\@undefined
611 \memberline{#2}
612 \else
Fred Drake24340ea1998-04-28 18:30:34 +0000613 \def\py@thisclass{#1}
Fred Drake6cb71491998-03-27 05:22:53 +0000614 \memberline[#1]{#2}
615 \fi
616}{\end{fulllineitems}}
617
618% similar to {memberdesc}, but doesn't add to the index
619% (never actually uses the optional argument)
Fred Drake24340ea1998-04-28 18:30:34 +0000620\newcommand{\memberlineni}[2][\py@classbadkey]{\item[\bfcode{#2}]}
621\newenvironment{memberdescni}[2][\py@classbadkey]{
Fred Drake6cb71491998-03-27 05:22:53 +0000622 \begin{fulllineitems}
623 \memberlineni{#2}
624}{\end{fulllineitems}}
625
626% For exceptions: --------------------------------------------------------
627% \begin{excdesc}{name}
628% -- need support for constructor; maybe use optional parameter?
629\newenvironment{excdesc}[1]{
630 \begin{fulllineitems}
631 \item[\bfcode{#1}\ttindex{#1}]
632}{\end{fulllineitems}}
633
634% Module data or constants: ----------------------------------------------
635% \begin{datadesc}{name}
Fred Drake6659c301998-03-03 22:02:19 +0000636\newcommand{\dataline}[1]{\datalineni{#1}\ttindex{#1}}
Fred Drake6cb71491998-03-27 05:22:53 +0000637\newenvironment{datadesc}[1]{
638 \begin{fulllineitems}
639 \dataline{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000640}{\end{fulllineitems}}
641
642% similar to {datadesc}, but doesn't add to the index
Fred Drake6cb71491998-03-27 05:22:53 +0000643\newcommand{\datalineni}[1]{\item[\bfcode{#1}]\nopagebreak}
644\newenvironment{datadescni}[1]{
645 \begin{fulllineitems}
646 \datalineni{#1}
Fred Drake6659c301998-03-03 22:02:19 +0000647}{\end{fulllineitems}}
648
Fred Drake6cb71491998-03-27 05:22:53 +0000649% bytecode instruction ---------------------------------------------------
650% \begin{opcodedesc}{name}{var}
651% -- {var} may be {}
652\newenvironment{opcodedesc}[2]{
653 \begin{fulllineitems}
654 \item[\bfcode{#1}\quad\var{#2}]
Fred Drake6659c301998-03-03 22:02:19 +0000655}{\end{fulllineitems}}
656
657
Fred Drake24340ea1998-04-28 18:30:34 +0000658\newcommand{\nodename}[1]{\label{#1}}
Fred Drake55730311998-03-25 15:41:23 +0000659
Fred Drake6659c301998-03-03 22:02:19 +0000660% For these commands, use \command{} to get the typography right, not
661% {\command}. This works better with the texinfo translation.
662\newcommand{\ABC}{{\sc abc}}
663\newcommand{\UNIX}{{\sc Unix}}
664\newcommand{\POSIX}{POSIX}
665\newcommand{\ASCII}{{\sc ascii}}
666\newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}}
667\newcommand{\C}{C}
668\newcommand{\EOF}{{\sc eof}}
Fred Drake24340ea1998-04-28 18:30:34 +0000669\newcommand{\NULL}{\constant{NULL}}
Fred Drake6659c301998-03-03 22:02:19 +0000670
Fred Drake53714971998-04-02 22:33:16 +0000671% Also for consistency: spell Python "Python", not "python"!
672
Fred Drake6659c301998-03-03 22:02:19 +0000673% code is the most difficult one...
Fred Drake1c8d0e01998-03-07 05:29:15 +0000674\newcommand{\code}[1]{{\@vobeyspaces\@noligs\def\{{\char`\{}\def\}{\char`\}}\def\~{\char`\~}\def\^{\char`\^}\def\e{\char`\\}\def\${\char`\$}\def\#{\char`\#}\def\&{\char`\&}\def\%{\char`\%}%
Fred Drake24340ea1998-04-28 18:30:34 +0000675\texttt{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000676
677\newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font
Fred Drake8e54abe1998-07-01 14:49:25 +0000678\newcommand{\kbd}[1]{\code{#1}}
Fred Drake24340ea1998-04-28 18:30:34 +0000679\newcommand{\samp}[1]{`\code{#1}'}
Fred Drake6659c301998-03-03 22:02:19 +0000680% This weird definition of \var{} allows it to always appear in roman
681% italics, and won't get funky in code fragments when we play around
Fred Drakefa1cceb1998-11-30 14:42:59 +0000682% with fonts. This also works directly in math mode.
683\newcommand{\var}[1]{%
684 \ifmmode%
685 \hbox{\normalsize\textrm{\textit{#1\/}}}%
686 \else%
687 \normalsize\textrm{\textit{#1\/}}%
688 \fi%
689}
Fred Drake24340ea1998-04-28 18:30:34 +0000690\renewcommand{\emph}[1]{{\em #1}}
Fred Drake6659c301998-03-03 22:02:19 +0000691\newcommand{\dfn}[1]{\emph{#1}}
692\newcommand{\strong}[1]{{\bf #1}}
693% let's experiment with a new font:
Fred Drake0ee9f721998-03-12 06:41:40 +0000694\newcommand{\file}[1]{`{\small\textsf{#1}}'}
Fred Drake6659c301998-03-03 22:02:19 +0000695
696% Use this def/redef approach for \url{} since hyperref defined this already,
697% but only if we actually used hyperref:
Fred Drake6cb71491998-03-27 05:22:53 +0000698\@ifundefined{pdfannotlink}{
Fred Drakea2c2a831998-04-15 17:50:01 +0000699 \newcommand{\py@url}[1]{\mbox{\small\textsf{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000700}{
Fred Drakea2c2a831998-04-15 17:50:01 +0000701 \newcommand{\py@url}[1]{{%
Fred Drake6659c301998-03-03 22:02:19 +0000702 \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}%
Fred Drake24340ea1998-04-28 18:30:34 +0000703 \py@LinkColor% color of the link text
704 \mbox{\small\textsf{#1}}%
705 \py@NormalColor% Turn it back off; these are declarative
Fred Drake6659c301998-03-03 22:02:19 +0000706 \pdfendlink}% and don't appear bound to the current
707 }% formatting "box".
708}
Fred Drakea2c2a831998-04-15 17:50:01 +0000709\let\url=\py@url
Fred Drake0ee9f721998-03-12 06:41:40 +0000710\newcommand{\email}[1]{{\small\textsf{#1}}}
Fred Drake454a4fb1998-04-01 22:20:14 +0000711\newcommand{\newsgroup}[1]{{\small\textsf{#1}}}
Fred Drake6659c301998-03-03 22:02:19 +0000712
Fred Drake300775d1998-04-17 02:17:00 +0000713\newcommand{\py@varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}}
Fred Drake24340ea1998-04-28 18:30:34 +0000714% let's see if this breaks anything now; we may be able to simplify...
715\renewcommand{\py@varvars}[1]{\var{#1}}
Fred Drake6659c301998-03-03 22:02:19 +0000716
Fred Drake24340ea1998-04-28 18:30:34 +0000717% I'd really like to get rid of this!
Fred Drake6659c301998-03-03 22:02:19 +0000718\newif\iftexi\texifalse
Fred Drake6659c301998-03-03 22:02:19 +0000719
Fred Drake1e4973b1998-07-28 21:52:17 +0000720% This is used to get l2h to put the copyright and abstract on
721% a separate HTML page.
722\newif\ifhtml\htmlfalse
723
724
Fred Drake6659c301998-03-03 22:02:19 +0000725% These should be used for all references to identifiers which are
726% used to refer to instances of specific language constructs. See the
727% names for specific semantic assignments.
728%
729% For now, don't do anything really fancy with them; just use them as
730% logical markup. This might change in the future.
731%
Fred Drake24340ea1998-04-28 18:30:34 +0000732\newcommand{\module}[1]{\texttt{#1}}
733\newcommand{\keyword}[1]{\texttt{#1}}
734\newcommand{\exception}[1]{\texttt{#1}}
735\newcommand{\class}[1]{\texttt{#1}}
736\newcommand{\function}[1]{\texttt{#1}}
737\newcommand{\member}[1]{\texttt{#1}}
738\newcommand{\method}[1]{\texttt{#1}}
Fred Drake6659c301998-03-03 22:02:19 +0000739
Fred Drake53714971998-04-02 22:33:16 +0000740\newcommand{\pytype}[1]{#1} % built-in Python type
741
Fred Drake24340ea1998-04-28 18:30:34 +0000742\newcommand{\cfunction}[1]{\texttt{#1}}
743\newcommand{\ctype}[1]{\texttt{#1}} % C struct or typedef name
744\newcommand{\cdata}[1]{\texttt{#1}} % C variable, typically global
Fred Drake6659c301998-03-03 22:02:19 +0000745
Fred Drake0ee9f721998-03-12 06:41:40 +0000746\newcommand{\mimetype}[1]{{\small\textsf{#1}}}
Fred Drake94fac131998-03-12 19:37:03 +0000747% The \! is a "negative thin space" in math mode.
748\newcommand{\regexp}[1]{%
749 {\tiny$^{^\lceil}\!\!$%
750 {\normalsize\code{#1}}%
Fred Drake47cfd031998-04-03 21:22:31 +0000751 $\!\rfloor\!$%
Fred Drake94fac131998-03-12 19:37:03 +0000752 }}
Fred Drake0ee9f721998-03-12 06:41:40 +0000753\newcommand{\envvar}[1]{%
Fred Drake94fac131998-03-12 19:37:03 +0000754 \$#1% $ <-- bow to font-lock 3 times!
755 \index{#1@{\$#1}}% $
756 \index{environment variables!{\$#1}}% $
Fred Drake0ee9f721998-03-12 06:41:40 +0000757}
Fred Drake24340ea1998-04-28 18:30:34 +0000758\newcommand{\makevar}[1]{#1} % variable in a Makefile
759\newcommand{\character}[1]{\samp{#1}}
Fred Drake0ee9f721998-03-12 06:41:40 +0000760
Fred Drake6659c301998-03-03 22:02:19 +0000761% constants defined in Python modules or C headers, not language constants:
Fred Drake24340ea1998-04-28 18:30:34 +0000762\newcommand{\constant}[1]{\code{#1}} % manifest constant, not syntactic
Fred Drake6659c301998-03-03 22:02:19 +0000763
764\newcommand{\manpage}[2]{{\emph{#1}(#2)}}
765\newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}}
766\newcommand{\program}[1]{\strong{#1}}
767
768
769% Deprecation stuff.
770% Should be extended to allow an index / list of deprecated stuff. But
771% there's a lot of stuff that needs to be done to make that automatable.
772%
773% First parameter is the release number that deprecates the feature, the
774% second is the action the should be taken by users of the feature.
775%
776% Example:
Fred Drake24340ea1998-04-28 18:30:34 +0000777% \deprecated{1.5.1}{Use \method{frobnicate()} instead.}
Fred Drake6659c301998-03-03 22:02:19 +0000778%
779\newcommand{\deprecated}[2]{%
780 \strong{Deprecated since release #1.} #2\par}
781
Fred Drakeaf958c71998-07-27 20:32:33 +0000782% New stuff.
783% This should be used to mark things which have been added to the
784% development tree but that aren't in the release, but are documented.
785% This allows release of documentation that already includes updated
Fred Drake2116d981999-02-02 18:02:48 +0000786% descriptions. Place at end of descriptor environment.
Fred Drakeaf958c71998-07-27 20:32:33 +0000787%
788% Example:
789% \versionadded{1.5.2}
790%
791\newcommand{\versionadded}[1]{%
Fred Drake2116d981999-02-02 18:02:48 +0000792 { New in version #1. }}
Fred Drakeaf958c71998-07-27 20:32:33 +0000793\newcommand{\versionchanged}[1]{%
Fred Drake2116d981999-02-02 18:02:48 +0000794 { Changed in version #1. }}
Fred Drake6659c301998-03-03 22:02:19 +0000795
Fred Drakeaf958c71998-07-27 20:32:33 +0000796
797% Tables.
798%
Fred Drake6659c301998-03-03 22:02:19 +0000799\newenvironment{tableii}[4]{%
800 \begin{center}%
801 \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
Fred Drakeee601911998-04-11 20:53:03 +0000802 \begin{tabular}{#1}\strong{#3}&\strong{#4} \\ \hline%
Fred Drake6659c301998-03-03 22:02:19 +0000803}{%
Fred Drake6659c301998-03-03 22:02:19 +0000804 \end{tabular}%
805 \end{center}%
806}
807
808\newenvironment{tableiii}[5]{%
809 \begin{center}%
810 \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
Fred Drakeee601911998-04-11 20:53:03 +0000811 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5} \\ \hline%
Fred Drake6659c301998-03-03 22:02:19 +0000812}{%
Fred Drake6659c301998-03-03 22:02:19 +0000813 \end{tabular}%
814 \end{center}%
815}
816
Fred Drake30e52651998-07-24 22:11:29 +0000817\newenvironment{tableiv}[6]{%
818 \begin{center}%
819 \def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}%
820 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6} \\%
821 \hline%
822}{%
823 \end{tabular}%
824 \end{center}%
825}
826
Fred Drake24340ea1998-04-28 18:30:34 +0000827% Cross-referencing (AMK, new impl. FLD)
Fred Drake6659c301998-03-03 22:02:19 +0000828% Sample usage:
829% \begin{seealso}
830% \seemodule{rand}{Uniform random number generator}; % Module xref
831% \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book
Fred Drakeebcb6581998-03-06 21:25:17 +0000832%
833% % A funky case: module name contains '_'; have to supply an optional key
834% \seemodule[copyreg]{copy_reg}{pickle interface constructor registration}
835%
Fred Drake6659c301998-03-03 22:02:19 +0000836% \end{seealso}
837
Fred Drake1c8d0e01998-03-07 05:29:15 +0000838\@ifundefined{pdfannotlink}{%
Fred Drake24340ea1998-04-28 18:30:34 +0000839 \newcommand{\py@seemodule}[3][\py@modulebadkey]{%
Fred Drakeda943741999-01-13 17:09:06 +0000840 \par%
Fred Drake24340ea1998-04-28 18:30:34 +0000841 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
842 \ref{module-\py@modulekey}:\quad %
Fred Drakeebcb6581998-03-06 21:25:17 +0000843 Module \module{#2}%
844 \quad (#3)%
845 }
Fred Drake24340ea1998-04-28 18:30:34 +0000846}{\newcommand{\py@seemodule}[3][\py@modulebadkey]{%
Fred Drakeda943741999-01-13 17:09:06 +0000847 \par%
Fred Drake24340ea1998-04-28 18:30:34 +0000848 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
849 \ref{module-\py@modulekey}:\quad %
Fred Drakeaa2aea01999-01-27 17:37:36 +0000850 \py@linkToName{label-module-\py@modulekey}{ Module \module{#2} }
Fred Drakeebcb6581998-03-06 21:25:17 +0000851 \quad (#3)%
852 }
853}
Fred Drake6659c301998-03-03 22:02:19 +0000854\newenvironment{seealso}[0]{
855 \strong{See Also:}\par
Fred Drake6659c301998-03-03 22:02:19 +0000856 \def\seetext##1{\par{##1}}
Fred Drake24340ea1998-04-28 18:30:34 +0000857 \let\seemodule=\py@seemodule
Fred Drake6659c301998-03-03 22:02:19 +0000858}{\par}
859
860
Fred Drakeaf958c71998-07-27 20:32:33 +0000861% Allow the Python release number to be specified independently of the
Fred Drake6659c301998-03-03 22:02:19 +0000862% \date{}. This allows the date to reflect the document's date and
863% release to specify the Python release that is documented.
864%
Fred Drake24340ea1998-04-28 18:30:34 +0000865\newcommand{\py@release}{}
Fred Drake6659c301998-03-03 22:02:19 +0000866\newcommand{\version}{}
867\newcommand{\releasename}{Release}
868\newcommand{\release}[1]{%
Fred Drake24340ea1998-04-28 18:30:34 +0000869 \renewcommand{\py@release}{\releasename\space\version}%
Fred Drake6659c301998-03-03 22:02:19 +0000870 \renewcommand{\version}{#1}}
871
872% Allow specification of the author's address separately from the
873% author's name. This can be used to format them differently, which
874% is a good thing.
875%
Fred Drake24340ea1998-04-28 18:30:34 +0000876\newcommand{\py@authoraddress}{}
877\newcommand{\authoraddress}[1]{\renewcommand{\py@authoraddress}{#1}}
Fred Drake6df93ef1998-05-14 20:56:31 +0000878\let\developersaddress=\authoraddress
879\let\developer=\author
880\let\developers=\author
Fred Drake6659c301998-03-03 22:02:19 +0000881
Fred Drake6659c301998-03-03 22:02:19 +0000882% This sets up the fancy chapter headings that make the documents look
883% at least a little better than the usual LaTeX output.
884%
Fred Drake1c8d0e01998-03-07 05:29:15 +0000885\@ifundefined{ChTitleVar}{}{
Fred Drake24340ea1998-04-28 18:30:34 +0000886 \ChNameVar{\raggedleft\normalsize\py@HeaderFamily}
887 \ChNumVar{\raggedleft \bfseries\Large\py@HeaderFamily}
888 \ChTitleVar{\raggedleft \rm\Huge\py@HeaderFamily}
Fred Drake6659c301998-03-03 22:02:19 +0000889 % This creates chapter heads without the leading \vspace*{}:
Fred Drake1c8d0e01998-03-07 05:29:15 +0000890 \def\@makechapterhead#1{%
891 {\parindent \z@ \raggedright \normalfont
892 \ifnum \c@secnumdepth >\m@ne
Fred Drake6659c301998-03-03 22:02:19 +0000893 \DOCH
894 \fi
Fred Drake1c8d0e01998-03-07 05:29:15 +0000895 \interlinepenalty\@M
Fred Drake6659c301998-03-03 22:02:19 +0000896 \DOTI{#1}
897 }
898 }
Fred Drake6659c301998-03-03 22:02:19 +0000899}
900
Fred Drake3bf78651998-05-20 17:42:17 +0000901
902% Definition lists; requested by AMK for HOWTO documents. Probably useful
903% elsewhere as well, so keep in in the general style support.
904%
905\newenvironment{definitions}{%
906 \begin{description}%
Fred Drakef9acc591998-09-09 15:27:43 +0000907 \def\term##1{\item[##1]\mbox{}\\*[0mm]}
Fred Drake3bf78651998-05-20 17:42:17 +0000908}{%
909 \end{description}%
910}
911
Fred Drake6659c301998-03-03 22:02:19 +0000912% Tell TeX about pathological hyphenation cases:
913\hyphenation{Base-HTTP-Re-quest-Hand-ler}