Allows Python code execution inside of graphviz diagrams.
Project description
graphviz-py
Allows Python code execution inside of graphviz diagrams
Example
graph python_graph {
{{
import math
value = 0.5
sin = math.sin(value)
cos = math.cos(value)
}}
A [label="{{= value }}"];
B [label="{{= sin }}"];
C [label="{{= cos }}"];
A -- B [headlabel="sin"];
A -- C [headlabel="cos"];
}
Output
Installation
pip install graphviz-py
Important: Make sure graphviz is installed! See graphviz installation instructions.
Usage
Using files
graphviz-py -Tsvg example/example.py.dot -o output.svg
graphviz-py -Tpng example/example.py.dot -o output.png
Using stdin / pipes
echo 'digraph { A -> B [label="{{= 38 * 73 }}"] }' | graphviz-py -Tsvg > output.svg
graphviz-py passes all unknown arguments to graphviz. So you can use all graphviz arguments.
Output
Variables
graphviz-py -Tsvg -a myvalue=5 example/variable_example.py.dot -o output.svg
Here we pass a variable called "myvalue" with the value 5
Output
Security
Please keep in mind that graphviz-py executes all Python code in the diagram. So make sure that your diagrams dies not include harmful code.
Coming soon
- Compartibility with asciidoctor-diagram (Status: Implemented & Approved, waiting for merging)
Arguments
# graphviz-py --help
usage: graphviz-py [-h] [-v] [-d] [-a ARGUMENT] [files [files ...]]
graphviz-py diagram builder
positional arguments:
files the paths to the graphviz-py files
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-d, --debug show debug information
-a ARGUMENT, --argument ARGUMENT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
graphviz-py-1.0.5.tar.gz
(9.3 kB
view hashes)
Built Distribution
Close
Hashes for graphviz_py-1.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76779d219f0bdcc59bf3d2312ac127885c99594e08851841b106fac63f27a71d |
|
MD5 | 6dfd4b9a8a585275afe87bf8226a0d74 |
|
BLAKE2b-256 | cf28c2943336ec1ebb24517f0872c54c83580eb6894c89eb267c7a896a3dfb48 |