]> granicus.if.org Git - python/commitdiff
\py@linkToName: New macro to consolidate support for most internal
authorFred Drake <fdrake@acm.org>
Wed, 27 Jan 1999 17:37:36 +0000 (17:37 +0000)
committerFred Drake <fdrake@acm.org>
Wed, 27 Jan 1999 17:37:36 +0000 (17:37 +0000)
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.

Doc/texinputs/python.sty

index 8f957640b5d48e5da83033bebf1becfec7c1634d..3ed1255e94e916d9276105b373b9f759209ce019 100644 (file)
   % active links.  Some work, some don't.
   %
   \let\py@OldContentsline=\contentsline
+  %
+  % 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]{%
+    \pdfannotlink 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}{%
-      \pdfannotlink attr{/Border [0 0 0]} goto name{page\my@pageno}%
-        \py@LinkColor#2\py@NormalColor%
-      \pdfendlink%
-    }{#3}%
+    \py@OldContentsline{#1}{\py@linkToName{page\my@pageno}{#2}}{#3}%
   }
   \AtEndDocument{
     \InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{}
 % name, at least if we're building PDF:
 \@ifundefined{pdfannotlink}{%
   \newcommand{\refmodule}[2][\py@modulebadkey]{\module{#2}}
-}{\newcommand{\refmodule}[2][\py@modulebadkey]{%
+}{%
+  \newcommand{\refmodule}[2][\py@modulebadkey]{%
     \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
-    {\pdfannotlink attr{/Border [0 0 0]} goto name{label-module-\py@modulekey}%
-     \py@LinkColor\module{#2}\py@NormalColor%
-     \pdfendlink%
-    }%
+    \py@linkToName{label-module-\py@modulekey}{\module{#2}}%
   }
 }
 
 \@ifundefined{pdfoutput}{
   \newcommand{\py@ModSynopsisSummary}[4]{\bfcode{#2} & #4\\}
 }{
-  \newcommand{\py@ModSynopsisSummary}[4]{
-    {\pdfannotlink attr{/Border [0 0 0]} goto name{label-module-#1}
-     \py@LinkColor \bfcode{#2} \py@NormalColor
-     \pdfendlink}& #4\\}
+  \newcommand{\py@ModSynopsisSummary}[4]{%
+    \py@linkToName{label-module-#1}{\bfcode{#2}} & #4\\
+  }
 }
 \newenvironment{synopsistable}{
   % key, name, type, synopsis
     \par%
     \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi%
     \ref{module-\py@modulekey}:\quad %
-    {\pdfannotlink attr{/Border [0 0 0]} goto name{label-module-\py@modulekey}%
-     \py@LinkColor Module \module{#2} \py@NormalColor%
-     \pdfendlink%
-    }%
+    \py@linkToName{label-module-\py@modulekey}{ Module \module{#2} }
     \quad (#3)%
   }
 }