From 250f328c7d651fdf4591a939f613ccf3e9dca78c Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Mon, 18 Dec 2023 09:45:28 -0500 Subject: [PATCH] chore: Upgrade to quartodoc 0.7.2 and use pandoc.blocks.DefinitionList to write parameters --- docs/_renderer.py | 22 +++++++--------------- setup.cfg | 4 ++-- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/docs/_renderer.py b/docs/_renderer.py index a9775fbbc..fc4ccac56 100644 --- a/docs/_renderer.py +++ b/docs/_renderer.py @@ -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()) @@ -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): @@ -163,9 +164,9 @@ def render(self, el: ds.DocstringParameter): @dispatch def render(self, el: ds.DocstringSectionParameters): rows = list(map(self.render, el.value)) - header = ["Parameter", "Description"] + # rows is a list of tuples of (, ) - return render_definition_list(rows) + return str(DefinitionList(rows)) @dispatch def signature(self, el: dc.Function, source: Optional[dc.Alias] = None): @@ -183,15 +184,6 @@ def signature(self, el: dc.Function, source: Optional[dc.Alias] = None): return super().signature(el, source) -def render_definition_list(rows: list[tuple[str, str]]) -> str: - def indent_newlines(s: str) -> str: - return s.replace("\n", "\n ") - - out = [f"{param}\n\n: {indent_newlines(desc)}" for param, desc in rows] - - return "\n\n".join(out) - - def html_escape_except_backticks(s: str) -> str: """ HTML-escape a string, except for content inside of backticks. diff --git a/setup.cfg b/setup.cfg index 814ccd013..15d1112a3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -103,8 +103,8 @@ doc = tabulate shinylive==0.1.1 pydantic==1.10 - quartodoc==0.4.1 - griffe==0.32.3 + quartodoc==0.7.2 + griffe==0.33.0 [options.packages.find] include = shiny, shiny.*