Skip to content

Commit 6511042

Browse files
committed
feat(demo): add Mermaid demo package and generator script
1 parent 5fb7cac commit 6511042

File tree

12 files changed

+268
-0
lines changed

12 files changed

+268
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The format is based on Keep a Changelog, and this project follows Semantic Versi
1212
- Added `orgscript check <file> --json` for machine-readable combined quality diagnostics.
1313
- Added `npm run check:all` and switched CI to the combined quality path.
1414
- Added `orgscript export mermaid <file>` for first-pass Mermaid exports of processes and stateflows.
15+
- Added `npm run demo:generate` plus a Mermaid demo package with generated Markdown and `.mmd` artifacts.
1516
- Added a canonical master language spec and lightweight governance guidance.
1617
- Added an example catalog and an initial VS Code syntax-highlighting scaffold.
1718

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,21 @@ process CraftBusinessLeadToOrder
7171

7272
See the full example in [`examples/craft-business-lead-to-order.orgs`](examples/craft-business-lead-to-order.orgs).
7373

74+
## From Source To Diagram
75+
76+
OrgScript already generates visible downstream artifacts.
77+
78+
Minimal Mermaid demos live in [`docs/demos/mermaid/README.md`](docs/demos/mermaid/README.md):
79+
80+
- process demo from [`examples/lead-qualification.orgs`](examples/lead-qualification.orgs) to [`docs/demos/mermaid/lead-qualification.mermaid.md`](docs/demos/mermaid/lead-qualification.mermaid.md)
81+
- stateflow demo from [`examples/order-approval.orgs`](examples/order-approval.orgs) to [`docs/demos/mermaid/order-approval.mermaid.md`](docs/demos/mermaid/order-approval.mermaid.md)
82+
83+
Generate the demo artifacts with:
84+
85+
```text
86+
npm run demo:generate
87+
```
88+
7489
## Why this matters
7590

