cinap_lenrekadd hg and python4bb9e2215 years agoHistory
1327 lines · 40.2 KB · TeX
RawDownload
%% python.sty for the Python docummentation  [works only with Latex2e]% \NeedsTeXFormat{LaTeX2e}[1995/12/01]\ProvidesPackage{python}             [1998/01/11 LaTeX package (Python markup)] \RequirePackage{longtable}\RequirePackage{underscore} % Uncomment these two lines to ignore the paper size and make the page % size more like a typical published manual.%\renewcommand{\paperheight}{9in}%\renewcommand{\paperwidth}{8.5in}   % typical squarish manual%\renewcommand{\paperwidth}{7in}     % O'Reilly ``Programmming Python'' % These packages can be used to add marginal annotations which indicate% index entries and labels; useful for reviewing this messy documentation!%%\RequirePackage{showkeys}%\RequirePackage{showidx} % If we ever want to indent paragraphs, this needs to be changed.% This is used inside the macros defined here instead of coding% \noindent directly.\let\py@parindent=\noindent % for PDF output, use maximal compression & a lot of other stuff% (test for PDF recommended by Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov>)%\newif\ifpy@doing@page@targets\py@doing@page@targetsfalse \newif\ifpdf\pdffalse\ifx\pdfoutput\undefined\else\ifcase\pdfoutput\else  \pdftrue  \input{pdfcolor}  \let\py@LinkColor=\NavyBlue  \let\py@NormalColor=\Black  \pdfcompresslevel=9  \pdfpagewidth=\paperwidth    % page width of PDF output  \pdfpageheight=\paperheight  % page height of PDF output  %  % Pad the number with '0' to 3 digits wide so no page name is a prefix  % of any other.  %  \newcommand{\py@targetno}[1]{\ifnum#1<100 0\fi\ifnum#1<10 0\fi#1}  \newcommand{\py@pageno}{\py@targetno\thepage}  %  % This definition allows the entries in the page-view of the ToC to be  % active links.  Some work, some don't.  %  \let\py@OldContentsline=\contentsline  %  % Backward compatibility hack: pdfTeX 0.13 defined \pdfannotlink,  % but it changed to \pdfstartlink in 0.14.  This let's us use either  % version and still get useful behavior.  %  \@ifundefined{pdfstartlink}{    \let\pdfstartlink=\pdfannotlink  }{}  %  % The \py@parindent here is a hack -- we're forcing pdfTeX into  % horizontal mode since \pdfstartlink requires that.  \def\py@pdfstartlink{%    \ifvmode\py@parindent\fi%    \pdfstartlink%  }  %  % Macro that takes two args: the name to link to and the content of  % the link.  This takes care of the PDF magic, getting the colors  % the same for each link, and avoids having lots of garbage all over   % this style file.  \newcommand{\py@linkToName}[2]{%    \py@pdfstartlink attr{/Border [0 0 0]} goto name{#1}%      \py@LinkColor#2\py@NormalColor%    \pdfendlink%  }  % Compute the padded page number separately since we end up with a pair of  % \relax tokens; this gets the right string computed and works.  \renewcommand{\contentsline}[3]{%    \def\my@pageno{\py@targetno{#3}}%    \py@OldContentsline{#1}{\py@linkToName{page\my@pageno}{#2}}{#3}%  }  \AtEndDocument{    \def\_{\string_}    \InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{}  }  \newcommand{\py@target}[1]{%    \ifpy@doing@page@targets%      {\pdfdest name{#1} xyz}%    \fi%  }  \let\py@OldLabel=\label  \renewcommand{\label}[1]{%    \py@OldLabel{#1}%    \py@target{label-#1}%  }  % This stuff adds a page# destination to every PDF page, where # is three  % digits wide, padded with leading zeros.  This doesn't really help with  % the frontmatter, but does fine with the body.  %  % This is *heavily* based on the hyperref package.  %  \def\@begindvi{%    \unvbox \@begindvibox    \@hyperfixhead  }  \def\@hyperfixhead{%   \let\H@old@thehead\@thehead       \global\def\@foo{\py@target{page\py@pageno}}%     \expandafter\ifx\expandafter\@empty\H@old@thehead       \def\H@old@thehead{\hfil}\fi    \def\@thehead{\@foo\relax\H@old@thehead}%  }\fi\fi % Increase printable page size (copied from fullpage.sty)\topmargin 0pt\advance \topmargin by -\headheight\advance \topmargin by -\headsep % attempt to work a little better for A4 users\textheight \paperheight\advance\textheight by -2in \oddsidemargin 0pt\evensidemargin 0pt%\evensidemargin -.25in  % for ``manual size'' documents\marginparwidth 0.5in \textwidth \paperwidth\advance\textwidth by -2in  % Style parameters and macros used by most documents here\raggedbottom\sloppy\parindent = 0mm\parskip = 2mm\hbadness = 5000                % don't print trivial gripes \pagestyle{empty}               % start this way; change for\pagenumbering{roman}           % ToC & chapters % Use this to set the font family for headers and other decor:\newcommand{\py@HeaderFamily}{\sffamily} % Set up abstract ways to get the normal and smaller font sizes that% work even in footnote context.\newif\ifpy@infootnote \py@infootnotefalse\let\py@oldmakefntext\@makefntext\def\@makefntext#1{%  \bgroup%    \py@infootnotetrue    \py@oldmakefntext{#1}%  \egroup%}\def\py@defaultsize{%  \ifpy@infootnote\footnotesize\else\normalsize\fi%}\def\py@smallsize{%  \ifpy@infootnote\scriptsize\else\small\fi%} % Redefine the 'normal' header/footer style when using "fancyhdr" package:\@ifundefined{fancyhf}{}{  % Use \pagestyle{normal} as the primary pagestyle for text.  \fancypagestyle{normal}{    \fancyhf{}    \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}    \fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}}    \fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}}    \renewcommand{\headrulewidth}{0pt}    \renewcommand{\footrulewidth}{0.4pt}  }  % Update the plain style so we get the page number & footer line,  % but not a chapter or section title.  This is to keep the first  % page of a chapter and the blank page between chapters `clean.'  \fancypagestyle{plain}{    \fancyhf{}    \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}    \renewcommand{\headrulewidth}{0pt}    \renewcommand{\footrulewidth}{0.4pt}  }  % Redefine \cleardoublepage so that the blank page between chapters  % gets the plain style and not the fancy style.  This is described  % in the documentation for the fancyhdr package by Piet von Oostrum.  \@ifundefined{chapter}{}{    \renewcommand{\cleardoublepage}{      \clearpage\if@openright \ifodd\c@page\else      \hbox{}      \thispagestyle{plain}      \newpage      \if@twocolumn\hbox{}\newpage\fi\fi\fi    }  }} % This sets up the {verbatim} environment to be indented and a minipage,% and to have all the other mostly nice properties that we want for% code samples. \let\py@OldVerbatim=\verbatim\let\py@OldEndVerbatim=\endverbatim\RequirePackage{verbatim}\let\py@OldVerbatimInput=\verbatiminput % Variable used by begin code command\newlength{\py@codewidth} \renewcommand{\verbatim}{%  \setlength{\parindent}{1cm}%  % Calculate the text width for the minipage:  \setlength{\py@codewidth}{\linewidth}%  \addtolength{\py@codewidth}{-\parindent}%  %  \par\indent%  \begin{minipage}[t]{\py@codewidth}%    \small%    \py@OldVerbatim%}\renewcommand{\endverbatim}{%    \py@OldEndVerbatim%  \end{minipage}%}\renewcommand{\verbatiminput}[1]{%  {\setlength{\parindent}{1cm}%   % Calculate the text width for the minipage:   \setlength{\py@codewidth}{\linewidth}%   \addtolength{\py@codewidth}{-\parindent}%   %   \small%   \begin{list}{}{\setlength{\leftmargin}{1cm}}     \item%     \py@OldVerbatimInput{#1}%   \end{list}  }%} % This does a similar thing for the {alltt} environment:\RequirePackage{alltt}\let\py@OldAllTT=\alltt\let\py@OldEndAllTT=\endalltt \renewcommand{\alltt}{%  \setlength{\parindent}{1cm}%  % Calculate the text width for the minipage:  \setlength{\py@codewidth}{\linewidth}%  \addtolength{\py@codewidth}{-\parindent}%  \let\e=\textbackslash%  %  \par\indent%  \begin{minipage}[t]{\py@codewidth}%    \small%    \py@OldAllTT%}\renewcommand{\endalltt}{%    \py@OldEndAllTT%  \end{minipage}%}  \newcommand{\py@modulebadkey}{{--just-some-junk--}}  %%  Lots of index-entry generation support. % Command to wrap around stuff that refers to function / module /% attribute names  in the index.  Default behavior: like \code{}.  To% just keep the index entries in the roman font, uncomment the second% definition; it matches O'Reilly style more.%\newcommand{\py@idxcode}[1]{\texttt{#1}}%\renewcommand{\py@idxcode}[1]{#1} % Command to generate two index entries (using subentries)\newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}} % And three entries (using only one level of subentries)\newcommand{\indexiii}[3]{\index{#1!#2 #3}\index{#2!#3, #1}\index{#3!#1 #2}} % And four (again, using only one level of subentries)\newcommand{\indexiv}[4]{\index{#1!#2 #3 #4}\index{#2!#3 #4, #1}\index{#3!#4, #1 #2}\index{#4!#1 #2 #3}} % Command to generate a reference to a function, statement, keyword,% operator.\newcommand{\kwindex}[1]{\indexii{keyword}{#1@{\py@idxcode{#1}}}}\newcommand{\stindex}[1]{\indexii{statement}{#1@{\py@idxcode{#1}}}}\newcommand{\opindex}[1]{\indexii{operator}{#1@{\py@idxcode{#1}}}}\newcommand{\exindex}[1]{\indexii{exception}{#1@{\py@idxcode{#1}}}}\newcommand{\obindex}[1]{\indexii{object}{#1}}\newcommand{\bifuncindex}[1]{%  \index{#1@{\py@idxcode{#1()}} (built-in function)}} % Add an index entry for a module\newcommand{\py@refmodule}[2]{\index{#1@{\py@idxcode{#1}} (#2module)}}\newcommand{\refmodindex}[1]{\py@refmodule{#1}{}}\newcommand{\refbimodindex}[1]{\py@refmodule{#1}{built-in }}\newcommand{\refexmodindex}[1]{\py@refmodule{#1}{extension }}\newcommand{\refstmodindex}[1]{\py@refmodule{#1}{standard }} % Refer to a module's documentation using a hyperlink of the module's% name, at least if we're building PDF:\ifpdf  \newcommand{\refmodule}[2][\py@modulebadkey]{%    \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%    \py@linkToName{label-module-\py@modulekey}{\module{#2}}%  }\else  \newcommand{\refmodule}[2][\py@modulebadkey]{\module{#2}}\fi % support for the module index\newif\ifpy@UseModuleIndex\py@UseModuleIndexfalse \newcommand{\makemodindex}{  \newwrite\modindexfile  \openout\modindexfile=mod\jobname.idx  \py@UseModuleIndextrue} % Add the defining entry for a module\newcommand{\py@modindex}[2]{%  \renewcommand{\py@thismodule}{#1}  \setindexsubitem{(in module #1)}%  \index{#1@{\py@idxcode{#1}} (#2module)|textbf}%  \ifpy@UseModuleIndex%    \@ifundefined{py@modplat@\py@thismodulekey}{      \write\modindexfile{\protect\indexentry{#1@{\texttt{#1}}}{\thepage}}%    }{\write\modindexfile{\protect\indexentry{#1@{\texttt{#1} %        \emph{(\py@platformof[\py@thismodulekey]{})}}}{\thepage}}%    }  \fi%} % *** XXX *** THE NEXT FOUR MACROS ARE NOW OBSOLETE !!! *** % built-in & Python modules in the main distribution\newcommand{\bimodindex}[1]{\py@modindex{#1}{built-in }%  \typeout{*** MACRO bimodindex IS OBSOLETE -- USE declaremodule INSTEAD!}}\newcommand{\stmodindex}[1]{\py@modindex{#1}{standard }%  \typeout{*** MACRO stmodindex IS OBSOLETE -- USE declaremodule INSTEAD!}} % Python & extension modules outside the main distribution\newcommand{\modindex}[1]{\py@modindex{#1}{}%  \typeout{*** MACRO modindex IS OBSOLETE -- USE declaremodule INSTEAD!}}\newcommand{\exmodindex}[1]{\py@modindex{#1}{extension }%  \typeout{*** MACRO exmodindex IS OBSOLETE -- USE declaremodule INSTEAD!}} % Additional string for an index entry\newif\ifpy@usingsubitem\py@usingsubitemfalse\newcommand{\py@indexsubitem}{}\newcommand{\setindexsubitem}[1]{\renewcommand{\py@indexsubitem}{ #1}%                                 \py@usingsubitemtrue}\newcommand{\ttindex}[1]{%  \ifpy@usingsubitem    \index{#1@{\py@idxcode{#1}}\py@indexsubitem}%  \else%    \index{#1@{\py@idxcode{#1}}}%  \fi%}\newcommand{\withsubitem}[2]{%  \begingroup%    \def\ttindex##1{\index{##1@{\py@idxcode{##1}} #1}}%    #2%  \endgroup%}  % Module synopsis processing -----------------------------------------------%\newcommand{\py@thisclass}{}\newcommand{\py@thismodule}{}\newcommand{\py@thismodulekey}{}\newcommand{\py@thismoduletype}{} \newcommand{\py@standardIndexModule}[1]{\py@modindex{#1}{standard }}\newcommand{\py@builtinIndexModule}[1]{\py@modindex{#1}{built-in }}\newcommand{\py@extensionIndexModule}[1]{\py@modindex{#1}{extension }}\newcommand{\py@IndexModule}[1]{\py@modindex{#1}{}} \newif\ifpy@HaveModSynopsis       \py@HaveModSynopsisfalse\newif\ifpy@ModSynopsisFileIsOpen \py@ModSynopsisFileIsOpenfalse\newif\ifpy@HaveModPlatform       \py@HaveModPlatformfalse % \declaremodule[key]{type}{name}\newcommand{\declaremodule}[3][\py@modulebadkey]{  \py@openModSynopsisFile  \renewcommand{\py@thismoduletype}{#2}  \ifx\py@modulebadkey#1    \renewcommand{\py@thismodulekey}{#3}  \else    \renewcommand{\py@thismodulekey}{#1}  \fi  \@ifundefined{py@#2IndexModule}{%    \typeout{*** MACRO declaremodule called with unknown module type: `#2'}    \py@IndexModule{#3}%  }{%    \csname py@#2IndexModule\endcsname{#3}%  }  \label{module-\py@thismodulekey}}\newif\ifpy@ModPlatformFileIsOpen \py@ModPlatformFileIsOpenfalse\newcommand{\py@ModPlatformFilename}{\jobname.pla}\newcommand{\platform}[1]{  \ifpy@ModPlatformFileIsOpen\else    \newwrite\py@ModPlatformFile    \openout\py@ModPlatformFile=\py@ModPlatformFilename    \py@ModPlatformFileIsOpentrue  \fi}\InputIfFileExists{\jobname.pla}{}{}\newcommand{\py@platformof}[2][\py@modulebadkey]{%  \ifx\py@modulebadkey#1 \def\py@key{#2}%  \else \def\py@key{#1}%  \fi%  \csname py@modplat@\py@key\endcsname%}\newcommand{\ignorePlatformAnnotation}[1]{} % \moduleauthor{name}{email}\newcommand{\moduleauthor}[2]{} % \sectionauthor{name}{email}\newcommand{\sectionauthor}[2]{}  \newcommand{\py@defsynopsis}{Module has no synopsis.}\newcommand{\py@modulesynopsis}{\py@defsynopsis}\newcommand{\modulesynopsis}[1]{  \py@HaveModSynopsistrue  \renewcommand{\py@modulesynopsis}{#1}} % define the file\newwrite\py@ModSynopsisFile % hacked from \addtocontents from latex.ltx:\long\def\py@writeModSynopsisFile#1{%  \protected@write\py@ModSynopsisFile%      {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%      {\string#1}%}\newcommand{\py@closeModSynopsisFile}{  \ifpy@ModSynopsisFileIsOpen    \closeout\py@ModSynopsisFile    \py@ModSynopsisFileIsOpenfalse  \fi}\newcommand{\py@openModSynopsisFile}{  \ifpy@ModSynopsisFileIsOpen\else    \openout\py@ModSynopsisFile=\py@ModSynopsisFilename    \py@ModSynopsisFileIsOpentrue  \fi} \newcommand{\py@ProcessModSynopsis}{  \ifpy@HaveModSynopsis    \py@writeModSynopsisFile{\modulesynopsis%      {\py@thismodulekey}{\py@thismodule}%      {\py@thismoduletype}{\py@modulesynopsis}}%    \py@HaveModSynopsisfalse  \fi  \renewcommand{\py@modulesynopsis}{\py@defsynopsis}}\AtEndDocument{\py@ProcessModSynopsis\py@closeModSynopsisFile}  \long\def\py@writeModPlatformFile#1{%  \protected@write\py@ModPlatformFile%    {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%    {\string#1}%}  \newcommand{\localmoduletable}{  \IfFileExists{\py@ModSynopsisFilename}{    \begin{synopsistable}      \input{\py@ModSynopsisFilename}    \end{synopsistable}  }{}} \ifpdf  \newcommand{\py@ModSynopsisSummary}[4]{%    \py@linkToName{label-module-#1}{\bfcode{#2}} & #4\\  }\else  \newcommand{\py@ModSynopsisSummary}[4]{\bfcode{#2} & #4\\}\fi\newenvironment{synopsistable}{

Lines 1–500 of 1327.