Juha Jeronen has added some features to the Python call-graph generator (pyan) I’ve previously blogged about. With a single command line, I can now get pictures like this:
A bit of colour always shows a program’s structure in a better light. Green for the backup program, orange and blue for high-level and low-level journal manipulation, and yellow for link creation.
As well as automatic colouring by namespace, there are options to control whether use- and define- edges are shown, and whether nodes in each namespaces are grouped together. For instance, instead of drawing define-edges between namespaces and their members as above, we could omit those edges and instead group them. The “fdp” layout algorithm seems to render best for this graph:
Juha’s colour and grouping enhancements are implemented for the GraphViz output. pyan also outputs .tgf files for yEd. But “trivial graph format” is just too trivial to support these options, so I may soon extend the program to write the more advanced .graphml format.
Thanks for the post. Nice ‘screenshots’ :)
By the way, I have now modified XDot, too. The new version comes with an incremental Find feature (handy for looking for nodes by label text), and highlights outgoing/incoming linked nodes (if modifiers held down) when hovering over nodes. It also has some new UI animations, the UI has been generally polished, and it has built-in documentation.
I just posted about the changes to the original site ( http://code.google.com/p/jrfonseca/wiki/XDot ), currently waiting if there is an interest.
Check it out (no pun intended) if you or any of the readers are interested. It’s available at:
https://yousource.it.jyu.fi/jjrandom2/miniprojects/trees/master/refactoring/
Update: my repository for this was getting a bit messy, so it has been reorganized. The modified Pyan and XDot are now both in their own subfolders:
https://yousource.it.jyu.fi/jjrandom2/miniprojects/trees/master/refactoring/pyan
https://yousource.it.jyu.fi/jjrandom2/miniprojects/trees/master/refactoring/xdot
The top-level directory
https://yousource.it.jyu.fi/jjrandom2/miniprojects/trees/master/refactoring
contains a combined README and a wrapper script (analyze.sh) for convenience.
Pingback: More thoughts on version control | EJRH
This is a brilliant project and I was so glad to find it! I’ve extracted the code from both your repositories into a single one that contains a history from each of your original commits, but not in the same repository as your other software … I hope that’s useful. It’s at:
https://github.com/davidfraser/pyan/
In hindsight, my “miniprojects” repo may have been a bad idea to begin with :)
Thanks for reorganizing!
Sure, I did the same sort of thing when I first moved from svn to git. Love the code you’ve made!
Hi Edmund and Juha, I just got a request to clarify the license on this code. Based on the original post at https://ejrh.wordpress.com/2011/12/23/call-graphs-in-python/#comment-824 and on the repository at https://code.google.com/archive/p/ejrh/ I’ve indicated that it’s GNU GPL v2. Please tell me if this is in error…
Hi David, GPL v2 is what I would have picked, so that is fine by me.
GPL v2 is fine with me too.