Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlantUML: add arrow from history to initial memory #96

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion sismic/io/plantuml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
import sys

from typing import Dict, List, Tuple, Optional
from typing import Dict, List, Tuple, Union
from ..io import import_from_yaml
from ..model import (
DeepHistoryState, FinalState, Transition, CompoundState,
Expand Down Expand Up @@ -170,6 +170,9 @@ def export_state(self, name: str) -> None:

self.export_transitions(name)

if isinstance(state, (ShallowHistoryState, DeepHistoryState)):
self.export_history_memory(state)

# Nested states
for i, child in enumerate(self.statechart.children_for(name)):
if i != 0 and isinstance(state, OrthogonalState):
Expand Down Expand Up @@ -226,6 +229,16 @@ def export_transition(self, transition: Transition) -> None:
text=''.join(text),
))

def export_history_memory(self, history_state: Union[ShallowHistoryState, DeepHistoryState]):
if history_state.memory:
target = self.statechart.state_for(history_state.memory)

self.output('{source} {arrow} {target}'.format(
source=self.state_id(history_state.name),
arrow=self.arrow(history_state, target),
target=self.state_id(target.name)
))

def export(self) -> str:
self.output('@startuml')

Expand Down