retroflow 0.8.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,445 @@
1
+ Metadata-Version: 2.4
2
+ Name: retroflow
3
+ Version: 0.8.2
4
+ Summary: Generate beautiful ASCII and PNG flowcharts from simple text descriptions
5
+ Project-URL: Homepage, https://github.com/ronikobrosly/retroflow
6
+ Project-URL: Repository, https://github.com/ronikobrosly/retroflow
7
+ Project-URL: Issues, https://github.com/ronikobrosly/retroflow/issues
8
+ Author-email: Roni Kobrosly <roni.kobrosly@gmail.com>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: ascii,cli,diagram,flowchart,graph,visualization
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Topic :: Text Processing :: General
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.9
26
+ Requires-Dist: networkx>=3.0.0
27
+ Requires-Dist: pillow>=9.0.0
28
+ Description-Content-Type: text/markdown
29
+
30
+ # RetroFlow
31
+
32
+ ```
33
+ ___________________________________________________________
34
+ | |
35
+ | _____ _ ______ _ |
36
+ | | __ \ | | | ____| | |
37
+ | | |__) |___| |_ _ __ ___ | |__ | | _____ __ |
38
+ | | _ // _ \ __| '__/ _ \| __| | |/ _ \ \ /\ / / |
39
+ | | | \ \ __/ |_| | | (_) | | | | (_) \ V V / |
40
+ | |_| \_\___|\__|_| \___/|_| |_|\___/ \_/\_/ |
41
+ | |
42
+ | [ Beautiful ASCII Flowcharts ] |
43
+ |___________________________________________________________|
44
+ || ||
45
+ ```
46
+
47
+ A Python library for generating beautiful ASCII and PNG flowcharts from simple text descriptions.
48
+
49
+ [![PyPI version](https://badge.fury.io/py/retroflow.svg)](https://badge.fury.io/py/retroflow)
50
+ [![Python Versions](https://img.shields.io/pypi/pyversions/retroflow.svg)](https://pypi.org/project/retroflow/)
51
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
52
+ [![codecov](https://codecov.io/gh/ronikobrosly/retroflow/branch/main/graph/badge.svg)](https://codecov.io/gh/ronikobrosly/retroflow)
53
+
54
+
55
+ ## Overview
56
+
57
+ This is a project to help engineers, researchers, project managers, and others create beautiful, retro-looking ASCII flow diagrams. ASCII diagrams are pretty, and harken back to the mid-20th century technical documentation. They also have real advantages:
58
+
59
+ 1) They work wonderfully in the age of agentic AI, which can easily read and parse these small representations.
60
+ 2) ASCII diagrams can live inline with: PRs, Markdown files, Slack threads, etc.
61
+ 3) ASCII diagrams optimize for thinking speed, not presentation quality. It encourages iteration and deletion instead of premature refinement.
62
+ 4) Minimalist diagrams reduce visual noise (although they do still look retro and pretty)
63
+ 5) They're tool agnostic and can be rendered anywhere
64
+
65
+
66
+ ```
67
+ ╔════════╗
68
+ ║ Mesh ║
69
+ ╚════════╝
70
+
71
+
72
+
73
+
74
+ ┌──────────────────────────────────────────────────────────────────────────────────────┐
75
+ │ │
76
+ │ │
77
+ │ ┌────────────────────────────────────┐
78
+ │ │ │
79
+ │ │ │
80
+ │ ┌────────────────────────┼───────────┐ │
81
+ │ │ │ │ │
82
+ │ │ │ │ │
83
+ │┌───────────────────────┼───────────┐ │ │ │
84
+ ││ │ │ │ │ │
85
+ ││ │ │ │ │ │
86
+ ││ │ │ │ │ │
87
+ ▼▼ ▼ │ ▼ │ │
88
+ ┌──────────┐ ┌──────────┐ │ ┌──────────┐ │ ┌──────────┐ │
89
+ │ ┤────────────►│ ┤─┘ │ ┤─┘ │ ┤─┘
90
+ │ Node A ┤──────┐ │ Node B ┤────────────►│ Node C ┤──────┌─────►│ Node D │░
91
+ │ │░ │ │ │░ │ │░ │ │ │░
92
+ └──────────┘░ │ └──────────┘░ └──────────┘░ │ └──────────┘░
93
+ ░░░░░░░░░░░░ │ ░░░░░░░░░░░░ ░░░░░░░░░░░░ │ ░░░░░░░░░░░░
94
+ │ │
95
+ │ │
96
+ │ │
97
+ └─────────────────────────────────────────────────┘
98
+ ```
99
+
100
+
101
+ <p align="center">
102
+ <img src="/imgs/README_example.png" align="middle"/>
103
+ </p>
104
+
105
+
106
+ <p align="center">
107
+ <img src="/imgs/README_example2.png" align="middle"/>
108
+ </p>
109
+
110
+
111
+ ## Installation
112
+
113
+ ```bash
114
+ pip install retroflow
115
+ ```
116
+
117
+ Or with [uv](https://github.com/astral-sh/uv):
118
+
119
+ ```bash
120
+ uv add retroflow
121
+ ```
122
+
123
+ ## Quick Start
124
+
125
+ ```python
126
+ from retroflow import FlowchartGenerator
127
+
128
+ # Create a generator
129
+ generator = FlowchartGenerator()
130
+
131
+ # Define your flowchart using simple arrow syntax
132
+ flowchart = generator.generate("""
133
+ Start -> Process
134
+ Process -> Decision
135
+ Decision -> End
136
+ """)
137
+
138
+ print(flowchart)
139
+ ```
140
+
141
+ ## Features
142
+
143
+ - **Simple syntax**: Define flowcharts using intuitive `A -> B` arrow notation
144
+ - **ASCII output**: Generate text-based flowcharts for terminals and documentation
145
+ - **PNG export**: Save high-resolution PNG images with customizable fonts
146
+ - **Intelligent layout**: Automatic node positioning using NetworkX with barycenter heuristic
147
+ - **Smart edge routing**: Edges automatically route around intermediate boxes to avoid visual overlap
148
+ - **Cycle detection**: Handles cyclic graphs gracefully with back-edge routing
149
+ - **Customizable**: Adjust text width, box sizes, spacing, shadows, and fonts
150
+ - **Unicode box-drawing**: Beautiful boxes with optional shadow effects
151
+ - **Title banners**: Optional double-line bordered titles with automatic word wrapping
152
+ - **Horizontal flow**: Left-to-right layout mode for compact linear diagrams
153
+
154
+ ## Usage
155
+
156
+ ### Basic Generation
157
+
158
+ ```python
159
+ from retroflow import FlowchartGenerator
160
+
161
+ generator = FlowchartGenerator()
162
+
163
+ # Simple linear flow
164
+ result = generator.generate("""
165
+ A -> B
166
+ B -> C
167
+ C -> D
168
+ """)
169
+ print(result)
170
+ ```
171
+
172
+ ### Branching Flows
173
+
174
+ ```python
175
+ # Branching and merging
176
+ result = generator.generate("""
177
+ Start -> Validate
178
+ Validate -> Process
179
+ Validate -> Error
180
+ Process -> End
181
+ Error -> End
182
+ """)
183
+ print(result)
184
+ ```
185
+
186
+ ### Cyclic Flows
187
+
188
+ ```python
189
+ # Loops and cycles are supported
190
+ result = generator.generate("""
191
+ Init -> Check
192
+ Check -> Process
193
+ Process -> Check
194
+ Check -> Done
195
+ """)
196
+ print(result)
197
+ ```
198
+
199
+ ### Export to Text File
200
+
201
+ ```python
202
+ generator = FlowchartGenerator()
203
+
204
+ generator.save_txt("""
205
+ A -> B
206
+ B -> C
207
+ """, "flowchart.txt")
208
+ ```
209
+
210
+ ### Export to PNG
211
+
212
+ Save your flowchart as a high-resolution PNG image:
213
+
214
+ ```python
215
+ generator = FlowchartGenerator()
216
+
217
+ generator.save_png("""
218
+ A -> B
219
+ B -> C
220
+ """, "flowchart.png")
221
+ ```
222
+
223
+ Customize the PNG output with various options:
224
+
225
+ ```python
226
+ generator.save_png(
227
+ "A -> B\nB -> C",
228
+ "flowchart.png",
229
+ font_size=24, # Base font size in points (default: 16)
230
+ bg_color="#1a1a2e", # Background color (default: "#FFFFFF")
231
+ fg_color="#00ff00", # Text color (default: "#000000")
232
+ padding=40, # Padding around diagram in pixels (default: 20)
233
+ scale=2, # Resolution multiplier for crisp output (default: 2)
234
+ )
235
+ ```
236
+
237
+ The `scale` parameter controls the output resolution. With the default `scale=2`, images render at 2x resolution for crisp display on high-DPI/retina screens. Use `scale=1` for smaller file sizes, or `scale=3` for even sharper output.
238
+
239
+ ## Configuration
240
+
241
+ ### FlowchartGenerator Options
242
+
243
+ ```python
244
+ generator = FlowchartGenerator(
245
+ max_text_width=22, # Max width for text inside boxes before wrapping (default: 22)
246
+ min_box_width=10, # Minimum box width (default: 10)
247
+ horizontal_spacing=12, # Space between boxes horizontally (default: 12)
248
+ vertical_spacing=6, # Space between boxes vertically (default: 6)
249
+ shadow=True, # Whether to draw box shadows (default: True)
250
+ font="Cascadia Code", # Font for PNG output (default: None, uses system font)
251
+ title="My Diagram", # Optional title banner with double-line border (default: None)
252
+ direction="TB", # Flow direction: "TB" (top-to-bottom) or "LR" (left-to-right)
253
+ )
254
+ ```
255
+
256
+ ### Font Configuration
257
+
258
+ You can specify a font for PNG output either at initialization or per-call:
259
+
260
+ ```python
261
+ # Set font for all PNG exports from this generator
262
+ generator = FlowchartGenerator(font="Cascadia Code")
263
+ generator.save_png("A -> B", "flowchart.png")
264
+
265
+ # Or override the font for a specific export
266
+ generator.save_png("A -> B", "flowchart.png", font="Monaco")
267
+ ```
268
+
269
+ Common monospace fonts that work well:
270
+ - **Windows**: `Cascadia Code`, `Consolas`, `Courier New`
271
+ - **macOS**: `Monaco`, `Menlo`, `SF Mono`
272
+ - **Linux**: `DejaVu Sans Mono`, `Ubuntu Mono`, `Liberation Mono`
273
+
274
+ If the specified font isn't found, RetroFlow automatically falls back to available system fonts.
275
+
276
+ ### Title Banner
277
+
278
+ Add a title banner with a double-line border above your flowchart:
279
+
280
+ ```python
281
+ generator = FlowchartGenerator(title="CI/CD Pipeline")
282
+ result = generator.generate("""
283
+ Build -> Test
284
+ Test -> Deploy
285
+ """)
286
+ ```
287
+
288
+ Output:
289
+ ```
290
+ ╔══════════════════╗
291
+ ║ CI/CD Pipeline ║
292
+ ╚══════════════════╝
293
+
294
+ ┌─────────┐
295
+ │ Build │░
296
+ └────┬────┘░
297
+ ░░░░│░░░░░░
298
+
299
+
300
+ ┌─────────┐
301
+ │ Test │░
302
+ └────┬────┘░
303
+ ░░░░│░░░░░░
304
+
305
+
306
+ ┌──────────┐
307
+ │ Deploy │░
308
+ └──────────┘░
309
+ ░░░░░░░░░░░░
310
+ ```
311
+
312
+ **Title Wrapping**: Long titles automatically wrap at word boundaries (approximately every 15 characters) to keep the title box compact:
313
+
314
+ ```python
315
+ generator = FlowchartGenerator(title="My Very Long Project Title Here")
316
+ ```
317
+
318
+ ```
319
+ ╔═════════════════╗
320
+ ║ My Very Long ║
321
+ ║ Project Title ║
322
+ ║ Here ║
323
+ ╚═════════════════╝
324
+ ```
325
+
326
+ You can also override the title per-call:
327
+ ```python
328
+ generator.generate("A -> B", title="Override Title")
329
+ ```
330
+
331
+ ### Horizontal Flow Mode
332
+
333
+ Use `direction="LR"` for left-to-right layouts instead of top-to-bottom:
334
+
335
+ ```python
336
+ generator = FlowchartGenerator(direction="LR")
337
+ result = generator.generate("""
338
+ Start -> Process
339
+ Process -> End
340
+ """)
341
+ ```
342
+
343
+ This produces a horizontal flowchart where nodes flow from left to right, which can be more compact for linear processes.
344
+
345
+ ## Input Format
346
+
347
+ The input format uses a simple arrow syntax:
348
+
349
+ ```
350
+ # Comments start with #
351
+ NodeA -> NodeB
352
+ NodeB -> NodeC
353
+
354
+ # Node names can contain spaces
355
+ User Login -> Validate Credentials
356
+ Validate Credentials -> Access Granted
357
+ ```
358
+
359
+ ### Rules
360
+
361
+ - Each line defines one connection: `Source -> Target`
362
+ - Node names are trimmed of whitespace
363
+ - Empty lines are ignored
364
+ - Lines starting with `#` are comments
365
+ - Node names can contain spaces
366
+
367
+ ## API Reference
368
+
369
+ ### FlowchartGenerator
370
+
371
+ The main class for generating flowcharts.
372
+
373
+ #### Methods
374
+
375
+ | Method | Description |
376
+ |--------|-------------|
377
+ | `generate(input_text)` | Generate ASCII flowchart string |
378
+ | `save_txt(input_text, filename)` | Save flowchart to a text file |
379
+ | `save_png(input_text, filename, ...)` | Save flowchart as a PNG image |
380
+
381
+ ### Convenience Functions
382
+
383
+ ```python
384
+ from retroflow import parse_flowchart
385
+
386
+ # Parse without rendering
387
+ connections = parse_flowchart("A -> B\nB -> C")
388
+ # Returns: [('A', 'B'), ('B', 'C')]
389
+ ```
390
+
391
+ ### Lower-Level API
392
+
393
+ For advanced use cases, you can access the individual components:
394
+
395
+ ```python
396
+ from retroflow import (
397
+ Parser,
398
+ SugiyamaLayout, # Alias for NetworkXLayout
399
+ Canvas,
400
+ BoxRenderer,
401
+ )
402
+
403
+ # Parse input
404
+ parser = Parser()
405
+ connections = parser.parse("A -> B\nB -> C")
406
+
407
+ # Compute layout
408
+ layout_engine = SugiyamaLayout()
409
+ layout_result = layout_engine.layout(connections)
410
+
411
+ # Access layout information
412
+ for node_name, node_layout in layout_result.nodes.items():
413
+ print(f"{node_name}: layer={node_layout.layer}, position={node_layout.position}")
414
+ ```
415
+
416
+ ## Development
417
+
418
+ ### Setup
419
+
420
+ ```bash
421
+ git clone https://github.com/ronikobrosly/retroflow.git
422
+ cd retroflow
423
+ uv sync --dev
424
+ ```
425
+
426
+ ### Run Tests
427
+
428
+ ```bash
429
+ uv run pytest
430
+ ```
431
+
432
+ ### Run Linting
433
+
434
+ ```bash
435
+ uvx ruff check .
436
+ uvx ruff format --check .
437
+ ```
438
+
439
+ ## License
440
+
441
+ MIT License - see [LICENSE](LICENSE) for details.
442
+
443
+ ## Contributing
444
+
445
+ Contributions are 100% welcome! Please feel free to submit a PR.
@@ -0,0 +1,11 @@
1
+ retroflow/__init__.py,sha256=nLV_7Dy6m2oW4U17JRcTtETPg2G4rbv6FhN-A3k-dS4,1050
2
+ retroflow/generator.py,sha256=q4G2xqHmaDU3AuECARlz0dGSjd4nwAmWtJa-BzeeN5w,73036
3
+ retroflow/layout.py,sha256=C0vuhnGSaW46uie4lcu1RrSB3ccXErLBhSONWk5jzAU,7336
4
+ retroflow/parser.py,sha256=Z5_QJexjdh6-Wge-pxqqYEYoMdeKRwsjL64ueN_MhRY,2600
5
+ retroflow/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ retroflow/renderer.py,sha256=n47KaQIsvgg9Pr3016-6pRhNVbuv_lz5p0YSYLX5yFs,16211
7
+ retroflow/router.py,sha256=ledYdbJcID2UmLOMnLP_1aOpVxAfZLHTWRyYc9pkc5c,10878
8
+ retroflow-0.8.2.dist-info/METADATA,sha256=bSdABVBgL9F1Cp5LXm4FUmelGKi6dPLQOSle3eWYjys,14931
9
+ retroflow-0.8.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
10
+ retroflow-0.8.2.dist-info/licenses/LICENSE,sha256=pxkJvysic-mY3ELfi-ts2445liyatgXLCbZig1vnhZA,1070
11
+ retroflow-0.8.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Roni Kobrosly
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.