From 880c4d4ed696a2c36e59cb3d16173d2de68c0d7e Mon Sep 17 00:00:00 2001 From: NicolasNewman Date: Tue, 23 Jul 2024 15:31:11 -0500 Subject: [PATCH] feat(arch): updated syntax & demos/docs to reflect changes --- demos/architecture.html | 122 +++++++++--------- docs/syntax/architecture.md | 50 +++---- .../mermaid/src/docs/syntax/architecture.md | 32 ++--- .../architecture/architecture.langium | 12 +- 4 files changed, 112 insertions(+), 104 deletions(-) diff --git a/demos/architecture.html b/demos/architecture.html index 02f7c0a11..deacbc242 100644 --- a/demos/architecture.html +++ b/demos/architecture.html @@ -26,10 +26,10 @@ service server(server)[Server] in api service gateway(internet)[Gateway] - db L--R server - disk1 T--B server - disk2 T--B db - server T--B gateway + db:L -- R:server + disk1:T -- B:server + disk2:T -- B:db + server:T -- B:gateway
@@ -49,11 +49,11 @@ service gateway(internet)[Gateway] in api - serv1 B--T serv2 + serv1:B -- T:serv2 - serv2 L--R db + serv2:L -- R:db - serv1 L--R gateway + serv1:L -- R:gateway
@@ -73,10 +73,10 @@ service serv2(server)[Server 2] service disk(disk)[Disk] - db L--R s3 - serv1 L--T s3 - serv2 L--B s3 - serv1 T--B disk + db:L -- R:s3 + serv1:L -- T:s3 + serv2:L -- B:s3 + serv1:T -- B:disk
@@ -89,15 +89,15 @@ service servT(server)[Server 4] service servB(server)[Server 5] - servC (L--R) servL - servC (R--L) servR - servC (T--B) servT - servC (B--T) servB + servC:L <--> R:servL + servC:R <--> L:servR + servC:T <--> B:servT + servC:B <--> T:servB - servL (T--L) servT - servL (B--L) servB - servR (T--R) servT - servR (B--R) servB + servL:T <--> L:servT + servL:B <--> L:servB + servR:T <--> R:servT + servR:B <--> R:servB
       architecture-beta
@@ -107,15 +107,15 @@
         service servT(server)[Server 4]
         service servB(server)[Server 5]
 
-        servC (L--R) servL
-        servC (R--L) servR
-        servC (T--B) servT
-        servC (B--T) servB
+        servC:L <--> R:servL
+        servC:R <--> L:servR
+        servC:T <--> B:servT
+        servC:B <--> T:servB
 
-        servT (L--T) servL
-        servB (L--B) servL
-        servT (R--T) servR
-        servB (R--B) servR
+        servT:L <--> T:servL
+        servB:L <--> B:servL
+        servT:R <--> T:servR
+        servB:R <--> B:servR
     

@@ -134,10 +134,10 @@ service bottom_disk(disk)[Disk] in bottom_group service center_disk(disk)[Disk] in center_group - left_disk{group} (R--L) center_disk{group} - right_disk{group} (L--R) center_disk{group} - top_disk{group} (B--T) center_disk{group} - bottom_disk{group} (T--B) center_disk{group} + left_disk{group}:R <--> L:center_disk{group} + right_disk{group}:L <--> R:center_disk{group} + top_disk{group}:B <--> T:center_disk{group} + bottom_disk{group}:T <--> B:center_disk{group}
@@ -151,15 +151,15 @@ service servT(server)[Server 4] service servB(server)[Server 5] - servC L-[Label]-R servL - servC R-[Label]-L servR - servC T-[Label]-B servT - servC B-[Label]-T servB + servC:L -[Label]- R:servL + servC:R -[Label]- L:servR + servC:T -[Label]- B:servT + servC:B -[Label]- T:servB - servL T-[Label]-L servT - servL B-[Label]-L servB - servR T-[Label]-R servT - servR B-[Label]-R servB + servL:T -[Label]- L:servT + servL:B -[Label]- L:servB + servR:T -[Label]- R:servT + servR:B -[Label]- R:servB
       architecture-beta
@@ -169,15 +169,15 @@
         service servT(server)[Server 4]
         service servB(server)[Server 5]
 
-        servC L-[Label that is Long]-R servL
-        servC R-[Label that is Long]-L servR
-        servC T-[Label that is Long]-B servT
-        servC B-[Label that is Long]-T servB
+        servC:L -[Label that is Long]- R:servL
+        servC:R -[Label that is Long]- L:servR
+        servC:T -[Label that is Long]- B:servT
+        servC:B -[Label that is Long]- T:servB
 
