From 89a3e753b8fc918ec6f9ec92e3e594133e77aad9 Mon Sep 17 00:00:00 2001 From: Michael Chow Date: Wed, 9 Oct 2024 16:41:16 -0400 Subject: [PATCH 1/6] docs: use upcoming quartodoc description-list option --- docs/_quartodoc-core.yml | 2 ++ docs/_quartodoc-express.yml | 1 + docs/_renderer.py | 37 ++++++++----------------------------- 3 files changed, 11 insertions(+), 29 deletions(-) diff --git a/docs/_quartodoc-core.yml b/docs/_quartodoc-core.yml index d3dbea99e..d31b7f989 100644 --- a/docs/_quartodoc-core.yml +++ b/docs/_quartodoc-core.yml @@ -9,6 +9,7 @@ quartodoc: renderer: style: _renderer.py show_signature_annotations: false + table_style: description-list sections: - title: Page containers desc: Create a user interface page container. @@ -357,3 +358,4 @@ quartodoc: contents: - name: experimental.ui.card_image dynamic: false + diff --git a/docs/_quartodoc-express.yml b/docs/_quartodoc-express.yml index dbee0b740..2b1f8e50c 100644 --- a/docs/_quartodoc-express.yml +++ b/docs/_quartodoc-express.yml @@ -9,6 +9,7 @@ quartodoc: renderer: style: _renderer.py show_signature_annotations: false + table_style: description-list sections: - title: Input components desc: Gather user input. diff --git a/docs/_renderer.py b/docs/_renderer.py index 4d7299398..c07f91e49 100644 --- a/docs/_renderer.py +++ b/docs/_renderer.py @@ -24,6 +24,7 @@ from quartodoc import MdRenderer from quartodoc.pandoc.blocks import DefinitionList from quartodoc.renderers.base import convert_rst_link_to_md, sanitize +from quartodoc.renderers.md_renderer import ParamRow # from quartodoc.ast import preview @@ -101,12 +102,12 @@ def render_annotation(self, el: str): # TODO-future; Can be removed once we use quartodoc 0.3.5 # Related: https://github.com/machow/quartodoc/pull/205 @dispatch - def render(self, el: DocstringAttribute): - row = [ - sanitize(el.name), - self.render_annotation(el.annotation), - sanitize(el.description or "", allow_markdown=True), - ] + def render(self, el: DocstringAttribute) -> ParamRow: + row = ParamRow( + el.name, + el.description or "", + annotation=self.render_annotation(el.annotation), + ) return row @dispatch @@ -170,28 +171,6 @@ def summarize(self, obj: Union[Object, Alias]) -> str: return "" - # Consolidate the parameter type info into a single column - @dispatch - def render(self, el: DocstringParameter): - param = f'{el.name}' - annotation = self.render_annotation(el.annotation) - if annotation: - param = f'{param}: {annotation}' - if el.default: - param = f'{param} = {el.default}' - - # Wrap everything in a code block to allow for links - param = "" + param + "" - - return (param, el.description) - - @dispatch - def render(self, el: DocstringSectionParameters): - rows = list(map(self.render, el.value)) - # rows is a list of tuples of (, ) - - return str(DefinitionList(rows)) - @dispatch def signature(self, el: Function, source: Optional[Alias] = None): if el.name == "__call__": @@ -279,7 +258,7 @@ def read_file(file: str | Path, root_dir: str | Path | None = None) -> FileConte def check_if_missing_expected_example(el, converted): - if re.search(r"(^|\n)#{2,6} Examples\n", converted): + if re.search(r"(^|\n)#{2,6} Examples", converted): # Manually added examples are fine return From b3a62053799cf30d09bc6aae889b7d7c0277136e Mon Sep 17 00:00:00 2001 From: Michael Chow Date: Wed, 9 Oct 2024 16:41:36 -0400 Subject: [PATCH 2/6] ci: temporarily install quartodoc main branch --- .github/workflows/build-docs.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-docs.yaml b/.github/workflows/build-docs.yaml index f88b71ef9..76f431934 100644 --- a/.github/workflows/build-docs.yaml +++ b/.github/workflows/build-docs.yaml @@ -39,6 +39,7 @@ jobs: - name: Install dependencies run: | make ci-install-docs + pip install git+https://github.com/machow/quartodoc.git@main - name: Run quartodoc run: | From e659834fceffbc5c71c71ee321403491fa826ec0 Mon Sep 17 00:00:00 2001 From: Michael Chow Date: Wed, 9 Oct 2024 16:42:11 -0400 Subject: [PATCH 3/6] docs: remove old input handler methods section --- shiny/input_handler.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/shiny/input_handler.py b/shiny/input_handler.py index 38eff369d..83508224d 100644 --- a/shiny/input_handler.py +++ b/shiny/input_handler.py @@ -52,18 +52,6 @@ def _process_value( for more information on how to create custom input bindings. (The article is about Shiny for R, but the JavaScript and general principles are the same.) -Methods --------- -add(type: str, force: bool = False) -> Callable[[InputHandlerType], None] - Register an input handler. This method returns a decorator that registers the - decorated function as the handler for the given ``type``. This handler should - accept three arguments: - - the input ``value`` - - the input ``name`` - - the :class:`~shiny.Session` object -remove(type: str) - Unregister an input handler. - Note ---- ``add()`` ing an input handler will make it persist for the duration of the Python From 5e41890a2813446ebbf038a199a63b7aa6f96209 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Thu, 10 Oct 2024 11:59:01 -0400 Subject: [PATCH 4/6] Discard changes to shiny/input_handler.py --- shiny/input_handler.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/shiny/input_handler.py b/shiny/input_handler.py index 83508224d..38eff369d 100644 --- a/shiny/input_handler.py +++ b/shiny/input_handler.py @@ -52,6 +52,18 @@ def _process_value( for more information on how to create custom input bindings. (The article is about Shiny for R, but the JavaScript and general principles are the same.) +Methods +-------- +add(type: str, force: bool = False) -> Callable[[InputHandlerType], None] + Register an input handler. This method returns a decorator that registers the + decorated function as the handler for the given ``type``. This handler should + accept three arguments: + - the input ``value`` + - the input ``name`` + - the :class:`~shiny.Session` object +remove(type: str) + Unregister an input handler. + Note ---- ``add()`` ing an input handler will make it persist for the duration of the Python From 0354d7f83ec36cb94f8119749a5debf58fb8a52a Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Thu, 10 Oct 2024 16:01:43 -0400 Subject: [PATCH 5/6] Clean up param names and imports --- docs/_renderer.py | 3 --- shiny/render/_data_frame.py | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/_renderer.py b/docs/_renderer.py index c07f91e49..d07e721b7 100644 --- a/docs/_renderer.py +++ b/docs/_renderer.py @@ -12,8 +12,6 @@ from griffe import ( Alias, DocstringAttribute, - DocstringParameter, - DocstringSectionParameters, DocstringSectionText, Expr, ExprName, @@ -22,7 +20,6 @@ ) 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.renderers.md_renderer import ParamRow diff --git a/shiny/render/_data_frame.py b/shiny/render/_data_frame.py index 1b6f14983..c8085c32e 100644 --- a/shiny/render/_data_frame.py +++ b/shiny/render/_data_frame.py @@ -850,9 +850,9 @@ async def update_cell_value( ---------- value The new value to set the cell to. - row_index + row The row index of the cell to update. - column_index + column The column index of the cell to update. """ # TODO-barret; Test these assertions From 66529db7adae28e3c57a71ff15ac6237ea3b1812 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Thu, 10 Oct 2024 16:02:20 -0400 Subject: [PATCH 6/6] Install quartodoc via pyproject.toml --- .github/workflows/build-docs.yaml | 1 - pyproject.toml | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-docs.yaml b/.github/workflows/build-docs.yaml index 76f431934..f88b71ef9 100644 --- a/.github/workflows/build-docs.yaml +++ b/.github/workflows/build-docs.yaml @@ -39,7 +39,6 @@ jobs: - name: Install dependencies run: | make ci-install-docs - pip install git+https://github.com/machow/quartodoc.git@main - name: Run quartodoc run: | diff --git a/pyproject.toml b/pyproject.toml index 243e2838e..9e44f196a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -120,8 +120,9 @@ doc = [ "tabulate", "shinylive", "pydantic>=2.7.4", - "quartodoc>=0.7.6", - "griffe>=1.1.1", + # "quartodoc>=0.8.0", + "quartodoc@git+https://github.com/machow/quartodoc@main", + "griffe>=1.3.2", ] [project.urls]