diff --git a/CHANGELOG.md b/CHANGELOG.md index 477807e13..f900cd7cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,11 @@ All notable changes to Shiny for Python will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [UNRELEASED] +## [Unreleased] + +### Deprecations + +* `ui.output_text_verbatim()` is deprecated. Please use `ui.output_text()` if you want to create an output container for some text, or `ui.output_code()` if you want to create an output container for code (monospaced text). (#2097) ### Bug fixes diff --git a/examples/brand/app.py b/examples/brand/app.py index e952cb53d..e3143e62d 100644 --- a/examples/brand/app.py +++ b/examples/brand/app.py @@ -52,7 +52,7 @@ ), ui.card( ui.card_header("Text Output"), - ui.output_text_verbatim("out_text1"), + ui.output_code("out_text1"), ), ), ), @@ -279,7 +279,7 @@ def plot1(): spine.set_alpha(0.25) return fig - @render.text + @render.code def out_text1(): return "\n".join( ["def example_function():", ' return "Function output text"'] diff --git a/shiny/api-examples/ClientData/app-core.py b/shiny/api-examples/ClientData/app-core.py index 5faf4fea9..102e00865 100644 --- a/shiny/api-examples/ClientData/app-core.py +++ b/shiny/api-examples/ClientData/app-core.py @@ -19,7 +19,7 @@ to reactively read the client data values from the browser. """ ), - ui.output_text_verbatim("clientdatatext"), + ui.output_code("clientdatatext"), ui.output_plot("myplot"), ) diff --git a/shiny/api-examples/Renderer/app-core.py b/shiny/api-examples/Renderer/app-core.py index 3931c17e8..aa570408f 100644 --- a/shiny/api-examples/Renderer/app-core.py +++ b/shiny/api-examples/Renderer/app-core.py @@ -9,13 +9,13 @@ ui.h1("Capitalization renderer"), ui.input_text("caption", "Caption:", "Data summary"), "@render_upper: ", - ui.output_text_verbatim("upper", placeholder=True), + ui.output_code("upper", placeholder=True), "@render_upper(): ", - ui.output_text_verbatim("upper_with_paren", placeholder=True), + ui.output_code("upper_with_paren", placeholder=True), "@render_capitalize: ", - ui.output_text_verbatim("cap_upper", placeholder=True), + ui.output_code("cap_upper", placeholder=True), "@render_capitalize(to='lower'): ", - ui.output_text_verbatim("cap_lower", placeholder=True), + ui.output_code("cap_lower", placeholder=True), ) diff --git a/shiny/api-examples/Renderer/renderers.py b/shiny/api-examples/Renderer/renderers.py index a46dbc7be..7e1d27df9 100644 --- a/shiny/api-examples/Renderer/renderers.py +++ b/shiny/api-examples/Renderer/renderers.py @@ -3,7 +3,7 @@ from typing import Literal, Optional from shiny.render.renderer import Renderer, ValueFn -from shiny.ui import output_text_verbatim +from shiny.ui import output_code class render_capitalize(Renderer[str]): @@ -28,7 +28,7 @@ def auto_output_ui(self): """ Express UI for the renderer """ - return output_text_verbatim(self.output_id, placeholder=True) + return output_code(self.output_id, placeholder=True) def __init__( self, @@ -94,7 +94,7 @@ def auto_output_ui(self): """ Express UI for the renderer """ - return output_text_verbatim(self.output_id, placeholder=True) + return output_code(self.output_id, placeholder=True) async def transform(self, value: str) -> str: """ diff --git a/shiny/api-examples/accordion/app-core.py b/shiny/api-examples/accordion/app-core.py index 4c91ec8d5..f473186ce 100644 --- a/shiny/api-examples/accordion/app-core.py +++ b/shiny/api-examples/accordion/app-core.py @@ -25,20 +25,20 @@ def make_items(): ui.markdown("#### Accordion: (`multiple=False`)"), # Provide an id to create a shiny input binding ui.accordion(*make_items(), id="acc_single", multiple=False), - ui.output_text_verbatim("acc_single_val", placeholder=True), + ui.output_code("acc_single_val", placeholder=True), ui.tags.br(), ui.markdown("#### Accordion: (`multiple=True`)"), ui.accordion(*make_items(), id="acc_multiple"), - ui.output_text_verbatim("acc_multiple_val", placeholder=True), + ui.output_code("acc_multiple_val", placeholder=True), ) def server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code def acc_single_val(): return "input.acc_single(): " + str(input.acc_single()) - @render.text + @render.code def acc_multiple_val(): return "input.acc_multiple(): " + str(input.acc_multiple()) diff --git a/shiny/api-examples/accordion_panel/app-core.py b/shiny/api-examples/accordion_panel/app-core.py index c53697eb0..946eb1c81 100644 --- a/shiny/api-examples/accordion_panel/app-core.py +++ b/shiny/api-examples/accordion_panel/app-core.py @@ -9,7 +9,7 @@ # Provide an id to create a shiny input binding ui.accordion(*items, id="acc"), ui.h4("Accordion:"), - ui.output_text_verbatim("acc_val", placeholder=True), + ui.output_code("acc_val", placeholder=True), ) @@ -18,7 +18,7 @@ def server(input: Inputs, output: Outputs, session: Session): def _(): print(input.acc()) - @render.text + @render.code def acc_val(): return "input.acc(): " + str(input.acc()) diff --git a/shiny/api-examples/calc/app-core.py b/shiny/api-examples/calc/app-core.py index fe2620253..7f998853f 100644 --- a/shiny/api-examples/calc/app-core.py +++ b/shiny/api-examples/calc/app-core.py @@ -9,7 +9,7 @@ ui.input_action_button("first", "Invalidate first (slow) computation"), ui.input_action_button("second", "Invalidate second (fast) computation"), ), - ui.output_text_verbatim("result"), + ui.output_code("result"), ) ) @@ -30,7 +30,7 @@ def second(): input.second() return random.randint(1, 1000) - @render.text + @render.code def result(): return first() + second() diff --git a/shiny/api-examples/input_numeric/app-core.py b/shiny/api-examples/input_numeric/app-core.py index 3c6f2b0dc..ff2bde8b2 100644 --- a/shiny/api-examples/input_numeric/app-core.py +++ b/shiny/api-examples/input_numeric/app-core.py @@ -2,12 +2,12 @@ app_ui = ui.page_fluid( ui.input_numeric("obs", "Observations:", 10, min=1, max=100), - ui.output_text_verbatim("value"), + ui.output_code("value"), ) def server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code def value(): return input.obs() diff --git a/shiny/api-examples/input_password/app-core.py b/shiny/api-examples/input_password/app-core.py index 4d56c7024..08503739d 100644 --- a/shiny/api-examples/input_password/app-core.py +++ b/shiny/api-examples/input_password/app-core.py @@ -3,12 +3,12 @@ app_ui = ui.page_fluid( ui.input_password("password", "Password:"), ui.input_action_button("go", "Go"), - ui.output_text_verbatim("value"), + ui.output_code("value"), ) def server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code @reactive.event(input.go) def value(): return input.password() diff --git a/shiny/api-examples/input_text/app-core.py b/shiny/api-examples/input_text/app-core.py index bf6ddd859..34872d8d1 100644 --- a/shiny/api-examples/input_text/app-core.py +++ b/shiny/api-examples/input_text/app-core.py @@ -2,12 +2,12 @@ app_ui = ui.page_fluid( ui.input_text("caption", "Caption:", "Data summary"), - ui.output_text_verbatim("value"), + ui.output_code("value"), ) def server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code def value(): return input.caption() diff --git a/shiny/api-examples/input_text_area/app-core.py b/shiny/api-examples/input_text_area/app-core.py index 3c708bc4e..3af5ec423 100644 --- a/shiny/api-examples/input_text_area/app-core.py +++ b/shiny/api-examples/input_text_area/app-core.py @@ -6,23 +6,23 @@ "Caption:", "Data summary\nwith\nmultiple\nlines", ), - ui.output_text_verbatim("value_regular", placeholder=True), + ui.output_code("value_regular", placeholder=True), ui.input_text_area( "caption_autoresize", ui.markdown("Caption (w/ `autoresize=True`):"), "Data summary\nwith\nmultiple\nlines", autoresize=True, ), - ui.output_text_verbatim("value_autoresize", placeholder=True), + ui.output_code("value_autoresize", placeholder=True), ) def server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code def value_regular(): return input.caption_regular() - @render.text + @render.code def value_autoresize(): return input.caption_autoresize() diff --git a/shiny/api-examples/output_text/app-core.py b/shiny/api-examples/output_text/app-core.py index cf0d8e3d9..f19cef811 100644 --- a/shiny/api-examples/output_text/app-core.py +++ b/shiny/api-examples/output_text/app-core.py @@ -6,16 +6,16 @@ ui.column(6, ui.code("ui.output_text()"), ui.output_text("text")), ui.column( 6, - ui.code("ui.output_text_verbatim(placeholder=True)"), - ui.output_text_verbatim("verb", placeholder=True), + ui.code("ui.output_code(placeholder=True)"), + ui.output_code("verb", placeholder=True), ), ), ui.row( ui.column(6), ui.column( 6, - ui.code("ui.output_text_verbatim(placeholder=False)"), - ui.output_text_verbatim("verb_no_placeholder", placeholder=False), + ui.code("ui.output_code(placeholder=False)"), + ui.output_code("verb_no_placeholder", placeholder=False), ), ), ) @@ -26,11 +26,11 @@ def server(input: Inputs, output: Outputs, session: Session): def text(): return input.txt() - @render.text + @render.code def verb(): return input.txt() - @render.text + @render.code def verb_no_placeholder(): return input.txt() diff --git a/shiny/api-examples/output_transformer/app-core.py b/shiny/api-examples/output_transformer/app-core.py index e1c6a6a88..4dd98e0da 100644 --- a/shiny/api-examples/output_transformer/app-core.py +++ b/shiny/api-examples/output_transformer/app-core.py @@ -109,11 +109,11 @@ def render_capitalize( ui.h1("Capitalization renderer"), ui.input_text("caption", "Caption:", "Data summary"), "Renderer called with out parentheses:", - ui.output_text_verbatim("no_parens"), + ui.output_code("no_parens"), "To upper:", - ui.output_text_verbatim("to_upper"), + ui.output_code("to_upper"), "To lower:", - ui.output_text_verbatim("to_lower"), + ui.output_code("to_lower"), ) diff --git a/shiny/api-examples/popover/app-core.py b/shiny/api-examples/popover/app-core.py index 474821028..8f41eb102 100644 --- a/shiny/api-examples/popover/app-core.py +++ b/shiny/api-examples/popover/app-core.py @@ -25,13 +25,13 @@ id="card_popover", ), ), - ui.output_text_verbatim("plot_txt", placeholder=True), + ui.output_code("plot_txt", placeholder=True), ), ) def server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code def plot_txt(): return f"" diff --git a/shiny/api-examples/sidebar/app-core-dynamic.py b/shiny/api-examples/sidebar/app-core-dynamic.py index ec55e4496..75a9fc045 100644 --- a/shiny/api-examples/sidebar/app-core-dynamic.py +++ b/shiny/api-examples/sidebar/app-core-dynamic.py @@ -58,10 +58,10 @@ def sidebar_dynamic_container(): position=input.position(), ), ui.h2("Dynamic sidebar"), - ui.output_text_verbatim("state_dynamic"), + ui.output_code("state_dynamic"), ) - @render.text + @render.code def state_dynamic(): return f"input.sidebar_dynamic(): {input.sidebar_dynamic()}" diff --git a/shiny/api-examples/sidebar/app-core.py b/shiny/api-examples/sidebar/app-core.py index 48e4c53d7..421d1b281 100644 --- a/shiny/api-examples/sidebar/app-core.py +++ b/shiny/api-examples/sidebar/app-core.py @@ -4,44 +4,44 @@ ui.card( ui.layout_sidebar( ui.sidebar("Left sidebar content", id="sidebar_left"), - ui.output_text_verbatim("state_left"), + ui.output_code("state_left"), ) ), ui.card( ui.layout_sidebar( ui.sidebar("Right sidebar content", id="sidebar_right", position="right"), - ui.output_text_verbatim("state_right"), + ui.output_code("state_right"), ), ), ui.card( ui.layout_sidebar( ui.sidebar("Closed sidebar content", id="sidebar_closed", open="closed"), - ui.output_text_verbatim("state_closed"), + ui.output_code("state_closed"), ) ), ui.card( ui.layout_sidebar( ui.sidebar("Always sidebar content", id="sidebar_always", open="always"), - ui.output_text_verbatim("state_always"), + ui.output_code("state_always"), ) ), ) def server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code def state_left(): return f"input.sidebar_left(): {input.sidebar_left()}" - @render.text + @render.code def state_right(): return f"input.sidebar_right(): {input.sidebar_right()}" - @render.text + @render.code def state_closed(): return f"input.sidebar_closed(): {input.sidebar_closed()}" - @render.text + @render.code def state_always(): return f"input.sidebar_always(): {input.sidebar_always()}" diff --git a/shiny/api-examples/template/app-core.py b/shiny/api-examples/template/app-core.py index 7dacdbec2..412115e45 100644 --- a/shiny/api-examples/template/app-core.py +++ b/shiny/api-examples/template/app-core.py @@ -3,12 +3,12 @@ app_ui = ui.page_fluid( ui.panel_title("Hello Shiny!"), ui.input_slider("n", "N", 0, 100, 20), - ui.output_text_verbatim("txt"), + ui.output_code("txt"), ) def server(input, output, session): - @render.text + @render.code def txt(): return f"n*2 is {input.n() * 2}" diff --git a/shiny/api-examples/theme/__purgecss.py b/shiny/api-examples/theme/__purgecss.py index ebd1f8fba..4d5a4f136 100644 --- a/shiny/api-examples/theme/__purgecss.py +++ b/shiny/api-examples/theme/__purgecss.py @@ -26,7 +26,7 @@ title="Parameters", ), ui.h2("Output"), - ui.output_text_verbatim("txt"), + ui.output_code("txt"), ui.markdown(filler_text), title="Theme Example", theme=my_theme, diff --git a/shiny/api-examples/theme/app-core-local.py b/shiny/api-examples/theme/app-core-local.py index 133b3fcb6..281a7506c 100644 --- a/shiny/api-examples/theme/app-core-local.py +++ b/shiny/api-examples/theme/app-core-local.py @@ -10,7 +10,7 @@ title="Parameters", ), ui.h2("Output"), - ui.output_text_verbatim("txt"), + ui.output_code("txt"), ui.markdown(filler_text), title="Theme Example", theme=Path(__file__).parent / "css" / "shiny-theme-demo.css", @@ -18,7 +18,7 @@ def server(input, output, session): - @render.text + @render.code def txt(): return f"n*2 is {input.n() * 2}" diff --git a/shiny/api-examples/theme/app-core-remote.py b/shiny/api-examples/theme/app-core-remote.py index b55ad5992..32cfc690d 100644 --- a/shiny/api-examples/theme/app-core-remote.py +++ b/shiny/api-examples/theme/app-core-remote.py @@ -8,7 +8,7 @@ title="Parameters", ), ui.h2("Output"), - ui.output_text_verbatim("txt"), + ui.output_code("txt"), ui.markdown(filler_text), title="Theme Example", theme="https://cdn.jsdelivr.net/npm/bootswatch@5.3.3/dist/sketchy/bootstrap.min.css", @@ -16,7 +16,7 @@ def server(input, output, session): - @render.text + @render.code def txt(): return f"n*2 is {input.n() * 2}" diff --git a/shiny/api-examples/theme/app-core-shinyswatch.py b/shiny/api-examples/theme/app-core-shinyswatch.py index 0bb94a566..5dea03345 100644 --- a/shiny/api-examples/theme/app-core-shinyswatch.py +++ b/shiny/api-examples/theme/app-core-shinyswatch.py @@ -9,7 +9,7 @@ title="Parameters", ), ui.h2("Output"), - ui.output_text_verbatim("txt"), + ui.output_code("txt"), ui.markdown(filler_text), title="Theme Example", theme=shinyswatch.theme.slate(), @@ -17,7 +17,7 @@ def server(input, output, session): - @render.text + @render.code def txt(): return f"n*2 is {input.n() * 2}" diff --git a/shiny/api-examples/theme/app-core.py b/shiny/api-examples/theme/app-core.py index a4ac8241b..03ec10a5e 100644 --- a/shiny/api-examples/theme/app-core.py +++ b/shiny/api-examples/theme/app-core.py @@ -10,7 +10,7 @@ title="Parameters", ), ui.h2("Output"), - ui.output_text_verbatim("txt"), + ui.output_code("txt"), ui.markdown(filler_text), title="Theme Example", theme=my_theme, @@ -18,7 +18,7 @@ def server(input, output, session): - @render.text + @render.code def txt(): return f"n*2 is {input.n() * 2}" diff --git a/shiny/api-examples/update_sidebar/app-core.py b/shiny/api-examples/update_sidebar/app-core.py index 9dc0a155d..a868dd99c 100644 --- a/shiny/api-examples/update_sidebar/app-core.py +++ b/shiny/api-examples/update_sidebar/app-core.py @@ -6,7 +6,7 @@ ui.input_action_button("close_sidebar", label="Close sidebar", class_="me-3"), ui.br(), ui.br(), - ui.output_text_verbatim("state"), + ui.output_code("state"), fillable=False, ) @@ -22,7 +22,7 @@ def _(): def _(): ui.update_sidebar("sidebar", show=False) - @render.text + @render.code def state(): return f"input.sidebar(): {input.sidebar()}" diff --git a/shiny/templates/app/01-basic-app/app-core.py b/shiny/templates/app/01-basic-app/app-core.py index 7dacdbec2..412115e45 100644 --- a/shiny/templates/app/01-basic-app/app-core.py +++ b/shiny/templates/app/01-basic-app/app-core.py @@ -3,12 +3,12 @@ app_ui = ui.page_fluid( ui.panel_title("Hello Shiny!"), ui.input_slider("n", "N", 0, 100, 20), - ui.output_text_verbatim("txt"), + ui.output_code("txt"), ) def server(input, output, session): - @render.text + @render.code def txt(): return f"n*2 is {input.n() * 2}" diff --git a/shiny/ui/_output.py b/shiny/ui/_output.py index 5d98d7c42..49736dc20 100644 --- a/shiny/ui/_output.py +++ b/shiny/ui/_output.py @@ -14,6 +14,7 @@ from htmltools import Tag, TagAttrValue, TagFunction, css, div, tags +from .._deprecated import warn_deprecated from .._docstring import add_example, no_example from ..module import resolve_id from ..types import MISSING, MISSING_TYPE @@ -302,7 +303,7 @@ def output_code(id: str, placeholder: bool = True) -> Tag: -------- * :class:`~shiny.render.text` * :func:`~shiny.ui.output_text` - * :func:`~shiny.ui.output_text_verbatim` + * :func:`~shiny.ui.output_code` Example ------- @@ -316,7 +317,7 @@ def output_code(id: str, placeholder: bool = True) -> Tag: @add_example(ex_dir="../api-examples/input_text") def output_text_verbatim(id: str, placeholder: bool = False) -> Tag: """ - Create a output container for some text. + Deprecated. Create a output container for some text. Place a :class:`~shiny.render.text` result in the user interface. Differs from :func:`~shiny.ui.output_text` in that it wraps the text in a @@ -339,6 +340,7 @@ def output_text_verbatim(id: str, placeholder: bool = False) -> Tag: See Also -------- * :class:`~shiny.render.text` + * :class:`~shiny.render.code` * :func:`~shiny.ui.output_text` Example @@ -346,6 +348,12 @@ def output_text_verbatim(id: str, placeholder: bool = False) -> Tag: See :func:`~shiny.ui.output_text` """ + warn_deprecated( + "`ui.output_text_verbatim()` was deprecated in v1.6.0." + "Please use `ui.output_text()` / `@render.text` to create an output container for plain text " + "or `ui.output_code()` / `@render.code` to create an output container for monospaced text." + ) + cls = "shiny-text-output" + (" noplaceholder" if not placeholder else "") return tags.pre(id=resolve_id(id), class_=cls) diff --git a/tests/playwright/shiny/async/app.py b/tests/playwright/shiny/async/app.py index cafa7dbc8..60362afb7 100644 --- a/tests/playwright/shiny/async/app.py +++ b/tests/playwright/shiny/async/app.py @@ -18,7 +18,7 @@ def calc(value: str) -> str: "value", "Value to sha256sum", value="The quick brown fox", rows=5, width="100%" ), ui.p(ui.input_action_button("go", "Calculate"), class_="mb-3"), - ui.output_text_verbatim("hash_output"), + ui.output_code("hash_output"), ) diff --git a/tests/playwright/shiny/bugs/0648-update-slider-datetime-value/app.py b/tests/playwright/shiny/bugs/0648-update-slider-datetime-value/app.py index b9025647a..72d283814 100644 --- a/tests/playwright/shiny/bugs/0648-update-slider-datetime-value/app.py +++ b/tests/playwright/shiny/bugs/0648-update-slider-datetime-value/app.py @@ -28,7 +28,7 @@ def slider_with_reset_ui( timezone="UTC", time_format="%H:%M:%S", ), - ui.output_text_verbatim("txt"), + ui.output_code("txt"), ui.div(ui.input_action_button("reset", label)), ) @@ -43,7 +43,7 @@ def slider_with_reset_server( max: Optional[datetime.datetime] = None, value: Any = None, ): - @render.text + @render.code def txt(): if isinstance(input.times(), (tuple, list)): return " - ".join([str(x) for x in input.times()]) diff --git a/tests/playwright/shiny/bugs/0696-resolve-id/app.py b/tests/playwright/shiny/bugs/0696-resolve-id/app.py index 7a2bcc5c7..15478e875 100644 --- a/tests/playwright/shiny/bugs/0696-resolve-id/app.py +++ b/tests/playwright/shiny/bugs/0696-resolve-id/app.py @@ -99,11 +99,11 @@ def ui_navs(label: str) -> list[ui._navs.NavPanel]: ), ui.layout_column_wrap( *[ - ui.output_text_verbatim(f"status_x_{x_input_key}", placeholder=True) + ui.output_code(f"status_x_{x_input_key}", placeholder=True) for x_input_key in x_input_keys ], *[ - ui.output_text_verbatim(f"status_{input_key}", placeholder=True) + ui.output_code(f"status_{input_key}", placeholder=True) for input_key in input_keys ], width=1 / 2, @@ -200,7 +200,7 @@ def ui_navs(label: str) -> list[ui._navs.NavPanel]: "Image (Changes w/ `input.radio_buttons()`)", ui.output_image("out_image", height="180px"), ), - ("Text Verbatim", ui.output_text_verbatim("out_text_verbatim")), + ("Code", ui.output_code("out_code")), ("Text", ui.output_text("out_text")), ("UI", ui.output_ui("out_ui")), ) @@ -244,9 +244,9 @@ def out_data_frame(): def out_text(): return f"Output text content. `input.radio_buttons()`: `{input.input_radio_buttons()}`" - @render.text - def out_text_verbatim(): - return f"Output text verbatim content. `input.radio_buttons()`: `{input.input_radio_buttons()}`" + @render.code + def out_code(): + return f"Output Code content. `input.radio_buttons()`: `{input.input_radio_buttons()}`" @render.ui def out_ui(): @@ -371,7 +371,7 @@ def preprocess_file(x: Any) -> str: width=1 / 3, ), # ui.h3("Inputs that are not in a module:"), - # ui.output_text_verbatim("not_modules", placeholder=True), + # ui.output_code("not_modules", placeholder=True), ) diff --git a/tests/playwright/shiny/bugs/0696-resolve-id/test_0696_resolve_id.py b/tests/playwright/shiny/bugs/0696-resolve-id/test_0696_resolve_id.py index 1fb249eb5..7b18a2cc4 100644 --- a/tests/playwright/shiny/bugs/0696-resolve-id/test_0696_resolve_id.py +++ b/tests/playwright/shiny/bugs/0696-resolve-id/test_0696_resolve_id.py @@ -30,8 +30,8 @@ def resolve_id(id: str): controller.OutputText(page, resolve_id("out_text")).expect_value( f"Output text content. `input.radio_buttons()`: `{letter}`" ) - controller.OutputTextVerbatim(page, resolve_id("out_text_verbatim")).expect_value( - f"Output text verbatim content. `input.radio_buttons()`: `{letter}`" + controller.OutputCode(page, resolve_id("out_code")).expect_value( + f"Output Code content. `input.radio_buttons()`: `{letter}`" ) controller.OutputTable(page, resolve_id("out_table")).expect_nrow(count + 1) diff --git a/tests/playwright/shiny/bugs/1345-render-data-frame-input/app.py b/tests/playwright/shiny/bugs/1345-render-data-frame-input/app.py index 525dd197a..1a62bfa20 100644 --- a/tests/playwright/shiny/bugs/1345-render-data-frame-input/app.py +++ b/tests/playwright/shiny/bugs/1345-render-data-frame-input/app.py @@ -4,8 +4,8 @@ app_ui = ui.page_fluid( ui.output_data_frame("df1"), - ui.output_text_verbatim("selected_rows", placeholder=True), - ui.output_text_verbatim("cell_selection", placeholder=True), + ui.output_code("selected_rows", placeholder=True), + ui.output_code("cell_selection", placeholder=True), ) @@ -16,11 +16,11 @@ def server(input: Inputs): def df1(): return render.DataGrid(df(), selection_mode="rows") - @render.text + @render.code def selected_rows(): return f"Input selected rows: {input.df1_selected_rows()}" - @render.text + @render.code def cell_selection(): return f"Cell selection rows: {df1.cell_selection()['rows']}" diff --git a/tests/playwright/shiny/bugs/1351-render-data-frame-selected/app.py b/tests/playwright/shiny/bugs/1351-render-data-frame-selected/app.py index d81bc75d5..35343a84b 100644 --- a/tests/playwright/shiny/bugs/1351-render-data-frame-selected/app.py +++ b/tests/playwright/shiny/bugs/1351-render-data-frame-selected/app.py @@ -14,7 +14,7 @@ ), ui.input_action_button("add_row", "Add row"), ui.input_action_button("clear_table", "Clear table"), - ui.output_text_verbatim("number_of_selected_rows"), + ui.output_code("number_of_selected_rows"), ui.output_data_frame("df1"), ) @@ -35,7 +35,7 @@ def _(): ) df.set(new_df) - @render.text + @render.code def number_of_selected_rows(): df_selected = df1.data_view(selected=True) return f"Selected rows: {len(df_selected)}" diff --git a/tests/playwright/shiny/components/busy_indicators/app.py b/tests/playwright/shiny/components/busy_indicators/app.py index 5c02e4bdf..25516b0e5 100644 --- a/tests/playwright/shiny/components/busy_indicators/app.py +++ b/tests/playwright/shiny/components/busy_indicators/app.py @@ -45,7 +45,7 @@ def plot(): inline=True, ), ui.input_task_button("rerender", "Re-render"), - ui.output_text_verbatim("counter", placeholder=True), + ui.output_code("counter", placeholder=True), ui.layout_columns( card_ui("ring", "ring", "red", "10px"), card_ui("bars", "bars", "green", "20px"), @@ -77,7 +77,7 @@ def indicator_types_ui(): pulse=(selected_busy_indicator_type != "spinners"), ) - @render.text + @render.code def counter(): return str(rerender()) diff --git a/tests/playwright/shiny/components/data_frame/data_view_info/app.py b/tests/playwright/shiny/components/data_frame/data_view_info/app.py index 0d1a08d3c..c0f3e77d6 100644 --- a/tests/playwright/shiny/components/data_frame/data_view_info/app.py +++ b/tests/playwright/shiny/components/data_frame/data_view_info/app.py @@ -21,11 +21,11 @@ def mod_ui(): ui.card( ui.layout_column_wrap( ui.TagList( - ui.div("Sort: ", ui.output_text_verbatim("sort")), - ui.div("Filter: ", ui.output_text_verbatim("filter")), - ui.div("Rows: ", ui.output_text_verbatim("rows")), - ui.div("Selected Rows: ", ui.output_text_verbatim("selected_rows")), - ui.div("Type: ", ui.output_text_verbatim("df_type")), + ui.div("Sort: ", ui.output_code("sort")), + ui.div("Filter: ", ui.output_code("filter")), + ui.div("Rows: ", ui.output_code("rows")), + ui.div("Selected Rows: ", ui.output_code("selected_rows")), + ui.div("Type: ", ui.output_code("df_type")), ), ui.output_data_frame("penguins_df"), width=1 / 2, diff --git a/tests/playwright/shiny/components/data_frame/df_methods/app.py b/tests/playwright/shiny/components/data_frame/df_methods/app.py index fb55d944f..d87195f87 100644 --- a/tests/playwright/shiny/components/data_frame/df_methods/app.py +++ b/tests/playwright/shiny/components/data_frame/df_methods/app.py @@ -29,15 +29,15 @@ def mod_ui(): ui.br(), ui.output_data_frame("iris_df"), ui.h2("Data view indices"), - ui.output_text_verbatim("data_view_rows"), + ui.output_code("data_view_rows"), ui.h2("Indices when view_selected=True"), - ui.output_text_verbatim("data_view_selected_true"), + ui.output_code("data_view_selected_true"), ui.h2("Indices when view_selected=False"), - ui.output_text_verbatim("data_view_selected_false"), + ui.output_code("data_view_selected_false"), ui.h2("Show selected cell"), - ui.output_text_verbatim("cell_selection"), + ui.output_code("cell_selection"), ui.h2("Type:"), - ui.output_text_verbatim("df_type"), + ui.output_code("df_type"), ) diff --git a/tests/playwright/shiny/components/data_frame/html_columns/app.py b/tests/playwright/shiny/components/data_frame/html_columns/app.py index d6764e31d..99060f2ce 100644 --- a/tests/playwright/shiny/components/data_frame/html_columns/app.py +++ b/tests/playwright/shiny/components/data_frame/html_columns/app.py @@ -67,7 +67,7 @@ def random_generator(): ) pd_penguins.iloc[1, 5] = ui.p( # pyright: ignore[reportArgumentType] ui.input_action_button("pandas_test_cell_button", "Test button"), - ui.output_text_verbatim("pandas_test_cell_text", placeholder=True), + ui.output_code("pandas_test_cell_text", placeholder=True), ) @@ -116,9 +116,7 @@ def random_generator(): ui.input_action_button( "polars_test_cell_button", "Test button" ), - ui.output_text_verbatim( - "polars_test_cell_text", placeholder=True - ), + ui.output_code("polars_test_cell_text", placeholder=True), ) if i == 1 else ui.div(val) @@ -153,11 +151,11 @@ def random_generator(): def server(input: Inputs, output: Outputs, session: Session) -> None: - @render.text + @render.code def pandas_test_cell_text(): return f"pandas_test_cell_value {input.pandas_test_cell_button()}" - @render.text + @render.code def polars_test_cell_text(): return f"polars_test_cell_value {input.polars_test_cell_button()}" diff --git a/tests/playwright/shiny/deprecated/output_transformer/app.py b/tests/playwright/shiny/deprecated/output_transformer/app.py index 3ec9dfe38..21db13d4c 100644 --- a/tests/playwright/shiny/deprecated/output_transformer/app.py +++ b/tests/playwright/shiny/deprecated/output_transformer/app.py @@ -114,12 +114,12 @@ def render_capitalize( ui.h1("Capitalization renderer"), ui.input_text("caption", "Caption:", "Data summary"), "Renderer called with out parentheses:", - ui.output_text_verbatim("no_output", placeholder=True), - ui.output_text_verbatim("no_parens", placeholder=True), + ui.output_code("no_output", placeholder=True), + ui.output_code("no_parens", placeholder=True), "To upper:", - ui.output_text_verbatim("to_upper", placeholder=True), + ui.output_code("to_upper", placeholder=True), "To lower:", - ui.output_text_verbatim("to_lower", placeholder=True), + ui.output_code("to_lower", placeholder=True), ) diff --git a/tests/playwright/shiny/implicit-register/app.py b/tests/playwright/shiny/implicit-register/app.py index eb88220a1..f71a0d033 100644 --- a/tests/playwright/shiny/implicit-register/app.py +++ b/tests/playwright/shiny/implicit-register/app.py @@ -9,7 +9,7 @@ app_ui = ui.page_fluid( [ - ui.p(ui.div(desc), ui.output_text_verbatim(id, placeholder=True)) + ui.p(ui.div(desc), ui.output_code(id, placeholder=True)) for id, desc in scenarios.items() ] ) @@ -21,11 +21,11 @@ def server(input: Inputs, output: Outputs, session: Session): # does internally. @output(id="out2") - @render.text + @render.code def out1(): return "One" - @render.text + @render.code def out3(): return "Two" diff --git a/tests/playwright/shiny/inputs/input_file/app.py b/tests/playwright/shiny/inputs/input_file/app.py index 369d7f90a..4490af0da 100644 --- a/tests/playwright/shiny/inputs/input_file/app.py +++ b/tests/playwright/shiny/inputs/input_file/app.py @@ -15,7 +15,7 @@ ), ui.output_table("summary"), ui.input_file("file2", "Multiple files", multiple=True), - ui.output_text_verbatim("file2_info", placeholder=True), + ui.output_code("file2_info", placeholder=True), ) @@ -57,7 +57,7 @@ def summary(): # checkboxes return info_df.loc[:, input.stats()] - @render.text + @render.code def file2_info(): file2: typing.Union[typing.List["FileInfo"], None] = input.file2() if not file2: diff --git a/tests/playwright/shiny/inputs/input_radio_checkbox_group/app.py b/tests/playwright/shiny/inputs/input_radio_checkbox_group/app.py index 898124cf1..89865c83b 100644 --- a/tests/playwright/shiny/inputs/input_radio_checkbox_group/app.py +++ b/tests/playwright/shiny/inputs/input_radio_checkbox_group/app.py @@ -15,7 +15,7 @@ "c": HTML("C"), }, ), - ui.output_text_verbatim("radio1_out", placeholder=True), + ui.output_code("radio1_out", placeholder=True), ), ui.column( 6, @@ -29,7 +29,7 @@ }, inline=True, ), - ui.output_text_verbatim("radio2_out", placeholder=True), + ui.output_code("radio2_out", placeholder=True), ), ), ui.row( @@ -44,7 +44,7 @@ "blue": ui.span("BLUE", style="color: #0000AA;"), }, ), - ui.output_text_verbatim("check1_out", placeholder=True), + ui.output_code("check1_out", placeholder=True), ), ui.column( 6, @@ -58,26 +58,26 @@ }, inline=True, ), - ui.output_text_verbatim("check2_out", placeholder=True), + ui.output_code("check2_out", placeholder=True), ), ), ) def server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code def radio1_out(): return input.radio1() - @render.text + @render.code def radio2_out(): return input.radio2() - @render.text + @render.code def check1_out(): return input.check1() - @render.text + @render.code def check2_out(): return input.check2() diff --git a/tests/playwright/shiny/inputs/input_slider/app.py b/tests/playwright/shiny/inputs/input_slider/app.py index f423c7fa8..39fa22bf3 100644 --- a/tests/playwright/shiny/inputs/input_slider/app.py +++ b/tests/playwright/shiny/inputs/input_slider/app.py @@ -25,7 +25,7 @@ def slider_row( ), ui.column( 6, - ui.output_text_verbatim(f"txt{id_num}", placeholder=True), + ui.output_code(f"txt{id_num}", placeholder=True), ), ) @@ -103,7 +103,7 @@ def make_output(id_num: int): name = f"txt{id_num}" @output(id=name) - @render.text + @render.code def _(): return input[f"s{id_num}"]() diff --git a/tests/playwright/shiny/inputs/input_text_update_on/app.py b/tests/playwright/shiny/inputs/input_text_update_on/app.py index 51d74be5f..8addabc84 100644 --- a/tests/playwright/shiny/inputs/input_text_update_on/app.py +++ b/tests/playwright/shiny/inputs/input_text_update_on/app.py @@ -73,13 +73,13 @@ def text_input_ui(update_on: Literal["change", "blur"] = "change"): ui.h2(f'updateOn="{update_on}"'), ui.layout_columns( ui.input_text("txt", "Text", value="Hello", update_on=update_on), - ui.div("Text", ui.output_text_verbatim("value_txt")), + ui.div("Text", ui.output_code("value_txt")), ui.input_text_area("txtarea", "Text Area", update_on=update_on), - ui.div("Text Area", ui.output_text_verbatim("value_txtarea")), + ui.div("Text Area", ui.output_code("value_txtarea")), ui.input_numeric("num", "Numeric", value=1, update_on=update_on), - ui.div("Numeric", ui.output_text_verbatim("value_num")), + ui.div("Numeric", ui.output_code("value_num")), ui.input_password("pwd", "Password", update_on=update_on), - ui.div("Password", ui.output_text_verbatim("value_pwd")), + ui.div("Password", ui.output_code("value_pwd")), col_widths=6, ), ui.input_action_button("update_text", "Update Text"), @@ -91,19 +91,19 @@ def text_input_ui(update_on: Literal["change", "blur"] = "change"): @module.server def text_input_server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code def value_txt() -> str: return input.txt() - @render.text + @render.code def value_txtarea() -> str: return input.txtarea() - @render.text + @render.code def value_num() -> str: return str(input.num()) - @render.text + @render.code def value_pwd() -> str: return input.pwd() diff --git a/tests/playwright/shiny/server/output_transformer/app.py b/tests/playwright/shiny/server/output_transformer/app.py index 37d1063dc..8d92ba0d9 100644 --- a/tests/playwright/shiny/server/output_transformer/app.py +++ b/tests/playwright/shiny/server/output_transformer/app.py @@ -58,17 +58,17 @@ def render_test_text( app_ui = ui.page_fluid( ui.code("t1:"), - ui.output_text_verbatim("t1"), + ui.output_code("t1"), ui.code("t2:"), - ui.output_text_verbatim("t2"), + ui.output_code("t2"), ui.code("t3:"), - ui.output_text_verbatim("t3"), + ui.output_code("t3"), ui.code("t4:"), - ui.output_text_verbatim("t4"), + ui.output_code("t4"), ui.code("t5:"), - ui.output_text_verbatim("t5"), + ui.output_code("t5"), ui.code("t6:"), - ui.output_text_verbatim("t6"), + ui.output_code("t6"), ) diff --git a/tests/playwright/shiny/server/reactive_event/app.py b/tests/playwright/shiny/server/reactive_event/app.py index 8fc83359f..98160fae5 100644 --- a/tests/playwright/shiny/server/reactive_event/app.py +++ b/tests/playwright/shiny/server/reactive_event/app.py @@ -7,22 +7,22 @@ ui.input_action_button("btn_count", "Immediate Count"), ui.tags.br(), ui.tags.label("Rendered on click:"), - ui.output_text_verbatim("txt_immediate", placeholder=True), + ui.output_code("txt_immediate", placeholder=True), ui.input_action_button("btn_trigger", "Update Count"), ui.tags.br(), ui.tags.label("Reactive event on renderer:"), - ui.output_text_verbatim("txt_render_delayed", placeholder=True), + ui.output_code("txt_render_delayed", placeholder=True), ui.tags.label("Reactive event on reactive calc:"), - ui.output_text_verbatim("txt_reactive_delayed", placeholder=True), + ui.output_code("txt_reactive_delayed", placeholder=True), ) def server(input: Inputs, output: Outputs, session: Session): - @render.text + @render.code def txt_immediate(): return input.btn_count() - @render.text + @render.code @reactive.event(input.btn_trigger) def txt_render_delayed(): return input.btn_count() @@ -32,7 +32,7 @@ def txt_render_delayed(): def delayed_btn_count() -> int: return input.btn_count() - @render.text + @render.code def txt_reactive_delayed(): return str(delayed_btn_count()) diff --git a/tests/playwright/shiny/session/flush/app.py b/tests/playwright/shiny/session/flush/app.py index 39c046887..a4ad429a6 100644 --- a/tests/playwright/shiny/session/flush/app.py +++ b/tests/playwright/shiny/session/flush/app.py @@ -33,15 +33,15 @@ ui.input_action_button("btn", "Click me!"), ui.tags.br(), ui.tags.span("Counter: "), - ui.output_text_verbatim("btn_txt", placeholder=True), + ui.output_code("btn_txt", placeholder=True), ui.tags.span("All events: "), - ui.output_text_verbatim("all_txt", placeholder=True), + ui.output_code("all_txt", placeholder=True), ui.tags.span("Flush events: "), - ui.output_text_verbatim("flush_txt", placeholder=True), + ui.output_code("flush_txt", placeholder=True), ui.tags.span("Flushed events: "), - ui.output_text_verbatim("flushed_txt", placeholder=True), + ui.output_code("flushed_txt", placeholder=True), ui.tags.span("Session end events (refresh App to add events): "), - ui.output_text_verbatim("session_end_txt", placeholder=True), + ui.output_code("session_end_txt", placeholder=True), ui.tags.script( """ $(document).on('shiny:connected', function(event) { @@ -170,23 +170,23 @@ def reset(): cancel_on_ended_sync() cancel_on_ended_async() - @render.text + @render.code def btn_txt(): return str(input.btn()) - @render.text + @render.code def all_txt(): return str(all_vals.get()) - @render.text + @render.code def flush_txt(): return str(flush_vals.get()) - @render.text + @render.code def flushed_txt(): return str(flushed_vals.get()) - @render.text + @render.code def session_end_txt(): return str(session_ended_messages)