From 0ee9f727c9e4437d615f6f5877d9f0383d99e726 Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Thu, 12 Mar 1998 06:41:40 +0000 Subject: [PATCH] \withsubitem{}: New macro. Change indexsubitem temporarily for another macro. Intended usage: \withsubitem{(in module foo)}{\ttindex{myfunc()}} This allows indexing functions from other modules/class/whatnot without being dependent on the exact expansions of several macros internal to python.sty. It's also easier to read in the source! Some new "logical" macros that seem to be useful: \regexp{}: For regular expressions. To make it easier to keep the appearance consistent. \mimetype{}: Don't use \code{}! \envvar{}: Environment variable. This does some indexing as well. \character{}: Just a character we want to talk about in the text, but not a Python constant. --- Doc/texinputs/python.sty | 41 ++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/Doc/texinputs/python.sty b/Doc/texinputs/python.sty index e98b3edb4fe..f281cb5c5cb 100644 --- a/Doc/texinputs/python.sty +++ b/Doc/texinputs/python.sty @@ -286,17 +286,9 @@ \label{\indexlabel} } +% these should dump an error or warning to the transcript \newcommand{\@thismodule}{$<<$ ERROR - NO CURRENT MODULE $>>$} - -% Add the defining entry for a module -\newcommand{\@modindex}[2]{% - \index{#1@{\idxcode{#1}} (#2module)|textbf}% - \setindexsubitem{(in module #1)}% - \if@UseModuleIndex% - \write\modindexfile{\protect\indexentry{#1@{\tt #1}}{\thepage}}% - \fi% - \renewcommand{\@thismodule}{#1} -} +\newcommand{\@thisclass}{$<<$ ERROR - NO CURRENT CLASS $>>$} \newcommand{\makemodindex}{ \newwrite\modindexfile @@ -308,6 +300,16 @@ \IfFileExists{#1}{\input{#1}}{\begin{theindex}\end{theindex}} } +% Add the defining entry for a module +\newcommand{\@modindex}[2]{% + \renewcommand{\@thismodule}{#1} + \setindexsubitem{(in module \@thismodule)}% + \index{#1@{\idxcode{#1}} (#2module)|textbf}% + \if@UseModuleIndex% + \write\modindexfile{\protect\indexentry{#1@{\tt #1}}{\thepage}}% + \fi% +} + % built-in & Python modules in the main distribution \newcommand{\bimodindex}[1]{\@modindex{#1}{built-in }} \newcommand{\stmodindex}[1]{\@modindex{#1}{standard }} @@ -321,6 +323,11 @@ \newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}} \newcommand{\ttindex}[1]{\index{#1@{\idxcode{#1}} \index@subitem}} +\newcommand{\withsubitem}[2]{% + \begingroup% + \def\index@subitem{#1}#2% + \endgroup% +} % {fulllineitems} is used in one place in libregex.tex, but is really for % internal use in this file. @@ -371,6 +378,7 @@ }{\end{fulllineitems}} \newenvironment{classdesc}[2]{% + \renewcommand{\@thisclass}{#1}% \begin{fulllineitems}% \item[\code{\bfcode{#1}(\varvars{#2})}]% \ttindex{#1}% @@ -430,7 +438,7 @@ \newcommand{\dfn}[1]{\emph{#1}} \newcommand{\strong}[1]{{\bf #1}} % let's experiment with a new font: -\newcommand{\file}[1]{\mbox{`\small\textsf{#1}'}} +\newcommand{\file}[1]{`{\small\textsf{#1}}'} % Use this def/redef approach for \url{} since hyperref defined this already, % but only if we actually used hyperref: @@ -446,7 +454,7 @@ }% formatting "box". } \let\url=\pythonurl -\newcommand{\email}[1]{\mbox{\small\textsf{#1}}} +\newcommand{\email}[1]{{\small\textsf{#1}}} \newcommand{\varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}} @@ -472,6 +480,15 @@ \let\ctype=\code \let\cdata=\code +\newcommand{\mimetype}[1]{{\small\textsf{#1}}} +\newcommand{\regexp}[1]{$_\lceil$#1$^\rfloor$} +\newcommand{\envvar}[1]{% + \$#1% + \index{#1@{\$#1}}% + \index{environment variables!{\$#1}}% +} +\let\character=\samp + % constants defined in Python modules or C headers, not language constants: \let\constant=\code