blob: e98b3edb4fe4acdfde2af7bea80aa0ccf95b05b8 [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}
7 [1998/01/11 LaTeX package (Python manual markup)]
8
9% The "fncychap" package is used to get the nice chapter headers. The
10% .sty file is distributed with Python, so you should not need to disable
11% it. You'd also end up with a mixed page style; uglier than stock LaTeX!
12%
Fred Drake28f13911998-03-04 21:47:59 +000013\RequirePackage[Bjarne]{fncychap}\typeout{Using fancy chapter headings.}
Fred Drake6659c301998-03-03 22:02:19 +000014
Fred Drake6659c301998-03-03 22:02:19 +000015% for PDF output, use maximal compression
Fred Drake1c8d0e01998-03-07 05:29:15 +000016\@ifundefined{pdfannotlink}{
Fred Drake6659c301998-03-03 22:02:19 +000017 \let\LinkColor=\relax
18 \let\NormalColor=\relax
19}{%
20 \input{pdfcolor}
21 \let\LinkColor=\NavyBlue
22 \let\NormalColor=\Black
23 \pdfcompresslevel=9
Fred Drakeebcb6581998-03-06 21:25:17 +000024 %
25 % This definition allows the entries in the page-view of the ToC to be
26 % active links. Some work, some don't.
27 %
Fred Drake6659c301998-03-03 22:02:19 +000028 \let\OldContentsline=\contentsline
29 \renewcommand{\contentsline}[3]{%
30 \OldContentsline{#1}{%
31 \pdfannotlink attr{/Border [0 0 0]} goto name{page.#3}%
32 \LinkColor#2\NormalColor%
33 \pdfendlink%
34 }{#3}%
35 }
Fred Drakeebcb6581998-03-06 21:25:17 +000036 \renewcommand{\thepage}{\roman{page}}
37 %
38 % This is supposed to build the "outline" view of the document; it seems
39 % quite fragile. The breakages are the same as in the ToC.
40 %
41 \AtEndDocument{
42 \InputIfFileExists{\jobname.bkm}{\pdfcatalog pagemode{/UseOutlines}}{}
43 }
Fred Drake6659c301998-03-03 22:02:19 +000044 \let\OldLabel=\label
45 \renewcommand{\label}[1]{%
46 \OldLabel{#1}%
47 {\pdfdest name{label.#1} fit}%
48 }
49 % This stuff adds a page.# destination to every PDF page, where # has
50 % the same formatting as the displayed page number. This doesn't really
51 % help with the frontmatter, but does fine with the body.
52 %
53 % This is *heavily* based on the hyperref package.
54 %
Fred Drake1c8d0e01998-03-07 05:29:15 +000055 \def\@begindvi{%
56 \unvbox \@begindvibox
57 \@hyperfixhead
Fred Drake6659c301998-03-03 22:02:19 +000058 }
Fred Drakeebcb6581998-03-06 21:25:17 +000059 \def\hyperpageanchor{\pdfdest name{page.\thepage}}
Fred Drake6659c301998-03-03 22:02:19 +000060 \let\HYPERPAGEANCHOR\hyperpageanchor
Fred Drake1c8d0e01998-03-07 05:29:15 +000061 \def\@hyperfixhead{%
62 \let\H@old@thehead\@thehead
63 \gdef\@foo{\pdfdest name{page.\thepage} fit}%
64 \expandafter\ifx\expandafter\@empty\H@old@thehead
65 \def\H@old@thehead{\hfil}\fi
66 \def\@thehead{\@foo\relax\H@old@thehead}%
Fred Drake6659c301998-03-03 22:02:19 +000067 }
68}
69
70% Increase printable page size (copied from fullpage.sty)
71\topmargin 0pt
72\advance \topmargin by -\headheight
73\advance \topmargin by -\headsep
74
75% attempt to work a little better for A4 users
Fred Drake1c8d0e01998-03-07 05:29:15 +000076\@ifundefined{paperheight}{
Fred Drake6659c301998-03-03 22:02:19 +000077 \textheight 9in
78}{
79 \textheight \paperheight
80 \advance\textheight by -2in
81}
82
83\oddsidemargin 0pt
84\evensidemargin \oddsidemargin
85\marginparwidth 0.5in
86
Fred Drake1c8d0e01998-03-07 05:29:15 +000087\@ifundefined{paperwidth}{
Fred Drake6659c301998-03-03 22:02:19 +000088 \textwidth 6.5in
89}{
90 \textwidth \paperwidth
91 \advance\textwidth by -2in
92}
93
94
95% Style parameters and macros used by most documents here
96\raggedbottom
97\sloppy
98\parindent = 0mm
99\parskip = 2mm
100\hbadness = 5000 % don't print trivial gripes
101
102\pagestyle{empty} % start this way; change for
103\pagenumbering{roman} % ToC & chapters
104\setcounter{secnumdepth}{1}
105
106% Use this to set the font family for headers and other decor:
107\newcommand{\HeaderFamily}{\sffamily}
108
109% Redefine the 'normal' header/footer style when using "fancyhdr" package:
Fred Drake1c8d0e01998-03-07 05:29:15 +0000110\@ifundefined{fancyhf}{}{
Fred Drake6659c301998-03-03 22:02:19 +0000111 % Use \pagestyle{normal} as the primary pagestyle for text.
112 \fancypagestyle{normal}{
113 \fancyhf{}
114 \fancyfoot[LE,RO]{{\HeaderFamily\thepage}}
115 \fancyfoot[LO]{{\HeaderFamily\nouppercase{\rightmark}}}
116 \fancyfoot[RE]{{\HeaderFamily\nouppercase{\leftmark}}}
117 \renewcommand{\headrulewidth}{0pt}
118 \renewcommand{\footrulewidth}{0.4pt}
119 }
120 % Update the plain style so we get the page number & footer line,
121 % but not a chapter or section title. This is to keep the first
122 % page of a chapter and the blank page between chapters `clean.'
123 \fancypagestyle{plain}{
124 \fancyhf{}
125 \fancyfoot[LE,RO]{{\HeaderFamily\thepage}}
126 \renewcommand{\headrulewidth}{0pt}
127 \renewcommand{\footrulewidth}{0.4pt}
128 }
129 % Redefine \cleardoublepage so that the blank page between chapters
130 % gets the plain style and not the fancy style. This is described
131 % in the documentation for the fancyhdr package by Piet von Oostrum.
Fred Drake1c8d0e01998-03-07 05:29:15 +0000132 \@ifundefined{chapter}{}{
Fred Drake28f13911998-03-04 21:47:59 +0000133 \renewcommand{\cleardoublepage}{
Fred Drake1c8d0e01998-03-07 05:29:15 +0000134 \clearpage\if@openright \ifodd\c@page\else
Fred Drake28f13911998-03-04 21:47:59 +0000135 \hbox{}
136 \thispagestyle{plain}
137 \newpage
Fred Drake1c8d0e01998-03-07 05:29:15 +0000138 \if@twocolumn\hbox{}\newpage\fi\fi\fi
Fred Drake28f13911998-03-04 21:47:59 +0000139 }
140 }
Fred Drake6659c301998-03-03 22:02:19 +0000141}
142
143% old code font selections:
144\let\codefont=\tt
145\let\sectcodefont=\tt
146
147% (Haven't found a new one that gets <, >, and _ right without being
148% monospaced.)
149
150
151% This sets up the {verbatim} environment to be indented and a minipage,
152% and to have all the other mostly nice properties that we want for
153% code samples.
154
155% Variable used by begin code command
156\newlength{\codewidth}
157
158\newcommand{\examplevspace}{2mm}
159\newcommand{\exampleindent}{1cm}
160
161\let\OldVerbatim=\verbatim
162\let\OldEndVerbatim=\endverbatim
163\renewcommand{\verbatim}{%
164 \begingroup%
165 \setlength{\parindent}\exampleindent%
166 % Calculate the text width for the minipage:
167 \setlength{\codewidth}{\linewidth}%
168 \addtolength{\codewidth}{-\parindent}%
169 %
170 \par%
171 \vspace\examplevspace%
172 \indent%
173 \begin{minipage}[t]{\codewidth}%
174 \small%
175 \OldVerbatim%
176}
177\renewcommand{\endverbatim}{%
178 \OldEndVerbatim%
179 \end{minipage}%
180 \endgroup%
181}
182
183% Augment the sectioning commands used to get our own font family in place:
Fred Drake1c8d0e01998-03-07 05:29:15 +0000184\renewcommand{\section}{\@startsection {section}{1}{\z@}%
185 {-3.5ex \@plus -1ex \@minus -.2ex}%
186 {2.3ex \@plus.2ex}%
187 {\reset@font\Large\HeaderFamily}}
188\renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}%
189 {-3.25ex\@plus -1ex \@minus -.2ex}%
190 {1.5ex \@plus .2ex}%
191 {\reset@font\large\HeaderFamily}}
192\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}%
193 {-3.25ex\@plus -1ex \@minus -.2ex}%
194 {1.5ex \@plus .2ex}%
195 {\reset@font\normalsize\HeaderFamily}}
196\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}%
197 {3.25ex \@plus1ex \@minus.2ex}%
Fred Drake6659c301998-03-03 22:02:19 +0000198 {-1em}%
Fred Drake1c8d0e01998-03-07 05:29:15 +0000199 {\reset@font\normalsize\HeaderFamily}}
200\renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}%
201 {3.25ex \@plus1ex \@minus .2ex}%
Fred Drake6659c301998-03-03 22:02:19 +0000202 {-1em}%
Fred Drake1c8d0e01998-03-07 05:29:15 +0000203 {\reset@font\normalsize\HeaderFamily}}
Fred Drake6659c301998-03-03 22:02:19 +0000204
205
206% Underscore hack (only act like subscript operator if in math mode)
207%
208% The following is due to Mark Wooding (the old version didn't work with
209% Latex 2e.
210
211\DeclareRobustCommand\hackscore{%
212 \ifmmode_\else\textunderscore\fi%
213}
214\begingroup
215\catcode`\_\active
216\def\next{%
217 \AtBeginDocument{\catcode`\_\active\def_{\hackscore{}}}%
218}
219\expandafter\endgroup\next
220
221%
222% This is the old hack, which didn't work with 2e.
223% You should not need this since the rest of the documentation is now
224% LaTeX2e-only.
225%
226%\def\_{\ifnum\fam=\ttfamily \char'137\else{\tt\char'137}\fi}
227%\catcode`\_=12
228%\catcode`\_=\active\def_{\ifnum\fam=\ttfamily \char'137 \else{\tt\char'137}\fi}
229
230
231
232%% Lots of index-entry generation support.
233
234% Command to wrap around stuff that refers to function / module /
235% attribute names in the index. Default behavior: like \code{}. To
236% just keep the index entries in the roman font, uncomment the second
237% definition to use instead; it matches O'Reilly style more.
238%
239\newcommand{\idxcode}[1]{\codefont{#1}}
240%\renewcommand{\idxcode}[1]{#1}
241
242% Command to generate two index entries (using subentries)
243\newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}}
244
245% And three entries (using only one level of subentries)
246\newcommand{\indexiii}[3]{\index{#1!#2 #3}\index{#2!#3, #1}\index{#3!#1 #2}}
247
248% And four (again, using only one level of subentries)
249\newcommand{\indexiv}[4]{
250\index{#1!#2 #3 #4}
251\index{#2!#3 #4, #1}
252\index{#3!#4, #1 #2}
253\index{#4!#1 #2 #3}
254}
255
256% Command to generate a reference to a function, statement, keyword,
257% operator.
Fred Drake1c8d0e01998-03-07 05:29:15 +0000258\newcommand{\stindex}[1]{\indexii{statement}{#1@{\idxcode{#1}}}}
259\newcommand{\opindex}[1]{\indexii{operator}{#1@{\idxcode{#1}}}}
260\newcommand{\exindex}[1]{\indexii{exception}{#1@{\idxcode{#1}}}}
Fred Drake6659c301998-03-03 22:02:19 +0000261\newcommand{\obindex}[1]{\indexii{object}{#1}}
Fred Drake1c8d0e01998-03-07 05:29:15 +0000262\newcommand{\bifuncindex}[1]{\index{#1@{\idxcode{#1()}} (built-in function)}}
Fred Drake6659c301998-03-03 22:02:19 +0000263
264% Add an index entry for a module
Fred Drake1c8d0e01998-03-07 05:29:15 +0000265\newcommand{\refmodule}[2]{\index{#1@{\idxcode{#1}} (#2module)}}
Fred Drake6659c301998-03-03 22:02:19 +0000266\newcommand{\refmodindex}[1]{\refmodule{#1}{}}
267\newcommand{\refbimodindex}[1]{\refmodule{#1}{built-in }}
268\newcommand{\refexmodindex}[1]{\refmodule{#1}{extension }}
269\newcommand{\refstmodindex}[1]{\refmodule{#1}{standard }}
270
271% support for the module index
Fred Drakeb390daf1998-03-09 16:35:36 +0000272\newif\if@UseModuleIndex
273\@UseModuleIndexfalse
274
275\newcommand{\indexlabel}{genindex}
276
277% Fix the theindex environment to add an entry to the Table of
278% Contents; this is much nicer than just having to jump to the end of
279% the book and flip around, especially with multiple indexes.
280%
281\let\OldTheindex=\theindex
282\renewcommand{\theindex}{
283 \cleardoublepage
284 \OldTheindex
285 \addcontentsline{toc}{chapter}{\indexname}
286 \label{\indexlabel}
287}
288
289\newcommand{\@thismodule}{$<<$ ERROR - NO CURRENT MODULE $>>$}
Fred Drake6659c301998-03-03 22:02:19 +0000290
291% Add the defining entry for a module
Fred Drakeb390daf1998-03-09 16:35:36 +0000292\newcommand{\@modindex}[2]{%
Fred Drake1c8d0e01998-03-07 05:29:15 +0000293 \index{#1@{\idxcode{#1}} (#2module)|textbf}%
Fred Drake6659c301998-03-03 22:02:19 +0000294 \setindexsubitem{(in module #1)}%
Fred Drakeb390daf1998-03-09 16:35:36 +0000295 \if@UseModuleIndex%
296 \write\modindexfile{\protect\indexentry{#1@{\tt #1}}{\thepage}}%
297 \fi%
298 \renewcommand{\@thismodule}{#1}
299}
300
301\newcommand{\makemodindex}{
302 \newwrite\modindexfile
303 \openout\modindexfile=mod\jobname.idx
304 \@UseModuleIndextrue
305}
306
307\newcommand{\inputindex}[1]{
308 \IfFileExists{#1}{\input{#1}}{\begin{theindex}\end{theindex}}
309}
Fred Drake6659c301998-03-03 22:02:19 +0000310
311% built-in & Python modules in the main distribution
Fred Drakeb390daf1998-03-09 16:35:36 +0000312\newcommand{\bimodindex}[1]{\@modindex{#1}{built-in }}
313\newcommand{\stmodindex}[1]{\@modindex{#1}{standard }}
Fred Drake6659c301998-03-03 22:02:19 +0000314
315% Python & extension modules outside the main distribution
Fred Drakeb390daf1998-03-09 16:35:36 +0000316\newcommand{\modindex}[1]{\@modindex{#1}{}}
317\newcommand{\exmodindex}[1]{\@modindex{#1}{extension }}
Fred Drake6659c301998-03-03 22:02:19 +0000318
319% Additional string for an index entry
Fred Drake1c8d0e01998-03-07 05:29:15 +0000320\newcommand{\index@subitem}{}
321\newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}}
322\newcommand{\ttindex}[1]{\index{#1@{\idxcode{#1}} \index@subitem}}
Fred Drake6659c301998-03-03 22:02:19 +0000323
324
325% {fulllineitems} is used in one place in libregex.tex, but is really for
326% internal use in this file.
327%
328\newenvironment{fulllineitems}{
329 \begin{list}{}{\labelwidth \leftmargin \labelsep 0pt
330 \rightmargin 0pt \topsep -\parskip \partopsep \parskip
331 \itemsep -\parsep
332 \let\makelabel=\itemnewline}
333}{\end{list}}
334
335
336% cfuncdesc should be called as
337% \begin{cfuncdesc}{type}{name}{arglist}
338% ... description ...
339% \end{cfuncdesc}
340\newenvironment{cfuncdesc}[3]{%
341 \begin{fulllineitems}%
342 \item[\code{#1 \bfcode{#2}(\varvars{#3})}]%
Fred Drake1c8d0e01998-03-07 05:29:15 +0000343 \index{#2@{\idxcode{#2()}}}%
Fred Drake6659c301998-03-03 22:02:19 +0000344}{\end{fulllineitems}}
345
346\newenvironment{cvardesc}[2]{%
347 \begin{fulllineitems}%
348 \item[\code{#1 \bfcode{#2}}]%
Fred Drake1c8d0e01998-03-07 05:29:15 +0000349 \index{#2@{\idxcode{#2}}}%
Fred Drake6659c301998-03-03 22:02:19 +0000350}{\end{fulllineitems}}
351
352\newenvironment{ctypedesc}[1]{%
353 \begin{fulllineitems}%
354 \item[\bfcode{#1}]\ttindex{#1}
355}{\end{fulllineitems}}
356
357\newcommand{\funcline}[2]{\funclineni{#1}{#2}\ttindex{#1()}}
358\newenvironment{funcdesc}[2]{%
359 \begin{fulllineitems}%
360 \funcline{#1}{#2}%
361}{\end{fulllineitems}}
362
363\newcommand{\optional}[1]{%
364 {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
365
366% similar to {funcdesc}, but doesn't add to the index
367\newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(\varvars{#2})}]}
368\newenvironment{funcdescni}[2]{%
369 \begin{fulllineitems}%
370 \funclineni{#1}{#2}%
371}{\end{fulllineitems}}
372
373\newenvironment{classdesc}[2]{%
374 \begin{fulllineitems}%
375 \item[\code{\bfcode{#1}(\varvars{#2})}]%
376 \ttindex{#1}%
377 \def\baseclasses##1{}%
378}{\end{fulllineitems}}
379
380\newenvironment{excdesc}[1]{%
381 \begin{fulllineitems}%
382 \item[\bfcode{#1}]\ttindex{#1}%
383}{\end{fulllineitems}}
384
385\newcommand{\dataline}[1]{\datalineni{#1}\ttindex{#1}}
386\newenvironment{datadesc}[1]{%
387 \begin{fulllineitems}%
388 \dataline{#1}%
389}{\end{fulllineitems}}
390
391% similar to {datadesc}, but doesn't add to the index
392\newcommand{\datalineni}[1]{\item[\bfcode{#1}]}
393\newenvironment{datadescni}[1]{%
394 \begin{fulllineitems}%
395 \datalineni{#1}%
396}{\end{fulllineitems}}
397
398\newenvironment{opcodedesc}[2]{%
399 \begin{fulllineitems}%
400 \item[\bfcode{#1}\quad\var{#2}]%
401}{\end{fulllineitems}}
402
403
404\let\nodename=\label
405
406% For these commands, use \command{} to get the typography right, not
407% {\command}. This works better with the texinfo translation.
408\newcommand{\ABC}{{\sc abc}}
409\newcommand{\UNIX}{{\sc Unix}}
410\newcommand{\POSIX}{POSIX}
411\newcommand{\ASCII}{{\sc ascii}}
412\newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}}
413\newcommand{\C}{C}
414\newcommand{\EOF}{{\sc eof}}
415\newcommand{\NULL}{\code{NULL}}
416
417% code is the most difficult one...
Fred Drake1c8d0e01998-03-07 05:29:15 +0000418\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 Drake6659c301998-03-03 22:02:19 +0000419\mbox{\codefont{#1}}}}
420
421\newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font
422\newcommand{\kbd}[1]{\mbox{\tt #1}}
423\newcommand{\key}[1]{\mbox{\tt #1}}
424\newcommand{\samp}[1]{\mbox{`\code{#1}'}}
425% This weird definition of \var{} allows it to always appear in roman
426% italics, and won't get funky in code fragments when we play around
427% with fonts.
428\newcommand{\var}[1]{\mbox{\normalsize\textrm{\textit{#1\/}}}}
429\renewcommand{\emph}[1]{{\em #1\/}}
430\newcommand{\dfn}[1]{\emph{#1}}
431\newcommand{\strong}[1]{{\bf #1}}
432% let's experiment with a new font:
433\newcommand{\file}[1]{\mbox{`\small\textsf{#1}'}}
434
435% Use this def/redef approach for \url{} since hyperref defined this already,
436% but only if we actually used hyperref:
Fred Drake1c8d0e01998-03-07 05:29:15 +0000437\@ifundefined{pdfannotlink}{%
Fred Drake6659c301998-03-03 22:02:19 +0000438 \newcommand{\pythonurl}[1]{\mbox{\small\textsf{#1}}}%
439}{
440 \newcommand{\pythonurl}[1]{{%
441 \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}%
442 \LinkColor% color of the link text
443 \mbox{\small\textsf{#1}}%
444 \NormalColor% Turn it back off; these are declarative
445 \pdfendlink}% and don't appear bound to the current
446 }% formatting "box".
447}
448\let\url=\pythonurl
449\newcommand{\email}[1]{\mbox{\small\textsf{#1}}}
450
451\newcommand{\varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}}
452
453\newif\iftexi\texifalse
454\newif\iflatex\latextrue
455
456% These should be used for all references to identifiers which are
457% used to refer to instances of specific language constructs. See the
458% names for specific semantic assignments.
459%
460% For now, don't do anything really fancy with them; just use them as
461% logical markup. This might change in the future.
462%
463\let\module=\code
464\let\keyword=\code
465\let\exception=\code
466\let\class=\code
467\let\function=\code
468\let\member=\code
469\let\method=\code
470
471\let\cfunction=\code
472\let\ctype=\code
473\let\cdata=\code
474
475% constants defined in Python modules or C headers, not language constants:
476\let\constant=\code
477
478\newcommand{\manpage}[2]{{\emph{#1}(#2)}}
479\newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}}
480\newcommand{\program}[1]{\strong{#1}}
481
482
483% Deprecation stuff.
484% Should be extended to allow an index / list of deprecated stuff. But
485% there's a lot of stuff that needs to be done to make that automatable.
486%
487% First parameter is the release number that deprecates the feature, the
488% second is the action the should be taken by users of the feature.
489%
490% Example:
491%
492% \deprecated {1.5.1}
493% {Use \method{frobnicate()} instead.}
494%
495\newcommand{\deprecated}[2]{%
496 \strong{Deprecated since release #1.} #2\par}
497
498
499\newenvironment{tableii}[4]{%
500 \begin{center}%
501 \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
502 \begin{tabular}{#1}\hline \strong{#3}&\strong{#4} \\ \hline%
503}{%
504 \hline%
505 \end{tabular}%
506 \end{center}%
507}
508
509\newenvironment{tableiii}[5]{%
510 \begin{center}%
511 \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
512 \begin{tabular}{#1}\hline \strong{#3}&\strong{#4}&\strong{#5} \\ \hline%
513}{%
514 \hline%
515 \end{tabular}%
516 \end{center}%
517}
518
519\newcommand{\itemnewline}[1]{%
Fred Drake1c8d0e01998-03-07 05:29:15 +0000520 \@tempdima\linewidth%
521 \advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}%
Fred Drake6659c301998-03-03 22:02:19 +0000522}
523
524\newcommand{\sectcode}[1]{{\sectcodefont{#1}}}
525
526% Cross-referencing (AMK)
527% Sample usage:
528% \begin{seealso}
529% \seemodule{rand}{Uniform random number generator}; % Module xref
530% \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book
Fred Drakeebcb6581998-03-06 21:25:17 +0000531%
532% % A funky case: module name contains '_'; have to supply an optional key
533% \seemodule[copyreg]{copy_reg}{pickle interface constructor registration}
534%
Fred Drake6659c301998-03-03 22:02:19 +0000535% \end{seealso}
536
Fred Drake1c8d0e01998-03-07 05:29:15 +0000537\newif\if@keyedmodule\@keyedmodulefalse
538\newcommand{\@modulebadkey}{{--just-some-junk--}}
Fred Drakeebcb6581998-03-06 21:25:17 +0000539
Fred Drake1c8d0e01998-03-07 05:29:15 +0000540\@ifundefined{pdfannotlink}{%
541 \newcommand{\seemodule}[3][\@modulebadkey]{%
542 \ifx\@modulebadkey#1\def\@modulekey{#2}\else\def\@modulekey{#1}\fi%
543 \ref{module-\@modulekey}:\quad %
Fred Drakeebcb6581998-03-06 21:25:17 +0000544 Module \module{#2}%
545 \quad (#3)%
546 }
Fred Drake1c8d0e01998-03-07 05:29:15 +0000547}{\newcommand{\seemodule}[3][\@modulebadkey]{%
548 \ifx\@modulebadkey#1\def\@modulekey{#2}\else\def\@modulekey{#1}\fi%
549 \ref{module-\@modulekey}:\quad %
550 {\pdfannotlink attr{/Border [0 0 0]} goto name{label.module-\@modulekey}%
Fred Drakeebcb6581998-03-06 21:25:17 +0000551 \LinkColor Module \module{#2} \NormalColor%
552 \pdfendlink%
553 }%
554 \quad (#3)%
555 }
556}
Fred Drake6659c301998-03-03 22:02:19 +0000557\newenvironment{seealso}[0]{
558 \strong{See Also:}\par
Fred Drake6659c301998-03-03 22:02:19 +0000559 \def\seetext##1{\par{##1}}
560}{\par}
561
562
Fred Drake6659c301998-03-03 22:02:19 +0000563% Allow the release number to be specified independently of the
564% \date{}. This allows the date to reflect the document's date and
565% release to specify the Python release that is documented.
566%
Fred Drake1c8d0e01998-03-07 05:29:15 +0000567\newcommand{\@release}{}
Fred Drake6659c301998-03-03 22:02:19 +0000568\newcommand{\version}{}
569\newcommand{\releasename}{Release}
570\newcommand{\release}[1]{%
Fred Drake1c8d0e01998-03-07 05:29:15 +0000571 \renewcommand{\@release}{\releasename\space\version}%
Fred Drake6659c301998-03-03 22:02:19 +0000572 \renewcommand{\version}{#1}}
573
574% Allow specification of the author's address separately from the
575% author's name. This can be used to format them differently, which
576% is a good thing.
577%
Fred Drake1c8d0e01998-03-07 05:29:15 +0000578\newcommand{\@authoraddress}{}
579\newcommand{\authoraddress}[1]{\renewcommand{\@authoraddress}{#1}}
Fred Drake6659c301998-03-03 22:02:19 +0000580
Fred Drake6659c301998-03-03 22:02:19 +0000581% This sets up the fancy chapter headings that make the documents look
582% at least a little better than the usual LaTeX output.
583%
Fred Drake1c8d0e01998-03-07 05:29:15 +0000584\@ifundefined{ChTitleVar}{}{
Fred Drake6659c301998-03-03 22:02:19 +0000585 \ChNameVar{\raggedleft\normalsize\HeaderFamily}
586 \ChNumVar{\raggedleft \bfseries\Large\HeaderFamily}
587 \ChTitleVar{\raggedleft \rm\Huge\HeaderFamily}
588 % This creates chapter heads without the leading \vspace*{}:
Fred Drake1c8d0e01998-03-07 05:29:15 +0000589 \def\@makechapterhead#1{%
590 {\parindent \z@ \raggedright \normalfont
591 \ifnum \c@secnumdepth >\m@ne
Fred Drake6659c301998-03-03 22:02:19 +0000592 \DOCH
593 \fi
Fred Drake1c8d0e01998-03-07 05:29:15 +0000594 \interlinepenalty\@M
Fred Drake6659c301998-03-03 22:02:19 +0000595 \DOTI{#1}
596 }
597 }
Fred Drake6659c301998-03-03 22:02:19 +0000598}
599
600% Tell TeX about pathological hyphenation cases:
601\hyphenation{Base-HTTP-Re-quest-Hand-ler}