File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -63,4 +63,5 @@ dev = [
6363 " ruff>=0.9.2" ,
6464 " pytest>=7.2.0" ,
6565 " pytest-cov>=0.6" ,
66+ " docstring-parser>=0.16" ,
6667]
Original file line number Diff line number Diff line change 44import sys
55
66from amaranth .lib import wiring
7+ from docstring_parser import parse_from_object
78
89import chipflow_digital_ip
910
1011def children (mod ):
11- stack = [(attr , getattr (mod , attr )) for attr in dir (mod ) if not attr .startswith ("_" )]
12+ level = "chipflow_digital_ip"
13+ stack = [(f"{ level } .{ attr } " , getattr (mod , attr )) for attr in dir (mod ) if not attr .startswith ("_" )]
1214 done = []
1315 while stack :
1416 i = stack .pop ()
1517 e ,o = i
1618 if inspect .isclass (o ) and o .__module__ .startswith ('chipflow_digital_ip' ) and issubclass (o , wiring .Component ):
17- yield o
19+ yield e , o
1820 if inspect .ismodule (o ):
1921 if e in done :
2022 continue
2123 done .append (e )
22- stack .extend ([(attr , getattr (o , attr )) for attr in dir (o ) if not attr .startswith ("_" )])
24+ stack .extend ([(f" { e } . { attr } " , getattr (o , attr )) for attr in dir (o ) if not attr .startswith ("_" )])
2325
2426gen = children (chipflow_digital_ip )
2527output = {}
26- for cls in gen :
27- output [f"{ cls .__module__ } .{ cls .__qualname__ } " ]= cls .__doc__
28+ for name , cls in gen :
29+ docstring = parse_from_object (cls )
30+ d = {
31+ 'short_description' : docstring .short_description ,
32+ 'long_description' : docstring .long_description ,
33+ 'params' : [p .__dict__ for p in docstring .params ],
34+ 'examples' : [ e .__dict__ for e in docstring .examples ],
35+ }
36+ output [name ] = d
2837
2938json .dump (output , sys .stdout , indent = 2 )
You can’t perform that action at this time.
0 commit comments