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 | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 9 | % Uncomment these two lines to ignore the paper size and make the page |
| 10 | % size more like a typical published manual. |
| 11 | %\renewcommand{\paperheight}{9in} |
| 12 | %\renewcommand{\paperwidth}{8.5in} % typical squarish manual |
| 13 | %\renewcommand{\paperwidth}{7in} % O'Reilly ``Programmming Python'' |
| 14 | |
Fred Drake | 454a4fb | 1998-04-01 22:20:14 +0000 | [diff] [blame] | 15 | % These packages can be used to add marginal annotations which indicate |
| 16 | % index entries and labels; useful for reviewing this messy documentation! |
| 17 | % |
| 18 | %\RequirePackage{showkeys} |
| 19 | %\RequirePackage{showidx} |
| 20 | |
Fred Drake | c0b2e45 | 1998-03-25 14:53:43 +0000 | [diff] [blame] | 21 | % for PDF output, use maximal compression & a lot of other stuff |
| 22 | % (test for PDF recommended by Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov>) |
| 23 | % |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 24 | \newif\ifpy@doing@page@targets |
| 25 | \py@doing@page@targetsfalse |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 26 | |
Fred Drake | c0b2e45 | 1998-03-25 14:53:43 +0000 | [diff] [blame] | 27 | \ifx\pdfoutput\undefined\else\ifcase\pdfoutput |
Fred Drake | c0b2e45 | 1998-03-25 14:53:43 +0000 | [diff] [blame] | 28 | \else |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 29 | \input{pdfcolor} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 30 | \let\py@LinkColor=\NavyBlue |
| 31 | \let\py@NormalColor=\Black |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 32 | \pdfcompresslevel=9 |
Fred Drake | ba1700c | 1998-05-11 20:42:54 +0000 | [diff] [blame] | 33 | \pdfpagewidth=\paperwidth % page width of PDF output |
| 34 | \pdfpageheight=\paperheight % page height of PDF output |
Fred Drake | ebcb658 | 1998-03-06 21:25:17 +0000 | [diff] [blame] | 35 | % |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 36 | % Pad the number with '0' to 3 digits wide so no page name is a prefix |
| 37 | % of any other. |
| 38 | % |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 39 | \newcommand{\py@targetno}[1]{\ifnum#1<100 0\fi\ifnum#1<10 0\fi#1} |
| 40 | \newcommand{\py@pageno}{\py@targetno\thepage} |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 41 | % |
Fred Drake | ebcb658 | 1998-03-06 21:25:17 +0000 | [diff] [blame] | 42 | % This definition allows the entries in the page-view of the ToC to be |
| 43 | % active links. Some work, some don't. |
| 44 | % |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 45 | \let\py@OldContentsline=\contentsline |
Fred Drake | aa2aea0 | 1999-01-27 17:37:36 +0000 | [diff] [blame] | 46 | % |
| 47 | % Macro that takes two args: the name to link to and the content of |
| 48 | % the link. This takes care of the PDF magic, getting the colors |
| 49 | % the same for each link, and avoids having lots of garbage all over |
| 50 | % this style file. |
| 51 | \newcommand{\py@linkToName}[2]{% |
| 52 | \pdfannotlink attr{/Border [0 0 0]} goto name{#1}% |
| 53 | \py@LinkColor#2\py@NormalColor% |
| 54 | \pdfendlink% |
| 55 | } |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 56 | % Compute the padded page number separately since we end up with a pair of |
| 57 | % \relax tokens; this gets the right string computed and works. |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 58 | \renewcommand{\contentsline}[3]{% |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 59 | \def\my@pageno{\py@targetno{#3}}% |
Fred Drake | aa2aea0 | 1999-01-27 17:37:36 +0000 | [diff] [blame] | 60 | \py@OldContentsline{#1}{\py@linkToName{page\my@pageno}{#2}}{#3}% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 61 | } |
Fred Drake | ebcb658 | 1998-03-06 21:25:17 +0000 | [diff] [blame] | 62 | \AtEndDocument{ |
Fred Drake | c0b2e45 | 1998-03-25 14:53:43 +0000 | [diff] [blame] | 63 | \InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{} |
Fred Drake | ebcb658 | 1998-03-06 21:25:17 +0000 | [diff] [blame] | 64 | } |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 65 | \newcommand{\py@target}[1]{% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 66 | \ifpy@doing@page@targets% |
Fred Drake | 9b8afde | 1999-03-24 14:16:17 +0000 | [diff] [blame] | 67 | {\pdfdest name{#1} xyz}% |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 68 | \fi% |
| 69 | } |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 70 | \let\py@OldLabel=\label |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 71 | \renewcommand{\label}[1]{% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 72 | \py@OldLabel{#1}% |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 73 | \py@target{label-#1}% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 74 | } |
Fred Drake | ba1700c | 1998-05-11 20:42:54 +0000 | [diff] [blame] | 75 | % This stuff adds a page# destination to every PDF page, where # is three |
| 76 | % digits wide, padded with leading zeros. This doesn't really help with |
| 77 | % the frontmatter, but does fine with the body. |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 78 | % |
| 79 | % This is *heavily* based on the hyperref package. |
| 80 | % |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 81 | \def\@begindvi{% |
| 82 | \unvbox \@begindvibox |
| 83 | \@hyperfixhead |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 84 | } |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 85 | \def\@hyperfixhead{% |
| 86 | \let\H@old@thehead\@thehead |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 87 | \global\def\@foo{\py@target{page\py@pageno}}% |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 88 | \expandafter\ifx\expandafter\@empty\H@old@thehead |
| 89 | \def\H@old@thehead{\hfil}\fi |
| 90 | \def\@thehead{\@foo\relax\H@old@thehead}% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 91 | } |
Fred Drake | c0b2e45 | 1998-03-25 14:53:43 +0000 | [diff] [blame] | 92 | \fi\fi |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 93 | |
| 94 | % Increase printable page size (copied from fullpage.sty) |
| 95 | \topmargin 0pt |
| 96 | \advance \topmargin by -\headheight |
| 97 | \advance \topmargin by -\headsep |
| 98 | |
| 99 | % attempt to work a little better for A4 users |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 100 | \textheight \paperheight |
| 101 | \advance\textheight by -2in |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 102 | |
| 103 | \oddsidemargin 0pt |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 104 | \evensidemargin 0pt |
| 105 | %\evensidemargin -.25in % for ``manual size'' documents |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 106 | \marginparwidth 0.5in |
| 107 | |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 108 | \textwidth \paperwidth |
| 109 | \advance\textwidth by -2in |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 110 | |
| 111 | |
| 112 | % Style parameters and macros used by most documents here |
| 113 | \raggedbottom |
| 114 | \sloppy |
| 115 | \parindent = 0mm |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 116 | \parskip = 2mm |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 117 | \hbadness = 5000 % don't print trivial gripes |
| 118 | |
| 119 | \pagestyle{empty} % start this way; change for |
| 120 | \pagenumbering{roman} % ToC & chapters |
| 121 | \setcounter{secnumdepth}{1} |
| 122 | |
| 123 | % Use this to set the font family for headers and other decor: |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 124 | \newcommand{\py@HeaderFamily}{\sffamily} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 125 | |
| 126 | % Redefine the 'normal' header/footer style when using "fancyhdr" package: |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 127 | \@ifundefined{fancyhf}{}{ |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 128 | % Use \pagestyle{normal} as the primary pagestyle for text. |
| 129 | \fancypagestyle{normal}{ |
| 130 | \fancyhf{} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 131 | \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}} |
| 132 | \fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}} |
| 133 | \fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 134 | \renewcommand{\headrulewidth}{0pt} |
| 135 | \renewcommand{\footrulewidth}{0.4pt} |
| 136 | } |
| 137 | % Update the plain style so we get the page number & footer line, |
| 138 | % but not a chapter or section title. This is to keep the first |
| 139 | % page of a chapter and the blank page between chapters `clean.' |
| 140 | \fancypagestyle{plain}{ |
| 141 | \fancyhf{} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 142 | \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 143 | \renewcommand{\headrulewidth}{0pt} |
| 144 | \renewcommand{\footrulewidth}{0.4pt} |
| 145 | } |
| 146 | % Redefine \cleardoublepage so that the blank page between chapters |
| 147 | % gets the plain style and not the fancy style. This is described |
| 148 | % in the documentation for the fancyhdr package by Piet von Oostrum. |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 149 | \@ifundefined{chapter}{}{ |
Fred Drake | 28f1391 | 1998-03-04 21:47:59 +0000 | [diff] [blame] | 150 | \renewcommand{\cleardoublepage}{ |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 151 | \clearpage\if@openright \ifodd\c@page\else |
Fred Drake | 28f1391 | 1998-03-04 21:47:59 +0000 | [diff] [blame] | 152 | \hbox{} |
| 153 | \thispagestyle{plain} |
| 154 | \newpage |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 155 | \if@twocolumn\hbox{}\newpage\fi\fi\fi |
Fred Drake | 28f1391 | 1998-03-04 21:47:59 +0000 | [diff] [blame] | 156 | } |
| 157 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 158 | } |
| 159 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 160 | % This sets up the {verbatim} environment to be indented and a minipage, |
| 161 | % and to have all the other mostly nice properties that we want for |
| 162 | % code samples. |
| 163 | |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 164 | \let\py@OldVerbatim=\verbatim |
| 165 | \let\py@OldEndVerbatim=\endverbatim |
| 166 | \RequirePackage{verbatim} |
| 167 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 168 | % Variable used by begin code command |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 169 | \newlength{\py@codewidth} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 170 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 171 | \renewcommand{\verbatim}{% |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 172 | \setlength{\parindent}{1cm}% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 173 | % Calculate the text width for the minipage: |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 174 | \setlength{\py@codewidth}{\linewidth}% |
| 175 | \addtolength{\py@codewidth}{-\parindent}% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 176 | % |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 177 | \par\indent% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 178 | \begin{minipage}[t]{\py@codewidth}% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 179 | \small% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 180 | \py@OldVerbatim% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 181 | } |
| 182 | \renewcommand{\endverbatim}{% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 183 | \py@OldEndVerbatim% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 184 | \end{minipage}% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 185 | } |
| 186 | |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 187 | |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 188 | \newcommand{\py@modulebadkey}{{--just-some-junk--}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 189 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 190 | |
| 191 | %% Lots of index-entry generation support. |
| 192 | |
| 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 |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 196 | % definition; it matches O'Reilly style more. |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 197 | % |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 198 | \newcommand{\py@idxcode}[1]{\texttt{#1}} |
| 199 | %\renewcommand{\py@idxcode}[1]{#1} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 200 | |
| 201 | % Command to generate two index entries (using subentries) |
| 202 | \newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}} |
| 203 | |
| 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}} |
| 206 | |
| 207 | % And four (again, using only one level of subentries) |
| 208 | \newcommand{\indexiv}[4]{ |
| 209 | \index{#1!#2 #3 #4} |
| 210 | \index{#2!#3 #4, #1} |
| 211 | \index{#3!#4, #1 #2} |
| 212 | \index{#4!#1 #2 #3} |
| 213 | } |
| 214 | |
| 215 | % Command to generate a reference to a function, statement, keyword, |
| 216 | % operator. |
Fred Drake | 0cabff9 | 1998-05-06 19:36:01 +0000 | [diff] [blame] | 217 | \newcommand{\kwindex}[1]{\indexii{keyword}{#1@{\py@idxcode{#1}}}} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 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}}}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 221 | \newcommand{\obindex}[1]{\indexii{object}{#1}} |
Fred Drake | 2351c80 | 1998-04-02 18:48:32 +0000 | [diff] [blame] | 222 | \newcommand{\bifuncindex}[1]{\withsubitem{(built-in function)}{\ttindex{#1()}}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 223 | |
| 224 | % Add an index entry for a module |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 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 }} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 230 | |
Fred Drake | da94374 | 1999-01-13 17:09:06 +0000 | [diff] [blame] | 231 | % Refer to a module's documentation using a hyperlink of the module's |
| 232 | % name, at least if we're building PDF: |
| 233 | \@ifundefined{pdfannotlink}{% |
| 234 | \newcommand{\refmodule}[2][\py@modulebadkey]{\module{#2}} |
Fred Drake | aa2aea0 | 1999-01-27 17:37:36 +0000 | [diff] [blame] | 235 | }{% |
| 236 | \newcommand{\refmodule}[2][\py@modulebadkey]{% |
Fred Drake | da94374 | 1999-01-13 17:09:06 +0000 | [diff] [blame] | 237 | \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi% |
Fred Drake | aa2aea0 | 1999-01-27 17:37:36 +0000 | [diff] [blame] | 238 | \py@linkToName{label-module-\py@modulekey}{\module{#2}}% |
Fred Drake | da94374 | 1999-01-13 17:09:06 +0000 | [diff] [blame] | 239 | } |
| 240 | } |
| 241 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 242 | % support for the module index |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 243 | \newif\ifpy@UseModuleIndex |
| 244 | \py@UseModuleIndexfalse |
Fred Drake | b390daf | 1998-03-09 16:35:36 +0000 | [diff] [blame] | 245 | |
Fred Drake | b390daf | 1998-03-09 16:35:36 +0000 | [diff] [blame] | 246 | \newcommand{\makemodindex}{ |
| 247 | \newwrite\modindexfile |
| 248 | \openout\modindexfile=mod\jobname.idx |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 249 | \py@UseModuleIndextrue |
Fred Drake | b390daf | 1998-03-09 16:35:36 +0000 | [diff] [blame] | 250 | } |
| 251 | |
Fred Drake | 0ee9f72 | 1998-03-12 06:41:40 +0000 | [diff] [blame] | 252 | % Add the defining entry for a module |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 253 | \newcommand{\py@modindex}[2]{% |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 254 | \renewcommand{\py@thismodule}{#1} |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 255 | \setindexsubitem{(in module #1)}% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 256 | \index{#1@{\py@idxcode{#1}} (#2module)|textbf}% |
| 257 | \ifpy@UseModuleIndex% |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 258 | \@ifundefined{py@modplat@\py@thismodulekey}{ |
| 259 | \write\modindexfile{\protect\indexentry{#1@{\texttt{#1}}}{\thepage}}% |
| 260 | }{\write\modindexfile{\protect\indexentry{#1@{\texttt{#1} % |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 261 | \emph{(\py@platformof[\py@thismodulekey]{})}}}{\thepage}}% |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 262 | } |
Fred Drake | 0ee9f72 | 1998-03-12 06:41:40 +0000 | [diff] [blame] | 263 | \fi% |
| 264 | } |
| 265 | |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 266 | % *** XXX *** THE NEXT FOUR MACROS ARE NOW OBSOLETE !!! *** |
| 267 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 268 | % built-in & Python modules in the main distribution |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 269 | \newcommand{\bimodindex}[1]{\py@modindex{#1}{built-in }% |
| 270 | \typeout{*** MACRO bimodindex IS OBSOLETE -- USE declaremodule INSTEAD!}} |
| 271 | \newcommand{\stmodindex}[1]{\py@modindex{#1}{standard }% |
| 272 | \typeout{*** MACRO stmodindex IS OBSOLETE -- USE declaremodule INSTEAD!}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 273 | |
| 274 | % Python & extension modules outside the main distribution |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 275 | \newcommand{\modindex}[1]{\py@modindex{#1}{}% |
| 276 | \typeout{*** MACRO modindex IS OBSOLETE -- USE declaremodule INSTEAD!}} |
| 277 | \newcommand{\exmodindex}[1]{\py@modindex{#1}{extension }% |
| 278 | \typeout{*** MACRO exmodindex IS OBSOLETE -- USE declaremodule INSTEAD!}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 279 | |
| 280 | % Additional string for an index entry |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 281 | \newcommand{\index@subitem}{} |
| 282 | \newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 283 | \newcommand{\ttindex}[1]{\index{#1@{\py@idxcode{#1}} \index@subitem}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 284 | |
Fred Drake | 0ee9f72 | 1998-03-12 06:41:40 +0000 | [diff] [blame] | 285 | \newcommand{\withsubitem}[2]{% |
| 286 | \begingroup% |
| 287 | \def\index@subitem{#1}#2% |
| 288 | \endgroup% |
| 289 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 290 | |
Fred Drake | 5371497 | 1998-04-02 22:33:16 +0000 | [diff] [blame] | 291 | |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 292 | % Module synopsis processing ----------------------------------------------- |
| 293 | % |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 294 | \newcommand{\py@thisclass}{} |
| 295 | \newcommand{\py@thismodule}{} |
| 296 | \newcommand{\py@thismodulekey}{} |
| 297 | \newcommand{\py@thismoduletype}{} |
| 298 | |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 299 | \newcommand{\py@standardIndexModule}[1]{\py@modindex{#1}{standard }} |
| 300 | \newcommand{\py@builtinIndexModule}[1]{\py@modindex{#1}{built-in }} |
| 301 | \newcommand{\py@extensionIndexModule}[1]{\py@modindex{#1}{extension }} |
| 302 | \newcommand{\py@IndexModule}[1]{\py@modindex{#1}{}} |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 303 | |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 304 | \newif\ifpy@HaveModSynopsis \py@HaveModSynopsisfalse |
| 305 | \newif\ifpy@ModSynopsisFileIsOpen \py@ModSynopsisFileIsOpenfalse |
| 306 | \newif\ifpy@HaveModPlatform \py@HaveModPlatformfalse |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 307 | |
| 308 | % \declaremodule[key]{type}{name} |
| 309 | \newcommand{\declaremodule}[3][\py@modulebadkey]{ |
| 310 | \py@openModSynopsisFile |
| 311 | \renewcommand{\py@thismoduletype}{#2} |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 312 | \ifx\py@modulebadkey#1 |
| 313 | \renewcommand{\py@thismodulekey}{#3} |
| 314 | \else |
| 315 | \renewcommand{\py@thismodulekey}{#1} |
| 316 | \fi |
Fred Drake | 5bc8d99 | 1999-05-17 14:47:10 +0000 | [diff] [blame^] | 317 | \@ifundefined{py@#2IndexModule}{% |
| 318 | \typeout{*** MACRO declaremodule called with unknown module type: `#2'} |
| 319 | \py@ModuleIndex{#3}% |
| 320 | }{% |
| 321 | \csname py@#2IndexModule\endcsname{#3}% |
| 322 | } |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 323 | \label{module-\py@thismodulekey} |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 324 | } |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 325 | \newif\ifpy@ModPlatformFileIsOpen \py@ModPlatformFileIsOpenfalse |
| 326 | \newcommand{\py@ModPlatformFilename}{\jobname.pla} |
| 327 | \newcommand{\platform}[1]{ |
| 328 | \ifpy@ModPlatformFileIsOpen\else |
| 329 | \newwrite\py@ModPlatformFile |
| 330 | \openout\py@ModPlatformFile=\py@ModPlatformFilename |
| 331 | \py@ModPlatformFileIsOpentrue |
| 332 | \fi |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 333 | } |
| 334 | \InputIfFileExists{\jobname.pla}{}{} |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 335 | \newcommand{\py@platformof}[2][\py@modulebadkey]{% |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 336 | \ifx\py@modulebadkey#1 \def\py@key{#2}% |
| 337 | \else \def\py@key{#1}% |
| 338 | \fi% |
| 339 | \csname py@modplat@\py@key\endcsname% |
| 340 | } |
| 341 | \newcommand{\ignorePlatformAnnotation}[1]{} |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 342 | |
Fred Drake | b75c615 | 1998-08-10 18:41:43 +0000 | [diff] [blame] | 343 | % \moduleauthor{name}{email} |
| 344 | \newcommand{\moduleauthor}[2]{} |
| 345 | |
| 346 | % \sectionauthor{name}{email} |
| 347 | \newcommand{\sectionauthor}[2]{} |
| 348 | |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 349 | |
| 350 | \newcommand{\py@defsynopsis}{Module has no synopsis.} |
| 351 | \newcommand{\py@modulesynopsis}{\py@defsynopsis} |
| 352 | \newcommand{\modulesynopsis}[1]{ |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 353 | \py@HaveModSynopsistrue |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 354 | \renewcommand{\py@modulesynopsis}{#1} |
| 355 | } |
| 356 | |
| 357 | % define the file |
| 358 | \newwrite\py@ModSynopsisFile |
| 359 | |
| 360 | % hacked from \addtocontents from latex.ltx: |
| 361 | \long\def\py@writeModSynopsisFile#1{% |
| 362 | \protected@write\py@ModSynopsisFile% |
| 363 | {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}% |
| 364 | {\string#1}% |
| 365 | } |
| 366 | \newcommand{\py@closeModSynopsisFile}{ |
| 367 | \ifpy@ModSynopsisFileIsOpen |
| 368 | \closeout\py@ModSynopsisFile |
| 369 | \py@ModSynopsisFileIsOpenfalse |
| 370 | \fi |
| 371 | } |
| 372 | \newcommand{\py@openModSynopsisFile}{ |
| 373 | \ifpy@ModSynopsisFileIsOpen\else |
| 374 | \openout\py@ModSynopsisFile=\py@ModSynopsisFilename |
| 375 | \py@ModSynopsisFileIsOpentrue |
| 376 | \fi |
| 377 | } |
| 378 | |
| 379 | \newcommand{\py@ProcessModSynopsis}{ |
| 380 | \ifpy@HaveModSynopsis |
| 381 | \py@writeModSynopsisFile{\modulesynopsis% |
| 382 | {\py@thismodulekey}{\py@thismodule}% |
| 383 | {\py@thismoduletype}{\py@modulesynopsis}}% |
| 384 | \py@HaveModSynopsisfalse |
| 385 | \fi |
| 386 | \renewcommand{\py@modulesynopsis}{\py@defsynopsis} |
| 387 | } |
| 388 | \AtEndDocument{\py@ProcessModSynopsis\py@closeModSynopsisFile} |
| 389 | |
Fred Drake | 0c275fa | 1999-03-02 16:17:44 +0000 | [diff] [blame] | 390 | |
| 391 | \long\def\py@writeModPlatformFile#1{% |
| 392 | \protected@write\py@ModPlatformFile% |
| 393 | {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}% |
| 394 | {\string#1}% |
| 395 | } |
| 396 | |
| 397 | |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 398 | \newcommand{\localmoduletable}{ |
| 399 | \IfFileExists{\py@ModSynopsisFilename}{ |
| 400 | \begin{synopsistable} |
| 401 | \input{\py@ModSynopsisFilename} |
| 402 | \end{synopsistable} |
| 403 | }{} |
| 404 | } |
| 405 | |
| 406 | \@ifundefined{pdfoutput}{ |
| 407 | \newcommand{\py@ModSynopsisSummary}[4]{\bfcode{#2} & #4\\} |
| 408 | }{ |
Fred Drake | aa2aea0 | 1999-01-27 17:37:36 +0000 | [diff] [blame] | 409 | \newcommand{\py@ModSynopsisSummary}[4]{% |
| 410 | \py@linkToName{label-module-#1}{\bfcode{#2}} & #4\\ |
| 411 | } |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 412 | } |
| 413 | \newenvironment{synopsistable}{ |
| 414 | % key, name, type, synopsis |
| 415 | \let\modulesynopsis=\py@ModSynopsisSummary |
| 416 | \begin{tabular}{ll} |
| 417 | }{ |
| 418 | \end{tabular} |
| 419 | } |
| 420 | % |
| 421 | % -------------------------------------------------------------------------- |
| 422 | |
| 423 | |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 424 | \newcommand{\py@reset}{ |
| 425 | \py@ProcessModSynopsis |
| 426 | \renewcommand{\py@thisclass}{} |
| 427 | \renewcommand{\py@thismodule}{} |
| 428 | \renewcommand{\py@thismodulekey}{} |
| 429 | \renewcommand{\py@thismoduletype}{} |
| 430 | } |
| 431 | |
| 432 | % Augment the sectioning commands used to get our own font family in place, |
| 433 | % and reset some internal data items: |
| 434 | \renewcommand{\section}{\py@reset% |
| 435 | \@startsection{section}{1}{\z@}% |
| 436 | {-3.5ex \@plus -1ex \@minus -.2ex}% |
| 437 | {2.3ex \@plus.2ex}% |
| 438 | {\reset@font\Large\py@HeaderFamily}} |
| 439 | \renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}% |
| 440 | {-3.25ex\@plus -1ex \@minus -.2ex}% |
| 441 | {1.5ex \@plus .2ex}% |
| 442 | {\reset@font\large\py@HeaderFamily}} |
| 443 | \renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}% |
| 444 | {-3.25ex\@plus -1ex \@minus -.2ex}% |
| 445 | {1.5ex \@plus .2ex}% |
| 446 | {\reset@font\normalsize\py@HeaderFamily}} |
| 447 | \renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}% |
| 448 | {3.25ex \@plus1ex \@minus.2ex}% |
| 449 | {-1em}% |
| 450 | {\reset@font\normalsize\py@HeaderFamily}} |
| 451 | \renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}% |
| 452 | {3.25ex \@plus1ex \@minus .2ex}% |
| 453 | {-1em}% |
| 454 | {\reset@font\normalsize\py@HeaderFamily}} |
| 455 | |
| 456 | |
Fred Drake | 5420f33 | 1998-07-23 21:41:02 +0000 | [diff] [blame] | 457 | % This gets the underscores closer to the right width; the only change |
| 458 | % from standard LaTeX is the width specified. |
| 459 | |
| 460 | \DeclareTextCommandDefault{\textunderscore}{% |
| 461 | \leavevmode \kern.06em\vbox{\hrule\@width.55em}} |
| 462 | |
Fred Drake | a488f30 | 1998-07-23 17:50:45 +0000 | [diff] [blame] | 463 | % Underscore hack (only act like subscript operator if in math mode) |
| 464 | % |
| 465 | % The following is due to Mark Wooding (the old version didn't work with |
| 466 | % Latex 2e. |
| 467 | |
| 468 | \DeclareRobustCommand\hackscore{% |
| 469 | \ifmmode_\else\textunderscore\fi% |
| 470 | } |
| 471 | \begingroup |
| 472 | \catcode`\_\active |
| 473 | \def\next{% |
| 474 | \AtBeginDocument{\catcode`\_\active\def_{\hackscore{}}}% |
| 475 | } |
| 476 | \expandafter\endgroup\next |
| 477 | |
| 478 | |
Fred Drake | 5371497 | 1998-04-02 22:33:16 +0000 | [diff] [blame] | 479 | % Now for a lot of semantically-loaded environments that do a ton of magical |
| 480 | % things to get the right formatting and index entries for the stuff in |
| 481 | % Python modules and C API. |
| 482 | |
| 483 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 484 | % {fulllineitems} is used in one place in libregex.tex, but is really for |
| 485 | % internal use in this file. |
| 486 | % |
Fred Drake | f9acc59 | 1998-09-09 15:27:43 +0000 | [diff] [blame] | 487 | \newcommand{\py@itemnewline}[1]{% |
| 488 | \@tempdima\linewidth% |
| 489 | \advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}% |
| 490 | } |
| 491 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 492 | \newenvironment{fulllineitems}{ |
| 493 | \begin{list}{}{\labelwidth \leftmargin \labelsep 0pt |
| 494 | \rightmargin 0pt \topsep -\parskip \partopsep \parskip |
| 495 | \itemsep -\parsep |
Fred Drake | f9acc59 | 1998-09-09 15:27:43 +0000 | [diff] [blame] | 496 | \let\makelabel=\py@itemnewline} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 497 | }{\end{list}} |
| 498 | |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 499 | % \optional is mostly for use in the arguments parameters to the various |
| 500 | % {*desc} environments defined below, but may be used elsewhere. Known to |
| 501 | % be used in the debugger chapter. |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 502 | % |
| 503 | % Typical usage: |
| 504 | % |
| 505 | % \begin{funcdesc}{myfunc}{reqparm\optional{, optparm}} |
| 506 | % ^^^ ^^^ |
| 507 | % No space here No space here |
| 508 | % |
| 509 | % When a function has multiple optional parameters, \optional should be |
| 510 | % nested, not chained. This is right: |
| 511 | % |
| 512 | % \begin{funcdesc}{myfunc}{\optional{parm1\optional{, parm2}}} |
| 513 | % |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 514 | \newcommand{\optional}[1]{% |
| 515 | {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}} |
| 516 | |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 517 | % C functions ------------------------------------------------------------ |
| 518 | % \begin{cfuncdesc}{type}{name}{arglist} |
| 519 | \newenvironment{cfuncdesc}[3]{ |
| 520 | \begin{fulllineitems} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 521 | \item[\code{#1 \bfcode{#2}(\py@varvars{#3})}\index{#2@{\py@idxcode{#2()}}}] |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 522 | }{\end{fulllineitems}} |
| 523 | |
| 524 | % C variables ------------------------------------------------------------ |
| 525 | % \begin{cvardesc}{type}{name} |
| 526 | \newenvironment{cvardesc}[2]{ |
| 527 | \begin{fulllineitems} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 528 | \item[\code{#1 \bfcode{#2}}\index{#2@{\py@idxcode{#2}}}] |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 529 | }{\end{fulllineitems}} |
| 530 | |
| 531 | % C data types ----------------------------------------------------------- |
| 532 | % \begin{ctypedesc}{typedef name} |
| 533 | \newenvironment{ctypedesc}[1]{ |
| 534 | \begin{fulllineitems} |
| 535 | \item[\bfcode{#1}\ttindex{#1}] |
| 536 | }{\end{fulllineitems}} |
| 537 | |
| 538 | % simple functions (not methods) ----------------------------------------- |
| 539 | % \begin{funcdesc}{name}{args} |
| 540 | \newcommand{\funcline}[2]{\funclineni{#1}{#2}\ttindex{#1()}} |
| 541 | \newenvironment{funcdesc}[2]{ |
| 542 | \begin{fulllineitems} |
| 543 | \funcline{#1}{#2} |
| 544 | }{\end{fulllineitems}} |
| 545 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 546 | % similar to {funcdesc}, but doesn't add to the index |
Fred Drake | 300775d | 1998-04-17 02:17:00 +0000 | [diff] [blame] | 547 | \newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(\py@varvars{#2})}]} |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 548 | \newenvironment{funcdescni}[2]{ |
| 549 | \begin{fulllineitems} |
| 550 | \funclineni{#1}{#2} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 551 | }{\end{fulllineitems}} |
| 552 | |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 553 | % classes ---------------------------------------------------------------- |
| 554 | % \begin{classdesc}{name}{constructor args} |
| 555 | \newenvironment{classdesc}[2]{ |
Fred Drake | 1cbd196 | 1998-11-25 17:13:28 +0000 | [diff] [blame] | 556 | % Using \renewcommand doesn't work for this, for unknown reasons: |
| 557 | \global\def\py@thisclass{#1} |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 558 | \begin{fulllineitems} |
Fred Drake | 300775d | 1998-04-17 02:17:00 +0000 | [diff] [blame] | 559 | \item[\code{\bfcode{#1}(\py@varvars{#2})}% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 560 | \withsubitem{(class in \py@thismodule)}{\ttindex{#1}}] |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 561 | }{\end{fulllineitems}} |
| 562 | |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 563 | |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 564 | \let\py@classbadkey=\@undefined |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 565 | |
| 566 | % object method ---------------------------------------------------------- |
| 567 | % \begin{methoddesc}[classname]{methodname}{args} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 568 | \newcommand{\methodline}[3][\py@classbadkey]{ |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 569 | \methodlineni{#2}{#3} |
| 570 | \ifx#1\@undefined |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 571 | \withsubitem{(\py@thisclass\ method)}{\ttindex{#2()}} |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 572 | \else |
| 573 | \withsubitem{(#1 method)}{\ttindex{#2()}} |
| 574 | \fi |
| 575 | } |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 576 | \newenvironment{methoddesc}[3][\py@classbadkey]{ |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 577 | \begin{fulllineitems} |
| 578 | \ifx#1\@undefined |
| 579 | \methodline{#2}{#3} |
| 580 | \else |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 581 | \def\py@thisclass{#1} |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 582 | \methodline[#1]{#2}{#3} |
| 583 | \fi |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 584 | }{\end{fulllineitems}} |
| 585 | |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 586 | % similar to {methoddesc}, but doesn't add to the index |
| 587 | % (never actually uses the optional argument) |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 588 | \newcommand{\methodlineni}[3][\py@classbadkey]{% |
Fred Drake | 300775d | 1998-04-17 02:17:00 +0000 | [diff] [blame] | 589 | \item[\code{\bfcode{#2}(\py@varvars{#3})}]} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 590 | \newenvironment{methoddescni}[3][\py@classbadkey]{ |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 591 | \begin{fulllineitems} |
| 592 | \methodlineni{#2}{#3} |
| 593 | }{\end{fulllineitems}} |
| 594 | |
| 595 | % object data attribute -------------------------------------------------- |
| 596 | % \begin{memberdesc}[classname]{membername} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 597 | \newcommand{\memberline}[2][\py@classbadkey]{% |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 598 | \ifx#1\@undefined |
| 599 | \memberlineni{#2} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 600 | \withsubitem{(\py@thisclass\ attribute)}{\ttindex{#2}} |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 601 | \else |
| 602 | \memberlineni{#2} |
Fred Drake | 41565f6 | 1998-04-07 19:32:40 +0000 | [diff] [blame] | 603 | \withsubitem{(#1 attribute)}{\ttindex{#2}} |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 604 | \fi |
| 605 | } |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 606 | \newenvironment{memberdesc}[2][\py@classbadkey]{ |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 607 | \begin{fulllineitems} |
| 608 | \ifx#1\@undefined |
| 609 | \memberline{#2} |
| 610 | \else |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 611 | \def\py@thisclass{#1} |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 612 | \memberline[#1]{#2} |
| 613 | \fi |
| 614 | }{\end{fulllineitems}} |
| 615 | |
| 616 | % similar to {memberdesc}, but doesn't add to the index |
| 617 | % (never actually uses the optional argument) |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 618 | \newcommand{\memberlineni}[2][\py@classbadkey]{\item[\bfcode{#2}]} |
| 619 | \newenvironment{memberdescni}[2][\py@classbadkey]{ |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 620 | \begin{fulllineitems} |
| 621 | \memberlineni{#2} |
| 622 | }{\end{fulllineitems}} |
| 623 | |
| 624 | % For exceptions: -------------------------------------------------------- |
| 625 | % \begin{excdesc}{name} |
| 626 | % -- need support for constructor; maybe use optional parameter? |
| 627 | \newenvironment{excdesc}[1]{ |
| 628 | \begin{fulllineitems} |
| 629 | \item[\bfcode{#1}\ttindex{#1}] |
| 630 | }{\end{fulllineitems}} |
| 631 | |
| 632 | % Module data or constants: ---------------------------------------------- |
| 633 | % \begin{datadesc}{name} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 634 | \newcommand{\dataline}[1]{\datalineni{#1}\ttindex{#1}} |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 635 | \newenvironment{datadesc}[1]{ |
| 636 | \begin{fulllineitems} |
| 637 | \dataline{#1} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 638 | }{\end{fulllineitems}} |
| 639 | |
| 640 | % similar to {datadesc}, but doesn't add to the index |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 641 | \newcommand{\datalineni}[1]{\item[\bfcode{#1}]\nopagebreak} |
| 642 | \newenvironment{datadescni}[1]{ |
| 643 | \begin{fulllineitems} |
| 644 | \datalineni{#1} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 645 | }{\end{fulllineitems}} |
| 646 | |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 647 | % bytecode instruction --------------------------------------------------- |
| 648 | % \begin{opcodedesc}{name}{var} |
| 649 | % -- {var} may be {} |
| 650 | \newenvironment{opcodedesc}[2]{ |
| 651 | \begin{fulllineitems} |
| 652 | \item[\bfcode{#1}\quad\var{#2}] |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 653 | }{\end{fulllineitems}} |
| 654 | |
| 655 | |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 656 | \newcommand{\nodename}[1]{\label{#1}} |
Fred Drake | 5573031 | 1998-03-25 15:41:23 +0000 | [diff] [blame] | 657 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 658 | % For these commands, use \command{} to get the typography right, not |
| 659 | % {\command}. This works better with the texinfo translation. |
| 660 | \newcommand{\ABC}{{\sc abc}} |
| 661 | \newcommand{\UNIX}{{\sc Unix}} |
| 662 | \newcommand{\POSIX}{POSIX} |
| 663 | \newcommand{\ASCII}{{\sc ascii}} |
| 664 | \newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}} |
| 665 | \newcommand{\C}{C} |
| 666 | \newcommand{\EOF}{{\sc eof}} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 667 | \newcommand{\NULL}{\constant{NULL}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 668 | |
Fred Drake | 5371497 | 1998-04-02 22:33:16 +0000 | [diff] [blame] | 669 | % Also for consistency: spell Python "Python", not "python"! |
| 670 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 671 | % code is the most difficult one... |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 672 | \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 | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 673 | \texttt{#1}}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 674 | |
| 675 | \newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font |
Fred Drake | 8e54abe | 1998-07-01 14:49:25 +0000 | [diff] [blame] | 676 | \newcommand{\kbd}[1]{\code{#1}} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 677 | \newcommand{\samp}[1]{`\code{#1}'} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 678 | % This weird definition of \var{} allows it to always appear in roman |
| 679 | % italics, and won't get funky in code fragments when we play around |
Fred Drake | fa1cceb | 1998-11-30 14:42:59 +0000 | [diff] [blame] | 680 | % with fonts. This also works directly in math mode. |
| 681 | \newcommand{\var}[1]{% |
| 682 | \ifmmode% |
| 683 | \hbox{\normalsize\textrm{\textit{#1\/}}}% |
| 684 | \else% |
| 685 | \normalsize\textrm{\textit{#1\/}}% |
| 686 | \fi% |
| 687 | } |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 688 | \renewcommand{\emph}[1]{{\em #1}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 689 | \newcommand{\dfn}[1]{\emph{#1}} |
| 690 | \newcommand{\strong}[1]{{\bf #1}} |
| 691 | % let's experiment with a new font: |
Fred Drake | 0ee9f72 | 1998-03-12 06:41:40 +0000 | [diff] [blame] | 692 | \newcommand{\file}[1]{`{\small\textsf{#1}}'} |
Fred Drake | 0a0fd59 | 1999-04-28 14:59:44 +0000 | [diff] [blame] | 693 | \newcommand{\filenq}[1]{{\small\textsf{#1}}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 694 | |
| 695 | % Use this def/redef approach for \url{} since hyperref defined this already, |
| 696 | % but only if we actually used hyperref: |
Fred Drake | 6cb7149 | 1998-03-27 05:22:53 +0000 | [diff] [blame] | 697 | \@ifundefined{pdfannotlink}{ |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 698 | \newcommand{\py@url}[1]{\mbox{\small\textsf{#1}}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 699 | }{ |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 700 | \newcommand{\py@url}[1]{{% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 701 | \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 702 | \py@LinkColor% color of the link text |
| 703 | \mbox{\small\textsf{#1}}% |
| 704 | \py@NormalColor% Turn it back off; these are declarative |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 705 | \pdfendlink}% and don't appear bound to the current |
| 706 | }% formatting "box". |
| 707 | } |
Fred Drake | a2c2a83 | 1998-04-15 17:50:01 +0000 | [diff] [blame] | 708 | \let\url=\py@url |
Fred Drake | 0ee9f72 | 1998-03-12 06:41:40 +0000 | [diff] [blame] | 709 | \newcommand{\email}[1]{{\small\textsf{#1}}} |
Fred Drake | 454a4fb | 1998-04-01 22:20:14 +0000 | [diff] [blame] | 710 | \newcommand{\newsgroup}[1]{{\small\textsf{#1}}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 711 | |
Fred Drake | 300775d | 1998-04-17 02:17:00 +0000 | [diff] [blame] | 712 | \newcommand{\py@varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 713 | % let's see if this breaks anything now; we may be able to simplify... |
| 714 | \renewcommand{\py@varvars}[1]{\var{#1}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 715 | |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 716 | % I'd really like to get rid of this! |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 717 | \newif\iftexi\texifalse |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 718 | |
Fred Drake | 1e4973b | 1998-07-28 21:52:17 +0000 | [diff] [blame] | 719 | % This is used to get l2h to put the copyright and abstract on |
| 720 | % a separate HTML page. |
| 721 | \newif\ifhtml\htmlfalse |
| 722 | |
| 723 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 724 | % These should be used for all references to identifiers which are |
| 725 | % used to refer to instances of specific language constructs. See the |
| 726 | % names for specific semantic assignments. |
| 727 | % |
| 728 | % For now, don't do anything really fancy with them; just use them as |
| 729 | % logical markup. This might change in the future. |
| 730 | % |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 731 | \newcommand{\module}[1]{\texttt{#1}} |
| 732 | \newcommand{\keyword}[1]{\texttt{#1}} |
| 733 | \newcommand{\exception}[1]{\texttt{#1}} |
| 734 | \newcommand{\class}[1]{\texttt{#1}} |
| 735 | \newcommand{\function}[1]{\texttt{#1}} |
| 736 | \newcommand{\member}[1]{\texttt{#1}} |
| 737 | \newcommand{\method}[1]{\texttt{#1}} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 738 | |
Fred Drake | 5371497 | 1998-04-02 22:33:16 +0000 | [diff] [blame] | 739 | \newcommand{\pytype}[1]{#1} % built-in Python type |
| 740 | |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 741 | \newcommand{\cfunction}[1]{\texttt{#1}} |
| 742 | \newcommand{\ctype}[1]{\texttt{#1}} % C struct or typedef name |
| 743 | \newcommand{\cdata}[1]{\texttt{#1}} % C variable, typically global |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 744 | |
Fred Drake | 0ee9f72 | 1998-03-12 06:41:40 +0000 | [diff] [blame] | 745 | \newcommand{\mimetype}[1]{{\small\textsf{#1}}} |
Fred Drake | 94fac13 | 1998-03-12 19:37:03 +0000 | [diff] [blame] | 746 | % The \! is a "negative thin space" in math mode. |
| 747 | \newcommand{\regexp}[1]{% |
| 748 | {\tiny$^{^\lceil}\!\!$% |
| 749 | {\normalsize\code{#1}}% |
Fred Drake | 47cfd03 | 1998-04-03 21:22:31 +0000 | [diff] [blame] | 750 | $\!\rfloor\!$% |
Fred Drake | 94fac13 | 1998-03-12 19:37:03 +0000 | [diff] [blame] | 751 | }} |
Fred Drake | 0ee9f72 | 1998-03-12 06:41:40 +0000 | [diff] [blame] | 752 | \newcommand{\envvar}[1]{% |
Fred Drake | 94fac13 | 1998-03-12 19:37:03 +0000 | [diff] [blame] | 753 | \$#1% $ <-- bow to font-lock 3 times! |
| 754 | \index{#1@{\$#1}}% $ |
| 755 | \index{environment variables!{\$#1}}% $ |
Fred Drake | 0ee9f72 | 1998-03-12 06:41:40 +0000 | [diff] [blame] | 756 | } |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 757 | \newcommand{\makevar}[1]{#1} % variable in a Makefile |
| 758 | \newcommand{\character}[1]{\samp{#1}} |
Fred Drake | 0ee9f72 | 1998-03-12 06:41:40 +0000 | [diff] [blame] | 759 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 760 | % constants defined in Python modules or C headers, not language constants: |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 761 | \newcommand{\constant}[1]{\code{#1}} % manifest constant, not syntactic |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 762 | |
| 763 | \newcommand{\manpage}[2]{{\emph{#1}(#2)}} |
| 764 | \newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}} |
| 765 | \newcommand{\program}[1]{\strong{#1}} |
| 766 | |
| 767 | |
| 768 | % Deprecation stuff. |
| 769 | % Should be extended to allow an index / list of deprecated stuff. But |
| 770 | % there's a lot of stuff that needs to be done to make that automatable. |
| 771 | % |
| 772 | % First parameter is the release number that deprecates the feature, the |
| 773 | % second is the action the should be taken by users of the feature. |
| 774 | % |
| 775 | % Example: |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 776 | % \deprecated{1.5.1}{Use \method{frobnicate()} instead.} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 777 | % |
| 778 | \newcommand{\deprecated}[2]{% |
| 779 | \strong{Deprecated since release #1.} #2\par} |
| 780 | |
Fred Drake | af958c7 | 1998-07-27 20:32:33 +0000 | [diff] [blame] | 781 | % New stuff. |
| 782 | % This should be used to mark things which have been added to the |
| 783 | % development tree but that aren't in the release, but are documented. |
| 784 | % This allows release of documentation that already includes updated |
Fred Drake | 2116d98 | 1999-02-02 18:02:48 +0000 | [diff] [blame] | 785 | % descriptions. Place at end of descriptor environment. |
Fred Drake | af958c7 | 1998-07-27 20:32:33 +0000 | [diff] [blame] | 786 | % |
| 787 | % Example: |
| 788 | % \versionadded{1.5.2} |
| 789 | % |
| 790 | \newcommand{\versionadded}[1]{% |
Fred Drake | 2116d98 | 1999-02-02 18:02:48 +0000 | [diff] [blame] | 791 | { New in version #1. }} |
Fred Drake | af958c7 | 1998-07-27 20:32:33 +0000 | [diff] [blame] | 792 | \newcommand{\versionchanged}[1]{% |
Fred Drake | 2116d98 | 1999-02-02 18:02:48 +0000 | [diff] [blame] | 793 | { Changed in version #1. }} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 794 | |
Fred Drake | af958c7 | 1998-07-27 20:32:33 +0000 | [diff] [blame] | 795 | |
| 796 | % Tables. |
| 797 | % |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 798 | \newenvironment{tableii}[4]{% |
| 799 | \begin{center}% |
| 800 | \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}% |
Fred Drake | ee60191 | 1998-04-11 20:53:03 +0000 | [diff] [blame] | 801 | \begin{tabular}{#1}\strong{#3}&\strong{#4} \\ \hline% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 802 | }{% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 803 | \end{tabular}% |
| 804 | \end{center}% |
| 805 | } |
| 806 | |
| 807 | \newenvironment{tableiii}[5]{% |
| 808 | \begin{center}% |
| 809 | \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}% |
Fred Drake | ee60191 | 1998-04-11 20:53:03 +0000 | [diff] [blame] | 810 | \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5} \\ \hline% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 811 | }{% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 812 | \end{tabular}% |
| 813 | \end{center}% |
| 814 | } |
| 815 | |
Fred Drake | 30e5265 | 1998-07-24 22:11:29 +0000 | [diff] [blame] | 816 | \newenvironment{tableiv}[6]{% |
| 817 | \begin{center}% |
| 818 | \def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}% |
| 819 | \begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6} \\% |
| 820 | \hline% |
| 821 | }{% |
| 822 | \end{tabular}% |
| 823 | \end{center}% |
| 824 | } |
| 825 | |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 826 | % Cross-referencing (AMK, new impl. FLD) |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 827 | % Sample usage: |
| 828 | % \begin{seealso} |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 829 | % \seemodule{rand}{Uniform random number generator.}; % Module xref |
| 830 | % \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book |
Fred Drake | ebcb658 | 1998-03-06 21:25:17 +0000 | [diff] [blame] | 831 | % |
| 832 | % % A funky case: module name contains '_'; have to supply an optional key |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 833 | % \seemodule[copyreg]{copy_reg}{Interface constructor registration for |
| 834 | % \module{pickle}.} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 835 | % \end{seealso} |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 836 | % |
| 837 | % Note that the last parameter for \seemodule and \seetext should be complete |
| 838 | % sentences and be terminated with the proper punctuation. |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 839 | |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 840 | \@ifundefined{pdfannotlink}{% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 841 | \newcommand{\py@seemodule}[3][\py@modulebadkey]{% |
Fred Drake | da94374 | 1999-01-13 17:09:06 +0000 | [diff] [blame] | 842 | \par% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 843 | \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi% |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 844 | \begin{fulllineitems} |
| 845 | \item[Module \module{#2} (section \ref{module-\py@modulekey}):] |
| 846 | #3 |
| 847 | \end{fulllineitems} |
Fred Drake | ebcb658 | 1998-03-06 21:25:17 +0000 | [diff] [blame] | 848 | } |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 849 | }{\newcommand{\py@seemodule}[3][\py@modulebadkey]{% |
Fred Drake | da94374 | 1999-01-13 17:09:06 +0000 | [diff] [blame] | 850 | \par% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 851 | \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi% |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 852 | \begin{fulllineitems} |
| 853 | \item[\py@linkToName{label-module-\py@modulekey}{Module \module{#2}} |
| 854 | (section \ref{module-\py@modulekey}):] |
| 855 | #3 |
| 856 | \end{fulllineitems} |
Fred Drake | ebcb658 | 1998-03-06 21:25:17 +0000 | [diff] [blame] | 857 | } |
| 858 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 859 | \newenvironment{seealso}[0]{ |
Fred Drake | 9466b9a | 1999-03-18 16:18:27 +0000 | [diff] [blame] | 860 | \par |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 861 | \strong{See Also:}\par |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 862 | \def\seetext##1{\par{##1}} |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 863 | \let\seemodule=\py@seemodule |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 864 | }{\par} |
| 865 | |
| 866 | |
Fred Drake | af958c7 | 1998-07-27 20:32:33 +0000 | [diff] [blame] | 867 | % Allow the Python release number to be specified independently of the |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 868 | % \date{}. This allows the date to reflect the document's date and |
| 869 | % release to specify the Python release that is documented. |
| 870 | % |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 871 | \newcommand{\py@release}{} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 872 | \newcommand{\version}{} |
| 873 | \newcommand{\releasename}{Release} |
| 874 | \newcommand{\release}[1]{% |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 875 | \renewcommand{\py@release}{\releasename\space\version}% |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 876 | \renewcommand{\version}{#1}} |
| 877 | |
| 878 | % Allow specification of the author's address separately from the |
| 879 | % author's name. This can be used to format them differently, which |
| 880 | % is a good thing. |
| 881 | % |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 882 | \newcommand{\py@authoraddress}{} |
| 883 | \newcommand{\authoraddress}[1]{\renewcommand{\py@authoraddress}{#1}} |
Fred Drake | 6df93ef | 1998-05-14 20:56:31 +0000 | [diff] [blame] | 884 | \let\developersaddress=\authoraddress |
| 885 | \let\developer=\author |
| 886 | \let\developers=\author |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 887 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 888 | % This sets up the fancy chapter headings that make the documents look |
| 889 | % at least a little better than the usual LaTeX output. |
| 890 | % |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 891 | \@ifundefined{ChTitleVar}{}{ |
Fred Drake | 24340ea | 1998-04-28 18:30:34 +0000 | [diff] [blame] | 892 | \ChNameVar{\raggedleft\normalsize\py@HeaderFamily} |
| 893 | \ChNumVar{\raggedleft \bfseries\Large\py@HeaderFamily} |
| 894 | \ChTitleVar{\raggedleft \rm\Huge\py@HeaderFamily} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 895 | % This creates chapter heads without the leading \vspace*{}: |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 896 | \def\@makechapterhead#1{% |
| 897 | {\parindent \z@ \raggedright \normalfont |
| 898 | \ifnum \c@secnumdepth >\m@ne |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 899 | \DOCH |
| 900 | \fi |
Fred Drake | 1c8d0e0 | 1998-03-07 05:29:15 +0000 | [diff] [blame] | 901 | \interlinepenalty\@M |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 902 | \DOTI{#1} |
| 903 | } |
| 904 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 905 | } |
| 906 | |
Fred Drake | 3bf7865 | 1998-05-20 17:42:17 +0000 | [diff] [blame] | 907 | |
| 908 | % Definition lists; requested by AMK for HOWTO documents. Probably useful |
| 909 | % elsewhere as well, so keep in in the general style support. |
| 910 | % |
| 911 | \newenvironment{definitions}{% |
| 912 | \begin{description}% |
Fred Drake | f9acc59 | 1998-09-09 15:27:43 +0000 | [diff] [blame] | 913 | \def\term##1{\item[##1]\mbox{}\\*[0mm]} |
Fred Drake | 3bf7865 | 1998-05-20 17:42:17 +0000 | [diff] [blame] | 914 | }{% |
| 915 | \end{description}% |
| 916 | } |
| 917 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 918 | % Tell TeX about pathological hyphenation cases: |
| 919 | \hyphenation{Base-HTTP-Re-quest-Hand-ler} |