yoshimkd / swift-auto-diagram

A Ruby script that scans all swift code from the specified folders and files and automatically generates an entity diagram (similar to a class diagram) which can be viewed in a browser.
MIT License
496 stars 57 forks source link

Feature request: Sort class hierarchy & multiple selection #29

Open Hurricane31337 opened 4 years ago

Hurricane31337 commented 4 years ago

Would it be possible to sort the classes on horizontal levels instead? I imagine the diagrams would be easier to read and would require less reordering afterwards. In this context, multiple selection of the ordered groups of classes could also be helpful to move around the whole (already tidy) groups by context.

Here an example of a quite untidy diagram with many dependencies to UIViewController:

image

After reordering in horizontal hierarchy levels, sorted descending by dependency count (not very strictly, just as a quick example):

image

The algorithm could be roughly: find the class with the most inheritances and place it, then place all protocols below them, then place all inherited classes below (maybe also sorted left to right by dependency count), continue until inheritance ends. Then place next unplaced class with the most inheritances randomly somewhere else on the screen (maybe below) with the same algorithm and so on.

Even if this algorithm wouldn't work on some edge cases, it would already help a lot on big projects.