-        servL T-[Label that is Long]-L servT
-        servL B-[Label that is Long]-L servB
-        servR T-[Label that is Long]-R servT
-        servR B-[Label that is Long]-R servB
+        servL:T -[Label that is Long]- L:servT
+        servL:B -[Label that is Long]- L:servB
+        servR:T -[Label that is Long]- R:servT
+        servR:B -[Label that is Long]- R:servB
     

@@ -192,12 +192,12 @@ junction juncC junction juncR - left_disk R--L juncC - top_disk B--T juncC - bottom_disk T--B juncC - juncC R--L juncR - top_gateway B--T juncR - bottom_gateway T--B juncR + left_disk:R -- L:juncC + top_disk:B -- T:juncC + bottom_disk:T -- B:juncC + juncC:R -- L:juncR + top_gateway:B -- T:juncR + bottom_gateway:T -- B:juncR
@@ -214,15 +214,15 @@ junction juncC in left junction juncR in right - left_disk R--L juncC - top_disk B--T juncC - bottom_disk T--B juncC + left_disk:R -- L:juncC + top_disk:B -- T:juncC + bottom_disk:T -- B:juncC - top_gateway (B--T juncR - bottom_gateway (T--B juncR + top_gateway:B <-- T:juncR + bottom_gateway:T <-- B:juncR - juncC{group} R--L) juncR{group} + juncC{group}:R --> L:juncR{group}
@@ -233,8 +233,8 @@ service ec2(aws:ec2)[Server] service wave(aws:wavelength)[Wave] - s3 L--R ec2 - s3 T--B wave + s3:L -- R:ec2 + s3:T -- B:wave diff --git a/docs/syntax/architecture.md b/docs/syntax/architecture.md index 361e84aa8..2d71d84fb 100644 --- a/docs/syntax/architecture.md +++ b/docs/syntax/architecture.md @@ -19,9 +19,9 @@ architecture-beta service disk2(disk)[Storage] in api service server(server)[Server] in api - db L--R server - disk1 T--B server - disk2 T--B db + db:L -- R:server + disk1:T -- B:server + disk2:T -- B:db ``` ```mermaid @@ -33,9 +33,9 @@ architecture-beta service disk2(disk)[Storage] in api service server(server)[Server] in api - db L--R server - disk1 T--B server - disk2 T--B db + db:L -- R:server + disk1:T -- B:server + disk2:T -- B:db ``` ## Syntax @@ -95,35 +95,35 @@ service database(db)[Database] in private_api The syntax for declaring an edge is: ``` -{serviceId}{{group}}? {(}?{T|B|L|R}--{T|B|L|R}{)}? {serviceId}{{group}}? +{serviceId}{{group}}?:{T|B|L|R} {<}?--{>}? {T|B|L|R}:{serviceId}{{group}}? ``` #### Edge Direction -The side of the service the edge comes out of is specified by adding `L|R|T|B` to each end of `--`. +The side of the service the edge comes out of is specified by adding a colon (`:`) to the side of the service connecting to the arrow and adding `L|R|T|B` For example: ``` -db R--L server +db:R -- L:server ``` creates an edge between the services `db` and `server`, with the edge coming out of the right of `db` and the left of `server`. ``` -db T--L server +db:T -- L:server ``` creates a 90 degree edge between the services `db` and `server`, with the edge coming out of the top of `db` and the left of `server`. #### Arrows -Arrows can be added to each side of an edge by adding `(` before the direction on the left, and/or `)` after the direction on the right. +Arrows can be added to each side of an edge by adding `<` before the direction on the left, and/or `>` after the direction on the right. For example: ``` -subnet R--L) gateway +subnet:R --> L:gateway ``` creates an edge with the arrow going into the `gateway` service @@ -138,7 +138,7 @@ For example: service server[Server] in groupOne service subnet[Subnet] in groupTwo -server{group} B--T) subnet{group} +server{group}:B --> T:subnet{group} ``` creates an edge going out of `groupOne`, adjacent to `server`, and into `groupTwo`, adjacent to `subnet`. @@ -165,12 +165,12 @@ architecture-beta junction junctionCenter junction junctionRight - left_disk R--L junctionCenter - top_disk B--T junctionCenter - bottom_disk T--B junctionCenter - junctionCenter R--L junctionRight - top_gateway B--T junctionRight - bottom_gateway T--B junctionRight + left_disk:R -- L:junctionCenter + top_disk:B -- T:junctionCenter + bottom_disk:T -- B:junctionCenter + junctionCenter:R -- L:junctionRight + top_gateway:B -- T:junctionRight + bottom_gateway:T -- B:junctionRight ``` ```mermaid @@ -183,12 +183,12 @@ architecture-beta junction junctionCenter junction junctionRight - left_disk R--L junctionCenter - top_disk B--T junctionCenter - bottom_disk T--B junctionCenter - junctionCenter R--L junctionRight - top_gateway B--T junctionRight - bottom_gateway T--B junctionRight + left_disk:R -- L:junctionCenter + top_disk:B -- T:junctionCenter + bottom_disk:T -- B:junctionCenter + junctionCenter:R -- L:junctionRight + top_gateway:B -- T:junctionRight + bottom_gateway:T -- B:junctionRight ``` ## Configuration diff --git a/packages/mermaid/src/docs/syntax/architecture.md b/packages/mermaid/src/docs/syntax/architecture.md index 336269048..e74995ce3 100644 --- a/packages/mermaid/src/docs/syntax/architecture.md +++ b/packages/mermaid/src/docs/syntax/architecture.md @@ -13,9 +13,9 @@ architecture-beta service disk2(disk)[Storage] in api service server(server)[Server] in api - db L--R server - disk1 T--B server - disk2 T--B db + db:L -- R:server + disk1:T -- B:server + disk2:T -- B:db ``` ## Syntax @@ -75,35 +75,35 @@ service database(db)[Database] in private_api The syntax for declaring an edge is: ``` -{serviceId}{{group}}? {(}?{T|B|L|R}--{T|B|L|R}{)}? {serviceId}{{group}}? +{serviceId}{{group}}?:{T|B|L|R} {<}?--{>}? {T|B|L|R}:{serviceId}{{group}}? ``` #### Edge Direction -The side of the service the edge comes out of is specified by adding `L|R|T|B` to each end of `--`. +The side of the service the edge comes out of is specified by adding a colon (`:`) to the side of the service connecting to the arrow and adding `L|R|T|B` For example: ``` -db R--L server +db:R -- L:server ``` creates an edge between the services `db` and `server`, with the edge coming out of the right of `db` and the left of `server`. ``` -db T--L server +db:T -- L:server ``` creates a 90 degree edge between the services `db` and `server`, with the edge coming out of the top of `db` and the left of `server`. #### Arrows -Arrows can be added to each side of an edge by adding `(` before the direction on the left, and/or `)` after the direction on the right. +Arrows can be added to each side of an edge by adding `<` before the direction on the left, and/or `>` after the direction on the right. For example: ``` -subnet R--L) gateway +subnet:R --> L:gateway ``` creates an edge with the arrow going into the `gateway` service @@ -118,7 +118,7 @@ For example: service server[Server] in groupOne service subnet[Subnet] in groupTwo -server{group} B--T) subnet{group} +server{group}:B --> T:subnet{group} ``` creates an edge going out of `groupOne`, adjacent to `server`, and into `groupTwo`, adjacent to `subnet`. @@ -145,12 +145,12 @@ architecture-beta junction junctionCenter junction junctionRight - left_disk R--L junctionCenter - top_disk B--T junctionCenter - bottom_disk T--B junctionCenter - junctionCenter R--L junctionRight - top_gateway B--T junctionRight - bottom_gateway T--B junctionRight + left_disk:R -- L:junctionCenter + top_disk:B -- T:junctionCenter + bottom_disk:T -- B:junctionCenter + junctionCenter:R -- L:junctionRight + top_gateway:B -- T:junctionRight + bottom_gateway:T -- B:junctionRight ``` ## Configuration diff --git a/packages/parser/src/language/architecture/architecture.langium b/packages/parser/src/language/architecture/architecture.langium index 79a3899e8..6246b423e 100644 --- a/packages/parser/src/language/architecture/architecture.langium +++ b/packages/parser/src/language/architecture/architecture.langium @@ -18,8 +18,16 @@ fragment Statement: | edges+=Edge ; +fragment LeftPort: + ':'lhsDir=ARROW_DIRECTION +; + +fragment RightPort: + rhsDir=ARROW_DIRECTION':' +; + fragment Arrow: - lhsInto?=ARROW_INTO? lhsDir=ARROW_DIRECTION ('--' | '-' title=ARCH_TITLE '-') rhsDir=ARROW_DIRECTION rhsInto?=ARROW_INTO? + LeftPort lhsInto?=ARROW_INTO? ('--' | '-' title=ARCH_TITLE '-') rhsInto?=ARROW_INTO? RightPort ; Group: @@ -44,4 +52,4 @@ terminal ARCH_TEXT_ICON: /\("[^"]+"\)/; terminal ARCH_ICON: /\([\w:]+\)/; terminal ARCH_TITLE: /\[[\w ]+\]/; terminal ARROW_GROUP: /\{group\}/; -terminal ARROW_INTO: /\(|\)/; \ No newline at end of file +terminal ARROW_INTO: /<|>/; \ No newline at end of file