From ebcb658248dae9d4663c8bc530bab4f1d9fed4b8 Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Fri, 6 Mar 1998 21:25:17 +0000 Subject: Revise some of the PDF support to get at least preliminary outline support. Rewrite \seemodule (again) to allow an optional argument to support modules which include an underscore in the names. See example in comments. --- Doc/python.sty | 57 +++++++++++++++++++++++++++++++++++++++++++----- Doc/texinputs/python.sty | 57 +++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 102 insertions(+), 12 deletions(-) diff --git a/Doc/python.sty b/Doc/python.sty index 509fe6d..371a809 100644 --- a/Doc/python.sty +++ b/Doc/python.sty @@ -12,7 +12,6 @@ % \RequirePackage[Bjarne]{fncychap}\typeout{Using fancy chapter headings.} - % for PDF output, use maximal compression \@ifundefined{pdfannotlink}{ \let\LinkColor=\relax @@ -22,6 +21,10 @@ \let\LinkColor=\NavyBlue \let\NormalColor=\Black \pdfcompresslevel=9 + % + % This definition allows the entries in the page-view of the ToC to be + % active links. Some work, some don't. + % \let\OldContentsline=\contentsline \renewcommand{\contentsline}[3]{% \OldContentsline{#1}{% @@ -30,6 +33,14 @@ \pdfendlink% }{#3}% } + \renewcommand{\thepage}{\roman{page}} + % + % This is supposed to build the "outline" view of the document; it seems + % quite fragile. The breakages are the same as in the ToC. + % + \AtEndDocument{ + \InputIfFileExists{\jobname.bkm}{\pdfcatalog pagemode{/UseOutlines}}{} + } \let\OldLabel=\label \renewcommand{\label}[1]{% \OldLabel{#1}% @@ -44,11 +55,8 @@ \def\@begindvi{% \unvbox \@begindvibox \@hyperfixhead - \global\let \@begindvi \@hyperfixhead } - \def\hyperpageanchor{% - \hyper@anchorstart{page.\thepage}\hyper@anchorend - } + \def\hyperpageanchor{\pdfdest name{page.\thepage}} \let\HYPERPAGEANCHOR\hyperpageanchor \def\@hyperfixhead{% \let\H@old@thehead\@thehead @@ -494,12 +502,49 @@ % \begin{seealso} % \seemodule{rand}{Uniform random number generator}; % Module xref % \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book +% +% % A funky case: module name contains '_'; have to supply an optional key +% \seemodule[copyreg]{copy_reg}{pickle interface constructor registration} +% % \end{seealso} +\newif\if@keyedmodule\@keyedmodulefalse +\newcommand{\@modulebadkey}{{--just-some-junk--}} + +\@ifundefined{pdfannotlink}{% + \newcommand{\seemodule}[3][\@modulebadkey]{% + \ifx\@modulebadkey#1\def\@modulekey{#2}\else\def\@modulekey{#1}\fi% + \ref{module-\@modulekey}:\quad % + Module \module{#2}% + \quad (#3)% + } +}{\newcommand{\seemodule}[3][\@modulebadkey]{% + \ifx\@modulebadkey#1\def\@modulekey{#2}\else\def\@modulekey{#1}\fi% + \ref{module-\@modulekey}:\quad % + {\pdfannotlink attr{/Border [0 0 0]} goto name{label.module-\@modulekey}% + \LinkColor Module \module{#2} \NormalColor% + \pdfendlink% + }% + \quad (#3)% + } +} \newenvironment{seealso}[0]{ \strong{See Also:}\par % These should only be defined within the {seealso} environment: - \def\seemodule##1##2{\ref{module-##1}:\quad Module \module{##1}\quad (##2)} + %\def\see@module##1##2{\ref{module-##1}:\quad Module \module{##1}\quad (##2)} +% \def\@seemodule[##1]##2##3{% +% \ref{module-##2}:\quad % +% \@ifundefined{pdfannotlink}{% +% Module \module{##2}% +% }{\if@keyedmodule\@keyedmodulefalse\fi% +% {\pdfannotlink attr{/Border [0 0 0]} goto name{module.##1}% +% \LinkColor Module \module{##2}\NormalColor\pdfendlink}% +% }% +% \quad (##3)% +% } +% \def\seemodule{% +% \@ifnextchar [\@seemodule{\@keyedmoduletrue \@seemodule[]}% +% } \def\seetext##1{\par{##1}} }{\par} diff --git a/Doc/texinputs/python.sty b/Doc/texinputs/python.sty index 509fe6d..371a809 100644 --- a/Doc/texinputs/python.sty +++ b/Doc/texinputs/python.sty @@ -12,7 +12,6 @@ % \RequirePackage[Bjarne]{fncychap}\typeout{Using fancy chapter headings.} - % for PDF output, use maximal compression \@ifundefined{pdfannotlink}{ \let\LinkColor=\relax @@ -22,6 +21,10 @@ \let\LinkColor=\NavyBlue \let\NormalColor=\Black \pdfcompresslevel=9 + % + % This definition allows the entries in the page-view of the ToC to be + % active links. Some work, some don't. + % \let\OldContentsline=\contentsline \renewcommand{\contentsline}[3]{% \OldContentsline{#1}{% @@ -30,6 +33,14 @@ \pdfendlink% }{#3}% } + \renewcommand{\thepage}{\roman{page}} + % + % This is supposed to build the "outline" view of the document; it seems + % quite fragile. The breakages are the same as in the ToC. + % + \AtEndDocument{ + \InputIfFileExists{\jobname.bkm}{\pdfcatalog pagemode{/UseOutlines}}{} + } \let\OldLabel=\label \renewcommand{\label}[1]{% \OldLabel{#1}% @@ -44,11 +55,8 @@ \def\@begindvi{% \unvbox \@begindvibox \@hyperfixhead - \global\let \@begindvi \@hyperfixhead } - \def\hyperpageanchor{% - \hyper@anchorstart{page.\thepage}\hyper@anchorend - } + \def\hyperpageanchor{\pdfdest name{page.\thepage}} \let\HYPERPAGEANCHOR\hyperpageanchor \def\@hyperfixhead{% \let\H@old@thehead\@thehead @@ -494,12 +502,49 @@ % \begin{seealso} % \seemodule{rand}{Uniform random number generator}; % Module xref % \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book +% +% % A funky case: module name contains '_'; have to supply an optional key +% \seemodule[copyreg]{copy_reg}{pickle interface constructor registration} +% % \end{seealso} +\newif\if@keyedmodule\@keyedmodulefalse +\newcommand{\@modulebadkey}{{--just-some-junk--}} + +\@ifundefined{pdfannotlink}{% + \newcommand{\seemodule}[3][\@modulebadkey]{% + \ifx\@modulebadkey#1\def\@modulekey{#2}\else\def\@modulekey{#1}\fi% + \ref{module-\@modulekey}:\quad % + Module \module{#2}% + \quad (#3)% + } +}{\newcommand{\seemodule}[3][\@modulebadkey]{% + \ifx\@modulebadkey#1\def\@modulekey{#2}\else\def\@modulekey{#1}\fi% + \ref{module-\@modulekey}:\quad % + {\pdfannotlink attr{/Border [0 0 0]} goto name{label.module-\@modulekey}% + \LinkColor Module \module{#2} \NormalColor% + \pdfendlink% + }% + \quad (#3)% + } +} \newenvironment{seealso}[0]{ \strong{See Also:}\par % These should only be defined within the {seealso} environment: - \def\seemodule##1##2{\ref{module-##1}:\quad Module \module{##1}\quad (##2)} + %\def\see@module##1##2{\ref{module-##1}:\quad Module \module{##1}\quad (##2)} +% \def\@seemodule[##1]##2##3{% +% \ref{module-##2}:\quad % +% \@ifundefined{pdfannotlink}{% +% Module \module{##2}% +% }{\if@keyedmodule\@keyedmodulefalse\fi% +% {\pdfannotlink attr{/Border [0 0 0]} goto name{module.##1}% +% \LinkColor Module \module{##2}\NormalColor\pdfendlink}% +% }% +% \quad (##3)% +% } +% \def\seemodule{% +% \@ifnextchar [\@seemodule{\@keyedmoduletrue \@seemodule[]}% +% } \def\seetext##1{\par{##1}} }{\par} -- cgit v0.12