comparison Doc/texinputs/python.sty @ 7659:869373fa0bf8 legacy-trunk

\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.
author Fred Drake <fdrake@acm.org>
date Thu, 12 Mar 1998 06:41:40 +0000
parents 068a6942fe1a
children 8e6a58019887
comparison
equal deleted inserted replaced
7658:f75ff8d4434d 7659:869373fa0bf8
284 \OldTheindex 284 \OldTheindex
285 \addcontentsline{toc}{chapter}{\indexname} 285 \addcontentsline{toc}{chapter}{\indexname}
286 \label{\indexlabel} 286 \label{\indexlabel}
287 } 287 }
288 288
289 % these should dump an error or warning to the transcript
289 \newcommand{\@thismodule}{$<<$ ERROR - NO CURRENT MODULE $>>$} 290 \newcommand{\@thismodule}{$<<$ ERROR - NO CURRENT MODULE $>>$}
290 291 \newcommand{\@thisclass}{$<<$ ERROR - NO CURRENT CLASS $>>$}
291 % Add the defining entry for a module
292 \newcommand{\@modindex}[2]{%
293 \index{#1@{\idxcode{#1}} (#2module)|textbf}%
294 \setindexsubitem{(in module #1)}%
295 \if@UseModuleIndex%
296 \write\modindexfile{\protect\indexentry{#1@{\tt #1}}{\thepage}}%
297 \fi%
298 \renewcommand{\@thismodule}{#1}
299 }
300 292
301 \newcommand{\makemodindex}{ 293 \newcommand{\makemodindex}{
302 \newwrite\modindexfile 294 \newwrite\modindexfile
303 \openout\modindexfile=mod\jobname.idx 295 \openout\modindexfile=mod\jobname.idx
304 \@UseModuleIndextrue 296 \@UseModuleIndextrue
306 298
307 \newcommand{\inputindex}[1]{ 299 \newcommand{\inputindex}[1]{
308 \IfFileExists{#1}{\input{#1}}{\begin{theindex}\end{theindex}} 300 \IfFileExists{#1}{\input{#1}}{\begin{theindex}\end{theindex}}
309 } 301 }
310 302
303 % Add the defining entry for a module
304 \newcommand{\@modindex}[2]{%
305 \renewcommand{\@thismodule}{#1}
306 \setindexsubitem{(in module \@thismodule)}%
307 \index{#1@{\idxcode{#1}} (#2module)|textbf}%
308 \if@UseModuleIndex%
309 \write\modindexfile{\protect\indexentry{#1@{\tt #1}}{\thepage}}%
310 \fi%
311 }
312
311 % built-in & Python modules in the main distribution 313 % built-in & Python modules in the main distribution
312 \newcommand{\bimodindex}[1]{\@modindex{#1}{built-in }} 314 \newcommand{\bimodindex}[1]{\@modindex{#1}{built-in }}
313 \newcommand{\stmodindex}[1]{\@modindex{#1}{standard }} 315 \newcommand{\stmodindex}[1]{\@modindex{#1}{standard }}
314 316
315 % Python & extension modules outside the main distribution 317 % Python & extension modules outside the main distribution
319 % Additional string for an index entry 321 % Additional string for an index entry
320 \newcommand{\index@subitem}{} 322 \newcommand{\index@subitem}{}
321 \newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}} 323 \newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}}
322 \newcommand{\ttindex}[1]{\index{#1@{\idxcode{#1}} \index@subitem}} 324 \newcommand{\ttindex}[1]{\index{#1@{\idxcode{#1}} \index@subitem}}
323 325
326 \newcommand{\withsubitem}[2]{%
327 \begingroup%
328 \def\index@subitem{#1}#2%
329 \endgroup%
330 }
324 331
325 % {fulllineitems} is used in one place in libregex.tex, but is really for 332 % {fulllineitems} is used in one place in libregex.tex, but is really for
326 % internal use in this file. 333 % internal use in this file.
327 % 334 %
328 \newenvironment{fulllineitems}{ 335 \newenvironment{fulllineitems}{
369 \begin{fulllineitems}% 376 \begin{fulllineitems}%
370 \funclineni{#1}{#2}% 377 \funclineni{#1}{#2}%
371 }{\end{fulllineitems}} 378 }{\end{fulllineitems}}
372 379
373 \newenvironment{classdesc}[2]{% 380 \newenvironment{classdesc}[2]{%
381 \renewcommand{\@thisclass}{#1}%
374 \begin{fulllineitems}% 382 \begin{fulllineitems}%
375 \item[\code{\bfcode{#1}(\varvars{#2})}]% 383 \item[\code{\bfcode{#1}(\varvars{#2})}]%
376 \ttindex{#1}% 384 \ttindex{#1}%
377 \def\baseclasses##1{}% 385 \def\baseclasses##1{}%
378 }{\end{fulllineitems}} 386 }{\end{fulllineitems}}
428 \newcommand{\var}[1]{\mbox{\normalsize\textrm{\textit{#1\/}}}} 436 \newcommand{\var}[1]{\mbox{\normalsize\textrm{\textit{#1\/}}}}
429 \renewcommand{\emph}[1]{{\em #1\/}} 437 \renewcommand{\emph}[1]{{\em #1\/}}
430 \newcommand{\dfn}[1]{\emph{#1}} 438 \newcommand{\dfn}[1]{\emph{#1}}
431 \newcommand{\strong}[1]{{\bf #1}} 439 \newcommand{\strong}[1]{{\bf #1}}
432 % let's experiment with a new font: 440 % let's experiment with a new font:
433 \newcommand{\file}[1]{\mbox{`\small\textsf{#1}'}} 441 \newcommand{\file}[1]{`{\small\textsf{#1}}'}
434 442
435 % Use this def/redef approach for \url{} since hyperref defined this already, 443 % Use this def/redef approach for \url{} since hyperref defined this already,
436 % but only if we actually used hyperref: 444 % but only if we actually used hyperref:
437 \@ifundefined{pdfannotlink}{% 445 \@ifundefined{pdfannotlink}{%
438 \newcommand{\pythonurl}[1]{\mbox{\small\textsf{#1}}}% 446 \newcommand{\pythonurl}[1]{\mbox{\small\textsf{#1}}}%
444 \NormalColor% Turn it back off; these are declarative 452 \NormalColor% Turn it back off; these are declarative
445 \pdfendlink}% and don't appear bound to the current 453 \pdfendlink}% and don't appear bound to the current
446 }% formatting "box". 454 }% formatting "box".
447 } 455 }
448 \let\url=\pythonurl 456 \let\url=\pythonurl
449 \newcommand{\email}[1]{\mbox{\small\textsf{#1}}} 457 \newcommand{\email}[1]{{\small\textsf{#1}}}
450 458
451 \newcommand{\varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}} 459 \newcommand{\varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}}
452 460
453 \newif\iftexi\texifalse 461 \newif\iftexi\texifalse
454 \newif\iflatex\latextrue 462 \newif\iflatex\latextrue
469 \let\method=\code 477 \let\method=\code
470 478
471 \let\cfunction=\code 479 \let\cfunction=\code
472 \let\ctype=\code 480 \let\ctype=\code
473 \let\cdata=\code 481 \let\cdata=\code
482
483 \newcommand{\mimetype}[1]{{\small\textsf{#1}}}
484 \newcommand{\regexp}[1]{$_\lceil$#1$^\rfloor$}
485 \newcommand{\envvar}[1]{%
486 \$#1%
487 \index{#1@{\$#1}}%
488 \index{environment variables!{\$#1}}%
489 }
490 \let\character=\samp
474 491
475 % constants defined in Python modules or C headers, not language constants: 492 % constants defined in Python modules or C headers, not language constants:
476 \let\constant=\code 493 \let\constant=\code
477 494
478 \newcommand{\manpage}[2]{{\emph{#1}(#2)}} 495 \newcommand{\manpage}[2]{{\emph{#1}(#2)}}