Add three new tutorials and small tweaks to docs (#972)

This commit is contained in:
Fábio Rosado
2022-11-24 10:53:22 +00:00
committed by GitHub
parent cafebd68f2
commit 06df21e8e3
9 changed files with 562 additions and 33 deletions

View File

@@ -150,7 +150,11 @@ Use the `<py-config>` tag to set and configure general metadata along with decla
The ideal place to use `<py-config>` in between the `<body>...</body>` tags.
The `<py-config>` tag can be used as follows:
By default the `py-config` tag is set to TOML and can be used as follows:
```{note}
Reminder: when using TOML, any Arrays of Tables defined with double-brackets (like `[[runtimes]]` and `[[fetch]]` must come after individual keys (like `paths=...` and `packages=...`)
```
```html
<py-config>
@@ -162,7 +166,6 @@ The `<py-config>` tag can be used as follows:
lang = "python"
</py-config>
```
Note: `[[runtimes]]` is a TOML table. Make sure this is the last item within a py-config, as the properties created after it go into the runtimes object.
Alternatively, a JSON config can be passed using the `type` attribute.
@@ -297,6 +300,28 @@ as a shortcut, which takes the expression on the last line of the script and run
</html>
```
Besides the above format, a user can also supply any extra keys and values that are relevant as metadata information or perhaps are being used within the application.
For example, a valid config could also be with the snippet below:
```
<py-config type="toml">
magic = "unicorn"
</py-config>
```
OR in JSON like
```
<py-config type="json">
{
"magic": "unicorn"
}
</py-config>
```
If this `"magic"` key is present in config supplied via `src` and also present in config supplied via `inline`, then the value in the inline config is given priority i.e. the overriding process also works for custom keys.
### Local modules
In addition to packages, you can declare local Python modules that will
@@ -343,6 +368,8 @@ In the HTML tag `<py-config>`, paths to local modules are provided in the
</html>
```
### Supported configuration values
The following optional values are supported by `<py-config>`:
| Value | Type | Description |
| ------ | ---- | ----------- |
@@ -360,7 +387,10 @@ The following optional values are supported by `<py-config>`:
| `plugins` | List of Plugins | List of Plugins are to be specified here. The default value is an empty list. |
| `runtimes` | List of Runtimes | List of runtime configurations, described below. The default value contains a single Pyodide based runtime. |
#### Fetch
A fetch configuration consists of the following:
| Value | Type | Description |
| ----- | ---- | ----------- |
| `from` | string | Base URL for the resource to be fetched. |
@@ -368,7 +398,13 @@ A fetch configuration consists of the following:
| `to_file` | string | Name of the target to create in the filesystem. |
| `files` | List of string | List of files to be downloaded. |
```{note}
The parameters `to_file` and `files` shouldn't be supplied together.
```
You may be interested in reading the [tutorial on fetching resources](./py-config-fetch.md) to learn more about this feature.
#### Runtime
A runtime configuration consists of the following:
| Value | Type | Description |
@@ -377,27 +413,7 @@ A runtime configuration consists of the following:
| `name` | string | Name of the runtime. This field can be any string and is to be used by the application author for their own customization purposes |
| `lang` | string | Programming language supported by the runtime. This field can be used by the application author to provide clarification. It currently has no implications on how PyScript behaves. |
Besides the above format, a user can also supply any extra keys and values that are relevant as metadata information or perhaps are being used within the application.
For example, a valid config could also be with the snippet below:
```
<py-config type="toml">
magic = "unicorn"
</py-config>
```
OR in JSON like
```
<py-config type="json">
{
"magic": "unicorn"
}
</py-config>
```
If this `"magic"` key is present in config supplied via `src` and also present in config supplied via `inline`, then the value in the inline config is given priority i.e. the overriding process also works for custom keys.
You may be interested in reading the [tutorial on setting a runtime](./py-config-runtime.md) to learn more about this feature.
## The py-repl tag