@@ -120,8 +120,20 @@ def _populate_index_inner(
120
120
121
121
children .append (node .children )
122
122
if isinstance (node , Accessor ):
123
- children .append (node .getSignature )
124
- children .append (node .setSignature )
123
+ if node .getSignature :
124
+ if isinstance (node .getSignature , list ):
125
+ sig = node .getSignature [0 ]
126
+ else :
127
+ sig = node .getSignature
128
+ node .getSignature = sig
129
+ children .append ([sig ])
130
+ if node .setSignature :
131
+ if isinstance (node .setSignature , list ):
132
+ sig = node .setSignature [0 ]
133
+ else :
134
+ sig = node .setSignature
135
+ node .setSignature = sig
136
+ children .append ([sig ])
125
137
126
138
if isinstance (node , Callable ):
127
139
children .append (node .signatures )
@@ -132,6 +144,7 @@ def _populate_index_inner(
132
144
133
145
if isinstance (node , ClassOrInterface ):
134
146
children .append (node .typeParameter )
147
+ children .append (node .typeParameters )
135
148
136
149
for child in (c for l in children for c in l ):
137
150
self ._populate_index_inner (
@@ -253,10 +266,31 @@ class Source(BaseModel):
253
266
line : int
254
267
255
268
269
+ class Summary (BaseModel ):
270
+ kind : Literal ["text" ]
271
+ text : str
272
+
273
+
274
+ class Tag (BaseModel ):
275
+ tag : str
276
+ content : list [Summary ]
277
+
278
+
256
279
class Comment (BaseModel ):
257
280
returns : str = ""
258
281
shortText : str | None
259
282
text : str | None
283
+ summary : list [Summary ] | None
284
+ blockTags : list [Tag ] = []
285
+
286
+ def get_returns (self ) -> str :
287
+ result = self .returns .strip ()
288
+ if result :
289
+ return result
290
+ for tag in self .blockTags :
291
+ if tag .tag == "@returns" :
292
+ return tag .content [0 ].text .strip ()
293
+ return ""
260
294
261
295
262
296
class Flags (BaseModel ):
@@ -359,17 +393,17 @@ def _path_segments(self, base_dir: str) -> list[str]:
359
393
360
394
class Accessor (NodeBase ):
361
395
kindString : Literal ["Accessor" ]
362
- getSignature : list [" Signature" ] = []
363
- setSignature : list [" Signature" ] = []
396
+ getSignature : " list[Signature] | Signature" = []
397
+ setSignature : " list[Signature] | Signature" = []
364
398
365
399
def to_ir (self , converter : Converter ) -> tuple [ir .Attribute , Sequence ["Node" ]]:
366
400
if self .getSignature :
367
401
# There's no signature to speak of for a getter: only a return type.
368
- type = self .getSignature [ 0 ] .type
402
+ type = self .getSignature .type # type: ignore[union-attr]
369
403
else :
370
404
# ES6 says setters have exactly 1 param. I'm not sure if they
371
405
# can have multiple signatures, though.
372
- type = self .setSignature [ 0 ] .parameters [0 ].type
406
+ type = self .setSignature .parameters [0 ].type # type: ignore[union-attr]
373
407
res = ir .Attribute (
374
408
type = type .render_name (converter ),
375
409
** self .member_properties (),
@@ -410,6 +444,7 @@ class ClassOrInterface(NodeBase):
410
444
implementedTypes : list ["TypeD" ] = []
411
445
children : Sequence ["ClassChild" ] = []
412
446
typeParameter : list ["TypeParameter" ] = []
447
+ typeParameters : list ["TypeParameter" ] = []
413
448
414
449
def _related_types (
415
450
self ,
@@ -486,7 +521,9 @@ def to_ir(self, converter: Converter) -> tuple[ir.Class | None, Sequence["Node"]
486
521
supers = self ._related_types (converter , kind = "extendedTypes" ),
487
522
is_abstract = self .flags .isAbstract ,
488
523
interfaces = self ._related_types (converter , kind = "implementedTypes" ),
489
- type_params = [x .to_ir (converter ) for x in self .typeParameter ],
524
+ type_params = [
525
+ x .to_ir (converter ) for x in self .typeParameter or self .typeParameters
526
+ ],
490
527
** self ._top_level_properties (),
491
528
)
492
529
return result , self .children
@@ -569,7 +606,10 @@ class OtherNode(NodeBase):
569
606
570
607
def make_description (comment : Comment ) -> str :
571
608
"""Construct a single comment string from a fancy object."""
572
- ret = "\n \n " .join (text for text in [comment .shortText , comment .text ] if text )
609
+ if comment .summary :
610
+ ret = comment .summary [0 ].text
611
+ else :
612
+ ret = "\n \n " .join (text for text in [comment .shortText , comment .text ] if text )
573
613
return ret .strip ()
574
614
575
615
@@ -625,6 +665,7 @@ class Signature(TopLevelProperties):
625
665
626
666
name : str
627
667
typeParameter : list [TypeParameter ] = []
668
+ typeParameters : list [TypeParameter ] = []
628
669
parameters : list ["Param" ] = []
629
670
sources : list [Source ] = []
630
671
type : "TypeD" # This is the return type!
@@ -644,10 +685,11 @@ def return_type(self, converter: Converter) -> list[ir.Return]:
644
685
if self .type .type == "intrinsic" and self .type .name == "void" :
645
686
# Returns nothing
646
687
return []
688
+
647
689
return [
648
690
ir .Return (
649
691
type = self .type .render_name (converter ),
650
- description = self .comment .returns . strip (),
692
+ description = self .comment .get_returns (),
651
693
)
652
694
]
653
695
@@ -669,7 +711,9 @@ def to_ir(
669
711
exceptions = [],
670
712
# Though perhaps technically true, it looks weird to the user
671
713
# (and in the template) if constructors have a return value:
672
- type_params = [x .to_ir (converter ) for x in self .typeParameter ],
714
+ type_params = [
715
+ x .to_ir (converter ) for x in self .typeParameter or self .typeParameters
716
+ ],
673
717
returns = self .return_type (converter )
674
718
if self .kindString != "Constructor signature"
675
719
else [],
0 commit comments