initial commit + basic sequences
This commit is contained in:
51
src/diagram.typ
Normal file
51
src/diagram.typ
Normal file
@ -0,0 +1,51 @@
|
||||
#import "renderer.typ": render
|
||||
|
||||
#let _seq(p1, p2, comment: none, style: auto) = {
|
||||
return ((
|
||||
type: "seq",
|
||||
p1: p1,
|
||||
p2: p2,
|
||||
comment: comment,
|
||||
style: style
|
||||
),)
|
||||
}
|
||||
|
||||
#let _par(name, display-name: auto, start-at: 0) = {
|
||||
return ((
|
||||
type: "par",
|
||||
name: name,
|
||||
display-name: if display-name == auto {name} else {display-name},
|
||||
start-at: start-at
|
||||
),)
|
||||
}
|
||||
|
||||
#let _par-exists(participants, name) = {
|
||||
for p in participants {
|
||||
if name == p.name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
#let diagram(elements) = {
|
||||
let participants = ()
|
||||
for elmt in elements {
|
||||
if elmt.type == "par" {
|
||||
participants.push(elmt)
|
||||
} else if elmt.type == "seq" {
|
||||
if not _par-exists(participants, elmt.p1) {
|
||||
participants.push(_par(elmt.p1).first())
|
||||
}
|
||||
if not _par-exists(participants, elmt.p2) {
|
||||
participants.push(_par(elmt.p2).first())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
render(participants, elements)
|
||||
}
|
||||
|
||||
#let from-plantuml(code) = {
|
||||
let code = code.text
|
||||
}
|
Reference in New Issue
Block a user