I have to admit, I haven’t found a more formal programmatic tool. Ultimately I have to turn to “by hand” tools if I want something more complicated. If you can’t translate that last statement, it means I just never do anything more complicated.
Example at https://dev.azure.com/itmv/Coffee%20Shop/_wiki/wikis/Coffee-...
Project at https://github.com/Calpano/featdoc
Disclosure: I maintain this project
1. It provides a convenient DSL targeting specific diagram use-cases that I actually want (generally sequence diagrams.)
2. The "source code" for the diagram is trivial to check in and diff with version-control, sometimes right along with the code it describes.
3. If the app/renderer is for some reason not available, the source is clear enough that you aren't completely lost.
I hadn't heard of Mermaid before this conversation, but it seems to hit some of the same notes.
The creator of PlantUML is working on translating graphviz into a native form to eliminate the dependency for PlantUML use. Once this has been done, it would open up even a whole new world of possibilities (graphviz does allow a bit more specification of element locations).
What plantuml lacks (maybe mermaid less so) could really only be improved upon by working with raw svg I think. There is a LaTex package tikz that offer much more flexibility than plantuml/mermaid, but you still run into limitations in that diagram features are predefined.