-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User Story: Generate UML diagrams for rust code/crates. #33
Comments
Hey, thank you for the issue. This kind of analysis / metadata extraction should definitely be possible with marker. I have one quick question regarding the UML diagrams. Are they drawn on a per crate level or on a global level based on what the user specified? |
crate level. It looks for all *.rs files below src for a given crate, parses and transforms each in memory, and then outputs a single .dot (graphviz) and single .svg file for the crate. As I recall, it presently ignores module names, and thus collisions can occur. something to fix, but not easy with present impl. I made a script that can take a list of crate names and urls as input and output an html page with diagram links for each crate. (as per the above-linked example). In this script, the ml tool is invoked 3 times per crate to generate different levels of detail. |
Perfect, thank you for the explanation :) |
Personally, I think this should fall under what was discussed in #7. Namely, go for it, but it's not a use case that is explicitly supported. The primary goal of the project is a custom linter, after all. |
This is the second request we got related to extracting metadata. Maybe adding this as a primary use case could be good. I'd be careful with adding explicit utilities for this, as the main focus is linting. However, this and the other use cases I heard off, all require the same information that lints would need anyways. The main additional requirement, I see, would be, that it has to be possible to run the linter with only a specified lint crate. This can be handled by the CLI and is in fact something I already planned for ^^. |
btw, this diagram generator tool is rather crude. I think the ultimate evolution would be a tool that exports something like a high-level AST that expresses the data types and relations between them. It would include crate and module information. It would then be possible to run this tool over a crate and all its dependencies recursively to generate a full AST for entire dependency tree. A visualizer tool (2d and/or 3d) could then take the generated AST as input and render a navigable 3d graph, or 2d diagrams, where different levels of detail can by dynamically selected, including doc comments. So it could look like docs.rs all the way to just struct names. It might even be that such a visualizer tool could be built directly from the rust-marker AST with no translator tool necessary.... |
I have hacked a bit on ml, a tool that generates diagrams from rust code.
Here are some example diagrams
It presently uses the AST generated by nightly which seems to be always changing. So the ml tool is locked to a specific version of nightly.
This tool is very crusty (a prototype really) and badly needs a re-write. It occurs to me that rust-marker could serve as the AST basis for such.
The text was updated successfully, but these errors were encountered: