https://pypi.org/project/pylint/
pip install pylint
pyreverse -k -o dot /path/to/library
You can view the classes.dot with the command:
sudo apt-get install libgraph-easy-perl
cat classes.dot | graph-easy --as boxart
cat classes.dot | graph-easy --as boxart
Online grasphviz (dot file) https://dreampuf.github.io/GraphvizOnline
In order to auto generate it for every commit, you can use git hooks. Git hooks enable you to perform something before a git action occur. You can use the pre-commit hook to generate the classes.dot file, and then add it, before the commit is performed.
echo '#!/bin/sh pyreverse -o dot ./pylspclient -k git add ./classes.dot ' >> ./git/hooks/pre-commit chmod +x ./git/hooks/pre-commit After you add a couple of commits, you can view the diffs with graphdiff. In order to install you can:
pip install graphdiff After installing it, you can use the git-graph-diff-tool. It enables to view diffs between .dot files in visual way. First, you need to add to .gitattributes file rules to know how to handle .dot files. For example:
echo "*.dot diff=graph_diff" >> .gitattributes Then, configure the difftool to be the git-graph-diff-tool. For example:
git config diff.graph_diff.command git-graph-diff-tool Then, you can use git as usual, while adding –ext-diff flag to enable external difftools.
git log -p --ext-diff You can see a working example in the pylspclient library.
This posts was originally published in my blog.