Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9466b9a

Browse files
committed
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.
1 parent 5967667 commit 9466b9a

1 file changed

Lines changed: 35 additions & 41 deletions

File tree

Doc/texinputs/python.sty

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
\ProvidesPackage{python}
77
[1998/01/11 LaTeX package (Python markup)]
88

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+
915
% These packages can be used to add marginal annotations which indicate
1016
% index entries and labels; useful for reviewing this messy documentation!
1117
%
@@ -91,23 +97,16 @@
9197
\advance \topmargin by -\headsep
9298

9399
% attempt to work a little better for A4 users
94-
\@ifundefined{paperheight}{
95-
\textheight 9in
96-
}{
97-
\textheight \paperheight
98-
\advance\textheight by -2in
99-
}
100+
\textheight \paperheight
101+
\advance\textheight by -2in
100102

101103
\oddsidemargin 0pt
102-
\evensidemargin \oddsidemargin
104+
\evensidemargin 0pt
105+
%\evensidemargin -.25in % for ``manual size'' documents
103106
\marginparwidth 0.5in
104107

105-
\@ifundefined{paperwidth}{
106-
\textwidth 6.5in
107-
}{
108-
\textwidth \paperwidth
109-
\advance\textwidth by -2in
110-
}
108+
\textwidth \paperwidth
109+
\advance\textwidth by -2in
111110

112111

113112
% Style parameters and macros used by most documents here
@@ -162,32 +161,27 @@
162161
% and to have all the other mostly nice properties that we want for
163162
% code samples.
164163

164+
\let\py@OldVerbatim=\verbatim
165+
\let\py@OldEndVerbatim=\endverbatim
166+
\RequirePackage{verbatim}
167+
165168
% Variable used by begin code command
166169
\newlength{\py@codewidth}
167170

168-
\newcommand{\py@examplevspace}{2mm}
169-
\newcommand{\py@exampleindent}{1cm}
170-
171-
\let\py@OldVerbatim=\verbatim
172-
\let\py@OldEndVerbatim=\endverbatim
173171
\renewcommand{\verbatim}{%
174-
\begingroup%
175-
\setlength{\parindent}\py@exampleindent%
172+
\setlength{\parindent}{1cm}%
176173
% Calculate the text width for the minipage:
177174
\setlength{\py@codewidth}{\linewidth}%
178175
\addtolength{\py@codewidth}{-\parindent}%
179176
%
180-
\par%
181-
\vspace\py@examplevspace%
182-
\indent%
177+
\par\indent%
183178
\begin{minipage}[t]{\py@codewidth}%
184179
\small%
185180
\py@OldVerbatim%
186181
}
187182
\renewcommand{\endverbatim}{%
188183
\py@OldEndVerbatim%
189184
\end{minipage}%
190-
\endgroup%
191185
}
192186

193187

@@ -264,18 +258,24 @@
264258
\@ifundefined{py@modplat@\py@thismodulekey}{
265259
\write\modindexfile{\protect\indexentry{#1@{\texttt{#1}}}{\thepage}}%
266260
}{\write\modindexfile{\protect\indexentry{#1@{\texttt{#1} %
267-
\emph{(\platformof[\py@thismodulekey]{})}}}{\thepage}}%
261+
\emph{(\py@platformof[\py@thismodulekey]{})}}}{\thepage}}%
268262
}
269263
\fi%
270264
}
271265

266+
% *** XXX *** THE NEXT FOUR MACROS ARE NOW OBSOLETE !!! ***
267+
272268
% built-in & Python modules in the main distribution
273-
\newcommand{\bimodindex}[1]{\py@modindex{#1}{built-in }}
274-
\newcommand{\stmodindex}[1]{\py@modindex{#1}{standard }}
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!}}
275273

276274
% Python & extension modules outside the main distribution
277-
\newcommand{\modindex}[1]{\py@modindex{#1}{}}
278-
\newcommand{\exmodindex}[1]{\py@modindex{#1}{extension }}
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!}}
279279

280280
% Additional string for an index entry
281281
\newcommand{\index@subitem}{}
@@ -296,10 +296,10 @@
296296
\newcommand{\py@thismodulekey}{}
297297
\newcommand{\py@thismoduletype}{}
298298

299-
\newcommand{\py@standardIndexModule}[1]{\stmodindex{#1}}
300-
\newcommand{\py@builtinIndexModule}[1]{\bimodindex{#1}}
301-
\newcommand{\py@extensionIndexModule}[1]{\exmodindex{#1}}
302-
\newcommand{\py@IndexModule}[1]{\modindex{#1}}
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}{}}
303303

304304
\newif\ifpy@HaveModSynopsis \py@HaveModSynopsisfalse
305305
\newif\ifpy@ModSynopsisFileIsOpen \py@ModSynopsisFileIsOpenfalse
@@ -325,16 +325,9 @@
325325
\openout\py@ModPlatformFile=\py@ModPlatformFilename
326326
\py@ModPlatformFileIsOpentrue
327327
\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-
}
335328
}
336329
\InputIfFileExists{\jobname.pla}{}{}
337-
\newcommand{\platformof}[2][\py@modulebadkey]{%
330+
\newcommand{\py@platformof}[2][\py@modulebadkey]{%
338331
\ifx\py@modulebadkey#1 \def\py@key{#2}%
339332
\else \def\py@key{#1}%
340333
\fi%
@@ -852,6 +845,7 @@
852845
}
853846
}
854847
\newenvironment{seealso}[0]{
848+
\par
855849
\strong{See Also:}\par
856850
\def\seetext##1{\par{##1}}
857851
\let\seemodule=\py@seemodule

0 commit comments

Comments
 (0)