Skip to content

Commit

Permalink
Merge branch 'main' into fn_signatures_for_docs
Browse files Browse the repository at this point in the history
* main: (36 commits)
  Add shiny/templates to MANIFEST.in files (#926)
  docs: Function Reference Proofreads (#919)
  Fix failing deploy tests (#925)
  Add GitHub sources to shiny create
  Make changelog styling more consistent
  Function reference edits (#857)
  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)
  ...
  • Loading branch information
schloerke committed Dec 19, 2023
2 parents 850fdf2 + c19bf27 commit aecc5d8
Show file tree
Hide file tree
Showing 229 changed files with 2,361 additions and 1,123 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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Byte-compiled / optimized / DLL files
__pycache__/
**/__pycache__/
*.py[cod]
*$py.class

Expand Down 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
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [UNRELEASED]

### New features
- `shiny create` now allows you to select from a list of template apps.
- `shiny create` provides templates which help you build your own custom JavaScript components.

* `shiny create` now allows you to select from a list of template apps.
* `shiny create` provides templates which help you build your own custom JavaScript components.
* 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
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif
recursive-include shiny/www *
recursive-include shiny/experimental/www *
recursive-include shiny/api-examples *
recursive-include shiny/templates *
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/
5 changes: 4 additions & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ $(PYBIN): $(VENV)
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)

dev-htmltools: $(PYBIN) ## Install development version of htmltools
$(PYBIN)/pip install https://github.com/rstudio/py-htmltools/tarball/main

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
3 changes: 3 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ This directory contains files to generate Shiny for Python API documentation, us
To build the docs, first install the Python dependencies and Quarto extensions:

```bash
# Install development version of htmltools (do this if you are using a development version of shiny)
make dev-htmltools

# Install build dependencies
make deps
```
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
48 changes: 39 additions & 9 deletions docs/_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
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

# from quartodoc.ast import preview

SHINY_PATH = Path(files("shiny").joinpath())

SHINYLIVE_CODE_TEMPLATE = """
Expand Down Expand Up @@ -129,7 +132,7 @@ def render_annotation(self, el: None):

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

Expand All @@ -138,12 +141,40 @@ def render_annotation(self, el: exp.Expr):
@dispatch
def render_annotation(self, el: exp.ExprName):
# e.g. Name(source="Optional", full="typing.Optional")
return f"[{el.path}](`{el.canonical_path}`)"
return f"[{el.name}](`{el.canonical_path}`)"

@dispatch
def summarize(self, el: dc.Object | dc.Alias):
result = super().summarize(el)
return html.escape(result)
# Overload of `quartodoc.renderers.md_renderer` to fix bug where the descriptions
# are cut off and never display other places. Fixing by always displaying the
# documentation.
def summarize(self, obj: Union[dc.Object, dc.Alias]) -> str:
# get high-level description
doc = obj.docstring
if doc is None:
docstring_parts = []
else:
docstring_parts = doc.parsed

if len(docstring_parts) and isinstance(
docstring_parts[0], ds.DocstringSectionText
):
description = docstring_parts[0].value

# ## Approach: Always return the full description!
return description

# ## Alternative: Add ellipsis if the lines are cut off

# # If the description is more than one line, only show the first line.
# # Add `...` to indicate the description was truncated
# parts = description.split("\n")
# short = parts[0]
# if len(parts) > 1:
# short += "&hellip;"

# return short

return ""

# Consolidate the parameter type info into a single column
@dispatch
Expand All @@ -158,15 +189,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
Loading

0 comments on commit aecc5d8

Please sign in to comment.