A Python-based DOT language interpreter with multiple API styles
Project description
DotFlow
A Python-based DOT language interpreter with multiple API styles for creating flowcharts and diagrams effortlessly.
Features
- Multiple API Styles: Pythonic, natural language, and textual DSL
- Auto-shapes: Predefined shapes for common elements
- Clustering: Group nodes logically
- Themes: Built-in color schemes
- Export: PNG, SVG, PDF and DOT file export
Installation
pip install dotflow
Quick Start
from dotflow import Flow, create_flow
# Pythonic API
flow = create_flow("my_flow")
(flow.start("Start")
.process("Process Data")
.decision("Valid?")
.connect("Valid?", "End", label="Yes")
.connect("Valid?", "Process Data", label="No"))
flow.render("png", "my_flow.png")
API Styles
Pythonic API
flow.process("A").connect("A", "B", label="Next")
Natural Language
flow >> "A" >> "B" | "Label"
Textual DSL
flow.parse_dsl("""
A [shape=rect, label='Custom']
B [shape=rect, label="decision"]
C [shape=diamond, label=process]
A->B:Input Data
B{decison}->C:Valid
# End of of diagram
""")
Command Line Interface
DotFlow provides a powerful CLI for generating diagrams without writing Python code.
Basic Usage
# Generate from DSL text - Line breaks a mandatory just lik in dsl file
dotflow generate my_diagram.png --dsl-text \
"
A
B
A->B
" --theme green
# Generate from DSL file
dotflow generate diagram.svg --dsl-file workflow.dsl --theme dark
# Generate DOT file
dotflow generate workflow.dot --dsl-file workflow.dsl --format dot
- Interactive Wizard
# Interactive flow creation
dotflow wizard my_flow.png --interactive
# Quick sample flow
dotflow wizard sample.png
- Validation
# Validate DSL syntax
dotflow validate workflow.dsl
- Examples
# Generate example diagrams
dotflow examples --format svg --theme blue
# Generate DSL cheat sheet
dotflow cheat-sheet
- Themes
# List available themes
dotflow themes
- DSL Syntax
The textual DSL supports:
# Comments
# First lets define the nodes
Start[shape=ellipse]
Valid[shape=diamond, label="Valid?"]
Process
ErrorHandler[label='Error Handler']
Storage
End[shape=ellipse]
# make decisions and connect nodes
# Validate data
Start{decision}->Valid:Validate
Valid->Process:isValid
Process->Storage:Store data
# Handle processing errors
Process->ErrorHandler:Processing Error
Storage->End:Finalize
# Handle invalid data
Valid->ErrorHandler:Invalid data
ErrorHandler->End
Usage Examples
- Install the package:
pip install -e .
- Basic CLI usage:
# Generate a simple flow
dotflow generate my_diagram.png --dsl-text \
"
A
B
A->B
" \
--theme dark
# Use interactive wizard
dotflow wizard my_flow.png --interactive
# Validate DSL file
dotflow validate my_workflow.dsl
# Generate all examples
dotflow examples --format svg
- Using as Python module:
python -m dotflow generate diagram.png --dsl-text "
A
B
A->B
" \
--theme blue
This CLI implementation provides:
[] Multiple Commands: generate, wizard, validate, themes, examples, cheat-sheet
[] Interactive Mode: Build flows step-by-step
[] Comprehensive Validation: DSL syntax checking
[] Theme Support: All available themes accessible via CLI
[] Example Generation: Pre-built example diagrams
[] Error Handling: Robust error messages and exit codes
[] Testing: Complete test suite for CLI functionality
[] Flexible Output: Multiple formats (PNG, SVG, PDF, DOT)
The CLI makes the package accessible to users who prefer command-line tools or want to integrate diagram generation into scripts and automation workflows.
Documentation
See full documentation for advanced usage.
License
- This product is licensed under MIT license see license
Support
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dotflow_py-0.1.0.tar.gz.
File metadata
- Download URL: dotflow_py-0.1.0.tar.gz
- Upload date:
- Size: 36.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc84257d7e7143e6b84bb3f8391138f4bd1e3013966bf0ef9aa8b6f5156ec125
|
|
| MD5 |
220fccccf4b6924149168360980ed2e1
|
|
| BLAKE2b-256 |
d3baa903ee72c5cb5c5346646c91e3ca38b227bd86d3165aba0b6c9d8f853625
|
File details
Details for the file dotflow_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dotflow_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 42.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c869415990232593f2ee1788e5ab688e04ab799d5953ab0503db18f543de54b5
|
|
| MD5 |
011dc0cf473db4ea3a2eb4306fe0e266
|
|
| BLAKE2b-256 |
ba2b49575bdc4f7772318be1fd435aa70742c6ad724c413a03e4a9e447d95350
|