You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -1406,182 +1406,7 @@ from transitions.extensions import LockedHierarchicalGraphMachine as LHGMachine
1406
1406
machine= LHGMachine(model, states, transitions)
1407
1407
```
1408
1408
1409
-
#### <a name="diagrams"></a> Diagrams
1410
-
1411
-
Additional Keywords:
1412
-
1413
-
-`title` (optional): Sets the title of the generated image.
1414
-
-`show_conditions` (default False): Shows conditions at transition edges
1415
-
-`show_auto_transitions` (default False): Shows auto transitions in graph
1416
-
-`show_state_attributes` (default False): Show callbacks (enter, exit), tags and timeouts in graph
1417
-
1418
-
Transitions can generate basic state diagrams displaying all valid transitions between states.
1419
-
The basic diagram support generates a [mermaid](https://mermaid.js.org) state machine definition which can be used with mermaid's [live editor](https://mermaid.live), in markdown files in GitLab or GitHub and other web services.
1420
-
For instance, this code:
1421
-
```python
1422
-
from transitions.extensions.diagrams import HierarchicalGraphMachine
Independent of the backend you use, the draw function also accepts a file descriptor or a binary stream as the first argument. If you set this parameter to `None`, the byte stream will be returned:
1534
-
1535
-
```python
1536
-
import io
1537
-
1538
-
withopen('a_graph.png', 'bw') as f:
1539
-
# you need to pass the format when you pass objects instead of filenames.
If the format of references does not suit your needs, you can override the static method `GraphMachine.format_references`. If you want to skip reference entirely, just let `GraphMachine.format_references`return`None`.
1582
-
Also, have a look at our [example](./examples) IPython/Jupyter notebooks for a more detailed example about how to use and edit graphs.
1583
-
1584
-
### <a name="hsm"></a>Hierarchical State Machine (HSM)
1409
+
#### <a name="hsm"></a>Hierarchical State Machine (HSM)
1585
1410
1586
1411
Transitions includes an extension module which allows nesting states.
1587
1412
This allows us to create contexts and to model cases where states are related to certain subtasks in the state machine.
@@ -1832,7 +1657,7 @@ machine.final_Z()
1832
1657
# >>> Machine is final!
1833
1658
```
1834
1659
1835
-
#### Reuse of previously created HSMs
1660
+
##### Reuse of previously created HSMs
1836
1661
1837
1662
Besides semantic order, nested states are very handy if you want to specify state machines for specific tasks and plan to reuse them.
1838
1663
Before _0.8.0_, a `HierarchicalMachine` would not integrate the machine instance itself but the states and transitions by creating copies of them.
@@ -1949,6 +1774,181 @@ collector.increase()
1949
1774
assert collector.is_counting_2()
1950
1775
```
1951
1776
1777
+
#### <a name="diagrams"></a> Diagrams
1778
+
1779
+
Additional Keywords:
1780
+
1781
+
-`title` (optional): Sets the title of the generated image.
1782
+
-`show_conditions` (default False): Shows conditions at transition edges
1783
+
-`show_auto_transitions` (default False): Shows auto transitions in graph
1784
+
-`show_state_attributes` (default False): Show callbacks (enter, exit), tags and timeouts in graph
1785
+
1786
+
Transitions can generate basic state diagrams displaying all valid transitions between states.
1787
+
The basic diagram support generates a [mermaid](https://mermaid.js.org) state machine definition which can be used with mermaid's [live editor](https://mermaid.live), in markdown files in GitLab or GitHub and other web services.
1788
+
For instance, this code:
1789
+
```python
1790
+
from transitions.extensions.diagrams import HierarchicalGraphMachine
Independent of the backend you use, the draw function also accepts a file descriptor or a binary stream as the first argument. If you set this parameter to `None`, the byte stream will be returned:
1902
+
1903
+
```python
1904
+
import io
1905
+
1906
+
withopen('a_graph.png', 'bw') as f:
1907
+
# you need to pass the format when you pass objects instead of filenames.
If the format of references does not suit your needs, you can override the static method `GraphMachine.format_references`. If you want to skip reference entirely, just let `GraphMachine.format_references`return`None`.
1950
+
Also, have a look at our [example](./examples) IPython/Jupyter notebooks for a more detailed example about how to use and edit graphs.
1951
+
1952
1952
#### <a name="threading"></a> Threadsafe(-ish) State Machine
1953
1953
1954
1954
In cases where event dispatching is done in threads, one can use either `LockedMachine`or`LockedHierarchicalMachine` where **function access** (!sic) is secured with reentrant locks.
0 commit comments