Skip to content

Commit 5cd6ceb

Browse files
committed
Copy edit.
1 parent f16f917 commit 5cd6ceb

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

docs/api.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -419,30 +419,39 @@ store = await storage("my-data-store", storage_class=MyStorage)
419419

420420
### `@pyscript/core/donkey`
421421

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
432+
future.
423433

424434
```js title="A donkey worker"
425435
import { donkey } from '@pyscript/core/dist/core.js';
426436

427437
const {
428-
process, // process(code) directly (code visible on the terminal)
438+
process, // process(code) code (visible in the terminal)
429439
execute, // execute(statement) in Python exec way
430440
evaluate, // evaluate(expression) in Python eval way
431441
clear, // clear() the terminal
432442
reset, // reset() the terminal (including colors)
433443
kill, // kill() the worker forever
434444
} = donkey({
435-
type: 'py' || 'mpy', // the donkey interpreter to run
445+
type: 'py' || 'mpy', // the Python interpreter to run
436446
persistent: false, // use `true` to track globals and locals
437447
terminal: '', // optionally set a target terminal container
438448
config: {}, // the worker config (packages, files, etc.)
439449
});
440450
```
441451

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`).
446455

447456
### `@pyscript/core/dist/storage.js`
448457

0 commit comments

Comments
 (0)