jonascarpay / calligraphy

haskell source code visualizer
BSD 3-Clause "New" or "Revised" License
97 stars 13 forks source link

Mermaid output #13

Closed jonascarpay closed 1 year ago

jonascarpay commented 2 years ago

GitHub markdown now supports inline Mermaid flowchart diagrams:

flowchart LR
    foo --> bar
    bar --> baz

If calligraphy were to output Mermaid directly, you could easily e.g. include call graphs in your documentation or PRs. It shouldn't be too tricky, and it seems extremely useful.

Kleidukos commented 1 year ago

I have been looking for something like this for a long time!

An idea that I'd love to join with it would be to mark identifiers with a Haddock metadata so that only them are picked by Calligraphy. This would be useful to only show "domain-level" operations to non-technical people, with the beautiful Mermaid output. :)

jonascarpay commented 1 year ago

Oh, that's a neat idea! I don't really know or remember off the top of my head how much Haddock makes its way into HIE output, do you have any idea?

Kleidukos commented 1 year ago

Unfortunately the .hie files don't hold any documentation, it's all in .hi files according to @fendor

Kleidukos commented 1 year ago

@jonascarpay I'll try to give a stab to the Mermaid backend! I'll use the tasty framework to have unit and golden tests :+1:

jonascarpay commented 1 year ago

Nice! Let me know if you need help/input on anything. The trickiest thing is probably untangling the graphviz-specific parts and the more general parts of the rendering logic. Maybe it's useful to create an intermediate representation that's easy to render for both mermaid and graphviz?

Kleidukos commented 1 year ago

Yes, I'm going to do some internal refactoring. Ideas welcome when it comes to internal representations of flowcharts, I'm not exactly an expert in the field :)

jonascarpay commented 1 year ago

I started sketching out an internal representation, but I'm now so far along I might as well get it compiling and to a point where you should be able to adapt it pretty easily to a mermaid renderer. PR coming soon, I hope I didn't accidentally duplicate any of your efforts.

Kleidukos commented 1 year ago

Nope! I'm very eager to learn from you as well :)