This work is licensed under Apache License 2.0
This project will explore many ways to visualize KFSM definitions.
This project require Kotlin Grammar Tools in order to parse the code containing the FSM.
I made changes to https://github.com/Kotlin/grammar-tools
if the change had been merge the batch file change change to checkout
their version.
repositories {
maven {
url 'https://oss.sonatype.org/content/groups/public/'
}
mavenCentral()
}
dependencies {
testImplementation 'io.jumpco.open:kfsm-viz:1.5.2.4'
}
You can implement a test method to generate the required statemachine model artifacts, or you can configure the kfsm-viz-plugin for Gradle to produce visualizations.
By parsing the source code we can extract the details of the guard expressions and actions. This requires that you place one definition inside of one class. There is a chance for the parser based solution to misbehave. We request that you log an issue with the problematic FSM definition.
@Test
fun produceVisualizationTurnstileFSM() {
println("== TurnStile")
val visualisation = parseStateMachine("TurnstileFSM", File("src/test/kotlin/Turnstile.kt"))
File("generated-parsed", "turnstile.plantuml").writeText(plantUml(visualisation, true)) (1)
File("generated-parsed", "turnstile-simple.plantuml").writeText(plantUml(visualisation, false)) (2)
}
-
Detailed Included in State Diagram
-
Detail like actions and guards ignored
@Test
fun produceVisualizationTurnstileFSM() {
println("== TurnStile")
val visualisation = parseStateMachine("TurnstileFSM", File("src/test/kotlin/Turnstile.kt"))
File("generated-parsed", "turnstile.adoc").writeText(asciiDoc(visualisation))
}
We generated an asciidoc table as well as a plantuml statemachine model.