Skip to content

Commit 69158d9

Browse files
committed
refactor!: move sanitize description to inside ParamRow
1 parent 6c5ec48 commit 69158d9

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

quartodoc/renderers/md_renderer.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class ParamRow:
5959
def to_definition_list(self):
6060
name = self.name
6161
anno = self.annotation
62-
desc = self.description
62+
desc = sanitize(self.description, allow_markdown=True)
6363
default = sanitize(str(self.default))
6464

6565
part_name = (
@@ -100,13 +100,15 @@ def to_definition_list(self):
100100

101101
def to_tuple(self, style: Literal["parameters", "attributes", "returns"]):
102102
name = self.name
103+
description = sanitize(self.description, allow_markdown=True)
104+
103105
if style == "parameters":
104106
default = "_required_" if self.default is None else escape(self.default)
105-
return (name, self.annotation, self.description, default)
107+
return (name, self.annotation, description, default)
106108
elif style == "attributes":
107-
return (name, self.annotation, self.description)
109+
return (name, self.annotation, description)
108110
elif style == "returns":
109-
return (name, self.annotation, self.description)
111+
return (name, self.annotation, description)
110112

111113
raise NotImplementedError(f"Unsupported table style: {style}")
112114

@@ -595,8 +597,9 @@ def render(self, el: ds.DocstringSectionParameters):
595597
@dispatch
596598
def render(self, el: ds.DocstringParameter) -> ParamRow:
597599
annotation = self.render_annotation(el.annotation)
598-
clean_desc = sanitize(el.description, allow_markdown=True)
599-
return ParamRow(el.name, clean_desc, annotation=annotation, default=el.default)
600+
return ParamRow(
601+
el.name, el.description, annotation=annotation, default=el.default
602+
)
600603

601604
# attributes ----
602605

@@ -611,7 +614,7 @@ def render(self, el: ds.DocstringSectionAttributes):
611614
def render(self, el: ds.DocstringAttribute) -> ParamRow:
612615
return ParamRow(
613616
el.name,
614-
sanitize(el.description or "", allow_markdown=True),
617+
el.description or "",
615618
annotation=self.render_annotation(el.annotation),
616619
)
617620

@@ -680,7 +683,7 @@ def render(self, el: ds.DocstringReturn):
680683
# similar to DocstringParameter, but no name or default
681684
return ParamRow(
682685
el.name,
683-
sanitize(el.description, allow_markdown=True),
686+
el.description,
684687
annotation=self.render_annotation(el.annotation),
685688
)
686689

@@ -689,7 +692,7 @@ def render(self, el: ds.DocstringRaise) -> ParamRow:
689692
# similar to DocstringParameter, but no name or default
690693
return ParamRow(
691694
None,
692-
sanitize(el.description, allow_markdown=True),
695+
el.description,
693696
annotation=self.render_annotation(el.annotation),
694697
)
695698

0 commit comments

Comments
 (0)