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