Compare commits
	
		
			2 Commits
		
	
	
		
			534caf24a7
			...
			feat/parse
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| f369fc6e43 | |||
| 0bfe68b429 | 
| @@ -1,31 +0,0 @@ | |||||||
| name: CI |  | ||||||
| on: |  | ||||||
|   push: |  | ||||||
|     branches: [ main, dev ] |  | ||||||
|   pull_request: |  | ||||||
|     branches: [ main, dev ] |  | ||||||
|  |  | ||||||
| jobs: |  | ||||||
|   tests: |  | ||||||
|     runs-on: ubuntu-latest |  | ||||||
|     container: catthehacker/ubuntu:rust-latest |  | ||||||
|     steps: |  | ||||||
|       - name: Checkout |  | ||||||
|         uses: actions/checkout@v4 |  | ||||||
|  |  | ||||||
|       - name: Install tytanic |  | ||||||
|         run: cargo binstall tytanic@0.2.2 |  | ||||||
|  |  | ||||||
|       - name: Run test suite |  | ||||||
|         run: tt run |  | ||||||
|  |  | ||||||
|       - name: Archive artifacts |  | ||||||
|         uses: https://gitea.com/actions/gitea-upload-artifact@v4 |  | ||||||
|         if: always() |  | ||||||
|         with: |  | ||||||
|           name: artifacts |  | ||||||
|           path: | |  | ||||||
|             tests/**/diff/*.png |  | ||||||
|             tests/**/out/*.png |  | ||||||
|             tests/**/ref/*.png |  | ||||||
|           retention-days: 5 |  | ||||||
| @@ -15,7 +15,7 @@ This package lets you render sequence diagrams directly in Typst. The following | |||||||
| <td> | <td> | ||||||
|  |  | ||||||
| ```typst | ```typst | ||||||
| #import "@preview/chronos:0.2.2" | #import "@preview/chronos:0.1.0" | ||||||
| #chronos.diagram({ | #chronos.diagram({ | ||||||
|   import chronos: * |   import chronos: * | ||||||
|   _par("Alice") |   _par("Alice") | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|   chronos: chronos |   chronos: chronos | ||||||
| ) | ) | ||||||
|  |  | ||||||
| #let example(src, show-src: true, vertical: false, fill: false, wrap: true) = { | #let example(src, show-src: true, vertical: false, fill: true, wrap: true) = { | ||||||
|   src = src.text |   src = src.text | ||||||
|   let full-src = example-preamble + src |   let full-src = example-preamble + src | ||||||
|   let body = eval(full-src, scope: example-scope) |   let body = eval(full-src, scope: example-scope) | ||||||
| @@ -16,15 +16,15 @@ | |||||||
|       box( |       box( | ||||||
|         stroke: black + 1pt, |         stroke: black + 1pt, | ||||||
|         radius: .5em, |         radius: .5em, | ||||||
|         fill: if fill {color.white.darken(2%)} else {none}, |         fill: if fill {color.white.darken(5%)} else {none}, | ||||||
|         if show-src { |         if show-src { | ||||||
|           let src-block = raw(src, block: true, lang: "typc") |           let src-block = align(left, raw(src, lang: "typc")) | ||||||
|           table( |           table( | ||||||
|             columns: if vertical {1} else {2}, |             columns: if vertical {1} else {2}, | ||||||
|             inset: 5pt, |             inset: 1em, | ||||||
|             align: horizon + center, |             align: horizon + center, | ||||||
|             stroke: none, |             stroke: none, | ||||||
|             table.cell(inset: 1em, img), |             img, | ||||||
|             if vertical {table.hline()} else {table.vline()}, src-block |             if vertical {table.hline()} else {table.vline()}, src-block | ||||||
|           ) |           ) | ||||||
|         } else { |         } else { | ||||||
|   | |||||||
| @@ -1,23 +1,8 @@ | |||||||
| #import "example.typ": example | #import "example.typ": example | ||||||
|  |  | ||||||
| #let seq-return = example(``` |  | ||||||
| _seq( |  | ||||||
|   "Bob", "Alice", |  | ||||||
|   comment: [hello], |  | ||||||
|   enable-dst: true |  | ||||||
| ) |  | ||||||
| _seq( |  | ||||||
|   "Alice", "Alice", |  | ||||||
|   comment: [some action] |  | ||||||
| ) |  | ||||||
| _ret(comment: [bye]) |  | ||||||
| ```) |  | ||||||
|  |  | ||||||
| #let seq-comm-align = example(``` | #let seq-comm-align = example(``` | ||||||
| _par("p1", | _par("p1", display-name: "Start participant") | ||||||
|      display-name: "Start participant") | _par("p2", display-name: "End participant") | ||||||
| _par("p2", |  | ||||||
|      display-name: "End participant") |  | ||||||
| let alignments = ( | let alignments = ( | ||||||
|   "start", "end", |   "start", "end", | ||||||
|   "left", "right", |   "left", "right", | ||||||
| @@ -105,15 +90,15 @@ _par("a", display-name: "Alice") | |||||||
| _par("b", display-name: "Bob") | _par("b", display-name: "Bob") | ||||||
|  |  | ||||||
| _loop("default loop", { | _loop("default loop", { | ||||||
|   _seq("a", "b", comment: "Are you here?") |   _seq("a", "b", comment: "Are you here ?") | ||||||
| }) | }) | ||||||
| _gap() | _gap() | ||||||
| _loop("min loop", min: 1, { | _loop("min loop", min: 1, { | ||||||
|   _seq("a", "b", comment: "Are you here?") |   _seq("a", "b", comment: "Are you here ?") | ||||||
| }) | }) | ||||||
| _gap() | _gap() | ||||||
| _loop("min-max loop", min: 1, max: 5, { | _loop("min-max loop", min: 1, max: 5, { | ||||||
|   _seq("a", "b", comment: "Are you still here?") |   _seq("a", "b", comment: "Are you still here ?") | ||||||
| }) | }) | ||||||
| ```) | ```) | ||||||
|  |  | ||||||
| @@ -136,58 +121,15 @@ _sync({ | |||||||
| }) | }) | ||||||
| ```) | ```) | ||||||
|  |  | ||||||
| #let gaps = example(``` | #let gaps-seps = example(``` | ||||||
| _par("a", display-name: "Alice") | _par("alice", display-name: "Alice") | ||||||
| _par("b", display-name: "Bob") | _par("bob", display-name: "Bob") | ||||||
|  |  | ||||||
| _seq("a", "b", comment: [message 1]) | _seq("alice", "bob", comment: "Hello") | ||||||
| _seq("b", "a", comment: [ok], dashed: true) | _gap(size: 10) | ||||||
| _gap() | _seq("bob", "alice", comment: "Hi") | ||||||
| _seq("a", "b", comment: [message 2]) | _sep("Another day") | ||||||
| _seq("b", "a", comment: [ok], dashed: true) | _seq("alice", "bob", comment: "Hello again") | ||||||
| _gap(size: 40) |  | ||||||
| _seq("a", "b", comment: [message 3]) |  | ||||||
| _seq("b", "a", comment: [ok], dashed: true) |  | ||||||
| ```) |  | ||||||
|  |  | ||||||
| #let seps = example(``` |  | ||||||
| _par("a", display-name: "Alice") |  | ||||||
| _par("b", display-name: "Bob") |  | ||||||
|  |  | ||||||
| _sep[Initialization] |  | ||||||
| _seq("a", "b", comment: [Request 1]) |  | ||||||
| _seq( |  | ||||||
|   "b", "a", |  | ||||||
|   comment: [Response 1], |  | ||||||
|   dashed: true |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| _sep[Repetition] |  | ||||||
| _seq("a", "b", comment: [Request 2]) |  | ||||||
| _seq( |  | ||||||
|   "b", "a", |  | ||||||
|   comment: [Response 2], |  | ||||||
|   dashed: true |  | ||||||
| ) |  | ||||||
| ```) |  | ||||||
|  |  | ||||||
| #let delays = example(``` |  | ||||||
| _par("a", display-name: "Alice") |  | ||||||
| _par("b", display-name: "Bob") |  | ||||||
|  |  | ||||||
| _seq("a", "b", comment: [Auth Request]) |  | ||||||
| _delay() |  | ||||||
| _seq( |  | ||||||
|   "b", "a", |  | ||||||
|   comment: [Auth Response], |  | ||||||
|   dashed: true |  | ||||||
| ) |  | ||||||
| _delay(name: [5 minutes later]) |  | ||||||
| _seq( |  | ||||||
|   "b", "a", |  | ||||||
|   comment: [Good Bye !], |  | ||||||
|   dashed: true |  | ||||||
| ) |  | ||||||
| ```) | ```) | ||||||
|  |  | ||||||
| #let notes-shapes = example(``` | #let notes-shapes = example(``` | ||||||
|   | |||||||
| @@ -1,15 +1,8 @@ | |||||||
| /// Creates a separator before the next element |  | ||||||
| /// #examples.seps |  | ||||||
| /// - name (content): Name to display in the middle of the separator |  | ||||||
| #let _sep(name) = {} |  | ||||||
|  |  | ||||||
| /// Creates a delay before the next element |  | ||||||
| /// #examples.delays |  | ||||||
| /// - name (content, none): Name to display in the middle of the delay area |  | ||||||
| /// - size (int): Size of the delay |  | ||||||
| #let _delay(name: none, size: 30) = {} |  | ||||||
|  |  | ||||||
| /// Creates a gap before the next element | /// Creates a gap before the next element | ||||||
| /// #examples.gaps |  | ||||||
| /// - size (int): Size of the gap | /// - size (int): Size of the gap | ||||||
| #let _gap(size: 20) = {} | #let _gap(size: 20) = {} | ||||||
|  |  | ||||||
|  | /// Creates a separator before the next element | ||||||
|  | /// #examples.gaps-seps | ||||||
|  | /// - name (content): Name to display in the middle of the separator | ||||||
|  | #let _sep(name) = {} | ||||||
| @@ -34,7 +34,6 @@ | |||||||
| /// - invisible (bool): If set to true, the participant will not be shown | /// - invisible (bool): If set to true, the participant will not be shown | ||||||
| /// - shape (str): The shape of the participant. Possible values in @@SHAPES | /// - shape (str): The shape of the participant. Possible values in @@SHAPES | ||||||
| /// - color (color): The participant's color | /// - color (color): The participant's color | ||||||
| /// - line-stroke (stroke): The participant's line style (defaults to a light gray dashed line) |  | ||||||
| /// - custom-image (none, image): If shape is 'custom', sets the custom image to display | /// - custom-image (none, image): If shape is 'custom', sets the custom image to display | ||||||
| /// - show-bottom (bool): Whether to display the bottom shape | /// - show-bottom (bool): Whether to display the bottom shape | ||||||
| /// - show-top (bool): Whether to display the top shape | /// - show-top (bool): Whether to display the top shape | ||||||
| @@ -46,11 +45,6 @@ | |||||||
|   invisible: false, |   invisible: false, | ||||||
|   shape: "participant", |   shape: "participant", | ||||||
|   color: rgb("#E2E2F0"), |   color: rgb("#E2E2F0"), | ||||||
|   line-stroke: ( |  | ||||||
|     dash: "dashed", |  | ||||||
|     paint: gray.darken(40%), |  | ||||||
|     thickness: .5pt |  | ||||||
|   ), |  | ||||||
|   custom-image: none, |   custom-image: none, | ||||||
|   show-bottom: true, |   show-bottom: true, | ||||||
|   show-top: true, |   show-top: true, | ||||||
| @@ -64,12 +58,10 @@ | |||||||
| /// - width (auto, int, float, length): Optional fixed width of the column\ If the column's content (e.g. sequence comments) is larger, it will overflow | /// - width (auto, int, float, length): Optional fixed width of the column\ If the column's content (e.g. sequence comments) is larger, it will overflow | ||||||
| /// - margin (int, float, length): Additional margin to add to the column\ This margin is not included in `width` and `min-width`, but rather added separately | /// - margin (int, float, length): Additional margin to add to the column\ This margin is not included in `width` and `min-width`, but rather added separately | ||||||
| /// - min-width (int, float, length): Minimum width of the column\ If set to a larger value than `width`, the latter will be overriden | /// - min-width (int, float, length): Minimum width of the column\ If set to a larger value than `width`, the latter will be overriden | ||||||
| /// - max-width (int, float, length, none): Maximum width of the column\ If set to a lower value than `width`, the latter will be overriden\ If set to `none`, no restriction is applied |  | ||||||
| #let _col( | #let _col( | ||||||
|   p1, |   p1, | ||||||
|   p2, |   p2, | ||||||
|   width: auto, |   width: auto, | ||||||
|   margin: 0, |   margin: 0, | ||||||
|   min-width: 0, |   min-width: 0 | ||||||
|   max-width: none |  | ||||||
| ) = {} | ) = {} | ||||||
| @@ -42,17 +42,6 @@ | |||||||
|   slant: none |   slant: none | ||||||
| ) = {} | ) = {} | ||||||
|  |  | ||||||
| /// Creates a return sequence |  | ||||||
| /// #examples.seq-return |  | ||||||
| /// - comment (none, content): Optional comment to display along the arrow |  | ||||||
| #let _ret(comment: none) = {} |  | ||||||
|  |  | ||||||
| /// Accepted values for `comment-align` argument of @@_seq() |  | ||||||
| /// #examples.seq-comm-align |  | ||||||
| #let comment-align = ( |  | ||||||
|   "start", "end", "left", "center", "right" |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| /// Accepted values for `event` argument of @@_evt() | /// Accepted values for `event` argument of @@_evt() | ||||||
| ///  | ///  | ||||||
| /// `EVENTS = ("create", "destroy", "enable", "disable")` | /// `EVENTS = ("create", "destroy", "enable", "disable")` | ||||||
| @@ -62,4 +51,10 @@ | |||||||
| /// #examples.seq-tips | /// #examples.seq-tips | ||||||
| #let tips = ( | #let tips = ( | ||||||
|   "", ">", ">>", "\\", "\\\\", "/", "//", "x", "o", |   "", ">", ">>", "\\", "\\\\", "/", "//", "x", "o", | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | /// Accepted values for `comment-align` argument of @@_seq() | ||||||
|  | /// #examples.seq-comm-align | ||||||
|  | #let comment-align = ( | ||||||
|  |   "start", "end", "left", "center", "right" | ||||||
| ) | ) | ||||||
							
								
								
									
										27
									
								
								gallery.bash
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,27 @@ | |||||||
|  | #!/bin/bash | ||||||
|  |  | ||||||
|  |  | ||||||
|  | echo | ||||||
|  | echo "Generating gallery PDFs" | ||||||
|  |  | ||||||
|  | set -- ./gallery/*.typ | ||||||
|  | cnt="$#" | ||||||
|  | i=1 | ||||||
|  | for f | ||||||
|  | do | ||||||
|  |     f2="${f/typ/pdf}" | ||||||
|  |     echo "($i/$cnt) $f -> $f2" | ||||||
|  |     typst c --root ./ "$f" "$f2" | ||||||
|  |     i=$((i+1)) | ||||||
|  | done | ||||||
|  |  | ||||||
|  | set -- ./gallery/readme/*.typ | ||||||
|  | cnt="$#" | ||||||
|  | i=1 | ||||||
|  | for f | ||||||
|  | do | ||||||
|  |     f2="${f/typ/png}" | ||||||
|  |     echo "($i/$cnt) $f -> $f2" | ||||||
|  |     typst c --root ./ "$f" "$f2" | ||||||
|  |     i=$((i+1)) | ||||||
|  | done | ||||||
							
								
								
									
										
											BIN
										
									
								
								gallery/doc_examples.pdf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										689
									
								
								gallery/doc_examples.typ
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,689 @@ | |||||||
|  | #import "../src/lib.typ": from-plantuml | ||||||
|  |  | ||||||
|  | #set page(width: auto, height: auto) | ||||||
|  |  | ||||||
|  | #let examples = ( | ||||||
|  |   ( | ||||||
|  |     [Basic Examples], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     Alice -> Bob: Authentication Request | ||||||
|  |     Bob --> Alice: Authentication Response | ||||||
|  |  | ||||||
|  |     Alice -> Bob: Another authentication Request | ||||||
|  |     Alice <-- Bob: Another authentication Response | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Declaring participant], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     participant Participant as Foo | ||||||
|  |     actor       Actor       as Foo1 | ||||||
|  |     boundary    Boundary    as Foo2 | ||||||
|  |     control     Control     as Foo3 | ||||||
|  |     entity      Entity      as Foo4 | ||||||
|  |     database    Database    as Foo5 | ||||||
|  |     collections Collections as Foo6 | ||||||
|  |     queue       Queue       as Foo7 | ||||||
|  |     Foo -> Foo1 : To actor  | ||||||
|  |     Foo -> Foo2 : To boundary | ||||||
|  |     Foo -> Foo3 : To control | ||||||
|  |     Foo -> Foo4 : To entity | ||||||
|  |     Foo -> Foo5 : To database | ||||||
|  |     Foo -> Foo6 : To collections | ||||||
|  |     Foo -> Foo7: To queue | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Declaring participant (2)], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     actor Bob #red | ||||||
|  |     ' The only difference between actor | ||||||
|  |     'and participant is the drawing | ||||||
|  |     participant Alice | ||||||
|  |     participant "I have a really\nlong name" as L #99FF99 | ||||||
|  |     /' You can also declare: | ||||||
|  |       participant L as "I have a really\nlong name"  #99FF99 | ||||||
|  |       '/ | ||||||
|  |  | ||||||
|  |     Alice->Bob: Authentication Request | ||||||
|  |     Bob->Alice: Authentication Response | ||||||
|  |     Bob->L: Log transaction | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Use non-letters in participants], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     Alice -> "Bob()" : Hello | ||||||
|  |     "Bob()" -> "This is very\nlong" as Long | ||||||
|  |     ' You can also declare: | ||||||
|  |     ' "Bob()" -> Long as "This is very\nlong" | ||||||
|  |     Long --> "Bob()" : ok | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Message to Self], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     Alice -> Alice: This is a signal to self.\nIt also demonstrates\nmultiline \ntext | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Message to Self (2)], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     Alice <- Alice: This is a signal to self.\nIt also demonstrates\nmultiline \ntext | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Change arrow style], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     Bob ->x Alice | ||||||
|  |     Bob -> Alice | ||||||
|  |     Bob ->> Alice | ||||||
|  |     Bob -\ Alice | ||||||
|  |     Bob \\- Alice | ||||||
|  |     Bob //-- Alice | ||||||
|  |  | ||||||
|  |     Bob ->o Alice | ||||||
|  |     Bob o\\-- Alice | ||||||
|  |  | ||||||
|  |     Bob <-> Alice | ||||||
|  |     Bob <->o Alice | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Grouping message], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     Alice -> Bob: Authentication Request | ||||||
|  |  | ||||||
|  |     alt successful case | ||||||
|  |  | ||||||
|  |         Bob -> Alice: Authentication Accepted | ||||||
|  |  | ||||||
|  |     else some kind of failure | ||||||
|  |  | ||||||
|  |         Bob -> Alice: Authentication Failure | ||||||
|  |         group My own label | ||||||
|  |         Alice -> Log : Log attack start | ||||||
|  |             loop 1000 times | ||||||
|  |                 Alice -> Bob: DNS Attack | ||||||
|  |             end | ||||||
|  |         Alice -> Log : Log attack end | ||||||
|  |         end | ||||||
|  |  | ||||||
|  |     else Another type of failure | ||||||
|  |  | ||||||
|  |       Bob -> Alice: Please repeat | ||||||
|  |  | ||||||
|  |     end | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Secondary group label], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     Alice -> Bob: Authentication Request | ||||||
|  |     Bob -> Alice: Authentication Failure | ||||||
|  |     group My own label [My own label 2] | ||||||
|  |         Alice -> Log : Log attack start | ||||||
|  |         loop 1000 times | ||||||
|  |             Alice -> Bob: DNS Attack | ||||||
|  |         end | ||||||
|  |         Alice -> Log : Log attack end | ||||||
|  |     end | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Notes on messages], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     Alice->Bob : hello | ||||||
|  |     note left: this is a first note | ||||||
|  |  | ||||||
|  |     Bob->Alice : ok | ||||||
|  |     note right: this is another note | ||||||
|  |  | ||||||
|  |     Bob->Bob : I am thinking | ||||||
|  |     note left | ||||||
|  |     a note | ||||||
|  |     can also be defined | ||||||
|  |     on several lines | ||||||
|  |     end note | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Some other notes], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     participant Alice | ||||||
|  |     participant Bob | ||||||
|  |     note left of Alice #aqua | ||||||
|  |     This is displayed | ||||||
|  |     left of Alice. | ||||||
|  |     end note | ||||||
|  |  | ||||||
|  |     note right of Alice: This is displayed right of Alice. | ||||||
|  |  | ||||||
|  |     note over Alice: This is displayed over Alice. | ||||||
|  |  | ||||||
|  |     note over Alice, Bob #FFAAAA: This is displayed\n over Bob and Alice. | ||||||
|  |  | ||||||
|  |     note over Bob, Alice | ||||||
|  |     This is yet another | ||||||
|  |     example of | ||||||
|  |     a long note. | ||||||
|  |     end note | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Changing notes shape \[hnote, rnote\]], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     caller -> server : conReq | ||||||
|  |     hnote over caller : idle | ||||||
|  |     caller <- server : conConf | ||||||
|  |     rnote over server | ||||||
|  |      "r" as rectangle | ||||||
|  |      "h" as hexagon | ||||||
|  |     endrnote | ||||||
|  |     rnote over server | ||||||
|  |      this is | ||||||
|  |      on several | ||||||
|  |      lines | ||||||
|  |     endrnote | ||||||
|  |     hnote over caller | ||||||
|  |      this is | ||||||
|  |      on several | ||||||
|  |      lines | ||||||
|  |     endhnote | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Note over all participants \[across\]], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     Alice->Bob:m1 | ||||||
|  |     Bob->Charlie:m2 | ||||||
|  |     note over Alice, Charlie: Old method for note over all part. with:\n ""note over //FirstPart, LastPart//"". | ||||||
|  |     note across: New method with:\n""note across"" | ||||||
|  |     Bob->Alice | ||||||
|  |     hnote across:Note across all part. | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Several notes aligned at the same level \[/\]], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     note over Alice : initial state of Alice | ||||||
|  |     note over Bob : initial state of Bob | ||||||
|  |     Bob -> Alice : hello | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Several notes aligned at the same level \[/\] (2)], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     note over Alice : initial state of Alice | ||||||
|  |     / note over Bob : initial state of Bob | ||||||
|  |     Bob -> Alice : hello | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Divider or separator], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |  | ||||||
|  |     == Initialization == | ||||||
|  |  | ||||||
|  |     Alice -> Bob: Authentication Request | ||||||
|  |     Bob --> Alice: Authentication Response | ||||||
|  |  | ||||||
|  |     == Repetition == | ||||||
|  |  | ||||||
|  |     Alice -> Bob: Another authentication Request | ||||||
|  |     Alice <-- Bob: another authentication Response | ||||||
|  |  | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Delay], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |  | ||||||
|  |     Alice -> Bob: Authentication Request | ||||||
|  |     ... | ||||||
|  |     Bob --> Alice: Authentication Response | ||||||
|  |     ...5 minutes later... | ||||||
|  |     Bob --> Alice: Good Bye ! | ||||||
|  |  | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Space], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |  | ||||||
|  |     Alice -> Bob: message 1 | ||||||
|  |     Bob --> Alice: ok | ||||||
|  |     ||| | ||||||
|  |     Alice -> Bob: message 2 | ||||||
|  |     Bob --> Alice: ok | ||||||
|  |     ||45|| | ||||||
|  |     Alice -> Bob: message 3 | ||||||
|  |     Bob --> Alice: ok | ||||||
|  |  | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Lifeline Activation and Destruction], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     participant User | ||||||
|  |  | ||||||
|  |     User -> A: DoWork | ||||||
|  |     activate A | ||||||
|  |  | ||||||
|  |     A -> B: << createRequest >> | ||||||
|  |     activate B | ||||||
|  |  | ||||||
|  |     B -> C: DoWork | ||||||
|  |     activate C | ||||||
|  |     C --> B: WorkDone | ||||||
|  |     destroy C | ||||||
|  |  | ||||||
|  |     B --> A: RequestCreated | ||||||
|  |     deactivate B | ||||||
|  |  | ||||||
|  |     A -> User: Done | ||||||
|  |     deactivate A | ||||||
|  |  | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Lifeline Activation and Destruction (2)], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     participant User | ||||||
|  |  | ||||||
|  |     User -> A: DoWork | ||||||
|  |     activate A #FFBBBB | ||||||
|  |  | ||||||
|  |     A -> A: Internal call | ||||||
|  |     activate A #DarkSalmon | ||||||
|  |  | ||||||
|  |     A -> B: << createRequest >> | ||||||
|  |     activate B | ||||||
|  |  | ||||||
|  |     B --> A: RequestCreated | ||||||
|  |     deactivate B | ||||||
|  |     deactivate A | ||||||
|  |     A -> User: Done | ||||||
|  |     deactivate A | ||||||
|  |  | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   /*( | ||||||
|  |     [Lifeline Activation and Destruction (3)], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     'autoactivate on | ||||||
|  |     alice -> bob : hello | ||||||
|  |     bob -> bob : self call | ||||||
|  |     bill -> bob /'#005500'/ : hello from thread 2 | ||||||
|  |     bob -> george ** : create | ||||||
|  |     return done in thread 2 | ||||||
|  |     return rc | ||||||
|  |     bob -> george !! : delete | ||||||
|  |     return success | ||||||
|  |  | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ),*/ | ||||||
|  |   ( | ||||||
|  |     [Return], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     Bob -> Alice : hello | ||||||
|  |     activate Alice | ||||||
|  |     Alice -> Alice : some action | ||||||
|  |     return bye | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Participant creation], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     Bob -> Alice : hello | ||||||
|  |  | ||||||
|  |     create Other | ||||||
|  |     Alice -> Other : new | ||||||
|  |  | ||||||
|  |     create /'control'/ String | ||||||
|  |     Alice -> String | ||||||
|  |     note right : You can also put notes! | ||||||
|  |  | ||||||
|  |     Alice --> Bob : ok | ||||||
|  |  | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Shortcut syntax for activation, deactivation, creation], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     alice -> bob ++ : hello | ||||||
|  |     bob -> bob ++ : self call | ||||||
|  |     bob -> bib ++ /' #005500'/ : hello | ||||||
|  |     bob -> george ** : create | ||||||
|  |     return done | ||||||
|  |     return rc | ||||||
|  |     bob -> george !! : delete | ||||||
|  |     return success | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Shortcut syntax for activation, deactivation, creation (2)], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     alice   ->  bob     ++   : hello1 | ||||||
|  |     bob     ->  charlie --++ : hello2 | ||||||
|  |     charlie --> alice   --   : ok | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Shortcut syntax for activation, deactivation, creation (3)], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     alice -> bob   ++ /'#gold'/: hello | ||||||
|  |     bob   -> alice --++ /'#gold'/: you too | ||||||
|  |     alice -> bob   --: step1 | ||||||
|  |     alice -> bob   : step2 | ||||||
|  |     @enduml | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Incoming and outgoing messages], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     [-> A: DoWork | ||||||
|  |  | ||||||
|  |     activate A | ||||||
|  |  | ||||||
|  |     A -> A: Internal call | ||||||
|  |     activate A | ||||||
|  |  | ||||||
|  |     A ->] : << createRequest >> | ||||||
|  |  | ||||||
|  |     A<--] : RequestCreated | ||||||
|  |     deactivate A | ||||||
|  |     [<- A: Done | ||||||
|  |     deactivate A | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Incoming and outgoing messages (2)], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     participant Alice | ||||||
|  |     participant Bob #lightblue | ||||||
|  |     Alice -> Bob | ||||||
|  |     Bob -> Carol | ||||||
|  |     ... | ||||||
|  |     [-> Bob | ||||||
|  |     [o-> Bob | ||||||
|  |     [o->o Bob | ||||||
|  |     [x-> Bob | ||||||
|  |     ... | ||||||
|  |     [<- Bob | ||||||
|  |     [x<- Bob | ||||||
|  |     ... | ||||||
|  |     Bob ->] | ||||||
|  |     Bob ->o] | ||||||
|  |     Bob o->o] | ||||||
|  |     Bob ->x] | ||||||
|  |     ... | ||||||
|  |     Bob <-] | ||||||
|  |     Bob x<-] | ||||||
|  |  | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Short arrows for incoming and outgoing messages], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     ?-> Alice    : ""?->""\n**short** to actor1 | ||||||
|  |     [-> Alice    : ""[->""\n**from start** to actor1 | ||||||
|  |     [-> Bob      : ""[->""\n**from start** to actor2 | ||||||
|  |     ?-> Bob      : ""?->""\n**short** to actor2 | ||||||
|  |     Alice ->]    : ""->]""\nfrom actor1 **to end** | ||||||
|  |     Alice ->?    : ""->?""\n**short** from actor1 | ||||||
|  |     Alice -> Bob : ""->"" \nfrom actor1 to actor2 | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Normal arrow], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     participant Alice as a | ||||||
|  |     participant Bob   as b | ||||||
|  |     a ->     b : ""->   "" | ||||||
|  |     a ->>    b : ""->>  "" | ||||||
|  |     a -\     b : ""-\   "" | ||||||
|  |     a -\\    b : ""-\\\\"" | ||||||
|  |     a -/     b : ""-/   "" | ||||||
|  |     a -//    b : ""-//  "" | ||||||
|  |     a ->x    b : ""->x  "" | ||||||
|  |     a x->    b : ""x->  "" | ||||||
|  |     a o->    b : ""o->  "" | ||||||
|  |     a ->o    b : ""->o  "" | ||||||
|  |     a o->o   b : ""o->o "" | ||||||
|  |     a <->    b : ""<->  "" | ||||||
|  |     a o<->o  b : ""o<->o"" | ||||||
|  |     a x<->x  b : ""x<->x"" | ||||||
|  |     a ->>o   b : ""->>o "" | ||||||
|  |     a -\o    b : ""-\o  "" | ||||||
|  |     a -\\o   b : ""-\\\\o"" | ||||||
|  |     a -/o    b : ""-/o  "" | ||||||
|  |     a -//o   b : ""-//o "" | ||||||
|  |     a x->o   b : ""x->o "" | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Itself arrow], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     participant Alice as a | ||||||
|  |     participant Bob   as b | ||||||
|  |     a ->     a : ""->   "" | ||||||
|  |     a ->>    a : ""->>  "" | ||||||
|  |     a -\     a : ""-\   "" | ||||||
|  |     a -\\    a : ""-\\\\"" | ||||||
|  |     a -/     a : ""-/   "" | ||||||
|  |     a -//    a : ""-//  "" | ||||||
|  |     a ->x    a : ""->x  "" | ||||||
|  |     a x->    a : ""x->  "" | ||||||
|  |     a o->    a : ""o->  "" | ||||||
|  |     a ->o    a : ""->o  "" | ||||||
|  |     a o->o   a : ""o->o "" | ||||||
|  |     a <->    a : ""<->  "" | ||||||
|  |     a o<->o  a : ""o<->o"" | ||||||
|  |     a x<->x  a : ""x<->x"" | ||||||
|  |     a ->>o   a : ""->>o "" | ||||||
|  |     a -\o    a : ""-\o  "" | ||||||
|  |     a -\\o   a : ""-\\\\o"" | ||||||
|  |     a -/o    a : ""-/o  "" | ||||||
|  |     a -//o   a : ""-//o "" | ||||||
|  |     a x->o   a : ""x->o "" | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Incoming messages (with '|')], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     participant Alice as a | ||||||
|  |     participant Bob   as b | ||||||
|  |     [->      b : ""[->   "" | ||||||
|  |     [->>     b : ""[->>  "" | ||||||
|  |     [-\      b : ""[-\   "" | ||||||
|  |     [-\\     b : ""[-\\\\"" | ||||||
|  |     [-/      b : ""[-/   "" | ||||||
|  |     [-//     b : ""[-//  "" | ||||||
|  |     [->x     b : ""[->x  "" | ||||||
|  |     [x->     b : ""[x->  "" | ||||||
|  |     [o->     b : ""[o->  "" | ||||||
|  |     [->o     b : ""[->o  "" | ||||||
|  |     [o->o    b : ""[o->o "" | ||||||
|  |     [<->     b : ""[<->  "" | ||||||
|  |     [o<->o   b : ""[o<->o"" | ||||||
|  |     [x<->x   b : ""[x<->x"" | ||||||
|  |     [->>o    b : ""[->>o "" | ||||||
|  |     [-\o     b : ""[-\o  "" | ||||||
|  |     [-\\o    b : ""[-\\\\o"" | ||||||
|  |     [-/o     b : ""[-/o  "" | ||||||
|  |     [-//o    b : ""[-//o "" | ||||||
|  |     [x->o    b : ""[x->o "" | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Outgoing messages (with '|')], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     participant Alice as a | ||||||
|  |     participant Bob   as b | ||||||
|  |     a ->]      : ""->]   "" | ||||||
|  |     a ->>]     : ""->>]  "" | ||||||
|  |     a -\]      : ""-\]   "" | ||||||
|  |     a -\\]     : ""-\\\\]"" | ||||||
|  |     a -/]      : ""-/]   "" | ||||||
|  |     a -//]     : ""-//]  "" | ||||||
|  |     a ->x]     : ""->x]  "" | ||||||
|  |     a x->]     : ""x->]  "" | ||||||
|  |     a o->]     : ""o->]  "" | ||||||
|  |     a ->o]     : ""->o]  "" | ||||||
|  |     a o->o]    : ""o->o] "" | ||||||
|  |     a <->]     : ""<->]  "" | ||||||
|  |     a o<->o]   : ""o<->o]"" | ||||||
|  |     a x<->x]   : ""x<->x]"" | ||||||
|  |     a ->>o]    : ""->>o] "" | ||||||
|  |     a -\o]     : ""-\o]  "" | ||||||
|  |     a -\\o]    : ""-\\\\o]"" | ||||||
|  |     a -/o]     : ""-/o]  "" | ||||||
|  |     a -//o]    : ""-//o] "" | ||||||
|  |     a x->o]    : ""x->o] "" | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Short incoming (with '?')], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     participant Alice as a | ||||||
|  |     participant Bob   as b | ||||||
|  |     a ->     b : //Long long label// | ||||||
|  |     ?->      b : ""?->   "" | ||||||
|  |     ?->>     b : ""?->>  "" | ||||||
|  |     ?-\      b : ""?-\   "" | ||||||
|  |     ?-\\     b : ""?-\\\\"" | ||||||
|  |     ?-/      b : ""?-/   "" | ||||||
|  |     ?-//     b : ""?-//  "" | ||||||
|  |     ?->x     b : ""?->x  "" | ||||||
|  |     ?x->     b : ""?x->  "" | ||||||
|  |     ?o->     b : ""?o->  "" | ||||||
|  |     ?->o     b : ""?->o  "" | ||||||
|  |     ?o->o    b : ""?o->o "" | ||||||
|  |     ?<->     b : ""?<->  "" | ||||||
|  |     ?o<->o   b : ""?o<->o"" | ||||||
|  |     ?x<->x   b : ""?x<->x"" | ||||||
|  |     ?->>o    b : ""?->>o "" | ||||||
|  |     ?-\o     b : ""?-\o  "" | ||||||
|  |     ?-\\o    b : ""?-\\\\o "" | ||||||
|  |     ?-/o     b : ""?-/o  "" | ||||||
|  |     ?-//o    b : ""?-//o "" | ||||||
|  |     ?x->o    b : ""?x->o "" | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ), | ||||||
|  |   ( | ||||||
|  |     [Short outgoing (with '?')], | ||||||
|  |     ``` | ||||||
|  |     @startuml | ||||||
|  |     participant Alice as a | ||||||
|  |     participant Bob   as b | ||||||
|  |     a ->     b : //Long long label// | ||||||
|  |     a ->?      : ""->?   "" | ||||||
|  |     a ->>?     : ""->>?  "" | ||||||
|  |     a -\?      : ""-\?   "" | ||||||
|  |     a -\\?     : ""-\\\\?"" | ||||||
|  |     a -/?      : ""-/?   "" | ||||||
|  |     a -//?     : ""-//?  "" | ||||||
|  |     a ->x?     : ""->x?  "" | ||||||
|  |     a x->?     : ""x->?  "" | ||||||
|  |     a o->?     : ""o->?  "" | ||||||
|  |     a ->o?     : ""->o?  "" | ||||||
|  |     a o->o?    : ""o->o? "" | ||||||
|  |     a <->?     : ""<->?  "" | ||||||
|  |     a o<->o?   : ""o<->o?"" | ||||||
|  |     a x<->x?   : ""x<->x?"" | ||||||
|  |     a ->>o?    : ""->>o? "" | ||||||
|  |     a -\o?     : ""-\o?  "" | ||||||
|  |     a -\\o?    : ""-\\\\o?"" | ||||||
|  |     a -/o?     : ""-/o?  "" | ||||||
|  |     a -//o?    : ""-//o? "" | ||||||
|  |     a x->o?    : ""x->o? "" | ||||||
|  |     @enduml | ||||||
|  |     ``` | ||||||
|  |   ) | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | #{ | ||||||
|  |   for (title, uml) in examples { | ||||||
|  |     heading(title) | ||||||
|  |     box( | ||||||
|  |       stroke: gray, | ||||||
|  |       inset: 1em, | ||||||
|  |       stack( | ||||||
|  |         dir: ltr, | ||||||
|  |         spacing: 1em, | ||||||
|  |         raw(uml.text, block: true, lang: "plantuml"), | ||||||
|  |         from-plantuml(uml) | ||||||
|  |       ) | ||||||
|  |     ) | ||||||
|  |     pagebreak(weak: true) | ||||||
|  |   } | ||||||
|  | } | ||||||
							
								
								
									
										
											BIN
										
									
								
								gallery/plantuml_test.pdf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										271
									
								
								gallery/plantuml_test.typ
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,271 @@ | |||||||
|  | #import "../src/lib.typ": from-plantuml | ||||||
|  |  | ||||||
|  | #set page(width: auto, height: auto) | ||||||
|  |  | ||||||
|  | /* | ||||||
|  | #from-plantuml(``` | ||||||
|  | @startuml | ||||||
|  |  | ||||||
|  | actor User as usr | ||||||
|  | participant can_message as can | ||||||
|  | control kartculator as kc | ||||||
|  | queue XF as xf | ||||||
|  | entity Drive as drive | ||||||
|  | entity Steering as steering | ||||||
|  |  | ||||||
|  | usr -\ xf : set message "move" | ||||||
|  | xf -> can : new value on joystick | ||||||
|  |  | ||||||
|  | == If X axis change value == | ||||||
|  | can -> kc : calculate new position | ||||||
|  | kc -> can : build message | ||||||
|  | can -> steering : set new position | ||||||
|  |  | ||||||
|  | == If Y axis change value == | ||||||
|  | can -> kc : calculate new torque | ||||||
|  | kc -> can : build message | ||||||
|  | can -> xf : set message "torque" | ||||||
|  | xf -> drive : set new torque | ||||||
|  |  | ||||||
|  | @enduml | ||||||
|  | ```) | ||||||
|  |  | ||||||
|  | #pagebreak(weak: true) | ||||||
|  |  | ||||||
|  | #from-plantuml(``` | ||||||
|  | @startuml | ||||||
|  |  | ||||||
|  | actor CAN_BUS as bus | ||||||
|  | participant interrupt as ISR | ||||||
|  | queue XF as xf | ||||||
|  | participant ecan as ecan | ||||||
|  | participant canInterface as can | ||||||
|  | control canMessageController as msg | ||||||
|  |  | ||||||
|  |  | ||||||
|  | bus -\\ ISR ++  : can message | ||||||
|  | ISR -> can : newMsg | ||||||
|  | can -> ecan : read | ||||||
|  | ecan --> can : message | ||||||
|  | can -> xf : POST XF | ||||||
|  | destroy ISR | ||||||
|  |     group TICK XF | ||||||
|  | xf o-> can : receiveCan() | ||||||
|  | can -> msg : processIncoming() | ||||||
|  | msg -> can : create message | ||||||
|  | can -> xf : POST XF | ||||||
|  |     end | ||||||
|  |     group TICK XF | ||||||
|  | xf o-> can : sendCan() | ||||||
|  | can -> ecan : write | ||||||
|  | ecan -\\ bus : can message | ||||||
|  |     end | ||||||
|  |  | ||||||
|  | @enduml | ||||||
|  | ```) | ||||||
|  |  | ||||||
|  | #pagebreak(weak: true) | ||||||
|  | */ | ||||||
|  |  | ||||||
|  | /* | ||||||
|  | #from-plantuml(``` | ||||||
|  | @startuml | ||||||
|  |  | ||||||
|  | participant "Behavior::StateMachine" as sm | ||||||
|  | participant Dispatcher as d | ||||||
|  | participant TimeoutManager as tm | ||||||
|  | entity "Event::Timeout" as t | ||||||
|  | queue "TimeoutManager::timeouts_" as timeouts | ||||||
|  |  | ||||||
|  | autoactivate off | ||||||
|  | ||| | ||||||
|  | ||| | ||||||
|  | == Schedule timeout == | ||||||
|  | ||| | ||||||
|  | sm -> sm++ : scheduleTimeout | ||||||
|  | sm -> d ++: getDispatcher | ||||||
|  | d --> sm --: dispatcher | ||||||
|  | sm -> d --++ : scheduleTimeout | ||||||
|  | d -> tm ++: getTimeoutManager | ||||||
|  | tm --> d --: timeoutManager | ||||||
|  | d -> tm --++ : scheduleTimeout | ||||||
|  | tm -> t ** : new | ||||||
|  | t --> tm | ||||||
|  | tm -> timeouts --++: insert | ||||||
|  |  | ||||||
|  | ||| | ||||||
|  | ||| | ||||||
|  | == Decrement timeout (and dispatch) == | ||||||
|  | ||| | ||||||
|  | loop every tickInterval | ||||||
|  | ?->> tm ++: tick | ||||||
|  | tm -> timeouts : getFront | ||||||
|  | timeouts -> t ++ | ||||||
|  | t --> timeouts | ||||||
|  | timeouts --> tm : timeout | ||||||
|  | tm -> t  --: decrement | ||||||
|  | end | ||||||
|  | ||| | ||||||
|  | note left t | ||||||
|  | When timeout is 0, | ||||||
|  | dispatch event | ||||||
|  | end note | ||||||
|  | t -> timeouts : pop | ||||||
|  | deactivate timeouts | ||||||
|  | t ->? --: pushEvent | ||||||
|  |  | ||||||
|  | ||| | ||||||
|  | ||| | ||||||
|  | == Unschedule timeout == | ||||||
|  | ||| | ||||||
|  | sm -> sm++ : unscheduleTimeout | ||||||
|  | sm -> d ++: getDispatcher | ||||||
|  | d --> sm --: dispatcher | ||||||
|  | sm -> d --++ : unscheduleTimeout | ||||||
|  | d -> tm ++: getTimeoutManager | ||||||
|  | tm --> d --: timeoutManager | ||||||
|  | d -> tm --++ : unscheduleTimeout | ||||||
|  | tm -> timeouts --: erase | ||||||
|  | timeouts -> t !! | ||||||
|  |  | ||||||
|  | @enduml | ||||||
|  | ```) | ||||||
|  | */ | ||||||
|  |  | ||||||
|  | #pagebreak(weak: true) | ||||||
|  |  | ||||||
|  | #from-plantuml(``` | ||||||
|  | @startuml | ||||||
|  |  | ||||||
|  | participant Behavior as b | ||||||
|  | participant Dispatcher as d | ||||||
|  | entity Event as e | ||||||
|  | participant EventQueue as eq | ||||||
|  | queue "EventQueue::queue_" as q | ||||||
|  |  | ||||||
|  | == Create an Event == | ||||||
|  | ||| | ||||||
|  | ?->> b ++ : GEN | ||||||
|  | b -> e ** : new | ||||||
|  | b -> b --++ : pushEvent | ||||||
|  | e -> b : getBehavior | ||||||
|  | b --> e ++: setBehavior | ||||||
|  | e --> b -- | ||||||
|  | b -> d ++ : getDispatcher | ||||||
|  | d --> b | ||||||
|  | b -> d -- : pushEvent | ||||||
|  | d ->? -- : push | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ||| | ||||||
|  | ||| | ||||||
|  | == Push Event  == | ||||||
|  | ||| | ||||||
|  | ?->> d ++: pushEvent | ||||||
|  | d -> eq--++: push | ||||||
|  | eq -> q ++ | ||||||
|  | q --> eq | ||||||
|  | eq -> q -- : pushEndQueue | ||||||
|  |  | ||||||
|  | ||| | ||||||
|  | ||| | ||||||
|  | == Dispatch == | ||||||
|  | ||| | ||||||
|  | ?->> d ++: executeOnce | ||||||
|  | d -> q : getFront | ||||||
|  | q -> e ++ | ||||||
|  | e --> q | ||||||
|  | q --> d : event | ||||||
|  | d -> q : pop | ||||||
|  | deactivate q | ||||||
|  | d -> d --++ : dispatchEvent | ||||||
|  | d -> b ++ : getBehavior | ||||||
|  | b --> d | ||||||
|  | d -> b -- : process | ||||||
|  | b -> b--: processEvent | ||||||
|  |  | ||||||
|  | destroy e | ||||||
|  |  | ||||||
|  | @enduml | ||||||
|  | ```) | ||||||
|  |  | ||||||
|  | #pagebreak(weak: true) | ||||||
|  |  | ||||||
|  | #from-plantuml(``` | ||||||
|  | @startuml | ||||||
|  | 'https://plantuml.com/sequence-diagram | ||||||
|  | actor User as usr | ||||||
|  | participant "Pb L" as pbL | ||||||
|  | participant "Pb R" as pbR | ||||||
|  | participant "LED L" as ledL | ||||||
|  | participant "LED R" as ledR | ||||||
|  |  | ||||||
|  |  | ||||||
|  | == Single click == | ||||||
|  |  | ||||||
|  | group Single click left | ||||||
|  | usr -\ pbL ++: pressButton | ||||||
|  | usr -\ pbL : releaseButton | ||||||
|  | pbL -> ledL --++ : blink | ||||||
|  | usr -\ pbL ++: pressButton | ||||||
|  | usr -\ pbL : releaseButton | ||||||
|  | pbL -> ledL -- : endBlink | ||||||
|  | deactivate ledL | ||||||
|  | end | ||||||
|  |  | ||||||
|  | group Single click right | ||||||
|  | usr -\ pbR ++: pressButton | ||||||
|  | usr -\ pbR : releaseButton | ||||||
|  | pbR -> ledR --++ : blink | ||||||
|  | usr -\ pbR ++: pressButton | ||||||
|  | usr -\ pbR : releaseButton | ||||||
|  | pbR -> ledR -- : endBlink | ||||||
|  | deactivate ledR | ||||||
|  | end | ||||||
|  |  | ||||||
|  | == Double click == | ||||||
|  |  | ||||||
|  | group Double click left | ||||||
|  | usr -\ pbL ++: pressButton | ||||||
|  | usr -\ pbL : releaseButton | ||||||
|  | usr -\ pbL : pressButton | ||||||
|  | pbL -> ledL --++ : blink | ||||||
|  | note right ledL: blink 3x | ||||||
|  | ledL ->x ledL -- : finished | ||||||
|  | end | ||||||
|  |  | ||||||
|  | group Double click right | ||||||
|  | usr -\ pbR ++: pressButton | ||||||
|  | usr -\ pbR : releaseButton | ||||||
|  | usr -\ pbR : pressButton | ||||||
|  | pbR -> ledR --++ : blink | ||||||
|  | note right ledR: blink 3x | ||||||
|  | ledR ->x ledR -- : finished | ||||||
|  | end | ||||||
|  |  | ||||||
|  | == Long click == | ||||||
|  |  | ||||||
|  | group Long click left | ||||||
|  | usr -\ pbL ++: pressButton | ||||||
|  | pbL -> ledR--: blink | ||||||
|  | activate ledL | ||||||
|  | activate ledR | ||||||
|  | usr -\ pbL ++: pressButton | ||||||
|  | pbL -> ledR -- : endBlink | ||||||
|  | deactivate ledL | ||||||
|  | deactivate ledR | ||||||
|  | end | ||||||
|  |  | ||||||
|  | group Long click right | ||||||
|  | usr -\ pbR ++: pressButton | ||||||
|  | pbR -> ledR--: blink | ||||||
|  | activate ledL | ||||||
|  | activate ledR | ||||||
|  | usr -\ pbL ++: pressButton | ||||||
|  | pbL -> ledR -- : endBlink | ||||||
|  | deactivate ledL | ||||||
|  | deactivate ledR | ||||||
|  | end | ||||||
|  |  | ||||||
|  | @enduml | ||||||
|  | ```) | ||||||
| Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 13 KiB | 
| Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 96 KiB | 
| Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 24 KiB | 
							
								
								
									
										18
									
								
								justfile
									
									
									
									
									
								
							
							
						
						| @@ -1,18 +0,0 @@ | |||||||
| # Local Variables: |  | ||||||
| # mode: makefile |  | ||||||
| # End: |  | ||||||
| gallery_dir := "./gallery" |  | ||||||
| set shell := ["bash", "-uc"] |  | ||||||
|  |  | ||||||
| manual: |  | ||||||
|   typst c manual.typ manual.pdf |  | ||||||
|  |  | ||||||
| gallery: |  | ||||||
|   for f in "{{gallery_dir}}"/*.typ; do typst c --root . "$f" "${f%typ}pdf"; done |  | ||||||
|   for f in "{{gallery_dir}}"/readme/*.typ; do typst c --root . "$f" "${f%typ}png"; done |  | ||||||
|  |  | ||||||
| test *filter: |  | ||||||
|   tt run {{filter}} |  | ||||||
|  |  | ||||||
| update-test *filter: |  | ||||||
|   tt update {{filter}} |  | ||||||
							
								
								
									
										
											BIN
										
									
								
								manual.pdf
									
									
									
									
									
								
							
							
						
						
							
								
								
									
										82
									
								
								manual.typ
									
									
									
									
									
								
							
							
						
						| @@ -1,6 +1,4 @@ | |||||||
| #import "@preview/tidy:0.4.2" | #import "@preview/tidy:0.3.0" | ||||||
| #import "@preview/codly:1.2.0": codly-init, codly |  | ||||||
| #import "@preview/codly-languages:0.1.8": codly-languages |  | ||||||
| #import "src/lib.typ" as chronos | #import "src/lib.typ" as chronos | ||||||
| #import "src/participant.typ" as mod-par | #import "src/participant.typ" as mod-par | ||||||
| #import "docs/examples.typ" | #import "docs/examples.typ" | ||||||
| @@ -8,48 +6,32 @@ | |||||||
|  |  | ||||||
| #let TYPST = image("gallery/typst.png", width: 1.5cm, height: 1.5cm, fit: "contain") | #let TYPST = image("gallery/typst.png", width: 1.5cm, height: 1.5cm, fit: "contain") | ||||||
|  |  | ||||||
| #show: codly-init | #let doc-ref(target, full: false, var: false) = { | ||||||
| #codly( |   let (module, func) = target.split(".") | ||||||
|   languages: codly-languages |   let label-name = module + func | ||||||
| ) |   let display-name = func | ||||||
|  |   if full { | ||||||
| #set text(font: "Source Sans 3") |     display-name = target | ||||||
|  |   } | ||||||
|  |   if not var { | ||||||
|  |     label-name += "()" | ||||||
|  |     display-name += "()" | ||||||
|  |   } | ||||||
|  |   link(label(label-name))[#display-name] | ||||||
|  | } | ||||||
|  |  | ||||||
| #set heading(numbering: (..num) => if num.pos().len() < 4 { | #set heading(numbering: (..num) => if num.pos().len() < 4 { | ||||||
|   numbering("1.1", ..num) |   numbering("1.1", ..num) | ||||||
| }) | }) | ||||||
|  |  | ||||||
| #align(center)[ |  | ||||||
|   #v(2cm) |  | ||||||
|   #text(size: 2em)[*Chronos*] |  | ||||||
|    |  | ||||||
|   _v#chronos.version;_ |  | ||||||
|   #v(1cm) |  | ||||||
|   #chronos.diagram({ |  | ||||||
|     import chronos: * |  | ||||||
|     _par("u", display-name: [User], shape: "actor") |  | ||||||
|     _par("wa", display-name: [Web App]) |  | ||||||
|     _par("tu", display-name: [Typst Universe], shape: "database") |  | ||||||
|  |  | ||||||
|     _seq("u", "wa", comment: [Compile document], enable-dst: true) |  | ||||||
|     _seq("wa", "tu", comment: [Fetch Chronos]) |  | ||||||
|     _seq("tu", "wa", dashed: true, slant: 10) |  | ||||||
|     _seq("wa", "wa", comment: [Render]) |  | ||||||
|     _ret(comment: [Nice sequence diagram]) |  | ||||||
|   }) |  | ||||||
| ] |  | ||||||
|  |  | ||||||
| #pagebreak() |  | ||||||
|  |  | ||||||
| #{ | #{ | ||||||
|   outline(indent: auto, depth: 3) |   outline(indent: true, depth: 3) | ||||||
| } | } | ||||||
| #show link: set text(fill: blue) | #show link: set text(fill: blue) | ||||||
|  |  | ||||||
| #set page(numbering: "1/1", header: align(right)[chronos #sym.dash.em v#chronos.version]) | #set page(numbering: "1/1", header: align(right)[chronos #sym.dash.em v#chronos.version]) | ||||||
| #set page( | #set page( | ||||||
|   header: align(left)[chronos #sym.dash.em v#chronos.version], |   header: locate(loc => align(left)[chronos #sym.dash.em v#chronos.version]), | ||||||
|   footer: context align(center, counter(page).display("1/1", both: true)) |   footer: locate(loc => align(center, counter(page).display("1/1", both: true))) | ||||||
| ) | ) | ||||||
|  |  | ||||||
| = Introduction | = Introduction | ||||||
| @@ -58,20 +40,18 @@ This package lets you create nice sequence diagrams using the CeTZ package. | |||||||
|  |  | ||||||
| = Usage | = Usage | ||||||
|  |  | ||||||
| #let import-stmt = "#import \"@preview/chronos:" + str(chronos.version) + "\"" |  | ||||||
|  |  | ||||||
| Simply import #link("https://typst.app/universe/package/chronos/")[chronos] and call the `diagram` function: | Simply import #link("https://typst.app/universe/package/chronos/")[chronos] and call the `diagram` function: | ||||||
| #raw(block:true, lang: "typ", ```typ | #pad(left: 1em)[```typ | ||||||
| $import | #import "@preview/chronos:0.1.0" | ||||||
| #chronos.diagram({ | #chronos.diagram({ | ||||||
|   import chronos: * |   import chronos: * | ||||||
|   ... |   ... | ||||||
| }) | }) | ||||||
| ```.text.replace("$import", import-stmt)) | ```] | ||||||
|  |  | ||||||
| = Examples | = Examples | ||||||
|  |  | ||||||
| You can find the following examples and more in the #link("https://git.kb28.ch/HEL/chronos/src/branch/main/gallery")[gallery] directory | You can find the following examples and more in the #link("https://git.kb28.ch/HEL/circuiteria/src/branch/main/gallery")[gallery] directory | ||||||
|  |  | ||||||
| == Some groups and sequences | == Some groups and sequences | ||||||
|  |  | ||||||
| @@ -141,11 +121,7 @@ chronos.diagram({ | |||||||
| == Custom images | == Custom images | ||||||
|  |  | ||||||
| #example(``` | #example(``` | ||||||
| let load-img(path) = image( | let load-img(path) = image(path, width: 1.5cm, height: 1.5cm, fit:"contain") | ||||||
|   path, |  | ||||||
|   width: 1.5cm, height: 1.5cm, |  | ||||||
|   fit:"contain" |  | ||||||
| ) |  | ||||||
| let TYPST = load-img("../gallery/typst.png") | let TYPST = load-img("../gallery/typst.png") | ||||||
| let FERRIS = load-img("../gallery/ferris.png") | let FERRIS = load-img("../gallery/ferris.png") | ||||||
| let ME = load-img("../gallery/me.jpg") | let ME = load-img("../gallery/me.jpg") | ||||||
| @@ -172,11 +148,11 @@ chronos.diagram({ | |||||||
|   read("docs/participants.typ"), |   read("docs/participants.typ"), | ||||||
|   name: "Participants", |   name: "Participants", | ||||||
|   require-all-parameters: true, |   require-all-parameters: true, | ||||||
|   old-syntax: true, |  | ||||||
|   scope: ( |   scope: ( | ||||||
|     chronos: chronos, |     chronos: chronos, | ||||||
|     mod-par: mod-par, |     mod-par: mod-par, | ||||||
|     TYPST: TYPST |     TYPST: TYPST, | ||||||
|  |     doc-ref: doc-ref | ||||||
|   ) |   ) | ||||||
| ) | ) | ||||||
| #tidy.show-module(par-docs, show-outline: false, sort-functions: none) | #tidy.show-module(par-docs, show-outline: false, sort-functions: none) | ||||||
| @@ -187,9 +163,9 @@ chronos.diagram({ | |||||||
|   read("docs/sequences.typ"), |   read("docs/sequences.typ"), | ||||||
|   name: "Sequences", |   name: "Sequences", | ||||||
|   require-all-parameters: true, |   require-all-parameters: true, | ||||||
|   old-syntax: true, |  | ||||||
|   scope: ( |   scope: ( | ||||||
|     chronos: chronos, |     chronos: chronos, | ||||||
|  |     doc-ref: doc-ref, | ||||||
|     examples: examples |     examples: examples | ||||||
|   ) |   ) | ||||||
| ) | ) | ||||||
| @@ -201,9 +177,9 @@ chronos.diagram({ | |||||||
|   read("docs/groups.typ"), |   read("docs/groups.typ"), | ||||||
|   name: "Groups", |   name: "Groups", | ||||||
|   require-all-parameters: true, |   require-all-parameters: true, | ||||||
|   old-syntax: true, |  | ||||||
|   scope: ( |   scope: ( | ||||||
|     chronos: chronos, |     chronos: chronos, | ||||||
|  |     doc-ref: doc-ref, | ||||||
|     examples: examples |     examples: examples | ||||||
|   ) |   ) | ||||||
| ) | ) | ||||||
| @@ -215,13 +191,13 @@ chronos.diagram({ | |||||||
|   read("docs/gaps_seps.typ"), |   read("docs/gaps_seps.typ"), | ||||||
|   name: "Gaps and separators", |   name: "Gaps and separators", | ||||||
|   require-all-parameters: true, |   require-all-parameters: true, | ||||||
|   old-syntax: true, |  | ||||||
|   scope: ( |   scope: ( | ||||||
|     chronos: chronos, |     chronos: chronos, | ||||||
|  |     doc-ref: doc-ref, | ||||||
|     examples: examples |     examples: examples | ||||||
|   ) |   ) | ||||||
| ) | ) | ||||||
| #tidy.show-module(gap-sep-docs, show-outline: false, sort-functions: none) | #tidy.show-module(gap-sep-docs, show-outline: false) | ||||||
|  |  | ||||||
| #pagebreak(weak: true) | #pagebreak(weak: true) | ||||||
|  |  | ||||||
| @@ -229,9 +205,9 @@ chronos.diagram({ | |||||||
|   read("docs/notes.typ"), |   read("docs/notes.typ"), | ||||||
|   name: "Notes", |   name: "Notes", | ||||||
|   require-all-parameters: true, |   require-all-parameters: true, | ||||||
|   old-syntax: true, |  | ||||||
|   scope: ( |   scope: ( | ||||||
|     chronos: chronos, |     chronos: chronos, | ||||||
|  |     doc-ref: doc-ref, | ||||||
|     examples: examples |     examples: examples | ||||||
|   ) |   ) | ||||||
| ) | ) | ||||||
|   | |||||||
| @@ -1 +0,0 @@ | |||||||
| #import "@preview/cetz:0.3.4": * |  | ||||||
| @@ -19,15 +19,14 @@ | |||||||
|   ),) |   ),) | ||||||
| } | } | ||||||
|  |  | ||||||
| #let _col(p1, p2, width: auto, margin: 0, min-width: 0, max-width: none) = { | #let _col(p1, p2, width: auto, margin: 0, min-width: 0) = { | ||||||
|   return (( |   return (( | ||||||
|     type: "col", |     type: "col", | ||||||
|     p1: p1, |     p1: p1, | ||||||
|     p2: p2, |     p2: p2, | ||||||
|     width: width, |     width: width, | ||||||
|     margin: margin, |     margin: margin, | ||||||
|     min-width: min-width, |     min-width: min-width | ||||||
|     max-width: max-width |  | ||||||
|   ),) |   ),) | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -46,6 +45,7 @@ | |||||||
|   while i < elmts.len() { |   while i < elmts.len() { | ||||||
|     let elmt = elmts.at(i) |     let elmt = elmts.at(i) | ||||||
|     if elmt.type == "grp" { |     if elmt.type == "grp" { | ||||||
|  |       let grp-elmts = elmt.elmts | ||||||
|       elmt.elmts = elmt.elmts.map(e => { |       elmt.elmts = elmt.elmts.map(e => { | ||||||
|         if e.type == "seq" { |         if e.type == "seq" { | ||||||
|           if e.p1 == "?" { |           if e.p1 == "?" { | ||||||
| @@ -59,17 +59,12 @@ | |||||||
|       elmts.at(i) = elmt |       elmts.at(i) = elmt | ||||||
|       elmts = ( |       elmts = ( | ||||||
|         elmts.slice(0, i + 1) + |         elmts.slice(0, i + 1) + | ||||||
|         elmt.elmts + |         grp-elmts + | ||||||
|         (( |         (( | ||||||
|           type: "grp-end", |           type: "grp-end" | ||||||
|           start-i: i |  | ||||||
|         ),) + |         ),) + | ||||||
|         elmts.slice(i+1) |         elmts.slice(i+1) | ||||||
|       ) |       ) | ||||||
|     } else if elmt.type == "grp-end" { |  | ||||||
|       // Put back elements in group because they might have changed |  | ||||||
|       elmts.at(elmt.start-i).elmts = elmts.slice(elmt.start-i + 1, i) |  | ||||||
|  |  | ||||||
|     } else if elmt.type == "seq" { |     } else if elmt.type == "seq" { | ||||||
|       if elmt.enable-dst { |       if elmt.enable-dst { | ||||||
|         activation-history.push(elmt) |         activation-history.push(elmt) | ||||||
| @@ -245,10 +240,7 @@ | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   set text(font: "Source Sans 3") | ||||||
|   let canvas = render(participants, elmts) |   let canvas = render(participants, elmts) | ||||||
|   fit-canvas(canvas, width: width) |   fit-canvas(canvas, width: width) | ||||||
| } |  | ||||||
|  |  | ||||||
| #let from-plantuml(code) = { |  | ||||||
|   let code = code.text |  | ||||||
| } | } | ||||||
| @@ -1,4 +1,4 @@ | |||||||
| #import "/src/cetz.typ": draw | #import "@preview/cetz:0.2.2": draw | ||||||
| #import "consts.typ": * | #import "consts.typ": * | ||||||
|  |  | ||||||
| #let _grp(name, desc: none, type: "default", elmts) = { | #let _grp(name, desc: none, type: "default", elmts) = { | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| #let version = version(0, 2, 2) | #let version = version(0, 1, 1) | ||||||
| #import "diagram.typ": diagram, from-plantuml, _gap, _evt, _col | #import "diagram.typ": diagram, _gap, _evt, _col | ||||||
|  | #import "parser.typ": from-plantuml | ||||||
|  |  | ||||||
| #import "sequence.typ": _seq, _ret | #import "sequence.typ": _seq, _ret | ||||||
| #import "group.typ": _grp, _loop, _alt, _opt, _break | #import "group.typ": _grp, _loop, _alt, _opt, _break | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| #import "/src/cetz.typ": draw | #import "@preview/cetz:0.2.2": draw | ||||||
| #import "consts.typ": * | #import "consts.typ": * | ||||||
|  |  | ||||||
| #let SIDES = ( | #let SIDES = ( | ||||||
|   | |||||||
							
								
								
									
										1036
									
								
								src/parser.typ
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -1,4 +1,4 @@ | |||||||
| #import "/src/cetz.typ": draw | #import "@preview/cetz:0.2.2": draw | ||||||
| #import "consts.typ": * | #import "consts.typ": * | ||||||
|  |  | ||||||
| #let PAR-SPECIALS = "?[]" | #let PAR-SPECIALS = "?[]" | ||||||
| @@ -22,11 +22,6 @@ | |||||||
|   invisible: false, |   invisible: false, | ||||||
|   shape: "participant", |   shape: "participant", | ||||||
|   color: DEFAULT-COLOR, |   color: DEFAULT-COLOR, | ||||||
|   line-stroke: ( |  | ||||||
|     dash: "dashed", |  | ||||||
|     paint: gray.darken(40%), |  | ||||||
|     thickness: .5pt |  | ||||||
|   ), |  | ||||||
|   custom-image: none, |   custom-image: none, | ||||||
|   show-bottom: true, |   show-bottom: true, | ||||||
|   show-top: true, |   show-top: true, | ||||||
| @@ -42,7 +37,6 @@ | |||||||
|     invisible: invisible, |     invisible: invisible, | ||||||
|     shape: shape, |     shape: shape, | ||||||
|     color: color, |     color: color, | ||||||
|     line-stroke: line-stroke, |  | ||||||
|     custom-image: custom-image, |     custom-image: custom-image, | ||||||
|     show-bottom: show-bottom, |     show-bottom: show-bottom, | ||||||
|     show-top: show-top |     show-top: show-top | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| #import "/src/cetz.typ": canvas, draw | #import "@preview/cetz:0.2.2": canvas, draw | ||||||
| #import "utils.typ": get-participants-i, get-style, normalize-units | #import "utils.typ": get-participants-i, get-style, normalize-units | ||||||
| #import "group.typ" | #import "group.typ" | ||||||
| #import "participant.typ" | #import "participant.typ" | ||||||
| @@ -218,13 +218,10 @@ | |||||||
|       if elmt.width != auto { |       if elmt.width != auto { | ||||||
|         widths.at(i) = normalize-units(elmt.width) |         widths.at(i) = normalize-units(elmt.width) | ||||||
|       } |       } | ||||||
|  |       widths.at(i) = calc.max( | ||||||
|       let width = widths.at(i) |         widths.at(i), | ||||||
|       width = calc.max(width, normalize-units(elmt.min-width)) |         normalize-units(elmt.min-width) | ||||||
|       if elmt.max-width != none { |       ) + normalize-units(elmt.margin) | ||||||
|         width = calc.min(width, normalize-units(elmt.max-width)) |  | ||||||
|       } |  | ||||||
|       widths.at(i) = width + normalize-units(elmt.margin) |  | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -432,7 +429,11 @@ | |||||||
|             draw.line( |             draw.line( | ||||||
|               (x, last-y), |               (x, last-y), | ||||||
|               (x, line.at(1)), |               (x, line.at(1)), | ||||||
|               stroke: p.line-stroke |               stroke: ( | ||||||
|  |                 dash: "dashed", | ||||||
|  |                 paint: gray.darken(40%), | ||||||
|  |                 thickness: .5pt | ||||||
|  |               ) | ||||||
|             ) |             ) | ||||||
|           } |           } | ||||||
|           lines.push(line) |           lines.push(line) | ||||||
| @@ -458,7 +459,11 @@ | |||||||
|           draw.line( |           draw.line( | ||||||
|             (x, last-y), |             (x, last-y), | ||||||
|             (x, line.at(1)), |             (x, line.at(1)), | ||||||
|             stroke: p.line-stroke |             stroke: ( | ||||||
|  |               dash: "dashed", | ||||||
|  |               paint: gray.darken(40%), | ||||||
|  |               thickness: .5pt | ||||||
|  |             ) | ||||||
|           ) |           ) | ||||||
|           last-y = line.at(1) |           last-y = line.at(1) | ||||||
|         } else if event == "delay-end" { |         } else if event == "delay-end" { | ||||||
| @@ -478,7 +483,11 @@ | |||||||
|       draw.line( |       draw.line( | ||||||
|         (x, last-y), |         (x, last-y), | ||||||
|         (x, y), |         (x, y), | ||||||
|         stroke: p.line-stroke |         stroke: ( | ||||||
|  |           dash: "dashed", | ||||||
|  |           paint: gray.darken(40%), | ||||||
|  |           thickness: .5pt | ||||||
|  |         ) | ||||||
|       ) |       ) | ||||||
|  |  | ||||||
|       // Draw lifeline rectangles (reverse for bottom to top) |       // Draw lifeline rectangles (reverse for bottom to top) | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| #import "/src/cetz.typ": draw | #import "@preview/cetz:0.2.2": draw | ||||||
| #import "consts.typ": * | #import "consts.typ": * | ||||||
|  |  | ||||||
| #let _sep(name) = { | #let _sep(name) = { | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| #import "/src/cetz.typ": draw, vector | #import "@preview/cetz:0.2.2": draw, vector | ||||||
| #import "consts.typ": * | #import "consts.typ": * | ||||||
| #import "participant.typ" | #import "participant.typ" | ||||||
| #import "note.typ" | #import "note.typ" | ||||||
| @@ -100,27 +100,19 @@ | |||||||
|  |  | ||||||
|   y -= Y-SPACE |   y -= Y-SPACE | ||||||
|  |  | ||||||
|   let i1 = pars-i.at(elmt.p1) |  | ||||||
|   let i2 = pars-i.at(elmt.p2) |  | ||||||
|   let width = calc.abs(x-pos.at(i1) - x-pos.at(i2)) |  | ||||||
|  |  | ||||||
|   let h = 0 |   let h = 0 | ||||||
|   let comment = if elmt.comment == none {none} else { |  | ||||||
|     let w = calc.min(width * 1pt, measure(elmt.comment).width) |  | ||||||
|     box( |  | ||||||
|       width: if i1 == i2 {auto} else {w}, |  | ||||||
|       elmt.comment |  | ||||||
|     ) |  | ||||||
|   } |  | ||||||
|   // Reserve space for comment |   // Reserve space for comment | ||||||
|   if comment != none { |   if elmt.comment != none { | ||||||
|     h = calc.max(h, measure(comment).height / 1pt + 6) |     h = calc.max(h, measure(box(elmt.comment)).height / 1pt + 6) | ||||||
|   } |   } | ||||||
|   if "linked-note" in elmt { |   if "linked-note" in elmt { | ||||||
|     h = calc.max(h, note.get-size(elmt.linked-note).height / 2) |     h = calc.max(h, note.get-size(elmt.linked-note).height / 2) | ||||||
|   } |   } | ||||||
|   y -= h |   y -= h | ||||||
|  |  | ||||||
|  |   let i1 = pars-i.at(elmt.p1) | ||||||
|  |   let i2 = pars-i.at(elmt.p2) | ||||||
|  |  | ||||||
|   let start-info = ( |   let start-info = ( | ||||||
|     i: i1, |     i: i1, | ||||||
|     x: x-pos.at(i1), |     x: x-pos.at(i1), | ||||||
| @@ -177,7 +169,7 @@ | |||||||
|     let m = measure(box(par.display-name)) |     let m = measure(box(par.display-name)) | ||||||
|     let f = if i1 > i2 {-1} else {1} |     let f = if i1 > i2 {-1} else {1} | ||||||
|     end-info.x -= (m.width + PAR-PAD.last() * 2) / 2pt * f |     end-info.x -= (m.width + PAR-PAD.last() * 2) / 2pt * f | ||||||
|     shapes += participant.render(x-pos, par, y: end-info.y) |     shapes += participant.render(x-pos, par, y: end-info.y - CREATE-OFFSET) | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   end-info.ll-lvl = lifelines.at(i2).level * LIFELINE-W / 2 |   end-info.ll-lvl = lifelines.at(i2).level * LIFELINE-W / 2 | ||||||
| @@ -252,7 +244,7 @@ | |||||||
|       (x2, end-info.y) |       (x2, end-info.y) | ||||||
|     ) |     ) | ||||||
|  |  | ||||||
|     if comment != none { |     if elmt.comment != none { | ||||||
|       comment-anchor = ( |       comment-anchor = ( | ||||||
|         start: if x-mid < x1 {"south-east"} else {"south-west"}, |         start: if x-mid < x1 {"south-east"} else {"south-west"}, | ||||||
|         end: if x-mid < x1 {"south-west"} else {"south-east"}, |         end: if x-mid < x1 {"south-west"} else {"south-east"}, | ||||||
| @@ -276,7 +268,7 @@ | |||||||
|       (x2, end-info.y) |       (x2, end-info.y) | ||||||
|     ) |     ) | ||||||
|  |  | ||||||
|     if comment != none { |     if elmt.comment != none { | ||||||
|       let start-pt = pts.first() |       let start-pt = pts.first() | ||||||
|       let end-pt = pts.last() |       let end-pt = pts.last() | ||||||
|       if elmt.start-tip != "" { |       if elmt.start-tip != "" { | ||||||
| @@ -356,26 +348,27 @@ | |||||||
|  |  | ||||||
|   shapes += draw.line(..pts, ..style) |   shapes += draw.line(..pts, ..style) | ||||||
|  |  | ||||||
|   if comment != none { |   if elmt.comment != none { | ||||||
|     shapes += draw.content( |     shapes += draw.content( | ||||||
|       comment-pt, |       comment-pt, | ||||||
|       comment, |       elmt.comment, | ||||||
|       anchor: comment-anchor, |       anchor: comment-anchor, | ||||||
|       angle: comment-angle, |       angle: comment-angle, | ||||||
|       padding: 3pt |       padding: 3pt | ||||||
|     ) |     ) | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   if elmt.create-dst { |  | ||||||
|     let dst-line = lifelines.at(i2) |  | ||||||
|     dst-line.lines.push(("create", end-info.y)) |  | ||||||
|     lifelines.at(i2) = dst-line |  | ||||||
|   } |  | ||||||
|   if elmt.enable-dst { |   if elmt.enable-dst { | ||||||
|     let dst-line = lifelines.at(i2) |     let dst-line = lifelines.at(i2) | ||||||
|     dst-line.lines.push(("enable", end-info.y, elmt.lifeline-style)) |     dst-line.lines.push(("enable", end-info.y, elmt.lifeline-style)) | ||||||
|     lifelines.at(i2) = dst-line |     lifelines.at(i2) = dst-line | ||||||
|   } |   } | ||||||
|  |   if elmt.create-dst { | ||||||
|  |     end-info.y -= CREATE-OFFSET | ||||||
|  |     let dst-line = lifelines.at(i2) | ||||||
|  |     dst-line.lines.push(("create", end-info.y)) | ||||||
|  |     lifelines.at(i2) = dst-line | ||||||
|  |   } | ||||||
|  |  | ||||||
|   if "linked-note" in elmt { |   if "linked-note" in elmt { | ||||||
|     let m = note.get-size(elmt.linked-note) |     let m = note.get-size(elmt.linked-note) | ||||||
|   | |||||||
| @@ -36,9 +36,6 @@ | |||||||
|       max-i = calc.max(max-i, i1) |       max-i = calc.max(max-i, i1) | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   if max-i < min-i { |  | ||||||
|     (min-i, max-i) = (max-i, min-i) |  | ||||||
|   } |  | ||||||
|   return (min-i, max-i) |   return (min-i, max-i) | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										4
									
								
								tests/empty/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						| @@ -1,4 +0,0 @@ | |||||||
| # generated by tytanic, do not edit |  | ||||||
|  |  | ||||||
| diff/** |  | ||||||
| out/** |  | ||||||
| Before Width: | Height: | Size: 105 B | 
| @@ -1,6 +0,0 @@ | |||||||
| #set page(width: auto, height: auto) |  | ||||||
| #import "/src/lib.typ": * |  | ||||||
|  |  | ||||||
| #diagram({}) |  | ||||||
|  |  | ||||||
| #diagram(()) |  | ||||||
							
								
								
									
										4
									
								
								tests/group/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						| @@ -1,4 +0,0 @@ | |||||||
| # generated by tytanic, do not edit |  | ||||||
|  |  | ||||||
| diff/** |  | ||||||
| out/** |  | ||||||
| Before Width: | Height: | Size: 46 KiB | 
| Before Width: | Height: | Size: 5.3 KiB | 
| Before Width: | Height: | Size: 6.7 KiB | 
| @@ -1,51 +0,0 @@ | |||||||
| #set page(width: auto, height: auto) |  | ||||||
| #import "/src/lib.typ": * |  | ||||||
|  |  | ||||||
| #diagram({ |  | ||||||
|   _seq("Alice", "Bob", comment: "Authentication Request") |  | ||||||
|  |  | ||||||
|   _alt( |  | ||||||
|     "successful case", { |  | ||||||
|       _seq("Bob", "Alice", comment: "Authentication Accepted") |  | ||||||
|     }, |  | ||||||
|     "some kind of failure", { |  | ||||||
|       _seq("Bob", "Alice", comment: "Authentication Failure") |  | ||||||
|  |  | ||||||
|       _grp("My own label", desc: "My own label2", { |  | ||||||
|         _seq("Alice", "Log", comment: "Log attack start") |  | ||||||
|         _loop("1000 times", { |  | ||||||
|           _seq("Alice", "Bob", comment: "DNS Attack") |  | ||||||
|         }) |  | ||||||
|         _seq("Alice", "Log", comment: "Log attack end") |  | ||||||
|       }) |  | ||||||
|     }, |  | ||||||
|     "Another type of failure", { |  | ||||||
|       _seq("Bob", "Alice", comment: "Please repeat") |  | ||||||
|     } |  | ||||||
|   ) |  | ||||||
| }) |  | ||||||
|  |  | ||||||
| #pagebreak() |  | ||||||
|  |  | ||||||
| #diagram({ |  | ||||||
|   _par("a", display-name: box(width: 1.5em, height: .5em), show-bottom: false) |  | ||||||
|   _par("b", display-name: box(width: 1.5em, height: .5em), show-bottom: false) |  | ||||||
|   _col("a", "b", width: 2cm) |  | ||||||
|   _loop("a<1", min: 1, { |  | ||||||
|     _seq("a", "b", end-tip: ">>") |  | ||||||
|     _seq("b", "a", end-tip: ">>") |  | ||||||
|   }) |  | ||||||
|   _seq("a", "b", end-tip: ">>") |  | ||||||
| }) |  | ||||||
|  |  | ||||||
| #pagebreak() |  | ||||||
|  |  | ||||||
| #diagram({ |  | ||||||
|   _par("A") |  | ||||||
|   _par("B") |  | ||||||
|   _col("A", "B", width: 3cm) |  | ||||||
|   _seq("A", "B", enable-dst: true) |  | ||||||
|   _alt([desc], { |  | ||||||
|     _ret() |  | ||||||
|   }) |  | ||||||
| }) |  | ||||||
							
								
								
									
										4
									
								
								tests/note/color/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						| @@ -1,4 +0,0 @@ | |||||||
| # generated by tytanic, do not edit |  | ||||||
|  |  | ||||||
| diff/** |  | ||||||
| out/** |  | ||||||
| Before Width: | Height: | Size: 33 KiB | 
| @@ -1,13 +0,0 @@ | |||||||
| #set page(width: auto, height: auto) |  | ||||||
| #import "/src/lib.typ": * |  | ||||||
|  |  | ||||||
| #diagram({ |  | ||||||
|   _par("a", display-name: "Alice") |  | ||||||
|   _par("b", display-name: "Bob") |  | ||||||
|  |  | ||||||
|   _note("left", [This is displayed\ left of Alice.], pos: "a", color: rgb("#00FFFF")) |  | ||||||
|   _note("right", [This is displayed right of Alice.], pos: "a") |  | ||||||
|   _note("over", [This is displayed over Alice.], pos: "a") |  | ||||||
|   _note("over", [This is displayed\ over Bob and Alice.], pos: ("a", "b"), color: rgb("#FFAAAA")) |  | ||||||
|   _note("over", [This is yet another\ example of\ a long note.], pos: ("a", "b")) |  | ||||||
| }) |  | ||||||
							
								
								
									
										4
									
								
								tests/note/position/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						| @@ -1,4 +0,0 @@ | |||||||
| # generated by tytanic, do not edit |  | ||||||
|  |  | ||||||
| diff/** |  | ||||||
| out/** |  | ||||||
| Before Width: | Height: | Size: 23 KiB | 
| Before Width: | Height: | Size: 13 KiB | 
| Before Width: | Height: | Size: 35 KiB | 
| @@ -1,49 +0,0 @@ | |||||||
| #set page(width: auto, height: auto) |  | ||||||
| #import "/src/lib.typ": * |  | ||||||
|  |  | ||||||
| #diagram({ |  | ||||||
|   _par("a", display-name: "Alice") |  | ||||||
|   _par("b", display-name: "Bob") |  | ||||||
|  |  | ||||||
|   _seq("a", "b", comment: [hello]) |  | ||||||
|   _note("left", [this is a first note]) |  | ||||||
|  |  | ||||||
|   _seq("b", "a", comment: [ok]) |  | ||||||
|   _note("right", [this is another note]) |  | ||||||
|  |  | ||||||
|   _seq("b", "b", comment: [I am thinking]) |  | ||||||
|   _note("left", [a note\ can also be defined\ on several lines]) |  | ||||||
| }) |  | ||||||
|  |  | ||||||
| #pagebreak() |  | ||||||
|  |  | ||||||
| #diagram({ |  | ||||||
|   _par("a", display-name: "Alice") |  | ||||||
|   _par("b", display-name: "Bob") |  | ||||||
|  |  | ||||||
|   _note("over", [initial state of Alice], pos: "a") |  | ||||||
|   _note("over", [initial state of Bob], pos: "b") |  | ||||||
|   _seq("b", "a", comment: [hello]) |  | ||||||
| }) |  | ||||||
|  |  | ||||||
| #pagebreak() |  | ||||||
|  |  | ||||||
| #diagram({ |  | ||||||
|   _par("a", display-name: "Alice") |  | ||||||
|   _par("b", display-name: "Bob") |  | ||||||
|   _par("c", display-name: "Charlie") |  | ||||||
|   _par("d", display-name: "Donald") |  | ||||||
|   _par("e", display-name: "Eddie") |  | ||||||
|  |  | ||||||
|   _note("across", [This note float above all participants]) |  | ||||||
|  |  | ||||||
|   _note("over", [initial state of Alice], pos: "a") |  | ||||||
|   _note("over", [initial state of Bob the builder], pos: "b", aligned: true) |  | ||||||
|  |  | ||||||
|   _note("over", [Note 1], pos: "a") |  | ||||||
|   _note("over", [Note 2], pos: "b", aligned: true) |  | ||||||
|   _note("over", [Note 3], pos: "c", aligned: true) |  | ||||||
|  |  | ||||||
|   _seq("a", "d") |  | ||||||
|   _note("over", [this is an extremely long note], pos: ("d", "e")) |  | ||||||
| }) |  | ||||||
							
								
								
									
										4
									
								
								tests/note/shape/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						| @@ -1,4 +0,0 @@ | |||||||
| # generated by tytanic, do not edit |  | ||||||
|  |  | ||||||
| diff/** |  | ||||||
| out/** |  | ||||||
| Before Width: | Height: | Size: 25 KiB | 
| @@ -1,14 +0,0 @@ | |||||||
| #set page(width: auto, height: auto) |  | ||||||
| #import "/src/lib.typ": * |  | ||||||
|  |  | ||||||
| #diagram({ |  | ||||||
|   _par("caller") |  | ||||||
|   _par("server") |  | ||||||
|  |  | ||||||
|   _seq("caller", "server", comment: [conReq]) |  | ||||||
|   _note("over", [idle], pos: "caller", shape: "hex") |  | ||||||
|   _seq("server", "caller", comment: [conConf]) |  | ||||||
|   _note("over", ["r" as rectangle\ "h" as hexagon], pos: "server", shape: "rect") |  | ||||||
|   _note("over", [this is\ on several\ lines], pos: "server", shape: "rect") |  | ||||||
|   _note("over", [this is\ on several\ lines], pos: "caller", shape: "hex") |  | ||||||
| }) |  | ||||||
							
								
								
									
										4
									
								
								tests/note/styled-body/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						| @@ -1,4 +0,0 @@ | |||||||
| # generated by tytanic, do not edit |  | ||||||
|  |  | ||||||
| diff/** |  | ||||||
| out/** |  | ||||||
| Before Width: | Height: | Size: 50 KiB | 
| @@ -1,33 +0,0 @@ | |||||||
| #set page(width: auto, height: auto) |  | ||||||
| #import "/src/lib.typ": * |  | ||||||
|  |  | ||||||
| #diagram({ |  | ||||||
|   _par("a", display-name: [Alice]) |  | ||||||
|   _par("b", display-name: [The *Famous* Bob]) |  | ||||||
|  |  | ||||||
|   _seq("a", "b", comment: [hello #strike([there])]) |  | ||||||
|  |  | ||||||
|   _gap() |  | ||||||
|   _seq("b", "a", comment: [ok]) |  | ||||||
|   _note("left", [ |  | ||||||
|     This is *bold*\ |  | ||||||
|     This is _italics_\ |  | ||||||
|     This is `monospaced`\ |  | ||||||
|     This is #strike([stroked])\ |  | ||||||
|     This is #underline([underlined])\ |  | ||||||
|     This is #underline([waved])\ |  | ||||||
|   ]) |  | ||||||
|  |  | ||||||
|   _seq("a", "b", comment: [A _well formatted_ message]) |  | ||||||
|   _note("right", [ |  | ||||||
|     This is #box(text([displayed], size: 18pt), fill: rgb("#5F9EA0"))\ |  | ||||||
|     #underline([left of]) Alice. |  | ||||||
|   ], pos: "a") |  | ||||||
|   _note("left", [ |  | ||||||
|     #underline([This], stroke: red) is #text([displayed], fill: rgb("#118888"))\ |  | ||||||
|     *#text([left of], fill: rgb("#800080")) #strike([Alice], stroke: red) Bob.* |  | ||||||
|   ], pos: "b") |  | ||||||
|   _note("over", [ |  | ||||||
|     #underline([This is hosted], stroke: rgb("#FF33FF")) by #box(baseline: 50%, image("/gallery/gitea.png", width: 1cm, height: 1cm, fit: "contain")) |  | ||||||
|   ], pos: ("a", "b")) |  | ||||||
| }) |  | ||||||
							
								
								
									
										4
									
								
								tests/participant/shapes/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						| @@ -1,4 +0,0 @@ | |||||||
| # generated by tytanic, do not edit |  | ||||||
|  |  | ||||||
| diff/** |  | ||||||
| out/** |  | ||||||
| Before Width: | Height: | Size: 102 KiB | 
| @@ -1,21 +0,0 @@ | |||||||
| #set page(width: auto, height: auto) |  | ||||||
| #import "/src/lib.typ": * |  | ||||||
|  |  | ||||||
|  |  | ||||||
| #let TYPST = image("/gallery/typst.png", width: 1.5cm, height: 1.5cm, fit: "contain") |  | ||||||
| #let FERRIS = image("/gallery/ferris.png", width: 1.5cm, height: 1.5cm, fit: "contain") |  | ||||||
| #let ME = image("/gallery/me.jpg", width: 1.5cm, height: 1.5cm, fit: "contain") |  | ||||||
|  |  | ||||||
| #diagram({ |  | ||||||
|   _par("Foo", display-name: "Participant", shape: "participant") |  | ||||||
|   _par("Foo1", display-name: "Actor", shape: "actor") |  | ||||||
|   _par("Foo2", display-name: "Boundary", shape: "boundary") |  | ||||||
|   _par("Foo3", display-name: "Control", shape: "control") |  | ||||||
|   _par("Foo4", display-name: "Entity", shape: "entity") |  | ||||||
|   _par("Foo5", display-name: "Database", shape: "database") |  | ||||||
|   _par("Foo6", display-name: "Collections", shape: "collections") |  | ||||||
|   _par("Foo7", display-name: "Queue", shape: "queue") |  | ||||||
|   _par("Foo8", display-name: "Typst", shape: "custom", custom-image: TYPST) |  | ||||||
|   _par("Foo9", display-name: "Ferris", shape: "custom", custom-image: FERRIS) |  | ||||||
|   _par("Foo10", display-name: "Baryhobal", shape: "custom", custom-image: ME) |  | ||||||
| }) |  | ||||||
							
								
								
									
										4
									
								
								tests/sequence/comment-align/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						| @@ -1,4 +0,0 @@ | |||||||
| # generated by tytanic, do not edit |  | ||||||
|  |  | ||||||
| diff/** |  | ||||||
| out/** |  | ||||||
| Before Width: | Height: | Size: 57 KiB | 
| Before Width: | Height: | Size: 28 KiB | 
| @@ -1,57 +0,0 @@ | |||||||
| #set page(width: auto, height: auto) |  | ||||||
| #import "/src/lib.typ": * |  | ||||||
|  |  | ||||||
| #diagram({ |  | ||||||
|   _par("alice", display-name: "Alice") |  | ||||||
|   _par("bob", display-name: "Bob") |  | ||||||
|   _seq("alice", "bob", comment: "This is a very long comment") |  | ||||||
|  |  | ||||||
|   // Left to right |  | ||||||
|   _seq("alice", "bob", comment: "Start aligned", comment-align: "start") |  | ||||||
|   _seq("alice", "bob", comment: "End aligned", comment-align: "end") |  | ||||||
|   _seq("alice", "bob", comment: "Left aligned", comment-align: "left") |  | ||||||
|   _seq("alice", "bob", comment: "Right aligned", comment-align: "right") |  | ||||||
|   _seq("alice", "bob", comment: "Centered", comment-align: "center") |  | ||||||
|   _gap() |  | ||||||
|  |  | ||||||
|   // Right to left |  | ||||||
|   _seq("bob", "alice", comment: "Start aligned", comment-align: "start") |  | ||||||
|   _seq("bob", "alice", comment: "End aligned", comment-align: "end") |  | ||||||
|   _seq("bob", "alice", comment: "Left aligned", comment-align: "left") |  | ||||||
|   _seq("bob", "alice", comment: "Right aligned", comment-align: "right") |  | ||||||
|   _seq("bob", "alice", comment: "Centered", comment-align: "center") |  | ||||||
|   _gap() |  | ||||||
|  |  | ||||||
|   // Slant left to right |  | ||||||
|   _seq("alice", "bob", comment: "Start aligned", comment-align: "start", slant: 10) |  | ||||||
|   _seq("alice", "bob", comment: "End aligned", comment-align: "end", slant: 10) |  | ||||||
|   _seq("alice", "bob", comment: "Left aligned", comment-align: "left", slant: 10) |  | ||||||
|   _seq("alice", "bob", comment: "Right aligned", comment-align: "right", slant: 10) |  | ||||||
|   _seq("alice", "bob", comment: "Centered", comment-align: "center", slant: 10) |  | ||||||
|   _gap() |  | ||||||
|  |  | ||||||
|   // Slant right to left |  | ||||||
|   _seq("bob", "alice", comment: "Start aligned", comment-align: "start", slant: 10) |  | ||||||
|   _seq("bob", "alice", comment: "End aligned", comment-align: "end", slant: 10) |  | ||||||
|   _seq("bob", "alice", comment: "Left aligned", comment-align: "left", slant: 10) |  | ||||||
|   _seq("bob", "alice", comment: "Right aligned", comment-align: "right", slant: 10) |  | ||||||
|   _seq("bob", "alice", comment: "Centered", comment-align: "center", slant: 10) |  | ||||||
| }) |  | ||||||
|  |  | ||||||
| #pagebreak() |  | ||||||
|  |  | ||||||
| #diagram({ |  | ||||||
|   _par("alice", display-name: "Alice") |  | ||||||
|  |  | ||||||
|   _seq("alice", "alice", comment: "Start aligned", comment-align: "start") |  | ||||||
|   _seq("alice", "alice", comment: "End aligned", comment-align: "end") |  | ||||||
|   _seq("alice", "alice", comment: "Left aligned", comment-align: "left") |  | ||||||
|   _seq("alice", "alice", comment: "Right aligned", comment-align: "right") |  | ||||||
|   _seq("alice", "alice", comment: "Centered", comment-align: "center") |  | ||||||
|  |  | ||||||
|   _seq("alice", "alice", comment: "Start aligned", comment-align: "start", flip: true) |  | ||||||
|   _seq("alice", "alice", comment: "End aligned", comment-align: "end", flip: true) |  | ||||||
|   _seq("alice", "alice", comment: "Left aligned", comment-align: "left", flip: true) |  | ||||||
|   _seq("alice", "alice", comment: "Right aligned", comment-align: "right", flip: true) |  | ||||||
|   _seq("alice", "alice", comment: "Centered", comment-align: "center", flip: true) |  | ||||||
| }) |  | ||||||
							
								
								
									
										4
									
								
								tests/sequence/special-par/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						| @@ -1,4 +0,0 @@ | |||||||
| # generated by tytanic, do not edit |  | ||||||
|  |  | ||||||
| diff/** |  | ||||||
| out/** |  | ||||||
| Before Width: | Height: | Size: 29 KiB | 
| @@ -1,12 +0,0 @@ | |||||||
| #set page(width: auto, height: auto) |  | ||||||
| #import "/src/lib.typ": * |  | ||||||
|  |  | ||||||
| #diagram({ |  | ||||||
|   _seq("?", "Alice", comment: [?->\ *short* to actor1]) |  | ||||||
|   _seq("[", "Alice", comment: [\[->\ *from start* to actor1]) |  | ||||||
|   _seq("[", "Bob", comment: [\[->\ *from start* to actor2]) |  | ||||||
|   _seq("?", "Bob", comment: [?->\ *short* to actor2]) |  | ||||||
|   _seq("Alice", "]", comment: [->\]\ from actor1 *to end*]) |  | ||||||
|   _seq("Alice", "?", comment: [->?\ *short* from actor1]) |  | ||||||
|   _seq("Alice", "Bob", comment: [->\ from actor1 to actor2]) |  | ||||||
| }) |  | ||||||
							
								
								
									
										4
									
								
								tests/sequence/tips/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						| @@ -1,4 +0,0 @@ | |||||||
| # generated by tytanic, do not edit |  | ||||||
|  |  | ||||||
| diff/** |  | ||||||
| out/** |  | ||||||
| Before Width: | Height: | Size: 24 KiB | 
| Before Width: | Height: | Size: 24 KiB | 
| Before Width: | Height: | Size: 26 KiB | 
| @@ -1,84 +0,0 @@ | |||||||
| #set page(width: auto, height: auto) |  | ||||||
| #import "/src/lib.typ": * |  | ||||||
|  |  | ||||||
| #diagram({ |  | ||||||
|   _par("a", display-name: "Alice") |  | ||||||
|   _par("b", display-name: "Bob") |  | ||||||
|  |  | ||||||
|   _seq("a", "b", end-tip: ">", comment: `->`) |  | ||||||
|   _seq("a", "b", end-tip: ">>", comment: `->>`) |  | ||||||
|   _seq("a", "b", end-tip: "\\", comment: `-\`) |  | ||||||
|   _seq("a", "b", end-tip: "\\\\", comment: `-\\`) |  | ||||||
|   _seq("a", "b", end-tip: "/", comment: `-/`) |  | ||||||
|   _seq("a", "b", end-tip: "//", comment: `-//`) |  | ||||||
|   _seq("a", "b", end-tip: "x", comment: `->x`) |  | ||||||
|   _seq("a", "b", start-tip: "x", comment: `x->`) |  | ||||||
|   _seq("a", "b", start-tip: "o", comment: `o->`) |  | ||||||
|   _seq("a", "b", end-tip: ("o", ">"), comment: `->o`) |  | ||||||
|   _seq("a", "b", start-tip: "o", end-tip: ("o", ">"), comment: `o->o`) |  | ||||||
|   _seq("a", "b", start-tip: ">", end-tip: ">", comment: `<->`) |  | ||||||
|   _seq("a", "b", start-tip: ("o", ">"), end-tip: ("o", ">"), comment: `o<->o`) |  | ||||||
|   _seq("a", "b", start-tip: "x", end-tip: "x", comment: `x<->x`) |  | ||||||
|   _seq("a", "b", end-tip: ("o", ">>"), comment: `->>o`) |  | ||||||
|   _seq("a", "b", end-tip: ("o", "\\"), comment: `-\o`) |  | ||||||
|   _seq("a", "b", end-tip: ("o", "\\\\"), comment: `-\\o`) |  | ||||||
|   _seq("a", "b", end-tip: ("o", "/"), comment: `-/o`) |  | ||||||
|   _seq("a", "b", end-tip: ("o", "//"), comment: `-//o`) |  | ||||||
|   _seq("a", "b", start-tip: "x", end-tip: ("o", ">"), comment: `x->o`) |  | ||||||
| }) |  | ||||||
|  |  | ||||||
| #pagebreak() |  | ||||||
|  |  | ||||||
| #diagram({ |  | ||||||
|   _par("a", display-name: "Alice") |  | ||||||
|   _par("b", display-name: "Bob") |  | ||||||
|  |  | ||||||
|   _seq("b", "a", end-tip: ">", comment: `->`) |  | ||||||
|   _seq("b", "a", end-tip: ">>", comment: `->>`) |  | ||||||
|   _seq("b", "a", end-tip: "\\", comment: `-\`) |  | ||||||
|   _seq("b", "a", end-tip: "\\\\", comment: `-\\`) |  | ||||||
|   _seq("b", "a", end-tip: "/", comment: `-/`) |  | ||||||
|   _seq("b", "a", end-tip: "//", comment: `-//`) |  | ||||||
|   _seq("b", "a", end-tip: "x", comment: `->x`) |  | ||||||
|   _seq("b", "a", start-tip: "x", comment: `x->`) |  | ||||||
|   _seq("b", "a", start-tip: "o", comment: `o->`) |  | ||||||
|   _seq("b", "a", end-tip: ("o", ">"), comment: `->o`) |  | ||||||
|   _seq("b", "a", start-tip: "o", end-tip: ("o", ">"), comment: `o->o`) |  | ||||||
|   _seq("b", "a", start-tip: ">", end-tip: ">", comment: `<->`) |  | ||||||
|   _seq("b", "a", start-tip: ("o", ">"), end-tip: ("o", ">"), comment: `o<->o`) |  | ||||||
|   _seq("b", "a", start-tip: "x", end-tip: "x", comment: `x<->x`) |  | ||||||
|   _seq("b", "a", end-tip: ("o", ">>"), comment: `->>o`) |  | ||||||
|   _seq("b", "a", end-tip: ("o", "\\"), comment: `-\o`) |  | ||||||
|   _seq("b", "a", end-tip: ("o", "\\\\"), comment: `-\\o`) |  | ||||||
|   _seq("b", "a", end-tip: ("o", "/"), comment: `-/o`) |  | ||||||
|   _seq("b", "a", end-tip: ("o", "//"), comment: `-//o`) |  | ||||||
|   _seq("b", "a", start-tip: "x", end-tip: ("o", ">"), comment: `x->o`) |  | ||||||
| }) |  | ||||||
|  |  | ||||||
| #pagebreak() |  | ||||||
|  |  | ||||||
| #diagram({ |  | ||||||
|   _par("a", display-name: "Alice") |  | ||||||
|   _par("b", display-name: "Bob") |  | ||||||
|  |  | ||||||
|   _seq("a", "a", end-tip: ">", comment: `->`) |  | ||||||
|   _seq("a", "a", end-tip: ">>", comment: `->>`) |  | ||||||
|   _seq("a", "a", end-tip: "\\", comment: `-\`) |  | ||||||
|   _seq("a", "a", end-tip: "\\\\", comment: `-\\`) |  | ||||||
|   _seq("a", "a", end-tip: "/", comment: `-/`) |  | ||||||
|   _seq("a", "a", end-tip: "//", comment: `-//`) |  | ||||||
|   _seq("a", "a", end-tip: "x", comment: `->x`) |  | ||||||
|   _seq("a", "a", start-tip: "x", comment: `x->`) |  | ||||||
|   _seq("a", "a", start-tip: "o", comment: `o->`) |  | ||||||
|   _seq("a", "a", end-tip: ("o", ">"), comment: `->o`) |  | ||||||
|   _seq("a", "a", start-tip: "o", end-tip: ("o", ">"), comment: `o->o`) |  | ||||||
|   _seq("a", "a", start-tip: ">", end-tip: ">", comment: `<->`) |  | ||||||
|   _seq("a", "a", start-tip: ("o", ">"), end-tip: ("o", ">"), comment: `o<->o`) |  | ||||||
|   _seq("a", "a", start-tip: "x", end-tip: "x", comment: `x<->x`) |  | ||||||
|   _seq("a", "a", end-tip: ("o", ">>"), comment: `->>o`) |  | ||||||
|   _seq("a", "a", end-tip: ("o", "\\"), comment: `-\o`) |  | ||||||
|   _seq("a", "a", end-tip: ("o", "\\\\"), comment: `-\\o`) |  | ||||||
|   _seq("a", "a", end-tip: ("o", "/"), comment: `-/o`) |  | ||||||
|   _seq("a", "a", end-tip: ("o", "//"), comment: `-//o`) |  | ||||||
|   _seq("a", "a", start-tip: "x", end-tip: ("o", ">"), comment: `x->o`) |  | ||||||
| }) |  | ||||||
| @@ -1,7 +1,7 @@ | |||||||
| [package] | [package] | ||||||
| name = "chronos" | name = "chronos" | ||||||
| version = "0.2.2" | version = "0.1.1" | ||||||
| compiler = "0.13.1" | compiler = "0.11.0" | ||||||
| repository = "https://git.kb28.ch/HEL/chronos" | repository = "https://git.kb28.ch/HEL/chronos" | ||||||
| entrypoint = "src/lib.typ" | entrypoint = "src/lib.typ" | ||||||
| authors = [ | authors = [ | ||||||
| @@ -11,4 +11,4 @@ categories = ["visualization"] | |||||||
| license = "Apache-2.0" | license = "Apache-2.0" | ||||||
| description = "A package to draw sequence diagrams with CeTZ" | description = "A package to draw sequence diagrams with CeTZ" | ||||||
| keywords = ["sequence", "diagram", "plantuml"] | keywords = ["sequence", "diagram", "plantuml"] | ||||||
| exclude = [ "gallery", "justfile", "docs" ] | exclude = [ "gallery", "gallery.bash", "docs" ] | ||||||
|   | |||||||