thebjorn/pydeps

Option to flip module order

Closed this issue · 1 comments

Currently, the main Module (the whole package/initial main) is showed at the bottom of all Dependencies and the Sub-Modules are stacked on these. To get an overview for my Package I have to start at the end. An option would be nice to show the Main-Module at the start and show the dependencies below (as im Reading a Page from top to bottom, not the other way).
So Instead of:
image

I´d prefer:
image

Hi @epg-horvath and thank you for your interest in pydeps.

I'm open to a PR for this. It should be under an option named --top-down (or better). This option must implicitly set --reverse.
The option should change self.rankdir to "TB" even when self.reverse is True. top_down=False should probably be added to the RenderContext ctor and set as an instance variable.

The relevant line is

self.rankdir = kw.get('rankdir', 'BT' if self.reverse else 'TB')

As a hack, you can achieve the result with something like (here calling pydeps on pydeps itself on a windows machine with gnuwin32 installed):

pydeps --reverse --show-dot --no-show pydeps | sed -e "s/rankdir = BT/rankdir = TD/g" > tmp.dot && dot -Tpng -o tmp.png tmp.dot && start tmp.png

giving:
tmp