@@ -251,10 +251,13 @@ def render(self, el: Union[layout.DocClass, layout.DocModule]):
251
251
252
252
extra_parts = []
253
253
meth_docs = []
254
+ class_docs = []
255
+
254
256
if el .members :
255
257
sub_header = "#" * (self .crnt_header_level + 1 )
256
258
raw_attrs = [x for x in el .members if x .obj .is_attribute ]
257
259
raw_meths = [x for x in el .members if x .obj .is_function ]
260
+ raw_classes = [x for x in el .members if x .obj .is_class ]
258
261
259
262
260
263
header = "| Name | Description |\n | --- | --- |"
@@ -267,30 +270,40 @@ def render(self, el: Union[layout.DocClass, layout.DocModule]):
267
270
if (
268
271
raw_attrs
269
272
and not _has_attr_section (el .obj .docstring )
270
- and not isinstance (el , layout .DocClass )
273
+ # TODO: what should backwards compat be?
274
+ # and not isinstance(el, layout.DocClass)
271
275
):
272
276
273
277
_attrs_table = "\n " .join (map (self .summarize , raw_attrs ))
274
278
attrs = f"{ sub_header } Attributes\n \n { header } \n { _attrs_table } "
275
279
extra_parts .append (attrs )
280
+
281
+ # classes summary table ----
282
+ if raw_classes :
283
+ _summary_table = "\n " .join (map (self .summarize , raw_classes ))
284
+ section_name = "Classes"
285
+ objs = f"{ sub_header } { section_name } \n \n { header } \n { _summary_table } "
286
+ extra_parts .append (objs )
287
+
288
+ class_docs = [self .render (x ) for x in raw_classes if isinstance (x , layout .Doc )]
276
289
277
290
# method summary table ----
278
291
if raw_meths :
279
- _meths_table = "\n " .join (map (self .summarize , raw_meths ))
292
+ _summary_table = "\n " .join (map (self .summarize , raw_meths ))
280
293
section_name = (
281
294
"Methods" if isinstance (el , layout .DocClass )
282
295
else "Functions"
283
296
)
284
- meths = f"{ sub_header } { section_name } \n \n { header } \n { _meths_table } "
285
- extra_parts .append (meths )
297
+ objs = f"{ sub_header } { section_name } \n \n { header } \n { _summary_table } "
298
+ extra_parts .append (objs )
286
299
287
300
# TODO use context manager, or context variable?
288
301
n_incr = 1 if el .flat else 2
289
302
with self ._increment_header (n_incr ):
290
303
meth_docs = [self .render (x ) for x in raw_meths if isinstance (x , layout .Doc )]
291
304
292
305
body = self .render (el .obj )
293
- return "\n \n " .join ([title , body , * extra_parts , * meth_docs ])
306
+ return "\n \n " .join ([title , body , * extra_parts , * meth_docs , * class_docs ])
294
307
295
308
@dispatch
296
309
def render (self , el : layout .DocFunction ):
0 commit comments