@@ -50,8 +50,8 @@ def imports_to_syntax_highlighted_html(subtypes: List[str])-> str:
5050        return  "" 
5151    module_to_class_names  =  defaultdict (list )
5252    for  subtype  in  subtypes :
53-         subtype_class   =  Artifact ._class_register . get (subtype )
54-         module_to_class_names [subtype_class . __module__ ].append (subtype_class . __name__ )
53+         ( module ,  class_name )  =  Artifact .get_module_class (subtype )
54+         module_to_class_names [module ].append (class_name )
5555
5656    imports_txt  =  "" 
5757    for  modu  in  sorted (module_to_class_names .keys ()):
@@ -101,31 +101,6 @@ def custom_walk(top):
101101            yield  entry 
102102
103103
104- def  all_subtypes_of_artifact (artifact ):
105-     if  (
106-         artifact  is  None 
107-         or  isinstance (artifact , str )
108-         or  isinstance (artifact , bool )
109-         or  isinstance (artifact , int )
110-         or  isinstance (artifact , float )
111-     ):
112-         return  []
113-     if  isinstance (artifact , list ):
114-         to_return  =  []
115-         for  art  in  artifact :
116-             to_return .extend (all_subtypes_of_artifact (art ))
117-         return  to_return 
118-     # artifact is a dict 
119-     to_return  =  []
120-     for  key , value  in  artifact .items ():
121-         if  isinstance (value , str ):
122-             if  key  ==  "__type__" :
123-                 to_return .append (value )
124-         else :
125-             to_return .extend (all_subtypes_of_artifact (value ))
126-     return  to_return 
127- 
128- 
129104def  get_all_type_elements (nested_dict ):
130105    type_elements  =  set ()
131106
@@ -148,19 +123,18 @@ def recursive_search(d):
148123
149124@lru_cache (maxsize = None ) 
150125def  artifact_type_to_link (artifact_type ):
151-     artifact_class  =  Artifact ._class_register .get (artifact_type )
152-     type_class_name  =  artifact_class .__name__ 
153-     artifact_class_id  =  f"{ artifact_class .__module__ } { type_class_name }  
154-     return  f'<a class="reference internal" href="../{ artifact_class .__module__ } { artifact_class_id } { artifact_class_id } { type_class_name }  
126+     artifact_module , artifact_class_name  =  Artifact .get_module_class (artifact_type )
127+     return  f'<a class="reference internal" href="../{ artifact_module } { artifact_module } { artifact_class_name } { artifact_module } { artifact_class_name } { artifact_class_name }  
155128
156129
157130# flake8: noqa: C901 
131+ 
132+ 
158133def  make_content (artifact , label , all_labels ):
159-     artifact_type  =  artifact ["__type__" ]
160-     artifact_class  =  Artifact ._class_register .get (artifact_type )
161-     type_class_name  =  artifact_class .__name__ 
162-     catalog_id  =  label .replace ("catalog." , "" )
134+     artifact_type  =  artifact ["__type__" ]    #qualified class name 
135+     artifact_class  =  Artifact .get_class_from_artifact_type (artifact_type )
163136
137+     catalog_id  =  label .replace ("catalog." , "" )
164138    result  =  "" 
165139
166140    if  "__description__"  in  artifact  and  artifact ["__description__" ] is  not None :
@@ -203,23 +177,16 @@ def make_content(artifact, label, all_labels):
203177        )
204178
205179    for  type_name  in  type_elements :
206-         # source = f'<span class="nt">__type__</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">{type_name}</span>' 
207-         source  =  f'<span class="n">__type__{ type_name }  
208-         target  =  artifact_type_to_link (type_name )
209-         html_for_dict  =  html_for_dict .replace (
210-             source ,
211-             f'<span class="n" STYLE="font-size:108%">{ target }  
212-             # '<span class="nt">"type"</span><span class="p">:</span><span class="w"> </span>' 
213-             # + target, 
214-         )
215- 
216-     pattern  =  r'(<span class="nt">)"(.*?)"(</span>)' 
180+         artifact_module , artifact_class_name  =  Artifact .get_module_class (type_name )
181+         pattern  =  re .compile (f'<span class="n">__type__(.*?)<span class="n">{ artifact_class_name }  )
182+         repl  =  '<span class="n" STYLE="font-size:108%">' + artifact_type_to_link (type_name )+ "</span>" 
183+         html_for_dict  =  pattern .sub (repl , html_for_dict )
217184
185+     # pattern = r'(<span class="nt">)"(.*?)"(</span>)' 
218186    # Replacement function 
219-     html_for_dict  =  re .sub (pattern , r"\1\2\3" , html_for_dict )
187+     #  html_for_dict = re.sub(pattern, r"\1\2\3", html_for_dict)
220188
221-     subtypes  =  all_subtypes_of_artifact (artifact )
222-     subtypes  =  list (set (subtypes ))
189+     subtypes  =  type_elements 
223190    subtypes .remove (artifact_type )  # this was already documented 
224191    html_for_imports  =  imports_to_syntax_highlighted_html (subtypes )
225192
@@ -235,13 +202,13 @@ def make_content(artifact, label, all_labels):
235202    result  +=  "    "  +  html_for_element  +  "\n " 
236203
237204    if  artifact_class .__doc__ :
238-         explanation_str  =  f"Explanation about `{ type_class_name }  
205+         explanation_str  =  f"Explanation about `{ artifact_class . __name__ }  
239206        result  +=  f"\n { explanation_str } \n " 
240207        result  +=  "+"  *  len (explanation_str ) +  "\n \n " 
241208        result  +=  artifact_class .__doc__  +  "\n " 
242209
243210    for  subtype  in  subtypes :
244-         subtype_class  =  Artifact ._class_register . get (subtype )
211+         subtype_class  =  Artifact .get_class_from_artifact_type (subtype )
245212        subtype_class_name  =  subtype_class .__name__ 
246213        if  subtype_class .__doc__ :
247214            explanation_str  =  f"Explanation about `{ subtype_class_name }  
0 commit comments