Aurélien's Room

Dependency diagrams for KDE Frameworks 5

written on Thursday, December 5, 2013

For a long time we have been missing diagrams for KDE Frameworks, to make it easier to grasp the dependencies of the various frameworks. Since I like working with images I decided to tackle on this.

I did some research and found out CMake comes with a --graphviz option to generate .dot files, which can then be fed to the dot tool from Graphviz to generate pngs, svgs or other formats.

Armed with this, I put together two scripts :

My initial goal was to generate one diagram showing all the frameworks, but this is way too messy, so I ended up extending kf5dot-generate to be more versatile. Right now the output can be customized to generate a diagram of all the dependencies of one framework, to include or not Qt libraries, and to show or hide targets within frameworks.

I also used tred, another tool from Graphviz, to remove unnecessary links. For example if you have this graph definition:

digraph G {
    A -> B -> C # A depends on B, which depends on C
    A -> C # A depends on C
}

You get this output:

Without tred

With tred, the link from A to C is removed, since you can already go from A to C through B:

With tred

This helps making dense diagrams more readable, but it also hides some dependencies. Depending on the reason you are looking at the diagrams, it may or may not be a problem.

Examples

Here is a selection of the generated diagrams. The "simplified" versions have been run through tred.

Some tier 1 frameworks

Mostly useful to check which Qt libraries they use:

KWindowSystem

KWindowSystem

Solid

Solid

Some tier 2 frameworks

KAuth

KAuth

KCompletion

KCompletion

KJobWidgets

KJobWidgets

Some tier 3 frameworks

To reduce clutter I removed the Qt libraries for tier 3 frameworks.

Some of them are readable:

KDESu

KDESu

KIconThemes

KIconThemes

Others are too crowded unless they are simplified:

KIO

KIO

Simplified:

KIO, simplified

KCMUtils

KCMUtils

Simplified:

KCMUtils, simplified

All of KF5

The big, crowded, overall diagram (and this is the simplified version!):

KF5

Useful .dot files

I took some extra care to ensure the generated .dot files are readable enough to be useful even if the resulting diagram is not: the code is correctly indented and relations are placed close to their relevant targets. For example, here is the .dot file for all frameworks: kf5.dot.

Under the hood

The scripts currently live in a git repository: kde:scratch/gateau/kf5dot. kf5dot-prepare is a shell script. kf5dot-generate is written in Python and uses yapgvb, a Python lib to read .dot files.

What's next

In the long term I would like to include these tools in our API documentation generation procedure so that when you browse the API of a framework on api.kde.org you get a diagram of its dependencies.

Flattr this

This entry was tagged CMake, Graphviz, KDE and Python

blog comments powered by Disqus