scottrogowski / code2flow

Pretty good call graphs for dynamic languages
MIT License
3.98k stars 295 forks source link

Request: Allow depth/downstream-depth without `--target-function` #66

Open Kilo59 opened 2 years ago

Kilo59 commented 2 years ago

I'm trying to use code2flow on a very large codebase and the resulting out.png file keeps getting scaled to the point where it is unreadable.

I would like to be able to set a graph depth without having to pick a particular function.

code2flow my_package --downstream-depth 3

Or maybe just a generic --depth.

Scaled out.png file

image

~I realize there's probably a way to get dot/graphwhiz to reduce the scaling, but I haven't figured that out yet.~ Also I only really care about the first few nodes in the graph.

Edit: changing the output type to .svg solved the issue with low res .png files. But I still think being able to set a depth without specifying a target function would be a good feature.

Very cool project BTW.

scottrogowski commented 2 years ago

Hey, sorry for the delay.

Yea... I know this is an issue 😅. The bigger the project, the more difficult it becomes to use it which is part of why the --*-depth parameters were added. I was working on something more interactive that would solve this issue but have had to stop working on that to focus on other life things.

How would you determine which node is the main node? Just the global node doesn't work when you have multiple files and while there are a few functions in each language that are more likely to be entry nodes, it's not standard enough to make any rule. Would be curious to hear if you have an idea.

Kilo59 commented 2 years ago

No worries about the delay. Life takes priority 😄 .

As far as "determining which node is the main node?", I was thinking that would be unnecessary. For any/all nodes just stop traversing the graph once the target depth has been reached.

Why does that require knowing what the main/entry node is?

Although if it's building the graph from leaf -> root, I can see how it might be more difficult. Would have to generate the full graph and then subtract/remove the steams/leaves that exceed the desired depth from the root nodes? Or something like that?? 🤷

Kilo59 commented 10 months ago

I think this would also address this issue