Mercurial > cpython-lru_cache-weakref
comparison Doc/texinputs/python.sty @ 9968:485502c42d89 legacy-trunk
\py@linkToName: New macro to consolidate support for most internal
hyperlinking in the PDF version. This also allows many of the
macros that do this stuff to be a good bit more readable.
Takes the target name and link content as parameters.
Use \py@linkToName for all internal links.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Wed, 27 Jan 1999 17:37:36 +0000 |
| parents | 2750e1de6829 |
| children | 80b215249b17 |
comparison
equal
deleted
inserted
replaced
| 9967:44146c06e7ed | 9968:485502c42d89 |
|---|---|
| 35 % | 35 % |
| 36 % This definition allows the entries in the page-view of the ToC to be | 36 % This definition allows the entries in the page-view of the ToC to be |
| 37 % active links. Some work, some don't. | 37 % active links. Some work, some don't. |
| 38 % | 38 % |
| 39 \let\py@OldContentsline=\contentsline | 39 \let\py@OldContentsline=\contentsline |
| 40 % | |
| 41 % Macro that takes two args: the name to link to and the content of | |
| 42 % the link. This takes care of the PDF magic, getting the colors | |
| 43 % the same for each link, and avoids having lots of garbage all over | |
| 44 % this style file. | |
| 45 \newcommand{\py@linkToName}[2]{% | |
| 46 \pdfannotlink attr{/Border [0 0 0]} goto name{#1}% | |
| 47 \py@LinkColor#2\py@NormalColor% | |
| 48 \pdfendlink% | |
| 49 } | |
| 40 % Compute the padded page number separately since we end up with a pair of | 50 % Compute the padded page number separately since we end up with a pair of |
| 41 % \relax tokens; this gets the right string computed and works. | 51 % \relax tokens; this gets the right string computed and works. |
| 42 \renewcommand{\contentsline}[3]{% | 52 \renewcommand{\contentsline}[3]{% |
| 43 \def\my@pageno{\py@targetno{#3}}% | 53 \def\my@pageno{\py@targetno{#3}}% |
| 44 \py@OldContentsline{#1}{% | 54 \py@OldContentsline{#1}{\py@linkToName{page\my@pageno}{#2}}{#3}% |
| 45 \pdfannotlink attr{/Border [0 0 0]} goto name{page\my@pageno}% | |
| 46 \py@LinkColor#2\py@NormalColor% | |
| 47 \pdfendlink% | |
| 48 }{#3}% | |
| 49 } | 55 } |
| 50 \AtEndDocument{ | 56 \AtEndDocument{ |
| 51 \InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{} | 57 \InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{} |
| 52 } | 58 } |
| 53 \newcommand{\py@target}[1]{% | 59 \newcommand{\py@target}[1]{% |
| 230 | 236 |
| 231 % Refer to a module's documentation using a hyperlink of the module's | 237 % Refer to a module's documentation using a hyperlink of the module's |
| 232 % name, at least if we're building PDF: | 238 % name, at least if we're building PDF: |
| 233 \@ifundefined{pdfannotlink}{% | 239 \@ifundefined{pdfannotlink}{% |
| 234 \newcommand{\refmodule}[2][\py@modulebadkey]{\module{#2}} | 240 \newcommand{\refmodule}[2][\py@modulebadkey]{\module{#2}} |
| 235 }{\newcommand{\refmodule}[2][\py@modulebadkey]{% | 241 }{% |
| 242 \newcommand{\refmodule}[2][\py@modulebadkey]{% | |
| 236 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi% | 243 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi% |
| 237 {\pdfannotlink attr{/Border [0 0 0]} goto name{label-module-\py@modulekey}% | 244 \py@linkToName{label-module-\py@modulekey}{\module{#2}}% |
| 238 \py@LinkColor\module{#2}\py@NormalColor% | |
| 239 \pdfendlink% | |
| 240 }% | |
| 241 } | 245 } |
| 242 } | 246 } |
| 243 | 247 |
| 244 % support for the module index | 248 % support for the module index |
| 245 \newif\ifpy@UseModuleIndex | 249 \newif\ifpy@UseModuleIndex |
| 360 } | 364 } |
| 361 | 365 |
| 362 \@ifundefined{pdfoutput}{ | 366 \@ifundefined{pdfoutput}{ |
| 363 \newcommand{\py@ModSynopsisSummary}[4]{\bfcode{#2} & #4\\} | 367 \newcommand{\py@ModSynopsisSummary}[4]{\bfcode{#2} & #4\\} |
| 364 }{ | 368 }{ |
| 365 \newcommand{\py@ModSynopsisSummary}[4]{ | 369 \newcommand{\py@ModSynopsisSummary}[4]{% |
| 366 {\pdfannotlink attr{/Border [0 0 0]} goto name{label-module-#1} | 370 \py@linkToName{label-module-#1}{\bfcode{#2}} & #4\\ |
| 367 \py@LinkColor \bfcode{#2} \py@NormalColor | 371 } |
| 368 \pdfendlink}& #4\\} | |
| 369 } | 372 } |
| 370 \newenvironment{synopsistable}{ | 373 \newenvironment{synopsistable}{ |
| 371 % key, name, type, synopsis | 374 % key, name, type, synopsis |
| 372 \let\modulesynopsis=\py@ModSynopsisSummary | 375 \let\modulesynopsis=\py@ModSynopsisSummary |
| 373 \begin{tabular}{ll} | 376 \begin{tabular}{ll} |
| 805 } | 808 } |
| 806 }{\newcommand{\py@seemodule}[3][\py@modulebadkey]{% | 809 }{\newcommand{\py@seemodule}[3][\py@modulebadkey]{% |
| 807 \par% | 810 \par% |
| 808 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi% | 811 \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi% |
| 809 \ref{module-\py@modulekey}:\quad % | 812 \ref{module-\py@modulekey}:\quad % |
| 810 {\pdfannotlink attr{/Border [0 0 0]} goto name{label-module-\py@modulekey}% | 813 \py@linkToName{label-module-\py@modulekey}{ Module \module{#2} } |
| 811 \py@LinkColor Module \module{#2} \py@NormalColor% | |
| 812 \pdfendlink% | |
| 813 }% | |
| 814 \quad (#3)% | 814 \quad (#3)% |
| 815 } | 815 } |
| 816 } | 816 } |
| 817 \newenvironment{seealso}[0]{ | 817 \newenvironment{seealso}[0]{ |
| 818 \strong{See Also:}\par | 818 \strong{See Also:}\par |
