Mercurial > cpython-lru_cache-weakref
comparison Doc/texinputs/python.sty @ 7764:9d0dc11775a4 legacy-trunk
Add comments about several of the environments.
Cleaned up some problems that caused minor warnings.
Added environments for object methods and members, with non-indexing variants.
This includes reduced use of the indexsubitem setting, allowing more robust
index generation.
Removed some unused definitions.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Fri, 27 Mar 1998 05:22:53 +0000 |
| parents | 423be7cd0479 |
| children | b17d200edf62 |
comparison
equal
deleted
inserted
replaced
| 7763:9c02e0a26511 | 7764:9d0dc11775a4 |
|---|---|
| 7 [1998/01/11 LaTeX package (Python markup)] | 7 [1998/01/11 LaTeX package (Python markup)] |
| 8 | 8 |
| 9 % for PDF output, use maximal compression & a lot of other stuff | 9 % for PDF output, use maximal compression & a lot of other stuff |
| 10 % (test for PDF recommended by Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov>) | 10 % (test for PDF recommended by Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov>) |
| 11 % | 11 % |
| 12 \newif\if@doing@page@targets | |
| 13 \@doing@page@targetsfalse | |
| 14 | |
| 12 \ifx\pdfoutput\undefined\else\ifcase\pdfoutput | 15 \ifx\pdfoutput\undefined\else\ifcase\pdfoutput |
| 13 \let\LinkColor=\relax | 16 \let\LinkColor=\relax |
| 14 \let\NormalColor=\relax | 17 \let\NormalColor=\relax |
| 15 \else | 18 \else |
| 16 \input{pdfcolor} | 19 \input{pdfcolor} |
| 49 % | 52 % |
| 50 \def\@begindvi{% | 53 \def\@begindvi{% |
| 51 \unvbox \@begindvibox | 54 \unvbox \@begindvibox |
| 52 \@hyperfixhead | 55 \@hyperfixhead |
| 53 } | 56 } |
| 54 \def\hyperpageanchor{\pdfdest name{page.\thepage}} | |
| 55 \let\HYPERPAGEANCHOR\hyperpageanchor | |
| 56 \def\@hyperfixhead{% | 57 \def\@hyperfixhead{% |
| 57 \let\H@old@thehead\@thehead | 58 \let\H@old@thehead\@thehead |
| 58 \gdef\@foo{\pdfdest name{page.\thepage} fit}% | 59 \gdef\@foo{\if@doing@page@targets\pdfdest name{page.\thepage} fit\fi}% |
| 59 \expandafter\ifx\expandafter\@empty\H@old@thehead | 60 \expandafter\ifx\expandafter\@empty\H@old@thehead |
| 60 \def\H@old@thehead{\hfil}\fi | 61 \def\H@old@thehead{\hfil}\fi |
| 61 \def\@thehead{\@foo\relax\H@old@thehead}% | 62 \def\@thehead{\@foo\relax\H@old@thehead}% |
| 62 } | 63 } |
| 63 \fi\fi | 64 \fi\fi |
| 173 \OldEndVerbatim% | 174 \OldEndVerbatim% |
| 174 \end{minipage}% | 175 \end{minipage}% |
| 175 \endgroup% | 176 \endgroup% |
| 176 } | 177 } |
| 177 | 178 |
| 178 % Augment the sectioning commands used to get our own font family in place: | 179 \newcommand{\reset@python}{ |
| 179 \renewcommand{\section}{\@startsection {section}{1}{\z@}% | 180 \global\let\@thisclass=\@undefined |
| 181 \global\let\@thismodule=\@undefined | |
| 182 } | |
| 183 \reset@python | |
| 184 | |
| 185 % Augment the sectioning commands used to get our own font family in place, | |
| 186 % and reset some internal data items: | |
| 187 \renewcommand{\section}{\reset@python% | |
| 188 \@startsection {section}{1}{\z@}% | |
| 180 {-3.5ex \@plus -1ex \@minus -.2ex}% | 189 {-3.5ex \@plus -1ex \@minus -.2ex}% |
| 181 {2.3ex \@plus.2ex}% | 190 {2.3ex \@plus.2ex}% |
| 182 {\reset@font\Large\HeaderFamily}} | 191 {\reset@font\Large\HeaderFamily}} |
| 183 \renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}% | 192 \renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}% |
| 184 {-3.25ex\@plus -1ex \@minus -.2ex}% | 193 {-3.25ex\@plus -1ex \@minus -.2ex}% |
| 276 \cleardoublepage | 285 \cleardoublepage |
| 277 \OldTheindex | 286 \OldTheindex |
| 278 \addcontentsline{toc}{chapter}{\indexname} | 287 \addcontentsline{toc}{chapter}{\indexname} |
| 279 } | 288 } |
| 280 | 289 |
| 281 % these should dump an error or warning to the transcript | |
| 282 \newcommand{\@thismodule}{$<<$ ERROR - NO CURRENT MODULE $>>$} | |
| 283 \newcommand{\@thisclass}{$<<$ ERROR - NO CURRENT CLASS $>>$} | |
| 284 | |
| 285 \newcommand{\makemodindex}{ | 290 \newcommand{\makemodindex}{ |
| 286 \newwrite\modindexfile | 291 \newwrite\modindexfile |
| 287 \openout\modindexfile=mod\jobname.idx | 292 \openout\modindexfile=mod\jobname.idx |
| 288 \@UseModuleIndextrue | 293 \@UseModuleIndextrue |
| 289 } | 294 } |
| 290 | 295 |
| 291 % Add the defining entry for a module | 296 % Add the defining entry for a module |
| 292 \newcommand{\@modindex}[2]{% | 297 \newcommand{\@modindex}[2]{% |
| 293 \renewcommand{\@thismodule}{#1} | 298 \global\def\@thismodule{#1} |
| 294 \setindexsubitem{(in module \@thismodule)}% | 299 \setindexsubitem{(in module #1)}% |
| 295 \index{#1@{\idxcode{#1}} (#2module)|textbf}% | 300 \index{#1@{\idxcode{#1}} (#2module)|textbf}% |
| 296 \if@UseModuleIndex% | 301 \if@UseModuleIndex% |
| 297 \write\modindexfile{\protect\indexentry{#1@{\tt #1}}{\thepage}}% | 302 \write\modindexfile{\protect\indexentry{#1@{\tt #1}}{\thepage}}% |
| 298 \fi% | 303 \fi% |
| 299 } | 304 } |
| 325 \rightmargin 0pt \topsep -\parskip \partopsep \parskip | 330 \rightmargin 0pt \topsep -\parskip \partopsep \parskip |
| 326 \itemsep -\parsep | 331 \itemsep -\parsep |
| 327 \let\makelabel=\itemnewline} | 332 \let\makelabel=\itemnewline} |
| 328 }{\end{list}} | 333 }{\end{list}} |
| 329 | 334 |
| 330 | 335 % \optional is mostly for use in the arguments parameters to the various |
| 331 % cfuncdesc should be called as | 336 % {*desc} environments defined below, but may be used elsewhere. Known to |
| 332 % \begin{cfuncdesc}{type}{name}{arglist} | 337 % be used in the debugger chapter. |
| 333 % ... description ... | |
| 334 % \end{cfuncdesc} | |
| 335 \newenvironment{cfuncdesc}[3]{% | |
| 336 \begin{fulllineitems}% | |
| 337 \item[\code{#1 \bfcode{#2}(\varvars{#3})}]% | |
| 338 \index{#2@{\idxcode{#2()}}}% | |
| 339 }{\end{fulllineitems}} | |
| 340 | |
| 341 \newenvironment{cvardesc}[2]{% | |
| 342 \begin{fulllineitems}% | |
| 343 \item[\code{#1 \bfcode{#2}}]% | |
| 344 \index{#2@{\idxcode{#2}}}% | |
| 345 }{\end{fulllineitems}} | |
| 346 | |
| 347 \newenvironment{ctypedesc}[1]{% | |
| 348 \begin{fulllineitems}% | |
| 349 \item[\bfcode{#1}]\ttindex{#1} | |
| 350 }{\end{fulllineitems}} | |
| 351 | |
| 352 \newcommand{\funcline}[2]{\funclineni{#1}{#2}\ttindex{#1()}} | |
| 353 \newenvironment{funcdesc}[2]{% | |
| 354 \begin{fulllineitems}% | |
| 355 \funcline{#1}{#2}% | |
| 356 }{\end{fulllineitems}} | |
| 357 | |
| 358 \newcommand{\optional}[1]{% | 338 \newcommand{\optional}[1]{% |
| 359 {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}} | 339 {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}} |
| 360 | 340 |
| 341 % C functions ------------------------------------------------------------ | |
| 342 % \begin{cfuncdesc}{type}{name}{arglist} | |
| 343 \newenvironment{cfuncdesc}[3]{ | |
| 344 \begin{fulllineitems} | |
| 345 \item[\code{#1 \bfcode{#2}(\varvars{#3})}\index{#2@{\idxcode{#2()}}}] | |
| 346 }{\end{fulllineitems}} | |
| 347 | |
| 348 % C variables ------------------------------------------------------------ | |
| 349 % \begin{cvardesc}{type}{name} | |
| 350 \newenvironment{cvardesc}[2]{ | |
| 351 \begin{fulllineitems} | |
| 352 \item[\code{#1 \bfcode{#2}}\index{#2@{\idxcode{#2}}}] | |
| 353 }{\end{fulllineitems}} | |
| 354 | |
| 355 % C data types ----------------------------------------------------------- | |
| 356 % \begin{ctypedesc}{typedef name} | |
| 357 \newenvironment{ctypedesc}[1]{ | |
| 358 \begin{fulllineitems} | |
| 359 \item[\bfcode{#1}\ttindex{#1}] | |
| 360 }{\end{fulllineitems}} | |
| 361 | |
| 362 % simple functions (not methods) ----------------------------------------- | |
| 363 % \begin{funcdesc}{name}{args} | |
| 364 \newcommand{\funcline}[2]{\funclineni{#1}{#2}\ttindex{#1()}} | |
| 365 \newenvironment{funcdesc}[2]{ | |
| 366 \begin{fulllineitems} | |
| 367 \funcline{#1}{#2} | |
| 368 }{\end{fulllineitems}} | |
| 369 | |
| 361 % similar to {funcdesc}, but doesn't add to the index | 370 % similar to {funcdesc}, but doesn't add to the index |
| 362 \newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(\varvars{#2})}]} | 371 \newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(\varvars{#2})}]} |
| 363 \newenvironment{funcdescni}[2]{% | 372 \newenvironment{funcdescni}[2]{ |
| 364 \begin{fulllineitems}% | 373 \begin{fulllineitems} |
| 365 \funclineni{#1}{#2}% | 374 \funclineni{#1}{#2} |
| 366 }{\end{fulllineitems}} | 375 }{\end{fulllineitems}} |
| 367 | 376 |
| 368 \newenvironment{classdesc}[2]{% | 377 % classes ---------------------------------------------------------------- |
| 369 \renewcommand{\@thisclass}{#1}% | 378 % \begin{classdesc}{name}{constructor args} |
| 370 \begin{fulllineitems}% | 379 \newenvironment{classdesc}[2]{ |
| 371 \item[\code{\bfcode{#1}(\varvars{#2})}]% | 380 \global\def\@thisclass{#1} |
| 372 \withsubitem{(class in \@thismodule)}{\ttindex{#1}}% | 381 \begin{fulllineitems} |
| 373 \def\baseclasses##1{}% | 382 \item[\code{\bfcode{#1}(\varvars{#2})}% |
| 374 }{\end{fulllineitems}} | 383 \withsubitem{(class in \@thismodule)}{\ttindex{#1}}] |
| 375 | 384 \def\baseclasses##1{} |
| 376 \newenvironment{excdesc}[1]{% | 385 }{\end{fulllineitems}} |
| 377 \begin{fulllineitems}% | 386 |
| 378 \item[\bfcode{#1}]\ttindex{#1}% | 387 |
| 379 }{\end{fulllineitems}} | 388 \newcommand{\@classbadkey}{--bad current class--} |
| 380 | 389 \let\@classbadkey=\@undefined |
| 390 | |
| 391 % object method ---------------------------------------------------------- | |
| 392 % \begin{methoddesc}[classname]{methodname}{args} | |
| 393 \newcommand{\methodline}[3][\@classbadkey]{ | |
| 394 \methodlineni{#2}{#3} | |
| 395 \ifx#1\@undefined | |
| 396 \withsubitem{(\@thisclass\ method)}{\ttindex{#2()}} | |
| 397 \else | |
| 398 \withsubitem{(#1 method)}{\ttindex{#2()}} | |
| 399 \fi | |
| 400 } | |
| 401 \newenvironment{methoddesc}[3][\@classbadkey]{ | |
| 402 \begin{fulllineitems} | |
| 403 \ifx#1\@undefined | |
| 404 \methodline{#2}{#3} | |
| 405 \else | |
| 406 \def\@thisclass{#1} | |
| 407 \methodline[#1]{#2}{#3} | |
| 408 \fi | |
| 409 }{\end{fulllineitems}} | |
| 410 | |
| 411 % similar to {methoddesc}, but doesn't add to the index | |
| 412 % (never actually uses the optional argument) | |
| 413 \newcommand{\methodlineni}[3][\@classbadkey]{% | |
| 414 \item[\code{\bfcode{#2}(\varvars{#3})}]} | |
| 415 \newenvironment{methoddescni}[3][\@classbadkey]{ | |
| 416 \begin{fulllineitems} | |
| 417 \methodlineni{#2}{#3} | |
| 418 }{\end{fulllineitems}} | |
| 419 | |
| 420 % object data attribute -------------------------------------------------- | |
| 421 % \begin{memberdesc}[classname]{membername} | |
| 422 \newcommand{\memberline}[2][\@classbadkey]{% | |
| 423 \ifx#1\@undefined | |
| 424 \memberlineni{#2} | |
| 425 \withsubitem{(\@thisclass\ attribute)}{\ttindex{#2()}} | |
| 426 \else | |
| 427 \memberlineni{#2} | |
| 428 \withsubitem{(#1 attribute)}{\ttindex{#2()}} | |
| 429 \fi | |
| 430 } | |
| 431 \newenvironment{memberdesc}[2][\@classbadkey]{ | |
| 432 \begin{fulllineitems} | |
| 433 \ifx#1\@undefined | |
| 434 \memberline{#2} | |
| 435 \else | |
| 436 \def\@thisclass{#1} | |
| 437 \memberline[#1]{#2} | |
| 438 \fi | |
| 439 }{\end{fulllineitems}} | |
| 440 | |
| 441 % similar to {memberdesc}, but doesn't add to the index | |
| 442 % (never actually uses the optional argument) | |
| 443 \newcommand{\memberlineni}[2][\@classbadkey]{\item[\bfcode{#2}]} | |
| 444 \newenvironment{memberdescni}[2][\@classbadkey]{ | |
| 445 \begin{fulllineitems} | |
| 446 \memberlineni{#2} | |
| 447 }{\end{fulllineitems}} | |
| 448 | |
| 449 % For exceptions: -------------------------------------------------------- | |
| 450 % \begin{excdesc}{name} | |
| 451 % -- need support for constructor; maybe use optional parameter? | |
| 452 \newenvironment{excdesc}[1]{ | |
| 453 \begin{fulllineitems} | |
| 454 \item[\bfcode{#1}\ttindex{#1}] | |
| 455 }{\end{fulllineitems}} | |
| 456 | |
| 457 % Module data or constants: ---------------------------------------------- | |
| 458 % \begin{datadesc}{name} | |
| 381 \newcommand{\dataline}[1]{\datalineni{#1}\ttindex{#1}} | 459 \newcommand{\dataline}[1]{\datalineni{#1}\ttindex{#1}} |
| 382 \newenvironment{datadesc}[1]{% | 460 \newenvironment{datadesc}[1]{ |
| 383 \begin{fulllineitems}% | 461 \begin{fulllineitems} |
| 384 \dataline{#1}% | 462 \dataline{#1} |
| 385 }{\end{fulllineitems}} | 463 }{\end{fulllineitems}} |
| 386 | 464 |
| 387 % similar to {datadesc}, but doesn't add to the index | 465 % similar to {datadesc}, but doesn't add to the index |
| 388 \newcommand{\datalineni}[1]{\item[\bfcode{#1}]} | 466 \newcommand{\datalineni}[1]{\item[\bfcode{#1}]\nopagebreak} |
| 389 \newenvironment{datadescni}[1]{% | 467 \newenvironment{datadescni}[1]{ |
| 390 \begin{fulllineitems}% | 468 \begin{fulllineitems} |
| 391 \datalineni{#1}% | 469 \datalineni{#1} |
| 392 }{\end{fulllineitems}} | 470 }{\end{fulllineitems}} |
| 393 | 471 |
| 394 \newenvironment{opcodedesc}[2]{% | 472 % bytecode instruction --------------------------------------------------- |
| 395 \begin{fulllineitems}% | 473 % \begin{opcodedesc}{name}{var} |
| 396 \item[\bfcode{#1}\quad\var{#2}]% | 474 % -- {var} may be {} |
| 475 \newenvironment{opcodedesc}[2]{ | |
| 476 \begin{fulllineitems} | |
| 477 \item[\bfcode{#1}\quad\var{#2}] | |
| 397 }{\end{fulllineitems}} | 478 }{\end{fulllineitems}} |
| 398 | 479 |
| 399 | 480 |
| 400 \let\nodename=\label | 481 \let\nodename=\label |
| 401 | 482 |
| 430 % let's experiment with a new font: | 511 % let's experiment with a new font: |
| 431 \newcommand{\file}[1]{`{\small\textsf{#1}}'} | 512 \newcommand{\file}[1]{`{\small\textsf{#1}}'} |
| 432 | 513 |
| 433 % Use this def/redef approach for \url{} since hyperref defined this already, | 514 % Use this def/redef approach for \url{} since hyperref defined this already, |
| 434 % but only if we actually used hyperref: | 515 % but only if we actually used hyperref: |
| 435 \@ifundefined{pdfannotlink}{% | 516 \@ifundefined{pdfannotlink}{ |
| 436 \newcommand{\pythonurl}[1]{\mbox{\small\textsf{#1}}}% | 517 \newcommand{\pythonurl}[1]{\mbox{\small\textsf{#1}}} |
| 437 }{ | 518 }{ |
| 438 \newcommand{\pythonurl}[1]{{% | 519 \newcommand{\pythonurl}[1]{{% |
| 439 \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% | 520 \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% |
| 440 \LinkColor% color of the link text | 521 \LinkColor% color of the link text |
| 441 \mbox{\small\textsf{#1}}% | 522 {\small\textsf{#1}}% |
| 442 \NormalColor% Turn it back off; these are declarative | 523 \NormalColor% Turn it back off; these are declarative |
| 443 \pdfendlink}% and don't appear bound to the current | 524 \pdfendlink}% and don't appear bound to the current |
| 444 }% formatting "box". | 525 }% formatting "box". |
| 445 } | 526 } |
| 446 \let\url=\pythonurl | 527 \let\url=\pythonurl |
| 542 % % A funky case: module name contains '_'; have to supply an optional key | 623 % % A funky case: module name contains '_'; have to supply an optional key |
| 543 % \seemodule[copyreg]{copy_reg}{pickle interface constructor registration} | 624 % \seemodule[copyreg]{copy_reg}{pickle interface constructor registration} |
| 544 % | 625 % |
| 545 % \end{seealso} | 626 % \end{seealso} |
| 546 | 627 |
| 547 \newif\if@keyedmodule\@keyedmodulefalse | |
| 548 \newcommand{\@modulebadkey}{{--just-some-junk--}} | 628 \newcommand{\@modulebadkey}{{--just-some-junk--}} |
| 549 | 629 |
| 550 \@ifundefined{pdfannotlink}{% | 630 \@ifundefined{pdfannotlink}{% |
| 551 \newcommand{\seemodule}[3][\@modulebadkey]{% | 631 \newcommand{\seemodule}[3][\@modulebadkey]{% |
| 552 \ifx\@modulebadkey#1\def\@modulekey{#2}\else\def\@modulekey{#1}\fi% | 632 \ifx\@modulebadkey#1\def\@modulekey{#2}\else\def\@modulekey{#1}\fi% |