7691
- Teams get a shared source of truth for operational logic.
@@ -126,6 +141,7 @@ See the full example in [`examples/craft-business-lead-to-order.orgs`](examples/
126141
- [`docs/repository-structure.md`](docs/repository-structure.md)
127142
- [`docs/syntax.md`](docs/syntax.md)
128143
- [`docs/semantics.md`](docs/semantics.md)
144+
- [`docs/demos/mermaid/README.md`](docs/demos/mermaid/README.md)
129145
- [`examples/README.md`](examples/README.md)
130146
- [`spec/grammar.ebnf`](spec/grammar.ebnf)
131147
- [`spec/language-spec.md`](spec/language-spec.md)
@@ -346,6 +362,7 @@ See [`docs/cli-v0.1-plan.md`](docs/cli-v0.1-plan.md) for the implementation plan
346362
```text
347363
npm test
348364
npm run export:mermaid
365+
npm run demo:generate
349366
npm run check
350367
npm run check:all
351368
npm run format:check:all

docs/demos/mermaid/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Mermaid demos
2+
3+
This folder shows the shortest useful path from OrgScript source to generated diagram artifacts.
4+
5+
Each demo keeps the source file in `examples/` and generates two downstream artifacts here:
6+
7+
- `*.mermaid.md`: a Markdown document ready for GitHub rendering
8+
- `*.mmd`: the first extracted Mermaid diagram block for direct Mermaid tooling use
9+
10+
## Generate
11+
12+
```text
13+
npm run demo:generate
14+
```
15+
16+
## Demos
17+
18+
| Demo | Source | Markdown artifact | Mermaid artifact |
19+
| --- | --- | --- | --- |
20+
| Lead qualification process | [lead-qualification.orgs](../../../examples/lead-qualification.orgs) | [lead-qualification.mermaid.md](./lead-qualification.mermaid.md) | [lead-qualification.mmd](./lead-qualification.mmd) |
21+
| | | | A compact process example that shows trigger, branching, assignment, notification, and state transition. |
22+
| Order approval stateflow | [order-approval.orgs](../../../examples/order-approval.orgs) | [order-approval.mermaid.md](./order-approval.mermaid.md) | [order-approval.mmd](./order-approval.mmd) |
23+
| | | | A stateflow-focused example that also demonstrates how Mermaid export skips unsupported blocks while still producing useful output. |
24+
25+
## Notes
26+
27+
- These artifacts are generated from the current exporter implementation.
28+
- `order-approval` intentionally demonstrates the current behavior where unsupported blocks are skipped and called out in the generated Markdown.
29+
- If you change Mermaid export behavior, regenerate this folder with `npm run demo:generate` and review the diffs.
30+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# OrgScript Mermaid Export
2+
3+
## Process: LeadQualification
4+
5+
```mermaid
6+
flowchart TD
7+
p1_start_1(["LeadQualification"])
8+
p1_action_2["when lead.created"]
9+
p1_decision_3{"if lead.source = &quot;referral&quot;"}
10+
p1_action_4["assign lead.priority = &quot;high&quot;"]
11+
p1_action_5["assign lead.path = &quot;premium&quot;"]
12+
p1_action_6["notify sales with &quot;New referral lead&quot;"]
13+
p1_decision_7{"if lead.source = &quot;ads&quot;"}
14+
p1_action_8["assign lead.priority = &quot;normal&quot;"]
15+
p1_action_9["assign lead.path = &quot;standard&quot;"]
16+
p1_decision_10{"if lead.budget < 10000"}
17+
p1_action_11["transition lead.status to &quot;disqualified&quot;"]
18+
p1_action_12["notify sales with &quot;Budget below threshold&quot;"]
19+
p1_stop_13(["stop"])
20+
p1_action_14["transition lead.status to &quot;qualified&quot;"]
21+
p1_end_15(["done"])
22+
p1_start_1 --> p1_action_2
23+
p1_action_2 --> p1_decision_3
24+
p1_decision_3 -->|yes| p1_action_4
25+
p1_action_4 --> p1_action_5
26+
p1_action_5 --> p1_action_6
27+
p1_decision_3 -->|no| p1_decision_7
28+
p1_decision_7 -->|yes| p1_action_8
29+
p1_action_8 --> p1_action_9
30+
p1_action_6 --> p1_decision_10
31+
p1_action_9 --> p1_decision_10
32+
p1_decision_7 -->|no| p1_decision_10
33+
p1_decision_10 -->|yes| p1_action_11
34+
p1_action_11 --> p1_action_12
35+
p1_action_12 --> p1_stop_13
36+
p1_decision_10 -->|no| p1_action_14
37+
p1_action_14 --> p1_end_15
38+
```
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
flowchart TD
2+
p1_start_1(["LeadQualification"])
3+
p1_action_2["when lead.created"]
4+
p1_decision_3{"if lead.source = &quot;referral&quot;"}
5+
p1_action_4["assign lead.priority = &quot;high&quot;"]
6+
p1_action_5["assign lead.path = &quot;premium&quot;"]
7+
p1_action_6["notify sales with &quot;New referral lead&quot;"]
8+
p1_decision_7{"if lead.source = &quot;ads&quot;"}
9+
p1_action_8["assign lead.priority = &quot;normal&quot;"]
10+
p1_action_9["assign lead.path = &quot;standard&quot;"]
11+
p1_decision_10{"if lead.budget < 10000"}
12+
p1_action_11["transition lead.status to &quot;disqualified&quot;"]
13+
p1_action_12["notify sales with &quot;Budget below threshold&quot;"]
14+
p1_stop_13(["stop"])
15+
p1_action_14["transition lead.status to &quot;qualified&quot;"]
16+
p1_end_15(["done"])
17+
p1_start_1 --> p1_action_2
18+
p1_action_2 --> p1_decision_3
19+
p1_decision_3 -->|yes| p1_action_4
20+
p1_action_4 --> p1_action_5
21+
p1_action_5 --> p1_action_6
22+
p1_decision_3 -->|no| p1_decision_7
23+
p1_decision_7 -->|yes| p1_action_8
24+
p1_action_8 --> p1_action_9
25+
p1_action_6 --> p1_decision_10
26+
p1_action_9 --> p1_decision_10
27+
p1_decision_7 -->|no| p1_decision_10
28+
p1_decision_10 -->|yes| p1_action_11
29+
p1_action_11 --> p1_action_12
30+
p1_action_12 --> p1_stop_13
31+
p1_decision_10 -->|no| p1_action_14
32+
p1_action_14 --> p1_end_15
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# OrgScript Mermaid Export
2+
3+
## Stateflow: OrderStatus
4+
5+
```mermaid
6+
stateDiagram-v2
7+
state "draft" as s1_state_1
8+
state "pending_approval" as s1_state_2
9+
state "approved" as s1_state_3
10+
state "production" as s1_state_4
11+
state "completed" as s1_state_5
12+
state "cancelled" as s1_state_6
13+
s1_state_1 --> s1_state_2
14+
s1_state_2 --> s1_state_3
15+
s1_state_3 --> s1_state_4
16+
s1_state_4 --> s1_state_5
17+
s1_state_1 --> s1_state_6
18+
s1_state_2 --> s1_state_6
19+
```
20+
21+
> Note: Mermaid export currently supports only process and stateflow blocks. Skipped: rule NoProductionWithoutApproval.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
stateDiagram-v2
2+
state "draft" as s1_state_1
3+
state "pending_approval" as s1_state_2
4+
state "approved" as s1_state_3
5+
state "production" as s1_state_4
6+
state "completed" as s1_state_5
7+
state "cancelled" as s1_state_6
8+
s1_state_1 --> s1_state_2
9+
s1_state_2 --> s1_state_3
10+
s1_state_3 --> s1_state_4
11+
s1_state_4 --> s1_state_5
12+
s1_state_1 --> s1_state_6
13+
s1_state_2 --> s1_state_6

docs/repository-structure.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ spec/
1616
docs/
1717
governance.md
1818
cli-v0.1-plan.md
19+
demos/
20+
mermaid/
21+
README.md
22+
lead-qualification.mermaid.md
23+
lead-qualification.mmd
24+
order-approval.mermaid.md
25+
order-approval.mmd
1926
language-principles.md
2027
manifesto.md
2128
repository-structure.md

docs/roadmaps/v0.4.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Make OrgScript easier to use in daily development, CI, and editor workflows with
2121
- JSON diagnostics examples in the README and diagnostics spec
2222
- canonical language spec and governance notes
2323
- initial VS Code syntax-highlighting scaffold
24+
- Mermaid demo package with generated Markdown and `.mmd` artifacts
2425

2526
## Non-goals
2627

examples/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ node ./bin/orgscript.js validate ./examples/lead-qualification.orgs
3232
node ./bin/orgscript.js check ./examples/craft-business-lead-to-order.orgs
3333
node ./bin/orgscript.js export mermaid ./examples/order-approval.orgs
3434
```
35+
36+
For generated Mermaid demo artifacts, see [`../docs/demos/mermaid/README.md`](../docs/demos/mermaid/README.md).

0 commit comments

Comments
 (0)