Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/holoviz/panel into docs_fix…
Browse files Browse the repository at this point in the history
…es_1.4_a1_review
  • Loading branch information
MarcSkovMadsen committed Feb 21, 2024
2 parents 37f1683 + ebe8d66 commit c245abd
Show file tree
Hide file tree
Showing 36 changed files with 429 additions and 181 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ on:
jobs:
build_docs:
name: Documentation
runs-on: 'macos-latest'
runs-on: 'macos-14'
timeout-minutes: 180
defaults:
run:
Expand All @@ -37,18 +37,18 @@ jobs:
DISPLAY: ":99.0"
PANEL_IPYWIDGET: 1
steps:
- uses: holoviz-dev/holoviz_tasks/install@v0.1a18
- uses: holoviz-dev/holoviz_tasks/install@v0.1a19
with:
name: doc_build
python-version: "3.9"
channels: pyviz/label/dev,bokeh,conda-forge,nodefaults
python-version: "3.11"
channels: pyviz/label/dev,bokeh/label/dev,conda-forge,nodefaults
conda-update: 'true'
nodejs: true
nodejs-version: 20
# Remove when all examples tools can be installed on 3.10
envs: -o examples -o doc -o build
cache: true
opengl: true
conda-mamba: mamba
- name: doit develop_install
if: steps.install.outputs.cache-hit != 'true'
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ jobs:
- 'doc/getting_started/**'
- 'doc/how_to/**'
- 'scripts/**'
- 'lite/**'
- name: Set matrix option
run: |
if [[ '${{ github.event_name }}' == 'workflow_dispatch' ]]; then
Expand Down
43 changes: 25 additions & 18 deletions doc/how_to/custom_components/reactive_html/reactive_html_layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ import param
pn.extension()
class LayoutSingleObject(pn.reactive.ReactiveHTML):
object = param.Parameter()
_ignored_refs = ("object",)
object = param.Parameter(allow_refs=False)
_template = """
<div>
Expand All @@ -26,7 +23,6 @@ class LayoutSingleObject(pn.reactive.ReactiveHTML):
</div>
"""
dial = pn.widgets.Dial(
name="°C",
value=37,
Expand All @@ -42,7 +38,9 @@ LayoutSingleObject(
).servable()
```

Please notice
:::{note}

Please note

- We define the HTML layout in the `_template` attribute.
- We can refer to the parameter `object` in the `_template` via the *template parameter* `${object}`.
Expand All @@ -53,6 +51,8 @@ parameter can be called anything. For example `value`, `dial` or `temperature`.
- We add the `border` in the `styles` parameter so that we can better see how the `_template` layes
out inside the `ReactiveHTML` component. This can be very useful for development.

:::

## Layout multiple parameters

```{pyodide}
Expand All @@ -62,10 +62,8 @@ import param
pn.extension()
class LayoutMultipleValues(pn.reactive.ReactiveHTML):
object1 = param.Parameter()
object2 = param.Parameter()
_ignored_refs = ("object1", "object2")
object1 = param.Parameter(allow_refs=False)
object2 = param.Parameter(allow_refs=False)
_template = """
<div>
Expand Down Expand Up @@ -121,7 +119,6 @@ class LayoutLiteralValues(pn.reactive.ReactiveHTML):
object1 = param.Parameter()
object2 = param.Parameter()
_ignored_refs = ("object1", "object2")
_child_config = {"object1": "literal", "object2": "literal"}
_template = """
Expand Down Expand Up @@ -182,17 +179,21 @@ LayoutOfList(objects=[

The component will trigger a rerendering if you update the `List` value.

Please note that you must
:::{note}

You must

- wrap the `{% for object in objects %}` loop in an HTML element with an `id`. Here it is wrapped
with `<div id="container">...</div>`.
- close all HTML tags! `<hr>` is valid HTML, but not valid with `ReactiveHTML`. You must close it
as `<hr/>`.

Please note you can optionally
You can optionally

- get the index of the `{% for object in objects %}` loop via `{{ loop.index0 }}`.

:::

## Create a list like layout

If you want to create a *list like* layout similar to `Column` and `Row`, you can
Expand Down Expand Up @@ -226,13 +227,15 @@ layout = ListLikeLayout(
layout.servable()
```

Please note that you must
You can now use `[...]` indexing and the `.append`, `.insert`, `pop`, ... methods that you would
expect.

:::{note}

- list `NamedListLike, ReactiveHTML` in exactly that order when you define the class! The other
You must list `NamedListLike, ReactiveHTML` in exactly that order when you define the class! The other
way around `ReactiveHTML, NamedListLike` will not work.

You can now use `[...]` indexing and the `.append`, `.insert`, `pop`, ... methods that you would
expect.
::::

## Layout a dictionary

Expand Down Expand Up @@ -266,9 +269,13 @@ LayoutOfDict(object={
).servable()
```

:::{note}

Please note

- We can insert the `key` as a literal value only using `{{ key }}`. Inserting it as a template
variable ${key} will not work.
variable `${key}` will not work.
- We must not give the HTML element containing `{{ key }}` an `id`. If we do, an exception will be
raised.

:::
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ from panel.reactive import ReactiveHTML
pn.extension()
class SensorLayout(ReactiveHTML):
object = param.Parameter()
_ignored_refs = ("object",)
object = param.Parameter(allow_refs=False)
_template = """
<div class="pn-container styled-container">
Expand Down
46 changes: 45 additions & 1 deletion examples/reference/chat/ChatFeed.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@
"___"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Basics"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -175,6 +182,13 @@
"message = chat_feed.send({\"object\": \"Overtaken!\", \"user\": \"Bot\"}, user=\"MegaBot\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Callbacks"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -339,6 +353,13 @@
"chat_feed.send(\"This will fail...\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Async Callbacks"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -550,6 +571,13 @@
"message = chat_feed.send(\"Hello bots!\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Serialize"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -712,7 +740,16 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"If a returned object is not a generator (notably LangChain output), it's still possible to stream the output with the `stream` method."
"#### Stream"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If a returned object is not a generator (notably LangChain output), it's still possible to stream the output with the `stream` method.\n",
"\n",
"Note, if you're working with `generator`s, use `yield` in your callback instead."
]
},
{
Expand Down Expand Up @@ -774,6 +811,13 @@
" message = chat_feed.stream(n, message=message)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Customization"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
21 changes: 21 additions & 0 deletions examples/reference/chat/ChatInterface.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@
"___"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Basics"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -110,6 +117,13 @@
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Input Widgets"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -367,6 +381,13 @@
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Buttons"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
Loading

0 comments on commit c245abd

Please sign in to comment.