8000 Add docs to repl with attr src (#1353) · Nsima/pyscript@088a264 · GitHub
[go: up one dir, main page]

Skip to content

Commit 088a264

Browse files
Add docs to repl with attr src (pyscript#1353)
* Add docs to repl with attr src * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent d7e80ad commit 088a264

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

docs/reference/elements/py-repl.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ The `<py-repl>` element provides a REPL(Read Eval Print Loop) to evaluate multi-
44

55
## Attributes
66

7-
| attribute | type | default | description |
8-
|-------------------|---------|---------|---------------------------------------|
7+
| attribute | type | default | description |
8+
|-------------------|---------|---------|--------------------------------------|
99
| **auto-generate** | boolean | | Auto-generates REPL after evaluation |
1010
| **output-mode** | string | "" | Determines whether the output element is cleared prior to writing output |
11-
| **output** | string | | The id of the element to write `stdout` and `stderr` to |
11+
| **output** | string | | The id of the element to write `stdout` and `stderr` to |
1212
| **stderr** | string | | The id of the element to write `stderr` to |
13+
| **src** | string | | Resource to be preloaded into the REPL |
1314

1415

1516
### `auto-generate`
@@ -24,6 +25,9 @@ The ID of an element in the DOM that `stdout` (e.g. `print()`), `stderr`, and th
2425
### `stderr`
2526
The ID of an element in the DOM that `stderr` will be written to. Defaults to None, though writes to `stderr` will still appear in the location specified by `output`.
2627

28+
### `src`
29+
If a \<py-repl\> tag has the `src` attribute, during page initialization, resource in the `src` will be preloaded into the REPL. Please note that this will not run in advance. If there is content in the \<py-repl\> tag, it will be cleared and replaced with preloaded resource.
30+
2731
## Examples
2832

2933
### `<py-repl>` element set to auto-generate
@@ -46,3 +50,13 @@ The following will write "Hello! World!" to the div with id `replOutput`.
4650
```
4751

4852
Note that if we `print` from the REPL (or otherwise write to `sys.stdout`), the output will be printed in the [`py-terminal`](../plugins/py-terminal.md) if is enabled.
53+
54+
### `<py-repl>` element with src
55+
Preload resource from src into the REPL
56+
```html
57+
<py-repl id="py-repl" output="replOutput" src="./src/py/py_code.py">
58+
If a py-repl tag has the src attribute,
59+
the content here will be cleared and replaced.
60+
</py-repl>
61+
<div id="replOutput"></div>
62+
```

0 commit comments

Comments
 (0)
0