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\ifpy@doing@page@targets
19 \py@doing@page@targetsfalse
21 \ifx\pdfoutput\undefined\else\ifcase\pdfoutput
24 \let\py@LinkColor=
\NavyBlue
25 \let\py@NormalColor=
\Black
27 \pdfpagewidth=
\paperwidth % page width of PDF output
28 \pdfpageheight=
\paperheight % page height of PDF output
30 % Pad the number with '0' to 3 digits wide so no page name is a prefix
33 \newcommand{\py@targetno
}[1]{\ifnum#1<
100 0\fi\ifnum#1<
10 0\fi#1}
34 \newcommand{\py@pageno
}{\py@targetno
\thepage}
36 % This definition allows the entries in the page-view of the ToC to be
37 % active links. Some work, some don't.
39 \let\py@OldContentsline=
\contentsline
40 % Compute the padded page number separately since we end up with a pair of
41 % \relax tokens; this gets the right string computed and works.
42 \renewcommand{\contentsline}[3]{%
43 \def\my@pageno
{\py@targetno
{#3}}%
44 \py@OldContentsline
{#1}{%
45 \pdfannotlink attr
{/Border
[0 0 0]} goto name
{page
\my@pageno
}%
46 \py@LinkColor
#2\py@NormalColor
%
51 \InputIfFileExists{\jobname.bkm
}{\pdfcatalog{/PageMode /UseOutlines
}}{}
53 \newcommand{\py@target
}[1]{%
54 \ifpy@doing@page@targets
%
55 {\pdfdest name
{#1} fit
}%
58 \let\py@OldLabel=
\label
59 \renewcommand{\label}[1]{%
63 % This stuff adds a page# destination to every PDF page, where # is three
64 % digits wide, padded with leading zeros. This doesn't really help with
65 % the frontmatter, but does fine with the body.
67 % This is *heavily* based on the hyperref package.
74 \let\H@old@thehead\@thehead
75 \global\def\@foo
{\py@target
{page
\py@pageno
}}%
76 \expandafter\ifx\expandafter\@empty
\H@old@thehead
77 \def\H@old@thehead
{\hfil}\fi
78 \def\@thehead
{\@foo
\relax\H@old@thehead
}%
82 % Increase printable page size (copied from fullpage.sty)
84 \advance \topmargin by -
\headheight
85 \advance \topmargin by -
\headsep
87 % attempt to work a little better for A4 users
88 \@ifundefined
{paperheight
}{
91 \textheight \paperheight
92 \advance\textheight by -
2in
96 \evensidemargin \oddsidemargin
99 \@ifundefined
{paperwidth
}{
102 \textwidth \paperwidth
103 \advance\textwidth by -
2in
107 % Style parameters and macros used by most documents here
112 \hbadness =
5000 % don't print trivial gripes
114 \pagestyle{empty
} % start this way; change for
115 \pagenumbering{roman
} % ToC & chapters
116 \setcounter{secnumdepth
}{1}
118 % Use this to set the font family for headers and other decor:
119 \newcommand{\py@HeaderFamily
}{\sffamily}
121 % Redefine the 'normal' header/footer style when using "fancyhdr" package:
122 \@ifundefined
{fancyhf
}{}{
123 % Use \pagestyle{normal} as the primary pagestyle for text.
124 \fancypagestyle{normal
}{
126 \fancyfoot[LE,RO
]{{\py@HeaderFamily
\thepage}}
127 \fancyfoot[LO
]{{\py@HeaderFamily
\nouppercase{\rightmark}}}
128 \fancyfoot[RE
]{{\py@HeaderFamily
\nouppercase{\leftmark}}}
129 \renewcommand{\headrulewidth}{0pt
}
130 \renewcommand{\footrulewidth}{0.4pt
}
132 % Update the plain style so we get the page number & footer line,
133 % but not a chapter or section title. This is to keep the first
134 % page of a chapter and the blank page between chapters `clean.'
135 \fancypagestyle{plain
}{
137 \fancyfoot[LE,RO
]{{\py@HeaderFamily
\thepage}}
138 \renewcommand{\headrulewidth}{0pt
}
139 \renewcommand{\footrulewidth}{0.4pt
}
141 % Redefine \cleardoublepage so that the blank page between chapters
142 % gets the plain style and not the fancy style. This is described
143 % in the documentation for the fancyhdr package by Piet von Oostrum.
144 \@ifundefined
{chapter
}{}{
145 \renewcommand{\cleardoublepage}{
146 \clearpage\if@openright
\ifodd\c@page
\else
148 \thispagestyle{plain
}
150 \if@twocolumn
\hbox{}\newpage\fi\fi\fi
155 % This sets up the {verbatim} environment to be indented and a minipage,
156 % and to have all the other mostly nice properties that we want for
159 % Variable used by begin code command
160 \newlength{\py@codewidth
}
162 \newcommand{\py@examplevspace
}{2mm
}
163 \newcommand{\py@exampleindent
}{1cm
}
165 \let\py@OldVerbatim=
\verbatim
166 \let\py@OldEndVerbatim=
\endverbatim
167 \renewcommand{\verbatim}{%
169 \setlength{\parindent}\py@exampleindent
%
170 % Calculate the text width for the minipage:
171 \setlength{\py@codewidth
}{\linewidth}%
172 \addtolength{\py@codewidth
}{-
\parindent}%
175 \vspace\py@examplevspace
%
177 \begin{minipage
}[t
]{\py@codewidth
}%
181 \renewcommand{\endverbatim}{%
188 \newcommand{\py@modulebadkey
}{{--just-some-junk--
}}
191 %% Lots of index-entry generation support.
193 % Command to wrap around stuff that refers to function / module /
194 % attribute names in the index. Default behavior: like \code{}. To
195 % just keep the index entries in the roman font, uncomment the second
196 % definition; it matches O'Reilly style more.
198 \newcommand{\py@idxcode
}[1]{\texttt{#1}}
199 %\renewcommand{\py@idxcode}[1]{#1}
201 % Command to generate two index entries (using subentries)
202 \newcommand{\indexii}[2]{\index{#1!
#2}\index{#2!
#1}}
204 % And three entries (using only one level of subentries)
205 \newcommand{\indexiii}[3]{\index{#1!
#2 #3}\index{#2!
#3,
#1}\index{#3!
#1 #2}}
207 % And four (again, using only one level of subentries)
208 \newcommand{\indexiv}[4]{
215 % Command to generate a reference to a function, statement, keyword,
217 \newcommand{\kwindex}[1]{\indexii{keyword
}{#1@
{\py@idxcode
{#1}}}}
218 \newcommand{\stindex}[1]{\indexii{statement
}{#1@
{\py@idxcode
{#1}}}}
219 \newcommand{\opindex}[1]{\indexii{operator
}{#1@
{\py@idxcode
{#1}}}}
220 \newcommand{\exindex}[1]{\indexii{exception
}{#1@
{\py@idxcode
{#1}}}}
221 \newcommand{\obindex}[1]{\indexii{object
}{#1}}
222 \newcommand{\bifuncindex}[1]{\withsubitem{(built-in function)
}{\ttindex{#1()
}}}
224 % Add an index entry for a module
225 \newcommand{\py@refmodule
}[2]{\index{#1@
{\py@idxcode
{#1}} (
#2module)
}}
226 \newcommand{\refmodindex}[1]{\py@refmodule
{#1}{}}
227 \newcommand{\refbimodindex}[1]{\py@refmodule
{#1}{built-in
}}
228 \newcommand{\refexmodindex}[1]{\py@refmodule
{#1}{extension
}}
229 \newcommand{\refstmodindex}[1]{\py@refmodule
{#1}{standard
}}
231 % support for the module index
232 \newif\ifpy@UseModuleIndex
233 \py@UseModuleIndexfalse
235 \newcommand{\makemodindex}{
236 \newwrite\modindexfile
237 \openout\modindexfile=mod
\jobname.idx
238 \py@UseModuleIndextrue
241 % Add the defining entry for a module
242 \newcommand{\py@modindex
}[2]{%
243 \renewcommand{\py@thismodule
}{#1}
244 \setindexsubitem{(in module
#1)
}%
245 \index{#1@
{\py@idxcode
{#1}} (
#2module)|textbf
}%
246 \ifpy@UseModuleIndex
%
247 \write\modindexfile{\protect\indexentry{#1@
{\tt #1}}{\thepage}}%
251 % built-in & Python modules in the main distribution
252 \newcommand{\bimodindex}[1]{\py@modindex
{#1}{built-in
}}
253 \newcommand{\stmodindex}[1]{\py@modindex
{#1}{standard
}}
255 % Python & extension modules outside the main distribution
256 \newcommand{\modindex}[1]{\py@modindex
{#1}{}}
257 \newcommand{\exmodindex}[1]{\py@modindex
{#1}{extension
}}
259 % Additional string for an index entry
260 \newcommand{\index@subitem
}{}
261 \newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem
}{#1}}
262 \newcommand{\ttindex}[1]{\index{#1@
{\py@idxcode
{#1}} \index@subitem
}}
264 \newcommand{\withsubitem}[2]{%
266 \def\index@subitem
{#1}#2%
271 % Module synopsis processing -----------------------------------------------
273 \newcommand{\py@standardIndexModule
}[1]{\stmodindex{#1}}
274 \newcommand{\py@builtinIndexModule
}[1]{\bimodindex{#1}}
275 \newcommand{\py@extensionIndexModule
}[1]{\exmodindex{#1}}
276 \newcommand{\py@IndexModule
}[1]{\modindex{#1}}
278 \newif\ifpy@HaveModSynopsis
\py@HaveModSynopsisfalse
279 \newif\ifpy@ModSynopsisFileIsOpen
\py@ModSynopsisFileIsOpenfalse
281 % \declaremodule[key]{type}{name}
282 \newcommand{\declaremodule}[3][\py@modulebadkey
]{
283 \py@openModSynopsisFile
284 \renewcommand{\py@thismoduletype
}{#2}
285 \csname py@
#2IndexModule
\endcsname{#3}
286 \ifx\py@modulebadkey
#1
287 \renewcommand{\py@thismodulekey
}{#3}
289 \renewcommand{\py@thismodulekey
}{#1}
291 \label{module-
\py@thismodulekey
}
292 \py@HaveModSynopsistrue
295 % \moduleauthor{name}{email}
296 \newcommand{\moduleauthor}[2]{}
298 % \sectionauthor{name}{email}
299 \newcommand{\sectionauthor}[2]{}
302 \newcommand{\py@defsynopsis
}{Module has no synopsis.
}
303 \newcommand{\py@modulesynopsis
}{\py@defsynopsis
}
304 \newcommand{\modulesynopsis}[1]{
305 \renewcommand{\py@modulesynopsis
}{#1}
309 \newwrite\py@ModSynopsisFile
311 % hacked from \addtocontents from latex.ltx:
312 \long\def\py@writeModSynopsisFile
#1{%
313 \protected@write
\py@ModSynopsisFile
%
314 {\let\label\@gobble
\let\index\@gobble
\let\glossary\@gobble
}%
317 \newcommand{\py@closeModSynopsisFile
}{
318 \ifpy@ModSynopsisFileIsOpen
319 \closeout\py@ModSynopsisFile
320 \py@ModSynopsisFileIsOpenfalse
323 \newcommand{\py@openModSynopsisFile
}{
324 \ifpy@ModSynopsisFileIsOpen
\else
325 \openout\py@ModSynopsisFile=
\py@ModSynopsisFilename
326 \py@ModSynopsisFileIsOpentrue
330 \newcommand{\py@ProcessModSynopsis
}{
331 \ifpy@HaveModSynopsis
332 \py@writeModSynopsisFile
{\modulesynopsis%
333 {\py@thismodulekey
}{\py@thismodule
}%
334 {\py@thismoduletype
}{\py@modulesynopsis
}}%
335 \py@HaveModSynopsisfalse
337 \renewcommand{\py@modulesynopsis
}{\py@defsynopsis
}
339 \AtEndDocument{\py@ProcessModSynopsis
\py@closeModSynopsisFile
}
341 \newcommand{\localmoduletable}{
342 \IfFileExists{\py@ModSynopsisFilename
}{
343 \begin{synopsistable
}
344 \input{\py@ModSynopsisFilename
}
349 \@ifundefined
{pdfoutput
}{
350 \newcommand{\py@ModSynopsisSummary
}[4]{\bfcode{#2} &
#4\\
}
352 \newcommand{\py@ModSynopsisSummary
}[4]{
353 {\pdfannotlink attr
{/Border
[0 0 0]} goto name
{label-module-
#1}
354 \py@LinkColor
\bfcode{#2} \py@NormalColor
357 \newenvironment{synopsistable
}{
358 % key, name, type, synopsis
359 \let\modulesynopsis=
\py@ModSynopsisSummary
365 % --------------------------------------------------------------------------
368 \newcommand{\py@thisclass
}{}
369 \newcommand{\py@thismodule
}{}
370 \newcommand{\py@thismodulekey
}{}
371 \newcommand{\py@thismoduletype
}{}
373 \newcommand{\py@reset
}{
374 \py@ProcessModSynopsis
375 \renewcommand{\py@thisclass
}{}
376 \renewcommand{\py@thismodule
}{}
377 \renewcommand{\py@thismodulekey
}{}
378 \renewcommand{\py@thismoduletype
}{}
381 % Augment the sectioning commands used to get our own font family in place,
382 % and reset some internal data items:
383 \renewcommand{\section}{\py@reset
%
384 \@startsection
{section
}{1}{\z@
}%
385 {-
3.5ex \@plus -
1ex \@minus -
.2ex
}%
387 {\reset@font
\Large\py@HeaderFamily
}}
388 \renewcommand{\subsection}{\@startsection
{subsection
}{2}{\z@
}%
389 {-
3.25ex\@plus -
1ex \@minus -
.2ex
}%
391 {\reset@font
\large\py@HeaderFamily
}}
392 \renewcommand{\subsubsection}{\@startsection
{subsubsection
}{3}{\z@
}%
393 {-
3.25ex\@plus -
1ex \@minus -
.2ex
}%
395 {\reset@font
\normalsize\py@HeaderFamily
}}
396 \renewcommand{\paragraph}{\@startsection
{paragraph
}{4}{\z@
}%
397 {3.25ex \@plus1ex \@minus
.2ex
}%
399 {\reset@font
\normalsize\py@HeaderFamily
}}
400 \renewcommand{\subparagraph}{\@startsection
{subparagraph
}{5}{\parindent}%
401 {3.25ex \@plus1ex \@minus
.2ex
}%
403 {\reset@font
\normalsize\py@HeaderFamily
}}
406 % This gets the underscores closer to the right width; the only change
407 % from standard LaTeX is the width specified.
409 \DeclareTextCommandDefault{\textunderscore}{%
410 \leavevmode \kern.06em
\vbox{\hrule\@width
.55em
}}
412 % Underscore hack (only act like subscript operator if in math mode)
414 % The following is due to Mark Wooding (the old version didn't work with
417 \DeclareRobustCommand\hackscore{%
418 \ifmmode_\else\textunderscore\fi%
423 \AtBeginDocument{\catcode`
\_\active\def_{\hackscore{}}}%
425 \expandafter\endgroup\next
428 % Now for a lot of semantically-loaded environments that do a ton of magical
429 % things to get the right formatting and index entries for the stuff in
430 % Python modules and C API.
433 % {fulllineitems} is used in one place in libregex.tex, but is really for
434 % internal use in this file.
436 \newcommand{\py@itemnewline
}[1]{%
437 \@tempdima
\linewidth%
438 \advance\@tempdima
\leftmargin\makebox[\@tempdima
][l
]{#1}%
441 \newenvironment{fulllineitems
}{
442 \begin{list
}{}{\labelwidth \leftmargin \labelsep 0pt
443 \rightmargin 0pt
\topsep -
\parskip \partopsep \parskip
445 \let\makelabel=
\py@itemnewline
}
448 % \optional is mostly for use in the arguments parameters to the various
449 % {*desc} environments defined below, but may be used elsewhere. Known to
450 % be used in the debugger chapter.
454 % \begin{funcdesc}{myfunc}{reqparm\optional{, optparm}}
456 % No space here No space here
458 % When a function has multiple optional parameters, \optional should be
459 % nested, not chained. This is right:
461 % \begin{funcdesc}{myfunc}{\optional{parm1\optional{, parm2}}}
463 \newcommand{\optional}[1]{%
464 {\textnormal{\Large[}}{#1}\hspace{0.5mm
}{\textnormal{\Large]}}}
466 % C functions ------------------------------------------------------------
467 % \begin{cfuncdesc}{type}{name}{arglist}
468 \newenvironment{cfuncdesc
}[3]{
469 \begin{fulllineitems
}
470 \item[\code{#1 \bfcode{#2}(
\py@varvars
{#3})
}\index{#2@
{\py@idxcode
{#2()
}}}]
471 }{\end{fulllineitems
}}
473 % C variables ------------------------------------------------------------
474 % \begin{cvardesc}{type}{name}
475 \newenvironment{cvardesc
}[2]{
476 \begin{fulllineitems
}
477 \item[\code{#1 \bfcode{#2}}\index{#2@
{\py@idxcode
{#2}}}]
478 }{\end{fulllineitems
}}
480 % C data types -----------------------------------------------------------
481 % \begin{ctypedesc}{typedef name}
482 \newenvironment{ctypedesc
}[1]{
483 \begin{fulllineitems
}
484 \item[\bfcode{#1}\ttindex{#1}]
485 }{\end{fulllineitems
}}
487 % simple functions (not methods) -----------------------------------------
488 % \begin{funcdesc}{name}{args}
489 \newcommand{\funcline}[2]{\funclineni{#1}{#2}\ttindex{#1()
}}
490 \newenvironment{funcdesc
}[2]{
491 \begin{fulllineitems
}
493 }{\end{fulllineitems
}}
495 % similar to {funcdesc}, but doesn't add to the index
496 \newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(
\py@varvars
{#2})
}]}
497 \newenvironment{funcdescni
}[2]{
498 \begin{fulllineitems
}
500 }{\end{fulllineitems
}}
502 % classes ----------------------------------------------------------------
503 % \begin{classdesc}{name}{constructor args}
504 \newenvironment{classdesc
}[2]{
505 \renewcommand{\py@thisclass
}{#1}
506 \begin{fulllineitems
}
507 \item[\code{\bfcode{#1}(
\py@varvars
{#2})
}%
508 \withsubitem{(class in
\py@thismodule)
}{\ttindex{#1}}]
509 }{\end{fulllineitems
}}
512 \let\py@classbadkey=\@undefined
514 % object method ----------------------------------------------------------
515 % \begin{methoddesc}[classname]{methodname}{args}
516 \newcommand{\methodline}[3][\py@classbadkey
]{
517 \methodlineni{#2}{#3}
519 \withsubitem{(
\py@thisclass\ method)
}{\ttindex{#2()
}}
521 \withsubitem{(
#1 method)
}{\ttindex{#2()
}}
524 \newenvironment{methoddesc
}[3][\py@classbadkey
]{
525 \begin{fulllineitems
}
529 \def\py@thisclass
{#1}
530 \methodline[#1]{#2}{#3}
532 }{\end{fulllineitems
}}
534 % similar to {methoddesc}, but doesn't add to the index
535 % (never actually uses the optional argument)
536 \newcommand{\methodlineni}[3][\py@classbadkey
]{%
537 \item[\code{\bfcode{#2}(
\py@varvars
{#3})
}]}
538 \newenvironment{methoddescni
}[3][\py@classbadkey
]{
539 \begin{fulllineitems
}
540 \methodlineni{#2}{#3}
541 }{\end{fulllineitems
}}
543 % object data attribute --------------------------------------------------
544 % \begin{memberdesc}[classname]{membername}
545 \newcommand{\memberline}[2][\py@classbadkey
]{%
548 \withsubitem{(
\py@thisclass\ attribute)
}{\ttindex{#2}}
551 \withsubitem{(
#1 attribute)
}{\ttindex{#2}}
554 \newenvironment{memberdesc
}[2][\py@classbadkey
]{
555 \begin{fulllineitems
}
559 \def\py@thisclass
{#1}
562 }{\end{fulllineitems
}}
564 % similar to {memberdesc}, but doesn't add to the index
565 % (never actually uses the optional argument)
566 \newcommand{\memberlineni}[2][\py@classbadkey
]{\item[\bfcode{#2}]}
567 \newenvironment{memberdescni
}[2][\py@classbadkey
]{
568 \begin{fulllineitems
}
570 }{\end{fulllineitems
}}
572 % For exceptions: --------------------------------------------------------
573 % \begin{excdesc}{name}
574 % -- need support for constructor; maybe use optional parameter?
575 \newenvironment{excdesc
}[1]{
576 \begin{fulllineitems
}
577 \item[\bfcode{#1}\ttindex{#1}]
578 }{\end{fulllineitems
}}
580 % Module data or constants: ----------------------------------------------
581 % \begin{datadesc}{name}
582 \newcommand{\dataline}[1]{\datalineni{#1}\ttindex{#1}}
583 \newenvironment{datadesc
}[1]{
584 \begin{fulllineitems
}
586 }{\end{fulllineitems
}}
588 % similar to {datadesc}, but doesn't add to the index
589 \newcommand{\datalineni}[1]{\item[\bfcode{#1}]\nopagebreak}
590 \newenvironment{datadescni
}[1]{
591 \begin{fulllineitems
}
593 }{\end{fulllineitems
}}
595 % bytecode instruction ---------------------------------------------------
596 % \begin{opcodedesc}{name}{var}
598 \newenvironment{opcodedesc
}[2]{
599 \begin{fulllineitems
}
600 \item[\bfcode{#1}\quad\var{#2}]
601 }{\end{fulllineitems
}}
604 \newcommand{\nodename}[1]{\label{#1}}
606 % For these commands, use \command{} to get the typography right, not
607 % {\command}. This works better with the texinfo translation.
608 \newcommand{\ABC}{{\sc abc
}}
609 \newcommand{\UNIX}{{\sc Unix
}}
610 \newcommand{\POSIX}{POSIX
}
611 \newcommand{\ASCII}{{\sc ascii
}}
612 \newcommand{\Cpp}{C
\protect\raisebox{.18ex
}{++
}}
614 \newcommand{\EOF}{{\sc eof
}}
615 \newcommand{\NULL}{\constant{NULL
}}
617 % Also for consistency: spell Python "Python", not "python"!
619 % code is the most difficult one...
620 \newcommand{\code}[1]{{\@vobeyspaces\@noligs
\def\
{{\char`\
{}\def\
}{\char`\
}}\def\~
{\char`\~
}\def\^
{\char`\^
}\def\e{\char`\\
}\def\$
{\char`\$
}\def\#
{\char`\#
}\def\&
{\char`\&
}\def\%
{\char`\%
}%
623 \newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font
624 \newcommand{\kbd}[1]{\code{#1}}
625 \newcommand{\samp}[1]{`
\code{#1}'
}
626 % This weird definition of \var{} allows it to always appear in roman
627 % italics, and won't get funky in code fragments when we play around
629 \newcommand{\var}[1]{\normalsize\textrm{\textit{#1\/
}}}
630 \renewcommand{\emph}[1]{{\em #1}}
631 \newcommand{\dfn}[1]{\emph{#1}}
632 \newcommand{\strong}[1]{{\bf #1}}
633 % let's experiment with a new font:
634 \newcommand{\file}[1]{`
{\small\textsf{#1}}'
}
636 % Use this def/redef approach for \url{} since hyperref defined this already,
637 % but only if we actually used hyperref:
638 \@ifundefined
{pdfannotlink
}{
639 \newcommand{\py@url
}[1]{\mbox{\small\textsf{#1}}}
641 \newcommand{\py@url
}[1]{{%
642 \pdfannotlink attr
{/Border
[0 0 0]} user
{/S /URI /URI (
#1)
}%
643 \py@LinkColor
% color of the link text
644 \mbox{\small\textsf{#1}}%
645 \py@NormalColor
% Turn it back off; these are declarative
646 \pdfendlink}% and don't appear bound to the current
650 \newcommand{\email}[1]{{\small\textsf{#1}}}
651 \newcommand{\newsgroup}[1]{{\small\textsf{#1}}}
653 \newcommand{\py@varvars
}[1]{{\def\,
{\/
{\char`\,
}}\var{#1}}}
654 % let's see if this breaks anything now; we may be able to simplify...
655 \renewcommand{\py@varvars
}[1]{\var{#1}}
657 % I'd really like to get rid of this!
658 \newif\iftexi\texifalse
660 % This is used to get l2h to put the copyright and abstract on
661 % a separate HTML page.
662 \newif\ifhtml\htmlfalse
665 % These should be used for all references to identifiers which are
666 % used to refer to instances of specific language constructs. See the
667 % names for specific semantic assignments.
669 % For now, don't do anything really fancy with them; just use them as
670 % logical markup. This might change in the future.
672 \newcommand{\module}[1]{\texttt{#1}}
673 \newcommand{\keyword}[1]{\texttt{#1}}
674 \newcommand{\exception}[1]{\texttt{#1}}
675 \newcommand{\class}[1]{\texttt{#1}}
676 \newcommand{\function}[1]{\texttt{#1}}
677 \newcommand{\member}[1]{\texttt{#1}}
678 \newcommand{\method}[1]{\texttt{#1}}
680 \newcommand{\pytype}[1]{#1} % built-in Python type
682 \newcommand{\cfunction}[1]{\texttt{#1}}
683 \newcommand{\ctype}[1]{\texttt{#1}} % C struct or typedef name
684 \newcommand{\cdata}[1]{\texttt{#1}} % C variable, typically global
686 \newcommand{\mimetype}[1]{{\small\textsf{#1}}}
687 % The \! is a "negative thin space" in math mode.
688 \newcommand{\regexp}[1]{%
689 {\tiny$^
{^
\lceil}\!\!$
%
690 {\normalsize\code{#1}}%
693 \newcommand{\envvar}[1]{%
694 \$
#1% $ <-- bow to font-lock 3 times!
696 \index{environment variables!
{\$
#1}}% $
698 \newcommand{\makevar}[1]{#1} % variable in a Makefile
699 \newcommand{\character}[1]{\samp{#1}}
701 % constants defined in Python modules or C headers, not language constants:
702 \newcommand{\constant}[1]{\code{#1}} % manifest constant, not syntactic
704 \newcommand{\manpage}[2]{{\emph{#1}(
#2)
}}
705 \newcommand{\rfc}[1]{RFC
#1\index{RFC!RFC
#1}}
706 \newcommand{\program}[1]{\strong{#1}}
710 % Should be extended to allow an index / list of deprecated stuff. But
711 % there's a lot of stuff that needs to be done to make that automatable.
713 % First parameter is the release number that deprecates the feature, the
714 % second is the action the should be taken by users of the feature.
717 % \deprecated{1.5.1}{Use \method{frobnicate()} instead.}
719 \newcommand{\deprecated}[2]{%
720 \strong{Deprecated since release
#1.
} #2\par}
723 % This should be used to mark things which have been added to the
724 % development tree but that aren't in the release, but are documented.
725 % This allows release of documentation that already includes updated
729 % \versionadded{1.5.2}
731 \newcommand{\versionadded}[1]{%
732 \strong{New in version
#1.
}\par}
733 \newcommand{\versionchanged}[1]{%
734 \strong{Changed in version
#1.
}\par}
739 \newenvironment{tableii
}[4]{%
741 \def\lineii#
#1#
#2{\csname#2\endcsname{#
#1}&#
#2\\
}%
742 \begin{tabular
}{#1}\strong{#3}&
\strong{#4} \\
\hline%
748 \newenvironment{tableiii
}[5]{%
750 \def\lineiii#
#1#
#2#
#3{\csname#2\endcsname{#
#1}&#
#2&#
#3\\
}%
751 \begin{tabular
}{#1}\strong{#3}&
\strong{#4}&
\strong{#5} \\
\hline%
757 \newenvironment{tableiv
}[6]{%
759 \def\lineiv#
#1#
#2#
#3#
#4{\csname#2\endcsname{#
#1}&#
#2&#
#3&#
#4\\
}%
760 \begin{tabular
}{#1}\strong{#3}&
\strong{#4}&
\strong{#5}&
\strong{#6} \\%
767 % Cross-referencing (AMK, new impl. FLD)
770 % \seemodule{rand}{Uniform random number generator}; % Module xref
771 % \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book
773 % % A funky case: module name contains '_'; have to supply an optional key
774 % \seemodule[copyreg]{copy_reg}{pickle interface constructor registration}
778 \@ifundefined
{pdfannotlink
}{%
779 \newcommand{\py@seemodule
}[3][\py@modulebadkey
]{%
780 \ifx\py@modulebadkey
#1\def\py@modulekey
{#2}\else\def\py@modulekey
{#1}\fi%
781 \ref{module-
\py@modulekey
}:
\quad %
785 }{\newcommand{\py@seemodule
}[3][\py@modulebadkey
]{%
786 \ifx\py@modulebadkey
#1\def\py@modulekey
{#2}\else\def\py@modulekey
{#1}\fi%
787 \ref{module-
\py@modulekey
}:
\quad %
788 {\pdfannotlink attr
{/Border
[0 0 0]} goto name
{label-module-
\py@modulekey
}%
789 \py@LinkColor Module
\module{#2} \py@NormalColor
%
795 \newenvironment{seealso
}[0]{
796 \strong{See Also:
}\par
797 \def\seetext#
#1{\par{#
#1}}
798 \let\seemodule=
\py@seemodule
802 % Allow the Python release number to be specified independently of the
803 % \date{}. This allows the date to reflect the document's date and
804 % release to specify the Python release that is documented.
806 \newcommand{\py@release
}{}
807 \newcommand{\version}{}
808 \newcommand{\releasename}{Release
}
809 \newcommand{\release}[1]{%
810 \renewcommand{\py@release
}{\releasename\space\version}%
811 \renewcommand{\version}{#1}}
813 % Allow specification of the author's address separately from the
814 % author's name. This can be used to format them differently, which
817 \newcommand{\py@authoraddress
}{}
818 \newcommand{\authoraddress}[1]{\renewcommand{\py@authoraddress
}{#1}}
819 \let\developersaddress=
\authoraddress
820 \let\developer=
\author
821 \let\developers=
\author
823 % This sets up the fancy chapter headings that make the documents look
824 % at least a little better than the usual LaTeX output.
826 \@ifundefined
{ChTitleVar
}{}{
827 \ChNameVar{\raggedleft\normalsize\py@HeaderFamily
}
828 \ChNumVar{\raggedleft \bfseries\Large\py@HeaderFamily
}
829 \ChTitleVar{\raggedleft \rm\Huge\py@HeaderFamily
}
830 % This creates chapter heads without the leading \vspace*{}:
831 \def\@makechapterhead
#1{%
832 {\parindent \z@
\raggedright \normalfont
833 \ifnum \c@secnumdepth >
\m@ne
843 % Definition lists; requested by AMK for HOWTO documents. Probably useful
844 % elsewhere as well, so keep in in the general style support.
846 \newenvironment{definitions
}{%
848 \def\term#
#1{\item[#
#1]\mbox{}\\*
[0mm
]}
853 % Tell TeX about pathological hyphenation cases:
854 \hyphenation{Base-HTTP-Re-quest-Hand-ler
}