@@ -64,6 +64,21 @@ def format_for_list(docstring, depth=1):
6464 spaces = depth * 2 * ' '
6565 return re.compile(r ' \n\n ' , re.MULTILINE ).sub(' \n\n ' + spaces, docstring)
6666
67+ def resolve_namespace_target (v ):
68+ """ If v's type resolves to an opengradient class in a different module, return link target."""
69+ result = [None ]
70+ var_mod = v.module.name if hasattr (v, ' module' ) and v.module else ' '
71+ def capture (dobj ):
72+ if not isinstance (dobj, pdoc.Module) and hasattr (dobj, ' module' ) and dobj.module is not None :
73+ mod_parts = dobj.module.name.split(' .' )
74+ if (len (mod_parts) >= 2 and mod_parts[0 ] == ' opengradient'
75+ and dobj.module.name != var_mod):
76+ result[0 ] = mod_parts[- 1 ] if len (mod_parts) > 2 else mod_parts[1 ]
77+ return ' `{} `' .format(dobj.qualname.split(' .' )[- 1 ])
78+ if show_type_annotations:
79+ v.type_annotation(link = capture)
80+ return result[0 ]
81+
6782def linkify (text , mod ):
6883 """ Convert backtick-wrapped qualified names to markdown links."""
6984 cur_parts = mod.name.split(' .' )
@@ -185,14 +200,21 @@ prefix = qual + ' ' if qual else ''
185200%> \
186201% for v in vs:
187202<%
188- return_type = get_annotation(v.type_annotation, link = link)
189- type_str = return_type if return_type else ' '
190203raw_desc = v.docstring.strip() if v.docstring else ' '
191204if raw_desc == ' The type of the None singleton.' :
192205 raw_desc = ' '
206+ ns_target = resolve_namespace_target(v)
207+ %> \
208+ % if ns_target:
209+ * [**`${ v.name} `**](./${ ns_target} )${ ' : ' + firstline(raw_desc) if raw_desc else ' ' }
210+ % else :
211+ <%
212+ return_type = get_annotation(v.type_annotation, link = link)
213+ type_str = return_type if return_type else ' '
193214desc = ' - ' + format_for_list(raw_desc, 1 ) if raw_desc else ' '
194215%> \
195216* ${ prefix} `${ v.name} `${ type_str}${ desc}
217+ % endif
196218% endfor
197219</%def > \
198220<%def name = "show_module(module ) "> \
0 commit comments