Skip to content

Commit de9a1f0

Browse files
committed
Workaround for args_html missing in Crystal when there are no args
crystal-lang/crystal#12043
1 parent 93cc543 commit de9a1f0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mkdocstrings/handlers/crystal/items.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def is_abstract(self) -> bool:
346346
return bool(self.data.get("abstract"))
347347

348348
@cached_property
349-
def args_string(self) -> crystal_html.TextWithLinks:
349+
def args_string(self) -> str:
350350
"""[A rich string][mkdocstrings.handlers.crystal.crystal_html.TextWithLinks] with the method's parameters.
351351
352352
e.g. `(foo : Bar) : Baz`
@@ -355,7 +355,11 @@ def args_string(self) -> crystal_html.TextWithLinks:
355355
try:
356356
html = self.data["args_html"]
357357
except KeyError:
358-
html = self.data.get("args_string", "")
358+
html = self.data.get("args_string")
359+
if html is None:
360+
# https://github.com/crystal-lang/crystal/issues/12043
361+
ret = self.data["def"].get("return_type", "")
362+
return ret and " : " + ret
359363
return crystal_html.parse_crystal_html(html)
360364

361365
@cached_property

0 commit comments

Comments
 (0)