Skip to content

Commit 6ea6e2d

Browse files
authored
docs: Improvements on the docs, removing jupyterlite (#331)
1 parent 2884494 commit 6ea6e2d

21 files changed

Lines changed: 394 additions & 144 deletions

README.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
====================
2-
Python State Machine
3-
====================
1+
===================
2+
Python StateMachine
3+
===================
44

55

66
.. image:: https://img.shields.io/pypi/v/python-statemachine.svg
@@ -112,7 +112,7 @@ Then start sending events:
112112
>>> traffic_light.cycle()
113113
'Running cycle from green to yellow'
114114

115-
You can inspect about the current state:
115+
You can inspect the current state:
116116

117117
>>> traffic_light.current_state.id
118118
'yellow'
@@ -151,13 +151,13 @@ Or over events:
151151
>>> [t.name for t in traffic_light.events]
152152
['cycle', 'go', 'slowdown', 'stop']
153153

154-
Call an event by it's name:
154+
Call an event by its name:
155155

156156
>>> traffic_light.cycle()
157157
Don't move.
158158
'Running cycle from yellow to red'
159159

160-
Or sending an event with the event name:
160+
Or send an event with the event name:
161161

162162
>>> traffic_light.send('cycle')
163163
Go ahead!
@@ -180,8 +180,8 @@ True
180180
And you can pass arbitrary positional or keyword arguments to the event, and
181181
they will be propagated to all actions and callbacks:
182182

183-
>>> traffic_light.cycle(message="Please, now slowdon.")
184-
'Running cycle from green to yellow. Please, now slowdon.'
183+
>>> traffic_light.cycle(message="Please, now slowdown.")
184+
'Running cycle from green to yellow. Please, now slowdown.'
185185

186186

187187
Models

docs/actions.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Actions
22

3-
An action is the way a StateMachine can cause things to happen in the
3+
Action is the way a StateMachine can cause things to happen in the
44
outside world, and indeed they are the main reason why they exist at all.
55

66
The main point of introducing a state machine is for the
77
actions to be invoked at the right times, depending on the sequence of events
88
and the state of the guards.
99

1010
Actions are most commonly performed on entry or exit of a state, although
11-
it is possible to add them before / after a transition.
11+
it is possible to add them before/after a transition.
1212

1313
There are several action callbacks that you can define to interact with a
1414
StateMachine in execution.
@@ -257,9 +257,9 @@ You can also declare an event while also adding a callback:
257257

258258
```
259259

260-
Note that with this syntax, the result `loop` that is present on the `ExampleStateMachine.loop`
260+
Note that with this syntax, the resulting `loop` that is present on the `ExampleStateMachine.loop`
261261
namespace is not a simple method, but an {ref}`event` trigger. So it only executes if the
262-
StateMachine is on the right state.
262+
StateMachine is in the right state.
263263

264264
So, you can use the event-oriented approach:
265265

@@ -275,8 +275,7 @@ On loop
275275

276276
## Other callbacks
277277

278-
In addition to {ref}`actions`, you can specify {ref}`validators-and-guards` that are checked
279-
before an transition is started. They are meant to stop a transition to occur.
278+
In addition to {ref}`actions`, you can specify {ref}`validators and guards` that are checked before a transition is started. They are meant to stop a transition to occur.
280279

281280
```{seealso}
282281
See {ref}`guards` and {ref}`validators`.
@@ -320,7 +319,7 @@ Actions and Guards will be executed in the following order:
320319

321320
python-statemachine implements a custom dispatch mechanism on all those available Actions and
322321
Guards, this means that you can declare an arbitrary number of `*args` and `**kwargs`, and the
323-
library will match your method signature of what's expect to receive with the provided arguments.
322+
library will match your method signature of what's expected to receive with the provided arguments.
324323

325324
This means that if on your `on_enter_<state.id>()` or `on_execute_<event>()` method, you need to know
326325
the `source` ({ref}`state`), or the `event` ({ref}`event`), or access a keyword
@@ -346,10 +345,10 @@ For your convenience, all these parameters are available for you on any Action o
346345
: The {ref}`Event` that was triggered.
347346

348347
`source`
349-
: The {ref}`State` the statemachine was when the {ref}`Event` started.
348+
: The {ref}`State` the state machine was when the {ref}`Event` started.
350349

351350
`state`
352-
: The current {ref}`State` of the statemachine.
351+
: The current {ref}`State` of the state machine.
353352

354353
`target`
355354
: The destination {ref}`State` of the transition.

docs/conf.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
"sphinx.ext.viewcode",
5151
"sphinx.ext.autosectionlabel",
5252
"sphinx_gallery.gen_gallery",
53-
"jupyterlite_sphinx",
5453
]
5554

5655
# Add any paths that contain templates here, relative to this directory.
@@ -243,11 +242,6 @@
243242
"event": "{ref}`event`",
244243
}
245244

246-
# JupyterLite
247-
jupyterlite_config = "jupyterlite_config.json"
248-
jupyterlite_contents = ["./examples", "./auto_examples"]
249-
jupyterlite_dir = "./auto_examples"
250-
251245
# Github
252246

253247
html_context = {
@@ -271,10 +265,5 @@
271265
"min_reported_time": 9999,
272266
"thumbnail_size": (400, 280),
273267
"image_scrapers": (MachineScraper(project_root),),
274-
"first_notebook_cell": (
275-
"# import piplite\n"
276-
"# await piplite.install('python-statemachine[diagrams]')\n"
277-
"# import patch_repr_svg\n"
278-
),
279268
"reset_modules": [],
280269
}

docs/diagram.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Diagrams
22

3-
You can generate diagrams from your statemachine.
3+
You can generate diagrams from your state machine.
44

55
```{note}
66
This functionality depends on [pydot](https://github.com/pydot/pydot), it means that you need to
@@ -25,7 +25,7 @@ To install Graphviz, you can visit the [Graphviz website](https://graphviz.org/)
2525
instructions for your operating system. Alternatively, you can use a package manager to install
2626
Graphviz. For example, on Debian-based systems (such as Ubuntu), you can use the following command:
2727
28-
apt-get install graphviz
28+
sudo apt install graphviz
2929
3030
```
3131

@@ -81,6 +81,16 @@ The current state is also highlighted:
8181
![OrderControl](images/order_control_machine_processing.png)
8282

8383

84+
```{hint}
85+
86+
A handy shortcut to have the graph representation:
87+
88+
```py
89+
>>> machine._graph()
90+
<pydot.Dot ...
91+
92+
```
93+
8494
## Generate from the command line
8595

8696
You can also generate a diagram from the command line using the `statemachine.contrib.diagram` as a module.
@@ -118,3 +128,13 @@ Machines instances are automatically displayed as a diagram when used on Jupyter
118128

119129

120130
![Approval machine on JupyterLab](images/lab_approval_machine_accepted.png)
131+
132+
133+
## Don't want to install Graphviz
134+
135+
136+
```{eval-rst}
137+
.. autofunction:: statemachine.contrib.diagram.quickchart_write_svg
138+
```
139+
140+
![OrderControl](images/oc_machine_processing.svg)

docs/examples/patch_repr_svg.py

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 90 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)