Skip to content

Commit

Permalink
Merge branch 'main' into garrettgman/main
Browse files Browse the repository at this point in the history
* main: (24 commits)
  docs: Use definition lists for parameter descriptions to enable full markdown support (#901)
  docs(layout_columns): Add example app (#903)
  fix(layout_columns): Remove use of enum for breakpoints (#912)
  Express: don't automatically put strings in a `<pre>` block (#905)
  Deprecate `nav()` in favor of `nav_panel()` (#876)
  chore: Remove unused import
  refactor(layout_column_wrap): Use helper for wrapping children (#910)
  fix(layout_columns): Don't apply fillable class to layout container (#909)
  Add output to React template (#908)
  fix(layout_columns): Add missing `bslib-mb-spacing` class (#906)
  Custom component template updates (#874)
  fix(layout_columns): If the breakpoint name is an enum, need to collect the value (#902)
  chore: exclude `_dev/` folder (#897)
  feat: Add `ui.layout_columns()` (#856)
  Update VS Code settings file
  Express: change default page function to page_fixed (#892)
  Better messages for `AttributeError` in Shiny Express (#888)
  Fix 0.6.0 release date
  Fix failing express tests (#887)
  Explain why function is called twice
  ...
  • Loading branch information
schloerke committed Dec 18, 2023
2 parents b508fab + 3bc7117 commit 6a48c66
Show file tree
Hide file tree
Showing 195 changed files with 1,686 additions and 563 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: |
make check
e2e:
playwright-shiny:
runs-on: ${{ matrix.os }}
if: github.event_name != 'release'
strategy:
Expand All @@ -67,9 +67,9 @@ jobs:
- name: Run End-to-End tests
timeout-minutes: 20
run: |
make e2e
make playwright-shiny
e2e-examples:
playwright-examples:
runs-on: ${{ matrix.os }}
if: github.event_name != 'release'
strategy:
Expand Down Expand Up @@ -99,11 +99,11 @@ jobs:
- name: Run example app tests
timeout-minutes: 20
run: |
make e2e-examples
make playwright-examples
e2e-deploys:
# Only allow one `e2e-deploys` job to run at a time. (Independent of branch / PR)
concurrency: e2e-deploys
playwright-deploys:
# Only allow one `playwright-deploys` job to run at a time. (Independent of branch / PR)
concurrency: playwright-deploys
runs-on: ${{ matrix.os }}
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && startsWith(github.head_ref, 'deploy')) }}
strategy:
Expand All @@ -128,7 +128,7 @@ jobs:
DEPLOY_SHINYAPPS_SECRET: "${{ secrets.DEPLOY_SHINYAPPS_SECRET }}"
timeout-minutes: 30
run: |
make e2e-deploys
make playwright-deploys
pypi:
name: "Deploy to PyPI"
Expand Down Expand Up @@ -202,7 +202,7 @@ jobs:
- name: Run End-to-End tests
timeout-minutes: 20
run: |
make e2e-junit
make testrail-junit
- name: Report results to Testrail
env:
TESTRAIL_URL: "https://posit.testrail.io"
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,6 @@ docs/source/reference/
.Rproj.user

/.luarc.json

# Developer scratch area
_dev/
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"editor.formatOnSave": true,
"editor.tabSize": 4,
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.organizeImports": "explicit"
}
},
"isort.args": ["--profile", "black"],
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Closed #814: The functions `reactive.Calc` and `reactive.Effect` have been changed to have lowercase names: `reactive.calc`, and `reactive.effect`. The old capitalized names are now aliases to the new lowercase names, so existing code will continue to work. Similarly, the class `reactive.Value` has a new alias, `reactive.value`, but in this case, since the original was a class, it keeps the original capitalized name as the primary name. The examples have not been changed yet, but will be changed in a future release. (#822)

* Added `ui.layout_columns()` for creating responsive column-forward layouts based on Bootstrap's 12-column CSS Grid. (#856)

### Bug fixes

* Fix support for `shiny.ui.accordion(multiple=)` (#799).

### Other changes

* Closed #492: `shiny.ui.nav()` is now deprecated in favor of the more aptly named `shiny.ui.nav_panel()` (#876).
* Update penguins example to credit Allison Horst and drop usage of `shiny.experimental` (#798).

* `as_fillable_container()` and `as_fill_item()` no longer mutate the `Tag` object that was passed in. Instead, it returns a new `Tag` object. Also closed #856: these functions now put the `html-fill-container` and `html-fill-item` CSS classes last, instead of first. (#862)


## [0.6.0] - 2023-08-08
## [0.6.0] - 2023-10-30

### Breaking Changes
* `shiny.run` only allows positional arguments for `app`, `host`, and `port`, all other arguments must be specified with keywords.
Expand Down
33 changes: 18 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: help clean clean-test clean-pyc clean-build help lint test e2e e2e-examples
.PHONY: help clean clean-test clean-pyc clean-build help lint test playwright-shiny playwright-examples playwright-deploys install-trcli install-playwright
.DEFAULT_GOAL := help

define BROWSER_PYSCRIPT
Expand Down Expand Up @@ -83,31 +83,34 @@ test: ## run tests quickly with the default Python
python3 tests/pytest/asyncio_prevent.py
pytest

# Default `FILE` to `e2e` if not specified
FILE:=tests/e2e
# Default `SUB_FILE` to empty
SUB_FILE:=

DEPLOYS_FILE:=tests/deploys
DEPLOYS_FILE:=tests/playwright/deploys

playwright-install:
install-playwright:
playwright install --with-deps

trcli-install:
install-trcli:
which trcli || pip install trcli

e2e: playwright-install ## end-to-end tests with playwright
pytest $(FILE) -m "not examples and not integrationtest"
install-rsconnect: ## install the main version of rsconnect till pypi version supports shiny express
pip install git+https://github.com/rstudio/rsconnect-python.git#egg=rsconnect-python

e2e-examples: playwright-install ## end-to-end tests on examples with playwright
pytest $(FILE) -m "examples"
playwright-shiny: install-playwright ## end-to-end tests with playwright
pytest tests/playwright/shiny/$(SUB_FILE)

e2e-deploys: playwright-install ## end-to-end tests on deploys with playwright
pytest $(DEPLOYS_FILE) -s -m "integrationtest"
playwright-examples: install-playwright ## end-to-end tests on examples with playwright
pytest tests/playwright/examples

e2e-junit: playwright-install trcli-install ## end-to-end tests with playwright and generate junit report
pytest $(FILE) --junitxml=report.xml
playwright-deploys: install-playwright install-rsconnect ## end-to-end tests on deploys with playwright
pytest tests/playwright/deploys/$(SUB_FILE) -s

testrail-junit: install-playwright install-trcli ## end-to-end tests with playwright and generate junit report
pytest tests/playwright/shiny/$(SUB_FILE) --junitxml=report.xml

coverage: ## check combined code coverage (must run e2e last)
pytest --cov-report term-missing --cov=shiny tests/pytest/ tests/e2e/ -m "not examples and not integrationtest"
pytest --cov-report term-missing --cov=shiny tests/pytest/ tests/playwright/shiny/$(SUB_FILE)
coverage html
$(BROWSER) htmlcov/index.html

Expand Down
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ _inv/
_sidebar.yml
/.quarto/
objects.json
site_libs/
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ deps: $(PYBIN) ## Install build dependencies
$(PYBIN)/pip install pip --upgrade
$(PYBIN)/pip install -e ..[doc]

quartodoc: ## Build qmd files for API docs
quartodoc: $(PYBIN) ## Build qmd files for API docs
. $(PYBIN)/activate \
&& quartodoc interlinks \
&& quartodoc build --config _quartodoc.yml --verbose
Expand Down
1 change: 1 addition & 0 deletions docs/_quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ project:
format:
html:
toc: true
css: shiny-docs.css

website:
title: "Shiny for Python (dev version)"
Expand Down
13 changes: 8 additions & 5 deletions docs/_quartodoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ quartodoc:
- express.layout.span
- express.layout.pre
- express.layout.sidebar
- express.layout.layout_columns
- express.layout.layout_column_wrap
- express.layout.column
- express.layout.row
- express.layout.card
- express.layout.accordion
- express.layout.accordion_panel
- express.layout.navset_tab
- express.layout.navset_card_tab
- express.layout.nav
- express.layout.navset
- express.layout.navset_card
- express.layout.nav_panel
- express.layout.page_fluid
- express.layout.page_fixed
- express.layout.page_fillable
Expand All @@ -46,6 +47,7 @@ quartodoc:
contents:
- ui.sidebar
- ui.layout_sidebar
- ui.layout_columns
- ui.layout_column_wrap
- ui.card
- ui.card_header
Expand Down Expand Up @@ -87,10 +89,10 @@ quartodoc:
- title: Navigation (tab) panels
desc: Create segments of UI content.
contents:
- ui.nav
- ui.nav_control
- ui.nav_panel
- ui.nav_spacer
- ui.nav_menu
- ui.nav_control
- ui.navset_bar
- ui.navset_tab
- ui.navset_pill
Expand Down Expand Up @@ -306,6 +308,7 @@ quartodoc:
contents:
- ui.panel_main
- ui.panel_sidebar
- ui.nav
- title: Experimental
desc: "These methods are under consideration and are considered unstable. However, if there is a method you are excited about, please let us know!"
contents:
Expand Down
16 changes: 8 additions & 8 deletions docs/_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from griffe.docstrings import dataclasses as ds
from plum import dispatch
from quartodoc import MdRenderer
from quartodoc.pandoc.blocks import DefinitionList
from quartodoc.renderers.base import convert_rst_link_to_md, sanitize

SHINY_PATH = Path(files("shiny").joinpath())
Expand Down Expand Up @@ -128,17 +129,17 @@ def render_annotation(self, el: None):
return ""

@dispatch
def render_annotation(self, el: exp.Expression):
# an expression is essentially a list[exp.Name | str]
def render_annotation(self, el: exp.Expr):
# an expression is essentially a list[exp.ExprName | str]
# e.g. Optional[TagList]
# -> [Name(source="Optional", ...), "[", Name(...), "]"]

return "".join(map(self.render_annotation, el))

@dispatch
def render_annotation(self, el: exp.Name):
def render_annotation(self, el: exp.ExprName):
# e.g. Name(source="Optional", full="typing.Optional")
return f"[{el.source}](`{el.full}`)"
return f"[{el.name}](`{el.canonical_path}`)"

@dispatch
def summarize(self, el: dc.Object | dc.Alias):
Expand All @@ -158,15 +159,14 @@ def render(self, el: ds.DocstringParameter):
# Wrap everything in a code block to allow for links
param = "<code>" + param + "</code>"

clean_desc = sanitize(el.description, allow_markdown=True)
return (param, clean_desc)
return (param, el.description)

@dispatch
def render(self, el: ds.DocstringSectionParameters):
rows = list(map(self.render, el.value))
header = ["Parameter", "Description"]
# rows is a list of tuples of (<parameter>, <description>)

return self._render_table(rows, header)
return str(DefinitionList(rows))

@dispatch
def signature(self, el: dc.Function, source: Optional[dc.Alias] = None):
Expand Down
4 changes: 4 additions & 0 deletions docs/shiny-docs.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#parameters dd {
margin-top: 0.5rem;
margin-left: 2rem;
}
4 changes: 2 additions & 2 deletions examples/event/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"""
),
ui.navset_card_tab(
ui.nav(
ui.nav_panel(
"Sync",
ui.input_action_button("btn", "Click me"),
ui.output_ui("btn_value"),
),
ui.nav(
ui.nav_panel(
"Async",
ui.input_action_button("btn_async", "Click me"),
ui.output_ui("btn_async_value"),
Expand Down
16 changes: 7 additions & 9 deletions examples/express/nav_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,24 @@
from shiny import render, ui
from shiny.express import input, layout

with layout.column(width=6):
with layout.navset_tab():
with layout.nav(title="One"):
with layout.layout_column_wrap(width=1 / 2):
with layout.navset():
with layout.nav_panel(title="One"):
ui.input_slider("n", "N", 1, 100, 50)

with layout.nav(title="Two"):
with layout.nav_panel(title="Two"):

@render.plot
def histogram():
np.random.seed(19680801)
x = 100 + 15 * np.random.randn(437)
plt.hist(x, input.n(), density=True)


with layout.column(width=6):
with layout.navset_card_tab():
with layout.nav(title="One"):
with layout.navset_card():
with layout.nav_panel(title="One"):
ui.input_slider("n2", "N", 1, 100, 50)

with layout.nav(title="Two"):
with layout.nav_panel(title="Two"):

@render.plot
def histogram2():
Expand Down
4 changes: 2 additions & 2 deletions examples/inputs-update/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
),
),
ui.navset_tab(
ui.nav("panel1", ui.h2("This is the first panel.")),
ui.nav("panel2", ui.h2("This is the second panel.")),
ui.nav_panel("panel1", ui.h2("This is the first panel.")),
ui.nav_panel("panel2", ui.h2("This is the second panel.")),
id="inTabset",
),
),
Expand Down
14 changes: 7 additions & 7 deletions examples/static_plots/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

nav = ui.navset_pill_list(
ui.nav_control(ui.p("Choose a package", class_="lead text-center")),
ui.nav(
ui.nav_panel(
"Plotnine",
ui.output_plot("plotnine"),
ui.div(
Expand All @@ -27,7 +27,7 @@
),
),
),
ui.nav(
ui.nav_panel(
"Seaborn",
ui.output_plot("seaborn"),
ui.div(
Expand All @@ -36,11 +36,11 @@
ui.input_slider("cov", "Co-variance", min=0, max=1, value=0.4),
),
),
ui.nav("Pandas", ui.output_plot("pandas")),
ui.nav("Holoviews", ui.output_plot("holoviews", height="600px")),
ui.nav("xarray", ui.output_plot("xarray")),
ui.nav("geopandas", ui.output_plot("geopandas")),
ui.nav("missingno", ui.output_plot("missingno")),
ui.nav_panel("Pandas", ui.output_plot("pandas")),
ui.nav_panel("Holoviews", ui.output_plot("holoviews", height="600px")),
ui.nav_panel("xarray", ui.output_plot("xarray")),
ui.nav_panel("geopandas", ui.output_plot("geopandas")),
ui.nav_panel("missingno", ui.output_plot("missingno")),
widths=(2, 10),
well=False,
)
Expand Down
3 changes: 2 additions & 1 deletion pyrightconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"dist",
"typings",
"sandbox",
"_dev",
"docs",
"tests/deploys/apps",
"tests/playwright/deploys/apps",
"shiny/templates"
],
"typeCheckingMode": "strict",
Expand Down
2 changes: 1 addition & 1 deletion scripts/htmlDependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ versions <- list()
message("Installing GitHub packages: bslib, shiny, htmltools")
withr::local_temp_libpaths()
ignore <- capture.output({
pak::pkg_install(c("cran::bslib", "cran::shiny", "cran::htmltools"))
pak::pkg_install(c("rstudio/bslib", "cran::shiny", "cran::htmltools"))
#pak::pkg_install(c("rstudio/bslib@main", "rstudio/shiny@main", "rstudio/htmltools@main"))
})

Expand Down
Loading

0 comments on commit 6a48c66

Please sign in to comment.