comparison Doc/texinputs/python.sty @ 10423:9a4baf0c57ea legacy-trunk

Add some (commented out) macros to change the page size to the size of typical published manuals, so people can more easily see what they're really asking for. ;-) Revise the verbatim environment: simple implementation, but more compatible if a document also add \usepackage{verbatim} at the beginning. Declare \modindex, \bimodindex, \exmodindex, and \stmodindex obsolete. These still work just fine, but \declaremodule should be used instead. The obsolete macros will print a warning on standard out.
author Fred Drake <fdrake@acm.org>
date Thu, 18 Mar 1999 16:18:27 +0000
parents f438c6e2b6c1
children 2b1dfc13951d
comparison
equal deleted inserted replaced
10422:b36469398262 10423:9a4baf0c57ea
3 % 3 %
4 4
5 \NeedsTeXFormat{LaTeX2e}[1995/12/01] 5 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
6 \ProvidesPackage{python} 6 \ProvidesPackage{python}
7 [1998/01/11 LaTeX package (Python markup)] 7 [1998/01/11 LaTeX package (Python markup)]
8
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''
8 14
9 % These packages can be used to add marginal annotations which indicate 15 % These packages can be used to add marginal annotations which indicate
10 % index entries and labels; useful for reviewing this messy documentation! 16 % index entries and labels; useful for reviewing this messy documentation!
11 % 17 %
12 %\RequirePackage{showkeys} 18 %\RequirePackage{showkeys}
89 \topmargin 0pt 95 \topmargin 0pt
90 \advance \topmargin by -\headheight 96 \advance \topmargin by -\headheight
91 \advance \topmargin by -\headsep 97 \advance \topmargin by -\headsep
92 98
93 % attempt to work a little better for A4 users 99 % attempt to work a little better for A4 users
94 \@ifundefined{paperheight}{ 100 \textheight \paperheight
95 \textheight 9in 101 \advance\textheight by -2in
96 }{
97 \textheight \paperheight
98 \advance\textheight by -2in
99 }
100 102
101 \oddsidemargin 0pt 103 \oddsidemargin 0pt
102 \evensidemargin \oddsidemargin 104 \evensidemargin 0pt
105 %\evensidemargin -.25in % for ``manual size'' documents
103 \marginparwidth 0.5in 106 \marginparwidth 0.5in
104 107
105 \@ifundefined{paperwidth}{ 108 \textwidth \paperwidth
106 \textwidth 6.5in 109 \advance\textwidth by -2in
107 }{
108 \textwidth \paperwidth
109 \advance\textwidth by -2in
110 }
111 110
112 111
113 % Style parameters and macros used by most documents here 112 % Style parameters and macros used by most documents here
114 \raggedbottom 113 \raggedbottom
115 \sloppy 114 \sloppy
160 159
161 % This sets up the {verbatim} environment to be indented and a minipage, 160 % This sets up the {verbatim} environment to be indented and a minipage,
162 % and to have all the other mostly nice properties that we want for 161 % and to have all the other mostly nice properties that we want for
163 % code samples. 162 % code samples.
164 163
164 \let\py@OldVerbatim=\verbatim
165 \let\py@OldEndVerbatim=\endverbatim
166 \RequirePackage{verbatim}
167
165 % Variable used by begin code command 168 % Variable used by begin code command
166 \newlength{\py@codewidth} 169 \newlength{\py@codewidth}
167 170
168 \newcommand{\py@examplevspace}{2mm}
169 \newcommand{\py@exampleindent}{1cm}
170
171 \let\py@OldVerbatim=\verbatim
172 \let\py@OldEndVerbatim=\endverbatim
173 \renewcommand{\verbatim}{% 171 \renewcommand{\verbatim}{%
174 \begingroup% 172 \setlength{\parindent}{1cm}%
175 \setlength{\parindent}\py@exampleindent%
176 % Calculate the text width for the minipage: 173 % Calculate the text width for the minipage:
177 \setlength{\py@codewidth}{\linewidth}% 174 \setlength{\py@codewidth}{\linewidth}%
178 \addtolength{\py@codewidth}{-\parindent}% 175 \addtolength{\py@codewidth}{-\parindent}%
179 % 176 %
180 \par% 177 \par\indent%
181 \vspace\py@examplevspace%
182 \indent%
183 \begin{minipage}[t]{\py@codewidth}% 178 \begin{minipage}[t]{\py@codewidth}%
184 \small% 179 \small%
185 \py@OldVerbatim% 180 \py@OldVerbatim%
186 } 181 }
187 \renewcommand{\endverbatim}{% 182 \renewcommand{\endverbatim}{%
188 \py@OldEndVerbatim% 183 \py@OldEndVerbatim%
189 \end{minipage}% 184 \end{minipage}%
190 \endgroup%
191 } 185 }
192 186
193 187
194 \newcommand{\py@modulebadkey}{{--just-some-junk--}} 188 \newcommand{\py@modulebadkey}{{--just-some-junk--}}
195 189
262 \index{#1@{\py@idxcode{#1}} (#2module)|textbf}% 256 \index{#1@{\py@idxcode{#1}} (#2module)|textbf}%
263 \ifpy@UseModuleIndex% 257 \ifpy@UseModuleIndex%
264 \@ifundefined{py@modplat@\py@thismodulekey}{ 258 \@ifundefined{py@modplat@\py@thismodulekey}{
265 \write\modindexfile{\protect\indexentry{#1@{\texttt{#1}}}{\thepage}}% 259 \write\modindexfile{\protect\indexentry{#1@{\texttt{#1}}}{\thepage}}%
266 }{\write\modindexfile{\protect\indexentry{#1@{\texttt{#1} % 260 }{\write\modindexfile{\protect\indexentry{#1@{\texttt{#1} %
267 \emph{(\platformof[\py@thismodulekey]{})}}}{\thepage}}% 261 \emph{(\py@platformof[\py@thismodulekey]{})}}}{\thepage}}%
268 } 262 }
269 \fi% 263 \fi%
270 } 264 }
271 265
266 % *** XXX *** THE NEXT FOUR MACROS ARE NOW OBSOLETE !!! ***
267
272 % built-in & Python modules in the main distribution 268 % built-in & Python modules in the main distribution
273 \newcommand{\bimodindex}[1]{\py@modindex{#1}{built-in }} 269 \newcommand{\bimodindex}[1]{\py@modindex{#1}{built-in }%
274 \newcommand{\stmodindex}[1]{\py@modindex{#1}{standard }} 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!}}
275 273
276 % Python & extension modules outside the main distribution 274 % Python & extension modules outside the main distribution
277 \newcommand{\modindex}[1]{\py@modindex{#1}{}} 275 \newcommand{\modindex}[1]{\py@modindex{#1}{}%
278 \newcommand{\exmodindex}[1]{\py@modindex{#1}{extension }} 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!}}
279 279
280 % Additional string for an index entry 280 % Additional string for an index entry
281 \newcommand{\index@subitem}{} 281 \newcommand{\index@subitem}{}
282 \newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}} 282 \newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}}
283 \newcommand{\ttindex}[1]{\index{#1@{\py@idxcode{#1}} \index@subitem}} 283 \newcommand{\ttindex}[1]{\index{#1@{\py@idxcode{#1}} \index@subitem}}
294 \newcommand{\py@thisclass}{} 294 \newcommand{\py@thisclass}{}
295 \newcommand{\py@thismodule}{} 295 \newcommand{\py@thismodule}{}
296 \newcommand{\py@thismodulekey}{} 296 \newcommand{\py@thismodulekey}{}
297 \newcommand{\py@thismoduletype}{} 297 \newcommand{\py@thismoduletype}{}
298 298
299 \newcommand{\py@standardIndexModule}[1]{\stmodindex{#1}} 299 \newcommand{\py@standardIndexModule}[1]{\py@modindex{#1}{standard }}
300 \newcommand{\py@builtinIndexModule}[1]{\bimodindex{#1}} 300 \newcommand{\py@builtinIndexModule}[1]{\py@modindex{#1}{built-in }}
301 \newcommand{\py@extensionIndexModule}[1]{\exmodindex{#1}} 301 \newcommand{\py@extensionIndexModule}[1]{\py@modindex{#1}{extension }}
302 \newcommand{\py@IndexModule}[1]{\modindex{#1}} 302 \newcommand{\py@IndexModule}[1]{\py@modindex{#1}{}}
303 303
304 \newif\ifpy@HaveModSynopsis \py@HaveModSynopsisfalse 304 \newif\ifpy@HaveModSynopsis \py@HaveModSynopsisfalse
305 \newif\ifpy@ModSynopsisFileIsOpen \py@ModSynopsisFileIsOpenfalse 305 \newif\ifpy@ModSynopsisFileIsOpen \py@ModSynopsisFileIsOpenfalse
306 \newif\ifpy@HaveModPlatform \py@HaveModPlatformfalse 306 \newif\ifpy@HaveModPlatform \py@HaveModPlatformfalse
307 307
323 \ifpy@ModPlatformFileIsOpen\else 323 \ifpy@ModPlatformFileIsOpen\else
324 \newwrite\py@ModPlatformFile 324 \newwrite\py@ModPlatformFile
325 \openout\py@ModPlatformFile=\py@ModPlatformFilename 325 \openout\py@ModPlatformFile=\py@ModPlatformFilename
326 \py@ModPlatformFileIsOpentrue 326 \py@ModPlatformFileIsOpentrue
327 \fi 327 \fi
328 \@ifundefined{py@modplat@\py@thismodulekey}{
329 \py@writeModPlatformFile{%
330 \newcommand{\csname py@modplat@\py@thismodulekey\endcsname}{#1}}%
331 }{\py@writeModPlatformFile{%
332 \newcommand{\string\py@modplat@\py@thismodulekey}{#1}%
333 }
334 }
335 } 328 }
336 \InputIfFileExists{\jobname.pla}{}{} 329 \InputIfFileExists{\jobname.pla}{}{}
337 \newcommand{\platformof}[2][\py@modulebadkey]{% 330 \newcommand{\py@platformof}[2][\py@modulebadkey]{%
338 \ifx\py@modulebadkey#1 \def\py@key{#2}% 331 \ifx\py@modulebadkey#1 \def\py@key{#2}%
339 \else \def\py@key{#1}% 332 \else \def\py@key{#1}%
340 \fi% 333 \fi%
341 \csname py@modplat@\py@key\endcsname% 334 \csname py@modplat@\py@key\endcsname%
342 } 335 }
850 \py@linkToName{label-module-\py@modulekey}{ Module \module{#2} } 843 \py@linkToName{label-module-\py@modulekey}{ Module \module{#2} }
851 \quad (#3)% 844 \quad (#3)%
852 } 845 }
853 } 846 }
854 \newenvironment{seealso}[0]{ 847 \newenvironment{seealso}[0]{
848 \par
855 \strong{See Also:}\par 849 \strong{See Also:}\par
856 \def\seetext##1{\par{##1}} 850 \def\seetext##1{\par{##1}}
857 \let\seemodule=\py@seemodule 851 \let\seemodule=\py@seemodule
858 }{\par} 852 }{\par}
859 853