libpetri_export/lib.rs
1//! # libpetri-export — DOT/Graphviz Export Pipeline
2//!
3//! Converts a [`PetriNet`](libpetri_core::petri_net::PetriNet) into a
4//! DOT string for Graphviz rendering.
5//!
6//! ## Architecture
7//!
8//! The pipeline has four layers, separating concerns cleanly:
9//!
10//! ```text
11//! PetriNet ──► map_to_graph() ──► Graph ──► render_dot() ──► DOT string
12//! (knows Petri nets) (format-agnostic)
13//! ```
14//!
15//! 1. **Styles** ([`styles`]) — Color/shape constants from the shared spec
16//! 2. **Graph model** ([`graph`]) — Format-agnostic typed graph (nodes, edges, clusters)
17//! 3. **Mapper** ([`mapper`]) — Petri net → Graph (place classification, arc styling)
18//! 4. **Renderer** ([`dot_renderer`]) — Graph → DOT string (no Petri net knowledge)
19//!
20//! ## Quick Start
21//!
22//! ```rust
23//! use libpetri_core::place::Place;
24//! use libpetri_core::transition::Transition;
25//! use libpetri_core::petri_net::PetriNet;
26//! use libpetri_core::input::one;
27//! use libpetri_core::output::out_place;
28//! use libpetri_core::action::fork;
29//! use libpetri_export::dot_exporter::dot_export;
30//!
31//! let p1 = Place::<i32>::new("input");
32//! let p2 = Place::<i32>::new("output");
33//!
34//! let t = Transition::builder("process")
35//! .input(one(&p1))
36//! .output(out_place(&p2))
37//! .action(fork())
38//! .build();
39//!
40//! let net = PetriNet::builder("example").transition(t).build();
41//! let dot = dot_export(&net, None);
42//!
43//! assert!(dot.contains("digraph"));
44//! ```
45//!
46//! ## Example Output
47//!
48#![doc = include_str!("../doc/export_example.svg")]
49//!
50//! ## Configuration
51//!
52//! [`DotConfig`](mapper::DotConfig) controls rendering:
53//!
54//! | Field | Default | Effect |
55//! |-------|---------|--------|
56//! | `direction` | `TopToBottom` | Graph layout direction |
57//! | `show_types` | `true` | Display place token types |
58//! | `show_intervals` | `true` | Display timing intervals on transitions |
59//! | `show_priority` | `true` | Display priority values |
60//! | `environment_places` | `{}` | Place names styled as external event sources |
61//!
62//! ## Visual Vocabulary
63//!
64//! - **Green** circles — start places (no incoming arcs)
65//! - **Blue** circles — end places (no outgoing arcs)
66//! - **Red** dashed circles — environment places (external event injection)
67//! - **Solid** arrows — input/output arcs
68//! - **Dashed** arrows — read arcs
69//! - **Dot-headed** arrows — inhibitor arcs
70//! - **Double** arrows — reset arcs
71
72pub mod dot_exporter;
73pub mod dot_renderer;
74pub mod graph;
75pub mod mapper;
76pub mod styles;