Adjust the index support a bit to make it easier to deal with module index.

Don't generate the mod???.idx file if it wasn't requested with the new command
\makemodindex.

Change the format of mod???.idx to match that of "normal" .idx files.  This
lets us use makeindex for it and not need a special script.
This commit is contained in:
Fred Drake 1998-03-09 16:35:36 +00:00
parent 8fcad7beb1
commit b390daf704
1 changed files with 38 additions and 23 deletions

View File

@ -269,26 +269,52 @@
\newcommand{\refstmodindex}[1]{\refmodule{#1}{standard }} \newcommand{\refstmodindex}[1]{\refmodule{#1}{standard }}
% support for the module index % support for the module index
\if@usemoduleindex \newif\if@UseModuleIndex
\newwrite\modindexfile \@UseModuleIndexfalse
\openout\modindexfile=mod\jobname.idx
\fi \newcommand{\indexlabel}{genindex}
% Fix the theindex environment to add an entry to the Table of
% Contents; this is much nicer than just having to jump to the end of
% the book and flip around, especially with multiple indexes.
%
\let\OldTheindex=\theindex
\renewcommand{\theindex}{
\cleardoublepage
\OldTheindex
\addcontentsline{toc}{chapter}{\indexname}
\label{\indexlabel}
}
\newcommand{\@thismodule}{$<<$ ERROR - NO CURRENT MODULE $>>$}
% Add the defining entry for a module % Add the defining entry for a module
\newcommand{\defmodindex}[2]{% \newcommand{\@modindex}[2]{%
\index{#1@{\idxcode{#1}} (#2module)|textbf}% \index{#1@{\idxcode{#1}} (#2module)|textbf}%
\setindexsubitem{(in module #1)}% \setindexsubitem{(in module #1)}%
\if@usemoduleindex% \if@UseModuleIndex%
\write\modindexfile{#1 \thepage}% \write\modindexfile{\protect\indexentry{#1@{\tt #1}}{\thepage}}%
\fi} \fi%
\renewcommand{\@thismodule}{#1}
}
\newcommand{\makemodindex}{
\newwrite\modindexfile
\openout\modindexfile=mod\jobname.idx
\@UseModuleIndextrue
}
\newcommand{\inputindex}[1]{
\IfFileExists{#1}{\input{#1}}{\begin{theindex}\end{theindex}}
}
% built-in & Python modules in the main distribution % built-in & Python modules in the main distribution
\newcommand{\bimodindex}[1]{\defmodindex{#1}{built-in }} \newcommand{\bimodindex}[1]{\@modindex{#1}{built-in }}
\newcommand{\stmodindex}[1]{\defmodindex{#1}{standard }} \newcommand{\stmodindex}[1]{\@modindex{#1}{standard }}
% Python & extension modules outside the main distribution % Python & extension modules outside the main distribution
\newcommand{\modindex}[1]{\defmodindex{#1}{}} \newcommand{\modindex}[1]{\@modindex{#1}{}}
\newcommand{\exmodindex}[1]{\defmodindex{#1}{extension }} \newcommand{\exmodindex}[1]{\@modindex{#1}{extension }}
% Additional string for an index entry % Additional string for an index entry
\newcommand{\index@subitem}{} \newcommand{\index@subitem}{}
@ -534,17 +560,6 @@
}{\par} }{\par}
% Fix the theindex environment to add an entry to the Table of
% Contents; this is much nicer than just having to jump to the end of
% the book and flip around, especially with multiple indexes.
%
\let\OldTheindex=\theindex
\renewcommand{\theindex}{
\cleardoublepage
\OldTheindex
\addcontentsline{toc}{chapter}{\indexname}
}
% Allow the release number to be specified independently of the % Allow the release number to be specified independently of the
% \date{}. This allows the date to reflect the document's date and % \date{}. This allows the date to reflect the document's date and
% release to specify the Python release that is documented. % release to specify the Python release that is documented.