This maybe not exact answer to your question, but Yii uses console commands which are part of Yii source. You can check them on the github and adopt to your needs.
The commands ends up with latex which in turn get converted to PDF via pdflatex. I cannot find decent tool to convert latex to decent html and I ended disappointed. That’s why I decided I would ask help to roll my script to do that!
I have tried every thing possible to find on net including much in the link (latex2html, hevea et al) and every link and what I have found is, latex is not easily convertible to html let alone CHM. I ended up with horrible output.
I see the only way is to workout the format from text files in docs, so that instead of producing latex it will produce the needed format. May be it is a time to move to docbook? I’m not good at it but It have many formats and it works fine.
I don’t know what to suggest but HTML is very common format and I wonder why it is not naturally supported.