Oops -- Lib/Test should be Lib/test, of course!
[python/dscho.git] / Doc / texinputs / python.sty
blobfc121b8b4c62c23b7a3440f0f368e23e433fd666
2 % python.sty for the Python docummentation [works only with with Latex2e]
5 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
6 \ProvidesPackage{python}
7 [1998/01/11 LaTeX package (Python markup)]
9 % These packages can be used to add marginal annotations which indicate
10 % index entries and labels; useful for reviewing this messy documentation!
12 %\RequirePackage{showkeys}
13 %\RequirePackage{showidx}
15 % for PDF output, use maximal compression & a lot of other stuff
16 % (test for PDF recommended by Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov>)
18 \newif\if@doing@page@targets
19 \@doing@page@targetsfalse
21 \ifx\pdfoutput\undefined\else\ifcase\pdfoutput
22 \let\LinkColor=\relax
23 \let\NormalColor=\relax
24 \else
25 \input{pdfcolor}
26 \let\LinkColor=\NavyBlue
27 \let\NormalColor=\Black
28 \pdfcompresslevel=9
30 % This definition allows the entries in the page-view of the ToC to be
31 % active links. Some work, some don't.
33 \let\OldContentsline=\contentsline
34 \renewcommand{\contentsline}[3]{%
35 \OldContentsline{#1}{%
36 \pdfannotlink attr{/Border [0 0 0]} goto name{page.#3}%
37 \LinkColor#2\NormalColor%
38 \pdfendlink%
39 }{#3}%
42 % This is supposed to build the "outline" view of the document; it seems
43 % quite fragile. The breakages are the same as in the ToC.
45 \AtEndDocument{
46 \InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{}
48 \let\OldLabel=\label
49 \renewcommand{\label}[1]{%
50 \OldLabel{#1}%
51 {\pdfdest name{label.#1} fit}%
53 % This stuff adds a page.# destination to every PDF page, where # has
54 % the same formatting as the displayed page number. This doesn't really
55 % help with the frontmatter, but does fine with the body.
57 % This is *heavily* based on the hyperref package.
59 \def\@begindvi{%
60 \unvbox \@begindvibox
61 \@hyperfixhead
63 \def\@hyperfixhead{%
64 \let\H@old@thehead\@thehead
65 \gdef\@foo{\if@doing@page@targets\pdfdest name{page.\thepage} fit\fi}%
66 \expandafter\ifx\expandafter\@empty\H@old@thehead
67 \def\H@old@thehead{\hfil}\fi
68 \def\@thehead{\@foo\relax\H@old@thehead}%
70 \fi\fi
72 % Increase printable page size (copied from fullpage.sty)
73 \topmargin 0pt
74 \advance \topmargin by -\headheight
75 \advance \topmargin by -\headsep
77 % attempt to work a little better for A4 users
78 \@ifundefined{paperheight}{
79 \textheight 9in
81 \textheight \paperheight
82 \advance\textheight by -2in
85 \oddsidemargin 0pt
86 \evensidemargin \oddsidemargin
87 \marginparwidth 0.5in
89 \@ifundefined{paperwidth}{
90 \textwidth 6.5in
92 \textwidth \paperwidth
93 \advance\textwidth by -2in
97 % Style parameters and macros used by most documents here
98 \raggedbottom
99 \sloppy
100 \parindent = 0mm
101 \parskip = 2mm
102 \hbadness = 5000 % don't print trivial gripes
104 \pagestyle{empty} % start this way; change for
105 \pagenumbering{roman} % ToC & chapters
106 \setcounter{secnumdepth}{1}
108 % Use this to set the font family for headers and other decor:
109 \newcommand{\HeaderFamily}{\sffamily}
111 % Redefine the 'normal' header/footer style when using "fancyhdr" package:
112 \@ifundefined{fancyhf}{}{
113 % Use \pagestyle{normal} as the primary pagestyle for text.
114 \fancypagestyle{normal}{
115 \fancyhf{}
116 \fancyfoot[LE,RO]{{\HeaderFamily\thepage}}
117 \fancyfoot[LO]{{\HeaderFamily\nouppercase{\rightmark}}}
118 \fancyfoot[RE]{{\HeaderFamily\nouppercase{\leftmark}}}
119 \renewcommand{\headrulewidth}{0pt}
120 \renewcommand{\footrulewidth}{0.4pt}
122 % Update the plain style so we get the page number & footer line,
123 % but not a chapter or section title. This is to keep the first
124 % page of a chapter and the blank page between chapters `clean.'
125 \fancypagestyle{plain}{
126 \fancyhf{}
127 \fancyfoot[LE,RO]{{\HeaderFamily\thepage}}
128 \renewcommand{\headrulewidth}{0pt}
129 \renewcommand{\footrulewidth}{0.4pt}
131 % Redefine \cleardoublepage so that the blank page between chapters
132 % gets the plain style and not the fancy style. This is described
133 % in the documentation for the fancyhdr package by Piet von Oostrum.
134 \@ifundefined{chapter}{}{
135 \renewcommand{\cleardoublepage}{
136 \clearpage\if@openright \ifodd\c@page\else
137 \hbox{}
138 \thispagestyle{plain}
139 \newpage
140 \if@twocolumn\hbox{}\newpage\fi\fi\fi
145 % old code font selections:
146 \let\codefont=\tt
147 \let\sectcodefont=\tt
149 % (Haven't found a new one that gets <, >, and _ right without being
150 % monospaced.)
153 % This sets up the {verbatim} environment to be indented and a minipage,
154 % and to have all the other mostly nice properties that we want for
155 % code samples.
157 % Variable used by begin code command
158 \newlength{\codewidth}
160 \newcommand{\examplevspace}{2mm}
161 \newcommand{\exampleindent}{1cm}
163 \let\OldVerbatim=\verbatim
164 \let\OldEndVerbatim=\endverbatim
165 \renewcommand{\verbatim}{%
166 \begingroup%
167 \setlength{\parindent}\exampleindent%
168 % Calculate the text width for the minipage:
169 \setlength{\codewidth}{\linewidth}%
170 \addtolength{\codewidth}{-\parindent}%
172 \par%
173 \vspace\examplevspace%
174 \indent%
175 \begin{minipage}[t]{\codewidth}%
176 \small%
177 \OldVerbatim%
179 \renewcommand{\endverbatim}{%
180 \OldEndVerbatim%
181 \end{minipage}%
182 \endgroup%
185 \newcommand{\reset@python}{
186 \global\let\@thisclass=\@undefined
187 \global\let\@thismodule=\@undefined
189 \reset@python
191 % Augment the sectioning commands used to get our own font family in place,
192 % and reset some internal data items:
193 \renewcommand{\section}{\reset@python%
194 \@startsection {section}{1}{\z@}%
195 {-3.5ex \@plus -1ex \@minus -.2ex}%
196 {2.3ex \@plus.2ex}%
197 {\reset@font\Large\HeaderFamily}}
198 \renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}%
199 {-3.25ex\@plus -1ex \@minus -.2ex}%
200 {1.5ex \@plus .2ex}%
201 {\reset@font\large\HeaderFamily}}
202 \renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}%
203 {-3.25ex\@plus -1ex \@minus -.2ex}%
204 {1.5ex \@plus .2ex}%
205 {\reset@font\normalsize\HeaderFamily}}
206 \renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}%
207 {3.25ex \@plus1ex \@minus.2ex}%
208 {-1em}%
209 {\reset@font\normalsize\HeaderFamily}}
210 \renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}%
211 {3.25ex \@plus1ex \@minus .2ex}%
212 {-1em}%
213 {\reset@font\normalsize\HeaderFamily}}
216 % Underscore hack (only act like subscript operator if in math mode)
218 % The following is due to Mark Wooding (the old version didn't work with
219 % Latex 2e.
221 \DeclareRobustCommand\hackscore{%
222 \ifmmode_\else\textunderscore\fi%
224 \begingroup
225 \catcode`\_\active
226 \def\next{%
227 \AtBeginDocument{\catcode`\_\active\def_{\hackscore{}}}%
229 \expandafter\endgroup\next
232 %% Lots of index-entry generation support.
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.
239 \newcommand{\idxcode}[1]{\codefont{#1}}
240 %\renewcommand{\idxcode}[1]{#1}
242 % Command to generate two index entries (using subentries)
243 \newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}}
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}}
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}
256 % Command to generate a reference to a function, statement, keyword,
257 % operator.
258 \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}}}}
261 \newcommand{\obindex}[1]{\indexii{object}{#1}}
262 \newcommand{\bifuncindex}[1]{\withsubitem{(built-in function)}{\ttindex{#1()}}}
264 % Add an index entry for a module
265 \newcommand{\refmodule}[2]{\index{#1@{\idxcode{#1}} (#2module)}}
266 \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 }}
271 % support for the module index
272 \newif\if@UseModuleIndex
273 \@UseModuleIndexfalse
275 % Fix the theindex environment to add an entry to the Table of
276 % Contents; this is much nicer than just having to jump to the end of
277 % the book and flip around, especially with multiple indexes.
279 \let\OldTheindex=\theindex
280 \renewcommand{\theindex}{
281 \cleardoublepage
282 \OldTheindex
283 \addcontentsline{toc}{chapter}{\indexname}
286 \newcommand{\makemodindex}{
287 \newwrite\modindexfile
288 \openout\modindexfile=mod\jobname.idx
289 \@UseModuleIndextrue
292 % Add the defining entry for a module
293 \newcommand{\@modindex}[2]{%
294 \global\def\@thismodule{#1}
295 \setindexsubitem{(in module #1)}%
296 \index{#1@{\idxcode{#1}} (#2module)|textbf}%
297 \if@UseModuleIndex%
298 \write\modindexfile{\protect\indexentry{#1@{\tt #1}}{\thepage}}%
299 \fi%
302 % built-in & Python modules in the main distribution
303 \newcommand{\bimodindex}[1]{\@modindex{#1}{built-in }}
304 \newcommand{\stmodindex}[1]{\@modindex{#1}{standard }}
306 % Python & extension modules outside the main distribution
307 \newcommand{\modindex}[1]{\@modindex{#1}{}}
308 \newcommand{\exmodindex}[1]{\@modindex{#1}{extension }}
310 % Additional string for an index entry
311 \newcommand{\index@subitem}{}
312 \newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}}
313 \newcommand{\ttindex}[1]{\index{#1@{\idxcode{#1}} \index@subitem}}
315 \newcommand{\withsubitem}[2]{%
316 \begingroup%
317 \def\index@subitem{#1}#2%
318 \endgroup%
322 % Now for a lot of semantically-loaded environments that do a ton of magical
323 % things to get the right formatting and index entries for the stuff in
324 % Python modules and C API.
327 % {fulllineitems} is used in one place in libregex.tex, but is really for
328 % internal use in this file.
330 \newenvironment{fulllineitems}{
331 \begin{list}{}{\labelwidth \leftmargin \labelsep 0pt
332 \rightmargin 0pt \topsep -\parskip \partopsep \parskip
333 \itemsep -\parsep
334 \let\makelabel=\itemnewline}
335 }{\end{list}}
337 % \optional is mostly for use in the arguments parameters to the various
338 % {*desc} environments defined below, but may be used elsewhere. Known to
339 % be used in the debugger chapter.
340 \newcommand{\optional}[1]{%
341 {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
343 % C functions ------------------------------------------------------------
344 % \begin{cfuncdesc}{type}{name}{arglist}
345 \newenvironment{cfuncdesc}[3]{
346 \begin{fulllineitems}
347 \item[\code{#1 \bfcode{#2}(\varvars{#3})}\index{#2@{\idxcode{#2()}}}]
348 }{\end{fulllineitems}}
350 % C variables ------------------------------------------------------------
351 % \begin{cvardesc}{type}{name}
352 \newenvironment{cvardesc}[2]{
353 \begin{fulllineitems}
354 \item[\code{#1 \bfcode{#2}}\index{#2@{\idxcode{#2}}}]
355 }{\end{fulllineitems}}
357 % C data types -----------------------------------------------------------
358 % \begin{ctypedesc}{typedef name}
359 \newenvironment{ctypedesc}[1]{
360 \begin{fulllineitems}
361 \item[\bfcode{#1}\ttindex{#1}]
362 }{\end{fulllineitems}}
364 % simple functions (not methods) -----------------------------------------
365 % \begin{funcdesc}{name}{args}
366 \newcommand{\funcline}[2]{\funclineni{#1}{#2}\ttindex{#1()}}
367 \newenvironment{funcdesc}[2]{
368 \begin{fulllineitems}
369 \funcline{#1}{#2}
370 }{\end{fulllineitems}}
372 % similar to {funcdesc}, but doesn't add to the index
373 \newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(\varvars{#2})}]}
374 \newenvironment{funcdescni}[2]{
375 \begin{fulllineitems}
376 \funclineni{#1}{#2}
377 }{\end{fulllineitems}}
379 % classes ----------------------------------------------------------------
380 % \begin{classdesc}{name}{constructor args}
381 \newenvironment{classdesc}[2]{
382 \global\def\@thisclass{#1}
383 \begin{fulllineitems}
384 \item[\code{\bfcode{#1}(\varvars{#2})}%
385 \withsubitem{(class in \@thismodule)}{\ttindex{#1}}]
386 \def\baseclasses##1{}
387 }{\end{fulllineitems}}
390 \newcommand{\@classbadkey}{--bad current class--}
391 \let\@classbadkey=\@undefined
393 % object method ----------------------------------------------------------
394 % \begin{methoddesc}[classname]{methodname}{args}
395 \newcommand{\methodline}[3][\@classbadkey]{
396 \methodlineni{#2}{#3}
397 \ifx#1\@undefined
398 \withsubitem{(\@thisclass\ method)}{\ttindex{#2()}}
399 \else
400 \withsubitem{(#1 method)}{\ttindex{#2()}}
403 \newenvironment{methoddesc}[3][\@classbadkey]{
404 \begin{fulllineitems}
405 \ifx#1\@undefined
406 \methodline{#2}{#3}
407 \else
408 \def\@thisclass{#1}
409 \methodline[#1]{#2}{#3}
411 }{\end{fulllineitems}}
413 % similar to {methoddesc}, but doesn't add to the index
414 % (never actually uses the optional argument)
415 \newcommand{\methodlineni}[3][\@classbadkey]{%
416 \item[\code{\bfcode{#2}(\varvars{#3})}]}
417 \newenvironment{methoddescni}[3][\@classbadkey]{
418 \begin{fulllineitems}
419 \methodlineni{#2}{#3}
420 }{\end{fulllineitems}}
422 % object data attribute --------------------------------------------------
423 % \begin{memberdesc}[classname]{membername}
424 \newcommand{\memberline}[2][\@classbadkey]{%
425 \ifx#1\@undefined
426 \memberlineni{#2}
427 \withsubitem{(\@thisclass\ attribute)}{\ttindex{#2}}
428 \else
429 \memberlineni{#2}
430 \withsubitem{(#1 attribute)}{\ttindex{#2}}
433 \newenvironment{memberdesc}[2][\@classbadkey]{
434 \begin{fulllineitems}
435 \ifx#1\@undefined
436 \memberline{#2}
437 \else
438 \def\@thisclass{#1}
439 \memberline[#1]{#2}
441 }{\end{fulllineitems}}
443 % similar to {memberdesc}, but doesn't add to the index
444 % (never actually uses the optional argument)
445 \newcommand{\memberlineni}[2][\@classbadkey]{\item[\bfcode{#2}]}
446 \newenvironment{memberdescni}[2][\@classbadkey]{
447 \begin{fulllineitems}
448 \memberlineni{#2}
449 }{\end{fulllineitems}}
451 % For exceptions: --------------------------------------------------------
452 % \begin{excdesc}{name}
453 % -- need support for constructor; maybe use optional parameter?
454 \newenvironment{excdesc}[1]{
455 \begin{fulllineitems}
456 \item[\bfcode{#1}\ttindex{#1}]
457 }{\end{fulllineitems}}
459 % Module data or constants: ----------------------------------------------
460 % \begin{datadesc}{name}
461 \newcommand{\dataline}[1]{\datalineni{#1}\ttindex{#1}}
462 \newenvironment{datadesc}[1]{
463 \begin{fulllineitems}
464 \dataline{#1}
465 }{\end{fulllineitems}}
467 % similar to {datadesc}, but doesn't add to the index
468 \newcommand{\datalineni}[1]{\item[\bfcode{#1}]\nopagebreak}
469 \newenvironment{datadescni}[1]{
470 \begin{fulllineitems}
471 \datalineni{#1}
472 }{\end{fulllineitems}}
474 % bytecode instruction ---------------------------------------------------
475 % \begin{opcodedesc}{name}{var}
476 % -- {var} may be {}
477 \newenvironment{opcodedesc}[2]{
478 \begin{fulllineitems}
479 \item[\bfcode{#1}\quad\var{#2}]
480 }{\end{fulllineitems}}
483 \let\nodename=\label
485 \newcommand{\sectcode}[1]{{\sectcodefont{#1}}}
487 % For these commands, use \command{} to get the typography right, not
488 % {\command}. This works better with the texinfo translation.
489 \newcommand{\ABC}{{\sc abc}}
490 \newcommand{\UNIX}{{\sc Unix}}
491 \newcommand{\POSIX}{POSIX}
492 \newcommand{\ASCII}{{\sc ascii}}
493 \newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}}
494 \newcommand{\C}{C}
495 \newcommand{\EOF}{{\sc eof}}
496 \newcommand{\NULL}{\sectcode{NULL}}
498 % Also for consistency: spell Python "Python", not "python"!
500 % code is the most difficult one...
501 \newcommand{\code}[1]{{\@vobeyspaces\@noligs\def\{{\char`\{}\def\}{\char`\}}\def\~{\char`\~}\def\^{\char`\^}\def\e{\char`\\}\def\${\char`\$}\def\#{\char`\#}\def\&{\char`\&}\def\%{\char`\%}%
502 \mbox{\codefont{#1}}}}
504 \newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font
505 \newcommand{\kbd}[1]{\mbox{\tt #1}}
506 \newcommand{\key}[1]{\mbox{\tt #1}}
507 \newcommand{\samp}[1]{\mbox{`\code{#1}'}}
508 % This weird definition of \var{} allows it to always appear in roman
509 % italics, and won't get funky in code fragments when we play around
510 % with fonts.
511 \newcommand{\var}[1]{\mbox{\normalsize\textrm{\textit{#1\/}}}}
512 \renewcommand{\emph}[1]{{\em #1\/}}
513 \newcommand{\dfn}[1]{\emph{#1}}
514 \newcommand{\strong}[1]{{\bf #1}}
515 % let's experiment with a new font:
516 \newcommand{\file}[1]{`{\small\textsf{#1}}'}
518 % Use this def/redef approach for \url{} since hyperref defined this already,
519 % but only if we actually used hyperref:
520 \@ifundefined{pdfannotlink}{
521 \newcommand{\pythonurl}[1]{\mbox{\small\textsf{#1}}}
523 \newcommand{\pythonurl}[1]{{%
524 \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}%
525 \LinkColor% color of the link text
526 {\small\textsf{#1}}%
527 \NormalColor% Turn it back off; these are declarative
528 \pdfendlink}% and don't appear bound to the current
529 }% formatting "box".
531 \let\url=\pythonurl
532 \newcommand{\email}[1]{{\small\textsf{#1}}}
533 \newcommand{\newsgroup}[1]{{\small\textsf{#1}}}
535 \newcommand{\varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}}
537 \newif\iftexi\texifalse
538 \newif\iflatex\latextrue
540 % These should be used for all references to identifiers which are
541 % used to refer to instances of specific language constructs. See the
542 % names for specific semantic assignments.
544 % For now, don't do anything really fancy with them; just use them as
545 % logical markup. This might change in the future.
547 \let\module=\sectcode
548 \let\keyword=\sectcode
549 \let\exception=\sectcode
550 \let\class=\sectcode
551 \let\function=\sectcode
552 \let\member=\sectcode
553 \let\method=\sectcode
555 \newcommand{\pytype}[1]{#1} % built-in Python type
557 \let\cfunction=\sectcode
558 \let\ctype=\sectcode
559 \let\cdata=\sectcode
561 \newcommand{\mimetype}[1]{{\small\textsf{#1}}}
562 % The \! is a "negative thin space" in math mode.
563 \newcommand{\regexp}[1]{%
564 {\tiny$^{^\lceil}\!\!$%
565 {\normalsize\code{#1}}%
566 $\!\rfloor\!$%
568 \newcommand{\envvar}[1]{%
569 \$#1% $ <-- bow to font-lock 3 times!
570 \index{#1@{\$#1}}% $
571 \index{environment variables!{\$#1}}% $
573 \newcommand{\makevar}[1]{#1}
574 \let\character=\samp
576 % constants defined in Python modules or C headers, not language constants:
577 \let\constant=\sectcode
579 \newcommand{\manpage}[2]{{\emph{#1}(#2)}}
580 \newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}}
581 \newcommand{\program}[1]{\strong{#1}}
584 % Deprecation stuff.
585 % Should be extended to allow an index / list of deprecated stuff. But
586 % there's a lot of stuff that needs to be done to make that automatable.
588 % First parameter is the release number that deprecates the feature, the
589 % second is the action the should be taken by users of the feature.
591 % Example:
593 % \deprecated {1.5.1}
594 % {Use \method{frobnicate()} instead.}
596 \newcommand{\deprecated}[2]{%
597 \strong{Deprecated since release #1.} #2\par}
600 \newenvironment{tableii}[4]{%
601 \begin{center}%
602 \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
603 \begin{tabular}{#1}\strong{#3}&\strong{#4} \\ \hline%
605 \end{tabular}%
606 \end{center}%
609 \newenvironment{tableiii}[5]{%
610 \begin{center}%
611 \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
612 \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5} \\ \hline%
614 \end{tabular}%
615 \end{center}%
618 \newcommand{\itemnewline}[1]{%
619 \@tempdima\linewidth%
620 \advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}%
623 % Cross-referencing (AMK)
624 % Sample usage:
625 % \begin{seealso}
626 % \seemodule{rand}{Uniform random number generator}; % Module xref
627 % \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book
629 % % A funky case: module name contains '_'; have to supply an optional key
630 % \seemodule[copyreg]{copy_reg}{pickle interface constructor registration}
632 % \end{seealso}
634 \newcommand{\@modulebadkey}{{--just-some-junk--}}
636 \@ifundefined{pdfannotlink}{%
637 \newcommand{\seemodule}[3][\@modulebadkey]{%
638 \ifx\@modulebadkey#1\def\@modulekey{#2}\else\def\@modulekey{#1}\fi%
639 \ref{module-\@modulekey}:\quad %
640 Module \module{#2}%
641 \quad (#3)%
643 }{\newcommand{\seemodule}[3][\@modulebadkey]{%
644 \ifx\@modulebadkey#1\def\@modulekey{#2}\else\def\@modulekey{#1}\fi%
645 \ref{module-\@modulekey}:\quad %
646 {\pdfannotlink attr{/Border [0 0 0]} goto name{label.module-\@modulekey}%
647 \LinkColor Module \module{#2} \NormalColor%
648 \pdfendlink%
650 \quad (#3)%
653 \newenvironment{seealso}[0]{
654 \strong{See Also:}\par
655 \def\seetext##1{\par{##1}}
656 }{\par}
659 % Allow the release number to be specified independently of the
660 % \date{}. This allows the date to reflect the document's date and
661 % release to specify the Python release that is documented.
663 \newcommand{\@release}{}
664 \newcommand{\version}{}
665 \newcommand{\releasename}{Release}
666 \newcommand{\release}[1]{%
667 \renewcommand{\@release}{\releasename\space\version}%
668 \renewcommand{\version}{#1}}
670 % Allow specification of the author's address separately from the
671 % author's name. This can be used to format them differently, which
672 % is a good thing.
674 \newcommand{\@authoraddress}{}
675 \newcommand{\authoraddress}[1]{\renewcommand{\@authoraddress}{#1}}
677 % This sets up the fancy chapter headings that make the documents look
678 % at least a little better than the usual LaTeX output.
680 \@ifundefined{ChTitleVar}{}{
681 \ChNameVar{\raggedleft\normalsize\HeaderFamily}
682 \ChNumVar{\raggedleft \bfseries\Large\HeaderFamily}
683 \ChTitleVar{\raggedleft \rm\Huge\HeaderFamily}
684 % This creates chapter heads without the leading \vspace*{}:
685 \def\@makechapterhead#1{%
686 {\parindent \z@ \raggedright \normalfont
687 \ifnum \c@secnumdepth >\m@ne
688 \DOCH
690 \interlinepenalty\@M
691 \DOTI{#1}
696 % Tell TeX about pathological hyphenation cases:
697 \hyphenation{Base-HTTP-Re-quest-Hand-ler}