TLDR; I'd like to make it cheap and easy to include / update diagrams in markdown.
If you're not familiar with it,
graphviz is a tool for automatically laying out and rendering a simple textual representation of a graph. There are a bunch of examples on their
gallery page and you can play with a web version at
viz-js.com. I think that it's well suited for easily generated and modifiable diagrams in our documents.
Naively, using graphviz today in
gitiles requires manually generating and checking in the
png file generated from the
.dot file. Then include the generated image in your markdown. Ideally we'd use SVG (smaller, scales nicely) except gitiles markdown images currently only
support png, jpg and gif unless the image is remote.
This is not ideal, and while you could imagine workarounds like making the generation part of the build I suspect linking to the build artifacts from the source may be difficult and subject to version skew. We could add a PRESUBMIT hook to verify that updated .dot files match their generated output to ensure that devs don't forget to freshen the output file.
I think there are several ways we could make this as easy as just including the .dot file:
- Run a web service similar to gravizo which responds to HTTP requests containing graphviz diagrams in the query parameter with the generated image. Embed graphviz within markdown as part of image link.
- Use a gitiles plugin to render embedded graphviz
- Include a library which can render embedded graphviz diagrams client-side, e.g. https://github.com/dagrejs/dagre
Adding support for this as a gitiles plugin (does one exist?) seems like the best solution, but I'd appreciate feedback / opinions / existing solutions we might be able to use if you're aware of them.