Skip to content
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

Refactor and add yEd GraphML output #1

Closed
wants to merge 8 commits into from

Conversation

PatrickMassot
Copy link

I like this project very much but I need to be able to edit the graph after generating it in order to improve the layout and remove a couple of errors. I couldn't find software allowing to do that with pyan's Graphviz dot output.The easiest way I could see was to use yEd's variant of GraphML. At some point I may try to implement Dia output but that would require to use Graphviz to do the layout hence adds some complication (it seems Dia has no automatic layout option).

However I didn't want to loose all the efforts that went to dot output. So I first needed to refactor quite a bit. The coloring stuff went to a colors module with its Colorizer class which knows nothing about output format. Then I have a graph module which contains an abstract class Graph which sits between CallGraphVisitor and the writers. And then I have writers module which actually output something. There is a base class Writer which mostly defines in what order various bits (nodes, subgraphs, edges) are written. It has three subclasses: TgfWriter, DotWriter, YedWriter that know about the output format. Here the result of running pyan on this stuff, with yEd doing the layout: pyan.pdf

I've also done some general clean up. Everything is Pep8'ed and logging uses the standard logging module. There is an new option -l logfile to specify a log file instead of stdout (which is still available using -v). There is also -f filename option to specify an output file. And of course --yed is the new output format option.

For me this version of pyan is more usable and I thought I should give it back. If there is interest I may continue cleaning things and add small improvements. For instance currently this project confuses Graphviz because there is a graph module which results in nodes of the dot file being called graph, which is of course a syntax error... I guess one should expect that kind of problem when running a code analyser on itself (the universe didn't blow up though).

@davidfraser
Copy link
Owner

Hi @PatrickMassot - sorry for the slow response! It certainly is a valuable feature to be able to edit the resulting files, and the output you showed looks good... I've pushed a branch called yed-support and have merged your changes into that as well as creating a fix for the graph unsafe id. But unfortunately it conflicts with the latest changes I merged. So if you're interested you could try merge those changes, or else I will try look at it soon...

@PatrickMassot
Copy link
Author

Hi @davidfraser. It seems you forgot to push your yed-support branch to github.

I just tried to incorporate your changes to my master branch. But I must admit I forgot everything about what I did last year so I can only hope I didn't mess up things. The only clear point is there is no hope to resolve conflicts between my fork and your master branch. I refactored too many things last year. You need to choose whether you want to switch to my structure (with writers separated from the main work). The main point of my work was to make it easier to add new output format.

@Technologicat Technologicat mentioned this pull request Nov 16, 2017
Technologicat added a commit to Technologicat/pyan that referenced this pull request Nov 16, 2017
@davidfraser
Copy link
Owner

This was apparently incorporated in #5 which was just merged - so I'm closing this for now but let me know if anything was left out etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants