This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-23485-ascii-art-renderer
in repository https://gitbox.apache.org/repos/asf/camel.git

commit e22f003db138f3ad45afd22c71b55646ae744baa
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue May 12 13:48:21 2026 +0200

    CAMEL-23485: camel-diagram - Update documentation for ASCII art renderer
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
 .../camel-diagram/src/main/docs/diagram.adoc       | 88 +++++++++++++++++++++-
 1 file changed, 84 insertions(+), 4 deletions(-)

diff --git a/components/camel-diagram/src/main/docs/diagram.adoc 
b/components/camel-diagram/src/main/docs/diagram.adoc
index d4517d27a0c8..49b08cdc5d87 100644
--- a/components/camel-diagram/src/main/docs/diagram.adoc
+++ b/components/camel-diagram/src/main/docs/diagram.adoc
@@ -10,14 +10,15 @@
 *Since Camel {since}*
 
 The Diagram module provides route diagram rendering capabilities for Apache 
Camel routes.
-It can generate visual route diagrams as PNG images representations from route 
structure data.
+It can generate visual route diagrams as PNG images or plain ASCII art text 
representations from route structure data.
 
 == Features
 
 * Render route diagrams as PNG images with colored nodes and scope boxes
+* Render route diagrams as plain ASCII art text for terminal output
 * Support for all Camel EIPs: choice, doTry/doCatch, filter, split, loop, 
multicast, and more
-* Scope boxes visually group branching and scoping EIPs
-* Multiple color themes: dark, light, transparent, or custom
+* Scope boxes visually group branching and scoping EIPs (PNG only)
+* Multiple color themes: dark, light, transparent, or custom (PNG only)
 
 == Usage
 
@@ -35,7 +36,7 @@ Add the `camel-diagram` dependency to your project:
 
 ==== Using Camel Java API
 
-You can use the diagram render with Camel based APIs such as:
+You can use the diagram renderer with the Camel API to render as PNG images:
 
 [source,java]
 ----
@@ -43,6 +44,14 @@ RouteDiagramDumper dumper = 
PluginHelper.getRouteDiagramDumper(context);
 BufferedImage image = dumper.dumpRoutesAsImage("*", 
RouteDiagramDumper.Theme.DARK);
 ----
 
+Or render as ASCII art text:
+
+[source,java]
+----
+RouteDiagramDumper dumper = PluginHelper.getRouteDiagramDumper(context);
+String ascii = dumper.dumpRoutesAsAsciiArt("*");
+----
+
 ==== Using standalone Java API
 
 Then use the API to render diagrams:
@@ -68,6 +77,25 @@ BufferedImage image = renderer.renderDiagram(List.of(lr), 
lr.maxY + RouteDiagram
 ImageIO.write(image, "PNG", new File("diagram.png"));
 ----
 
+To render as ASCII art instead:
+
+[source,java]
+----
+import org.apache.camel.diagram.*;
+import org.apache.camel.diagram.RouteDiagramLayoutEngine.*;
+
+// Parse route structure from JSON
+List<RouteInfo> routes = RouteDiagramHelper.parseRoutes(jsonObject);
+
+// Layout and render as ASCII
+RouteDiagramLayoutEngine engine = new RouteDiagramLayoutEngine();
+LayoutRoute lr = engine.layoutRoute(routes.get(0), 
RouteDiagramLayoutEngine.PADDING);
+
+RouteDiagramAsciiRenderer renderer = new 
RouteDiagramAsciiRenderer(engine.getNodeWidth());
+String ascii = renderer.renderDiagram(List.of(lr), lr.maxY + 
RouteDiagramLayoutEngine.V_GAP);
+System.out.println(ascii);
+----
+
 === With Camel JBang
 
 The diagram rendering is used by the `camel cmd route-diagram` command in 
Camel JBang:
@@ -100,3 +128,55 @@ To use dark theme
 ----
 camel cmd route-diagram MyRoute.java --theme=dark
 ----
+
+== ASCII Art Rendering
+
+The ASCII art renderer produces plain text diagrams using box-drawing 
characters.
+This is useful for terminal output where images cannot be displayed.
+
+Nodes are drawn as boxes using `+`, `-`, and `|` characters, with arrows using 
`|` and `v`.
+Branching EIPs (choice, multicast, etc.) produce L-shaped arrows with 
horizontal connector lines.
+Long labels are automatically wrapped to fit within the box width.
+
+Example output for a simple route:
+
+----
+route1
+    +----------------------+
+    |      timer:tick      |
+    +----------------------+
+                |
+                |
+                |
+                v
+    +----------------------+
+    |        log:a         |
+    +----------------------+
+----
+
+Example output for a branching route with choice:
+
+----
+route1
+                  +----------------------+
+                  |      timer:tick      |
+                  +----------------------+
+                              |
+                              v
+                  +----------------------+
+                  |       choice()       |
+                  +----------------------+
+                              |
+              +---------------+---------------+
+              v                               v
+  +----------------------+        +----------------------+
+  |      when(...)       |        |     otherwise()      |
+  +----------------------+        +----------------------+
+              |                               |
+              v                               v
+  +----------------------+        +----------------------+
+  |        log:a         |        |        log:b         |
+  +----------------------+        +----------------------+
+----
+
+NOTE: Scope boxes (dotted boundaries for filter, split, etc.) are not included 
in ASCII art rendering.

Reply via email to