Skip to content

Commit abbd83c

Browse files
committed
fix: Patch to get the statemachine diagram on jupyterlite
1 parent ac99985 commit abbd83c

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

docs/auto_examples/order_control_rich_model_machine.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ Since there's still $6 left to fulfill the payment, we cannot process the order.
214214
.. code-block:: none
215215
216216
217-
OrderControl(model=<__main__.Order object at 0x7f5730b462e0>, state_field='state', current_state='waiting_for_payment')
217+
OrderControl(model=<__main__.Order object at 0x7fa3456ef2e0>, state_field='state', current_state='waiting_for_payment')
218218
219219
220220
@@ -258,7 +258,7 @@ Now paying the left amount, we can proceed.
258258
.. code-block:: none
259259
260260
261-
OrderControl(model=<__main__.Order object at 0x7f5730b462e0>, state_field='state', current_state='processing')
261+
OrderControl(model=<__main__.Order object at 0x7fa3456ef2e0>, state_field='state', current_state='processing')
262262
263263
264264
@@ -292,7 +292,7 @@ Now paying the left amount, we can proceed.
292292
.. code-block:: none
293293
294294
295-
OrderControl(model=<__main__.Order object at 0x7f5730b462e0>, state_field='state', current_state='shipping')
295+
OrderControl(model=<__main__.Order object at 0x7fa3456ef2e0>, state_field='state', current_state='shipping')
296296
297297
298298
@@ -391,7 +391,7 @@ Just checking the final expected state
391391
.. code-block:: none
392392
393393
394-
OrderControl(model=<__main__.Order object at 0x7f5730b462e0>, state_field='state', current_state='completed')
394+
OrderControl(model=<__main__.Order object at 0x7fa3456ef2e0>, state_field='state', current_state='completed')
395395
396396
397397

docs/examples/patch_repr_svg.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import sys
22

33

4-
def patch__repr_svg_(): # pragma: no cover
4+
def patch__repr_html_(): # pragma: no cover
55
"""
66
You're running this example directly from your browser! By using the amazing
77
https://pyodide.org/.
88
99
Since we're in a browser, the default dependency of GraphViz installed locally don't work. So
10-
this cell is an option to see our examples and try the library on the fly without the need to
11-
install anything.
12-
13-
We've to patch `StateMachine._repr_svg_` to retrieve the svg diagram online as the graphviz is
14-
not available.
10+
as an option to see our examples and try the library on the fly without the need to
11+
install anything we'll patch `StateMachine._repr_html_` to retrieve the svg diagram online as
12+
the graphviz is not available.
1513
1614
This method will serialize and request the graph to an external service: https://quickchart.io.
1715
By using de diagrams support you trust quickchart.io. Please read
@@ -28,11 +26,11 @@ def show_sm(sm):
2826
)
2927
return '<svg width="auto" height="auto"><image xlink:href="{}"/>'.format(url)
3028

31-
StateMachine._repr_svg_ = show_sm
29+
StateMachine._repr_html_ = show_sm
3230

3331

3432
if sys.platform == "emscripten": # pragma: no cover
3533
# https://pyodide.org/ is the runtime!
36-
patch__repr_svg_()
37-
print(patch__repr_svg_.__doc__)
38-
print("'StateMachine._repr_svg_' patched!")
34+
patch__repr_html_()
35+
print(patch__repr_html_.__doc__)
36+
print("'StateMachine._repr_html_' patched!")

0 commit comments

Comments
 (0)