chanhx / crabviz

🦀 A LSP-based interative call graph generator
Apache License 2.0
679 stars 22 forks source link

Feature request: export call graphs as SVG after analyze finish by setting #42

Open River2000i opened 1 week ago

River2000i commented 1 week ago

Hi @chanhx, crabviz is a great tool to analyze codebase for us. We are using this tool to find out the potential impact modules of each PR.

However, we will analyze lots of rs files, which makes it impossible to open the generated svg file and export it manually. Therefore, we hope that the tool can automatically save the svg file when the analysis is finished.

chanhx commented 1 week ago

I'm glad it helped.

The auto-saving feature seems very specific to your use-case. I don't quite understand how you use the extension in your work flow, could you please give a further explanation? Maybe we can find an alternative approach.

River2000i commented 1 week ago

Thanks for your response quickly!

I will select some directory in our Rust codebase as the input of crabviz. After SVG file generated, i will save it locally. Then parse the SVG file as html.Node with golang and build a map relationship between id and file/function. Also the svg file will record the edge. I can get the call graph in the program.

IOW, parse the svg file to record it into our program's map, such as map[string]interface{} in go. Do some analyze for the whole call graph.

Once again, I would like to praise the project! If there are any idea, please ping me any time.

chanhx commented 1 week ago

Got it. Actually all the information you want is in the crabviz crate, but currently it can't be used outside the IDE environment. I will refactor the crate to make it more independently usable later.

For now, the easy way is to fork the extension, and modify it to fit your needs, and install it locally. I think you just need to call this function here, and modify the saveSVG method. Here is how to build the extension. Feel free to ask me if there are any problems.

River2000i commented 1 week ago

Great idea. Thanks for your help!

I will do fork and develop locally from your suggestion.