Still problems with multiple indexes in ltxdoc

I refer to the solution that was presented in multiple indexes in ltxdoc When I add some lines, it doesn't work anymore. I have the feeling that something deeper is wrong, but for a start consider this MWE.

1) The option nonewpage results in no index printed at all (delete the temp files first if they are already there, otherwise you won't notice this).

2) The "other" index contains the entry: Test String A , Test String A 1

To me it seems that the imakeidx package and the original indexing in the doc package have some communication problems.

\documentclass{ltxdoc}
% with option nonewpage no indexes are printed
%\usepackage[nonewpage]{imakeidx}
\usepackage{imakeidx}
\CodelineIndex\EnableCrossrefs

\indexsetup{level=\section*}

\makeindex[name=other]
\makeindex[options=-s gind.ist,title={General Index}]

\begin{document}
\DescribeMacro{\mymacroA}
\DescribeMacro{\mymacroB}\index[other]{\mymacroB}
\def\mymacroA{Test String A}
\def\mymacroB#1{%
\mymacroA\
#1
\mymacroA
}multiple indexes in ltxdoc
%
\newpage
\mymacroB{Test String B}
\printindex
\printindex[other]
\end{document}

• With nonewpage you must run MakeIndex separately. – egreg Feb 3 '18 at 12:15
• And what about problem 2), where the "other" index contains rubish? – Jack Feb 3 '18 at 15:36
• The other index contains \item \mymacroB, 1; you need to stringify it. – egreg Feb 3 '18 at 18:17

There are two problems here.

1. With the nonewpage option, you need to run MakeIndex manually.
2. You need to stringify \mymacroB for insertion in the index (ltxdoc does it for its automatically generated index, but not for the others).

Here's an example.

\documentclass{ltxdoc}
% with option nonewpage no indexes are printed
\usepackage[nonewpage]{imakeidx}

\CodelineIndex\EnableCrossrefs

\indexsetup{level=\section*}

\makeindex[name=other]
\makeindex[options=-s gind.ist,title={General Index}]

\begin{document}
\DescribeMacro{\mymacroA}
\DescribeMacro{\mymacroB}\index[other]{mymacroB@\texttt{\string\mymacroB}}
\def\mymacroA{Test String A}
\def\mymacroB#1{%
\mymacroA\
#1
\mymacroA
}multiple indexes in ltxdoc
%
\newpage
\mymacroB{Test String B}
\printindex
\printindex[other]
\end{document}


Here's the contents of jack.ind:

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

\item \verb*+\mymacroA+\pfill \usage{1}
\item \verb*+\mymacroB+\pfill \usage{1}

\end{theindex}


The contents of other.ind:

\begin{theindex}

\item \texttt{\string\mymacroB}, 1

\end{theindex}


• Thank you for explaining. However, when I try to use this in my real project dtx file, I encounter a more serious problem. I have posted a new question on this [tex.stackexchange.com/questions/413624/… – Jack Feb 4 '18 at 10:51