@@ -101,6 +101,11 @@ def _fetch_object_dispname(self, el: "dc.Alias | dc.Object"):
101
101
return el .canonical_path
102
102
103
103
raise ValueError (f"Unsupported display_name: `{ self .display_name } `" )
104
+
105
+ def _render_table (self , rows , headers ):
106
+ table = tabulate (rows , headers = headers , tablefmt = "github" )
107
+
108
+ return table
104
109
105
110
def render_annotation (self , el : "str | expr.Name | expr.Expression | None" ):
106
111
"""Special hook for rendering a type annotation.
@@ -411,7 +416,7 @@ def render(self, el: ds.DocstringSectionParameters):
411
416
rows = list (map (self .render , el .value ))
412
417
header = ["Name" , "Type" , "Description" , "Default" ]
413
418
414
- return tabulate (rows , header , tablefmt = "github" )
419
+ return self . _render_table (rows , header )
415
420
416
421
@dispatch
417
422
def render (self , el : ds .DocstringParameter ) -> Tuple [str ]:
@@ -429,7 +434,7 @@ def render(self, el: ds.DocstringSectionAttributes):
429
434
header = ["Name" , "Type" , "Description" ]
430
435
rows = list (map (self .render , el .value ))
431
436
432
- return tabulate (rows , header , tablefmt = "github" )
437
+ return self . _render_table (rows , header )
433
438
434
439
@dispatch
435
440
def render (self , el : ds .DocstringAttribute ):
@@ -485,7 +490,7 @@ def render(self, el: Union[ds.DocstringSectionReturns, ds.DocstringSectionRaises
485
490
rows = list (map (self .render , el .value ))
486
491
header = ["Type" , "Description" ]
487
492
488
- return tabulate (rows , header , tablefmt = "github" )
493
+ return self . _render_table (rows , header )
489
494
490
495
@dispatch
491
496
def render (self , el : Union [ds .DocstringReturn , ds .DocstringRaise ]):
0 commit comments