@@ -59,8 +59,8 @@ class ParamRow:
59
59
def to_definition_list (self ):
60
60
name = self .name
61
61
anno = self .annotation
62
- desc = self .description
63
- default = sanitize (str (self .default ))
62
+ desc = sanitize ( self .description , allow_markdown = True )
63
+ default = sanitize (str (self .default ), escape_quotes = True )
64
64
65
65
part_name = (
66
66
Span (Strong (name ), Attr (classes = ["parameter-name" ]))
@@ -77,7 +77,7 @@ def to_definition_list(self):
77
77
# in the table display format, not description lists....
78
78
# by this stage _required_ is basically a special token to indicate
79
79
# a required argument.
80
- if default is not None :
80
+ if self . default is not None :
81
81
part_default_sep = Span (" = " , Attr (classes = ["parameter-default-sep" ]))
82
82
part_default = Span (default , Attr (classes = ["parameter-default" ]))
83
83
else :
@@ -100,13 +100,15 @@ def to_definition_list(self):
100
100
101
101
def to_tuple (self , style : Literal ["parameters" , "attributes" , "returns" ]):
102
102
name = self .name
103
+ description = sanitize (self .description , allow_markdown = True )
104
+
103
105
if style == "parameters" :
104
106
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 )
106
108
elif style == "attributes" :
107
- return (name , self .annotation , self . description )
109
+ return (name , self .annotation , description )
108
110
elif style == "returns" :
109
- return (name , self .annotation , self . description )
111
+ return (name , self .annotation , description )
110
112
111
113
raise NotImplementedError (f"Unsupported table style: { style } " )
112
114
@@ -217,7 +219,7 @@ def render_annotation(self, el: str) -> str:
217
219
el:
218
220
An object representing a type annotation.
219
221
"""
220
- return sanitize (el )
222
+ return sanitize (el , escape_quotes = True )
221
223
222
224
@dispatch
223
225
def render_annotation (self , el : None ) -> str :
@@ -563,6 +565,9 @@ def render(self, el: dc.Parameter):
563
565
res = f"{ glob } { name } : { annotation } = { el .default } "
564
566
elif annotation :
565
567
res = f"{ glob } { name } : { annotation } "
568
+ else :
569
+ res = f"{ glob } { name } "
570
+
566
571
elif has_default :
567
572
res = f"{ glob } { name } ={ el .default } "
568
573
else :
@@ -595,8 +600,9 @@ def render(self, el: ds.DocstringSectionParameters):
595
600
@dispatch
596
601
def render (self , el : ds .DocstringParameter ) -> ParamRow :
597
602
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 )
603
+ return ParamRow (
604
+ el .name , el .description , annotation = annotation , default = el .default
605
+ )
600
606
601
607
# attributes ----
602
608
@@ -611,7 +617,7 @@ def render(self, el: ds.DocstringSectionAttributes):
611
617
def render (self , el : ds .DocstringAttribute ) -> ParamRow :
612
618
return ParamRow (
613
619
el .name ,
614
- sanitize ( el .description or "" , allow_markdown = True ) ,
620
+ el .description or "" ,
615
621
annotation = self .render_annotation (el .annotation ),
616
622
)
617
623
@@ -680,7 +686,7 @@ def render(self, el: ds.DocstringReturn):
680
686
# similar to DocstringParameter, but no name or default
681
687
return ParamRow (
682
688
el .name ,
683
- sanitize ( el .description , allow_markdown = True ) ,
689
+ el .description ,
684
690
annotation = self .render_annotation (el .annotation ),
685
691
)
686
692
@@ -689,7 +695,7 @@ def render(self, el: ds.DocstringRaise) -> ParamRow:
689
695
# similar to DocstringParameter, but no name or default
690
696
return ParamRow (
691
697
None ,
692
- sanitize ( el .description , allow_markdown = True ) ,
698
+ el .description ,
693
699
annotation = self .render_annotation (el .annotation ),
694
700
)
695
701
0 commit comments