# index completely messed up in dtx file

I fight with the strange and useless entries of the index in dtx files.

It can reproduced with

% \iffalse
%<*driver>
\ProvidesFile{dtxcode.tex}
%</driver>
%
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\listfiles

\begin{document}
\DocInput{dtxcode.tex}
\PrintIndex
\end{document}
%</driver>
% \fi
%%
% \DescribeMacro{\foobar} Prints out foobar
%
% \Finale
\endinput


the result is

foobar= \subitem *+\foobar+, \usage{1}

printed as shown here in the pdf.

Anyway: I would like to switch of the index functionality of doc.sty completely and replace it with my own. It tries to add EVERY latex command used in the index. With my current code this is hundrets of entries which have nothing to do with any command defined by the package.

-

If I run

makeindex -s gind.ist dtxcode


the content of the resulting .ind file is

 \begin{theindex}
\makeatletter\scan@allowedfalse
{\bfseries\hfil F\hfil}\nopagebreak

\item \verb*+\foobar+\pfill \usage{1}

\end{theindex}


If instead I run the wrong command

makeindex dtxcode


the resulting file contains

\begin{theindex}

\item foobar=\verb
\subitem *+\foobar+, \usage{1}

\end{theindex}


which is obviously wrong.

Indexing of a macro is suppressed by adding it as the argument to a \DoNotIndex command (there can be many, each receiving lists of macro names); for instance (from one .dtx of mine)

% \DoNotIndex{\newcommand,\newenvironment,\!,\@empty,\@gobble,\@gobbletwo}

It's customary that a DTX file has the .dtx extension, rather than .tex
Where does -s gind.ist come from? –  Matthias Pospiech Nov 29 '12 at 21:39
gind.ist is the MakeIndex style specifically tailored for building the index for a .dtx file. See section 2.9 of the documentation of the .dtx format (texdoc doc) –  egreg Nov 29 '12 at 22:00