[Feature request] Able to set graphviz arguments
yuyupopo opened this issue · 2 comments
Hi, thx for the project, I'm just starting to use this library, and it is really helpful.
I don't know if this is already possible, but would I be able to pass extra arguments to graphviz when rendering the graph?
Now, I'm using pydeps
to generate the dot file and rendering the dot file myself, but would it be possible to do it in one step?
Use cases for me is,
dot -Tps out.dot -o out.ps
: other output formats
dot -Kneato out.dot
: changing layout engine
Will it be possible to pass arguments to graphviz as pydeps --graphviz-args "-Tps"
or in a similar fashion?
pydeps
takes the -T<format>
parameter and passes it on to dot. pydeps
will try to display the generated file, so depending on your OS this might work flawlessly or not. I.e. on my windows box, pydeps -Tpdf ...
works great and opens in my default pdf viewer, while pydeps -Tps ...
does not (since I don't have a postscript viewer installed). You can specify which program to call for display with either the --display PROGRAM
option, or by setting either of the PYDEPS_DISPLAY
or BROWSER
environment variables. The entire logic behind displaying can be found at https://github.com/thebjorn/pydeps/blob/master/pydeps/dot.py#L89
There probably ought to be a --graphviz-cmd PROGRAM
flag (PYDEPS_GRAPHVIZ_CMD
environment variable?) that let you switch from dot
to something else. I'll happily merge a PR on this.. ;-)
I'll merge a PR that adds a --graphviz-args ARGS
parameter as well, provided it is documented in the README, and handles the potential of multiple -T
flags being passed to graphviz in a sensible manner (deleting the default is sensible as long as it is documented - generating all variants would be even better, and should just require multiple -ofile
to be passed...).
It should be a relatively easy fix:
- add a new argument here https://github.com/thebjorn/pydeps/blob/master/pydeps/cli.py#L151 and provide a default in the if-statement just below.
- extract the parameter from the
**kw
and pass it on todot.call_graphviz_dot(...)
here:
https://github.com/thebjorn/pydeps/blob/master/pydeps/pydeps.py#L47
It would be great if the graphviz-args could be sent on .pydeps file.
I for instance preffer RL ordering instead of the original TB, and I somehow my brain can only understand nodes if they have a shape box, instead of the default oval.
Being able to set this on the .pydeps file would be great!