Ideas for a Crate Code Map Viewer

So I was thinking recently about a tool like Visual Studio's Code Map, which I use at work a lot. But for Rust!

There are already a bunch of static analysis tools already; rustdoc, and of course the compiler itself, although I haven't looked through the rustdoc source yet, which doesn't look at blocks.

But I figured I could do some source analysis (via magic, can't be that hard, right? :slightly_smiling: ), build up a javascript graph of mods, structs, fns, calls etc and draw it up in d3.

The level of detail wouldn't need to be too high; just a visualisation of a crates architecture.

Has anyone else thought about doing something similar? Or have any thoughts on how impossible and foolish it would be?

That sound pretty interesting! I've been wanting to do some cool things with rustdoc for a while now.

Rustdoc has the option to output JSON, but it bit-rotted over the last year or so and doesn't work right now. I was looking into fixing it, but it's a bit too complex for the little time I have.

1 Like

You might be interested in rustc -Z save-analysis. rust-dxr is one tool that takes advantage of it.

1 Like

Thanks for pointing out save-analysis. It looks like this dxr format could already cover everything I need!

I'm pretty tied up with other projects for the next few weeks, but the csv output looks like it makes this actually viable. I'll spend some time poking through the format and what's actually in there.

It's too bad about the JSON output not working, I've been really impressed by rustdoc and hope it gets some love.