I tried to put either of
\endpostamble, as in the code excerpted from conteq below, but it seems to be ignored (sty and pdf created in the same directory as that of dtx), so I must have misunderstood its purpose.
Here's an excerpt from conteq.dtx, from which foo.dtx is based:
In the section Example, the same code is repeated twice, once verbatim, the other not. Is there a way to avoid this duplication?