Well, I sort of liked Doc (it seemed to have a nicely delimited set of
responsibilities). At least for rails, it seemed to work better to output
to a stream rather than buffer things up, but an object could wrap a
stream (I think that's how Doc worked at the end, but this code went
through enough changes that I won't trust my memory or my ability to
browse it really quickly).
Now, I'm not sure whether this solves your problems with indentation
levels or just provides another place for state to get reset, or not reset
(whichever is least convenient), but I'll leave that to you.