Skip to content

Commit

Permalink
updated asciidoctor plugin versions.
Browse files Browse the repository at this point in the history
updated locations to default convensions.
  • Loading branch information
corneil committed Sep 4, 2019
1 parent e61b2b7 commit 3bebfbf
Show file tree
Hide file tree
Showing 39 changed files with 30 additions and 16 deletions.
8 changes: 6 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Then we use the DSL to declare a definition of a statemachine matching the diagr

==== State Diagram

image::src/doc/asciidoc/turnstile_fsm.png[Turnstile state diagram]
image::src/docs/asciidoc/turnstile-fsm.png[Turnstile state diagram]

==== State Table

Expand Down Expand Up @@ -121,7 +121,11 @@ class TurnstileFSM(turnstile: Turnstile) {
fun coin() = fsm.sendEvent(TurnstileEvents.COIN)
fun pass() = fsm.sendEvent(TurnstileEvents.PASS)
companion object {
private val definition = stateMachine(TurnstileStates.values().toSet(), TurnstileEvents::class, Turnstile::class) {
private val definition = stateMachine(
TurnstileStates.values().toSet(),
TurnstileEvents::class,
Turnstile::class
) {
initial {
if (locked)
TurnstileStates.LOCKED
Expand Down
8 changes: 6 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ plugins {
id 'org.jetbrains.dokka' version '0.9.18'
id 'maven-publish'
id 'signing'
id 'org.asciidoctor.convert' version '2.2.0'
id 'org.asciidoctor.convert' version '2.3.0'
id 'org.jlleitschuh.gradle.ktlint' version '8.2.0'
id 'org.jlleitschuh.gradle.ktlint-idea' version '8.2.0'
id 'com.cosminpolifronie.gradle.plantuml' version '1.6.0'
}

repositories {
Expand All @@ -30,7 +31,6 @@ apply from: "$rootProject.projectDir/gradle/publish.gradle"
def useTarget = project.ext.useTarget



kotlin {
sourceSets {
commonTest {
Expand Down Expand Up @@ -64,3 +64,7 @@ ktlint {
include("**/kotlin/**")
}
}

plantUml {
render input: 'src/docs/plantuml/*.plantuml', output: 'src/docs/asciidoc', format: 'png', withMetadata: false
}
4 changes: 1 addition & 3 deletions gradle/docs.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ dokka {
}

asciidoctor {
sourceDir = file('src/doc/asciidoc')
outputDir = file('build/docs')
sources {
include 'index.adoc'
}
Expand All @@ -79,7 +77,7 @@ task docs(type: Zip, dependsOn: [asciidoctor, dokka]) {
archiveClassifier = 'doc'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE

from(file('build/docs/html5'))
from(file('build/asciidoc/html5'))

from(file('build/javadoc')) {
into('javadoc')
Expand Down
Binary file removed src/doc/asciidoc/paying_turnstile_fsm.png
Binary file not shown.
Binary file removed src/doc/asciidoc/statemachine_classes.png
Binary file not shown.
Binary file removed src/doc/asciidoc/statemachine_model.png
Binary file not shown.
Binary file removed src/doc/asciidoc/statemachine_packaged.png
Binary file not shown.
Binary file removed src/doc/asciidoc/statemachine_sequence.png
Binary file not shown.
Binary file removed src/doc/asciidoc/turnstile_sequence.png
Binary file not shown.
Binary file removed src/doc/asciidoc/useless_fsm.png
Binary file not shown.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Automatic transitions will be executed if the specific state applies after the e

The state can be any type but we have been using `enum class` in all samples.

image::statemachine_sequence.png[FSM sequence]
image::statemachine-sequence.png[FSM sequence]

When sendEvent is called the state machine applies the event to the current state map.
The current state map is usually top-level state map unless you have defined named maps and used a push transition.
Expand Down Expand Up @@ -162,7 +162,9 @@ The top level element is `stateMachine` either by using the function
[source,kotlin]
----
// using builder function
val definition = StateMachineBuilder<StateEnum,EventEnum,ContextType>(StateEnum.values().toSet()).stateMachine {
val definition = StateMachineBuilder<StateEnum, EventEnum, ContextType>(
StateEnum.values().toSet()
).stateMachine {
default { // global defaults
}
initial { // initial state expression
Expand All @@ -175,7 +177,11 @@ val definition = StateMachineBuilder<StateEnum,EventEnum,ContextType>(StateEnum.
}
}.build()
// using global function
val definition = stateMachine(StateEnum.values().toSet(), EventEnum::class,ContextType::class) {
val definition = stateMachine(
StateEnum.values().toSet(),
EventEnum::class,
ContextType::class
) {
default { // global defaults
}
initial { // initial state expression
Expand Down Expand Up @@ -239,7 +245,7 @@ Example:
[source,kotlin]
----
entry { fromState, targetState, args ->
println("Entering:$targetState from $fromState with ${args.toList()}")
entryAction()
}
----

Expand All @@ -255,7 +261,7 @@ Example:
[source,kotlin]
----
exit { fromState, targetState, args ->
println("Exiting:$fromState to $targetState with ${args.toList()}")
exitAction()
}
----
==== `transition`
Expand Down
File renamed without changes.
10 changes: 6 additions & 4 deletions src/doc/asciidoc/kfsm.adoc → src/docs/asciidoc/kfsm.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ We want to ensure that the `lock()` function is only called when the lock is not
Then we use the DSL to declare a definition of a statemachine matching the diagram:

==== State Diagram
image::turnstile_fsm.png[LockStateDiagram]
image::turnstile-fsm.png[LockStateDiagram]

==== State Table

Expand Down Expand Up @@ -164,7 +164,7 @@ fsm.coin()

link:https://github.com/open-jumpco/kfsm-samples[Samples]

image::statemachine_model.png[StateMachineModel]
image::statemachine-model.png[StateMachineModel]

=== Advanced Features
We can add arguments to events and use named state maps with push / pop and automatic transitions.
Expand All @@ -188,12 +188,12 @@ If we update the turnstile to include the value of the coin in the coin event we
A named state where decisions regarding coins are made.
We push to `coins` with COINS state and then the automatic states will be triggered if the guards are met.

image::paying_turnstile_fsm.png[Paying Turnstile]
image::paying-turnstile-fsm.png[Paying Turnstile]

==== State Table

|===
|Start State |Event |Guard| End State | Action
|Start State |Event |Guard Expression | End State | Action

|LOCKED
|PASS
Expand Down Expand Up @@ -292,7 +292,9 @@ class PayingTurnstile(
}
----

==== States and Events

[source,kotlin]
----
enum class PayingTurnstileStates {
Expand Down
Binary file added src/docs/asciidoc/lock-fsm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added src/docs/asciidoc/paying-turnstile-fsm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/docs/asciidoc/sample-fsm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/docs/asciidoc/statemachine-classes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/docs/asciidoc/statemachine-model.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/docs/asciidoc/statemachine-packaged.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/docs/asciidoc/statemachine-sequence.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/docs/asciidoc/turnstile-fsm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Binary file added src/docs/asciidoc/turnstile-sequence.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added src/docs/asciidoc/useless-fsm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 3bebfbf

Please sign in to comment.