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
Copy file name to clipboardExpand all lines: docs/api.md
+16-7Lines changed: 16 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -419,30 +419,39 @@ store = await storage("my-data-store", storage_class=MyStorage)
419
419
420
420
### `@pyscript/core/donkey`
421
421
422
-
Meant as *JS* related imports, you can `import { donkey } from '@pyscript/core/dist/core.js'` and automatically have both *pyscript* module running on your page and a utility to bootstrap a terminal based worker that could evaluate any Python code you need to.
422
+
Sometimes you need a Python worker ready and waiting to evaluate any code on
423
+
your behalf. This is the concept behind the JavaScript "donkey". We couldn't
424
+
think of a better way than "donkey" to describe something that is easy to
425
+
understand and shoulders the burden without complaint. This feature
426
+
means you're able to use PyScript without resorting to specialised
427
+
`<script type="py">` style tags. It's just vanilla JavaScript.
428
+
429
+
Simply `import { donkey } from '@pyscript/core/dist/core.js'` and automatically
430
+
have both a *pyscript* module running on your page and a utility to bootstrap a
431
+
terminal based worker to evaluate any Python code as and when needed in the
process, // process(code) directly (code visible on the terminal)
438
+
process, // process(code) code (visible in the terminal)
429
439
execute, // execute(statement) in Python exec way
430
440
evaluate, // evaluate(expression) in Python eval way
431
441
clear, // clear() the terminal
432
442
reset, // reset() the terminal (including colors)
433
443
kill, // kill() the worker forever
434
444
} =donkey({
435
-
type:'py'||'mpy', // the donkey interpreter to run
445
+
type:'py'||'mpy', // the Python interpreter to run
436
446
persistent:false, // use `true` to track globals and locals
437
447
terminal:'', // optionally set a target terminal container
438
448
config: {}, // the worker config (packages, files, etc.)
439
449
});
440
450
```
441
451
442
-
About the **terminal** option, please note by default *PyScript* would create a target for that, so that if you don't want it visible on your page you can point to a *CSS* addressable container that is not visible (that is: a `#target` element that has a `display: none` as *CSS* property).
443
-
444
-
With this primitive, and without even bothering with specialized *PyScript* tags, we hope anyone can try out of the box what is that *PyScript* enables on the Web!
445
-
452
+
By default PyScript creates a target terminal. If you don't want a terminal to
453
+
appear on your page, use the `terminal` option to point to a CSS addressable
454
+
container that is not visible (i.e. the target has `display: none`).
0 commit comments