Implement `make diagrams` command

I've fixed the most apparent issues. Lots of improvements may be done, but I'm not going to invent AI here :) So this implementation is good enough for now.

The patch is submitted under MIT License