Skip to content

Commit

Permalink
rc: v1.0.0 (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke authored Jul 18, 2024
1 parent c763e6b commit ea2d540
Show file tree
Hide file tree
Showing 71 changed files with 2,587 additions and 336 deletions.
1 change: 0 additions & 1 deletion .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
Expand Down
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,26 @@ quarto-exts:
deps: $(PYBIN)
$(PYBIN)/pip install pip --upgrade
$(PYBIN)/pip install -r requirements.txt
cd py-shiny/docs && make deps
. $(PYBIN)/activate && cd py-shiny && make install-deps
. $(PYBIN)/activate && cd py-shiny/docs && make deps

## Build qmd files for Shiny API docs
quartodoc:
cd py-shiny/docs && make quartodoc
quartodoc: $(PYBIN)
. $(PYBIN)/activate && cd py-shiny/docs && make quartodoc
# Copy all generated files except index.qmd
rsync -av --exclude="index.qmd" py-shiny/docs/api/ ./api
cp -R py-shiny/docs/_inv py-shiny/docs/objects.json ./
# Copy over index.qmd, but rename it to _api_index.qmd
cp py-shiny/docs/api/express/index.qmd ./api/express/_api_index.qmd
cp py-shiny/docs/api/core/index.qmd ./api/core/_api_index.qmd
cp py-shiny/docs/api/testing/index.qmd ./api/testing/_api_index.qmd

## Build website
site:
site: $(PYBIN)
. $(PYBIN)/activate && quarto render

## Build website and serve
serve:
serve: $(PYBIN)
. $(PYBIN)/activate && quarto preview

## Remove Quarto website build files
Expand Down
9 changes: 8 additions & 1 deletion _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ project:
- gallery
- api/express
- api/core
- api/testing
- templates
resources:
- /pypi/**
Expand Down Expand Up @@ -103,6 +104,8 @@ website:
href: api/express/index.qmd
- text: "Shiny Core"
href: api/core/index.qmd
- text: "Testing"
href: api/testing/index.qmd
tools:
- icon: discord
href: https://discord.gg/yMGCamUMnS
Expand Down Expand Up @@ -156,7 +159,7 @@ website:
- section: "![](/images/bar-chart-line-fill.svg){.sidebar-icon .sidebar-subtitle}__Outputs__"
contents:
- components/outputs/data-grid/index.qmd
- components/outputs/datatable/index.qmd
- components/outputs/data-table/index.qmd
- components/outputs/image/index.qmd
- components/outputs/map-ipyleaflet/index.qmd
- components/outputs/plot-matplotlib/index.qmd
Expand Down Expand Up @@ -258,6 +261,10 @@ website:
contents:
- docs/modules.qmd
- docs/module-communication.qmd
- section: "Testing"
contents:
- docs/unit-testing.qmd
- docs/end-to-end-testing.qmd
- section: "Extending"
contents:
- docs/custom-component-one-off.qmd
Expand Down
5 changes: 4 additions & 1 deletion _redirects
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/api/express/* /py/api/express/:splat
/api/core/* /py/api/core/:splat 200
/api/testing/* /py/api/testing/:splat 200
/api/* /py/api/core/:splat

/components/display-messages/modal.html /py/components/display-messages/modal/index.html
Expand All @@ -25,7 +26,7 @@
/components/inputs/text-area.html /py/components/inputs/text-area/index.html
/components/inputs/text-box.html /py/components/inputs/text-box/index.html
/components/outputs/data-grid.html /py/components/outputs/data-grid/index.html
/components/outputs/datatable.html /py/components/outputs/datatable/index.html
/components/outputs/datatable.html /py/components/outputs/data-table/index.html
/components/outputs/image.html /py/components/outputs/image/index.html
/components/outputs/map-ipyleaflet.html /py/components/outputs/map-ipyleaflet/index.html
/components/outputs/plot-matplotlib.html /py/components/outputs/plot-matplotlib/index.html
Expand All @@ -36,6 +37,8 @@
/components/outputs/value-box.html /py/components/outputs/value-box/index.html
/components/outputs/verbatim-text.html /py/components/outputs/verbatim-text/index.html

/py/components/outputs/datatable/* /py/components/outputs/data-table/:splat

/layouts/arrange.html /py/layouts/arrange/index.html
/layouts/navbars.html /py/layouts/navbars/index.html
/layouts/panels-cards.html /py/layouts/panels-cards/index.html
Expand Down
8 changes: 8 additions & 0 deletions api/testing/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Shiny Testing API

This page outlines Shiny's _Testing_ API reference.

For an introduction to Shiny testing, see the [unit testing](/docs/unit-testing.qmd) and [end to end testing](/docs/end-to-end-testing.qmd) tutorials.


{{< include _api_index.qmd >}}
22 changes: 22 additions & 0 deletions components/display-messages/chat/app-core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from shiny import App, ui

app_ui = ui.page_fillable(
ui.panel_title("Hello Shiny Chat"),
ui.chat_ui("chat"), # <<
fillable_mobile=True,
)


def server(input):
# Create a chat instance and display it
chat = ui.Chat(id="chat") # <<
chat.ui() # <<

# Define a callback to run when the user submits a message
@chat.on_user_submit # <<
async def _(): # <<
# Simply echo the user's input back to them
await chat.append_message(f"You said: {chat.user_input()}") # <<


app = App(app_ui, server)
18 changes: 18 additions & 0 deletions components/display-messages/chat/app-express.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from shiny.express import ui

ui.page_opts(
title="Hello Shiny Chat",
fillable=True,
fillable_mobile=True,
)

# Create a chat instance and display it
chat = ui.Chat(id="chat") # <<
chat.ui() # <<


# Define a callback to run when the user submits a message
@chat.on_user_submit # <<
async def _(): # <<
# Simply echo the user's input back to them
await chat.append_message(f"You said: {chat.user_input()}") # <<
19 changes: 19 additions & 0 deletions components/display-messages/chat/app-preview-code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from shiny.express import ui

# Set some Shiny page options
ui.page_opts(
title="Hello Shiny Chat",
fillable=True,
fillable_mobile=True,
)

# Create a chat instance and display it
chat = ui.Chat(id="chat")
chat.ui()


# Define a callback to run when the user submits a message
@chat.on_user_submit
async def _():
# Append a response to the chat
await chat.append_message(f"You said: {chat.user_input()}")
38 changes: 38 additions & 0 deletions components/display-messages/chat/app-preview.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from shiny.express import ui

# Set some Shiny page options
ui.page_opts(
title="Hello Shiny Chat",
fillable=True,
fillable_mobile=True,
)

# Create a welcome message
welcome = ui.markdown(
"""
Hi! This is a simple Shiny `Chat` UI. Enter a message below and I will
simply repeat it back to you. For more examples, see this
[folder of examples](https://github.com/posit-dev/py-shiny/tree/main/examples/chat).
"""
)

# Create a chat instance
chat = ui.Chat(
id="chat",
messages=[welcome],
)

# Display it
chat.ui()


# Define a callback to run when the user submits a message
@chat.on_user_submit
async def _():
# Get the chat messages.
messages = chat.messages()
# Typically you'd pass messages to an LLM for response generation,
# but for this example, we'll just echo the user's input
user = messages[-1]["content"]
# Append a response to the chat
await chat.append_message(f"You said: {user}")
Loading

0 comments on commit ea2d540

Please sign in to comment.