|
12 | 12 | from griffe import ( |
13 | 13 | Alias, |
14 | 14 | DocstringAttribute, |
15 | | - DocstringParameter, |
16 | | - DocstringSectionParameters, |
17 | 15 | DocstringSectionText, |
18 | 16 | Expr, |
19 | 17 | ExprName, |
|
22 | 20 | ) |
23 | 21 | from plum import dispatch |
24 | 22 | from quartodoc import MdRenderer |
25 | | -from quartodoc.pandoc.blocks import DefinitionList |
26 | 23 | from quartodoc.renderers.base import convert_rst_link_to_md, sanitize |
| 24 | +from quartodoc.renderers.md_renderer import ParamRow |
27 | 25 |
|
28 | 26 | # from quartodoc.ast import preview |
29 | 27 |
|
@@ -101,12 +99,12 @@ def render_annotation(self, el: str): |
101 | 99 | # TODO-future; Can be removed once we use quartodoc 0.3.5 |
102 | 100 | # Related: https://github.com/machow/quartodoc/pull/205 |
103 | 101 | @dispatch |
104 | | - def render(self, el: DocstringAttribute): |
105 | | - row = [ |
106 | | - sanitize(el.name), |
107 | | - self.render_annotation(el.annotation), |
108 | | - sanitize(el.description or "", allow_markdown=True), |
109 | | - ] |
| 102 | + def render(self, el: DocstringAttribute) -> ParamRow: |
| 103 | + row = ParamRow( |
| 104 | + el.name, |
| 105 | + el.description or "", |
| 106 | + annotation=self.render_annotation(el.annotation), |
| 107 | + ) |
110 | 108 | return row |
111 | 109 |
|
112 | 110 | @dispatch |
@@ -170,28 +168,6 @@ def summarize(self, obj: Union[Object, Alias]) -> str: |
170 | 168 |
|
171 | 169 | return "" |
172 | 170 |
|
173 | | - # Consolidate the parameter type info into a single column |
174 | | - @dispatch |
175 | | - def render(self, el: DocstringParameter): |
176 | | - param = f'<span class="parameter-name">{el.name}</span>' |
177 | | - annotation = self.render_annotation(el.annotation) |
178 | | - if annotation: |
179 | | - param = f'{param}<span class="parameter-annotation-sep">:</span> <span class="parameter-annotation">{annotation}</span>' |
180 | | - if el.default: |
181 | | - param = f'{param} <span class="parameter-default-sep">=</span> <span class="parameter-default">{el.default}</span>' |
182 | | - |
183 | | - # Wrap everything in a code block to allow for links |
184 | | - param = "<code>" + param + "</code>" |
185 | | - |
186 | | - return (param, el.description) |
187 | | - |
188 | | - @dispatch |
189 | | - def render(self, el: DocstringSectionParameters): |
190 | | - rows = list(map(self.render, el.value)) |
191 | | - # rows is a list of tuples of (<parameter>, <description>) |
192 | | - |
193 | | - return str(DefinitionList(rows)) |
194 | | - |
195 | 171 | @dispatch |
196 | 172 | def signature(self, el: Function, source: Optional[Alias] = None): |
197 | 173 | if el.name == "__call__": |
@@ -279,7 +255,7 @@ def read_file(file: str | Path, root_dir: str | Path | None = None) -> FileConte |
279 | 255 |
|
280 | 256 |
|
281 | 257 | def check_if_missing_expected_example(el, converted): |
282 | | - if re.search(r"(^|\n)#{2,6} Examples\n", converted): |
| 258 | + if re.search(r"(^|\n)#{2,6} Examples", converted): |
283 | 259 | # Manually added examples are fine |
284 | 260 | return |
285 | 261 |
|
|
0 commit comments