doxygen-mermaid main
Mermaid graphs in doxygen 🧜‍♀️
doxygen-mermaid 🧜‍♀️

This is an example of how to include Mermaid graphs in doxygen documentation.

https://github.com/tttapa/doxygen-mermaid


Demo: C++ coroutine example

task<> foo() {
co_return;
}
task<> bar() {
task<> f = foo();
co_await f;
}

flowchart start(( )) subgraph bar bar_coro_alloc["coroutine frame allocation\npromise_type promise {};\npromise.get_return_object()"] bar_coro_alloc --> call_foo["task<> f = foo();"] await_f["co_await f;"] await_f --> op_co_await["f.operator co_await()"] awaiter_promise["task::awaiter a {f.promise}"] op_co_await --> awaiter_promise await_rdy["a.await_ready()"] awaiter_promise --> await_rdy await_rdy --> if_await_rdy{{"f.done()"}} if_await_rdy -->|false| await_sus["a.await_suspend(bar)"] if_await_rdy -->|true| await_rsm["a.await_resume()"] await_sus --> await_sus_body["f.promise.continuation = bar\nreturn foo"] await_rsm --> bar_ret_void["promise.return_void()"] bar_ret_void --> destroy_f["f.~task()"] destroy_f --> destroy_foo["foo.destroy()"] destroy_foo --> bar_final_sus["promise.final_suspend()"] end subgraph foo coro_alloc["coroutine frame allocation\npromise_type promise {};\npromise.get_return_object()"] coro_alloc --> init_sus["co_await promise.initial_suspend()"] co_ret["co_return;"] co_ret --> ret_void["promise.return_void()"] ret_void --> final_sus["promise.final_suspend()"] final_sus --> final_sus_a["task::promise_type::final_awaiter a {}"] final_sus_a --> final_await_sus["a.await_suspend(foo)"] final_await_sus --> final_await_sus_body["return promise.continuation"] end end_(( )) start --> bar_coro_alloc call_foo -->|Function call| coro_alloc init_sus -->|Suspend| await_f await_sus_body -->|Symmetric Control Transfer| co_ret final_await_sus_body -->|Symmetric Control Transfer| await_rsm bar_final_sus --> end_

See also
https://tttapa.github.io/mp-coro/Doxygen/classmp__coro_1_1task.html