Show rust: A syntax-diagram generator for macro_rules!()-syntax



allow me to shamelessly crosspost from reddit: As I found the situation about documenting macro_rules()-syntax not very satisfying, I wrote a library to automatically generate syntax (“railroad”) diagrams directly from code. The obvious target for this is, where it might do some good. I’m now looking for comments if rust thinks this thing is useful and worth the effort.

A live demo, compiled to WASM, can be found here.

There are more examples of the macros from nom, stdlib, syn and various others.


Wow thanks for the great tool! :sparkling_heart: :confetti_ball: :tada:

Minor nit picks:

  1. The background color of pat (blue) makes the text unreadable.

    macro_rules! a {
    ) => {};
  2. :literal and :vis are not supported


Macro-internal rules omitted

*claps* I have to admit, I’m rather pleased to see that. Very nice work.

Also, I think the actual obvious target for this is rustdoc itself.


Fixed :literal and :vis, thanks for pointing this out.


Apart from Rustdoc, I feel like some sort of IDE integration could also be useful, and it could speed up the development of macros significantly