@@ -25,7 +25,10 @@ def run(self):
2525 obj = importlib .import_module (sPkg + "." + sMod )
2626 while len (sObj ):
2727 sSub , _ , sObj = sObj .partition ("." )
28- obj = getattr (obj , sSub , "not found" )
28+ if not hasattr (obj , sSub ):
29+ raise KeyError (f"Attribute { sSub } not found in { obj } " ) from None
30+ else :
31+ obj = getattr (obj , sSub )
2932 print (
3033 "INFO [" + self .arguments [0 ] + "] Type:" ,
3134 type (obj ),
@@ -43,14 +46,14 @@ def run(self):
4346 elif isinstance (obj , (complex , float , int , str , list , dict , tuple )): # no docstring
4447 text = str (obj ).strip ()
4548 else : # if type(obj).__name__ in ('module','type','function') or isinstance( obj, type): # objects where docstring should be returned
46- text = obj .__doc__ .strip ()
49+ text = obj .__doc__ .strip () if obj . __doc__ is not None else ""
4750
48- self . content = nodes .paragraph (text = text )
51+ par = nodes .paragraph (text = text )
4952 if self .typ is None : # need to parse the extracted text
5053 parNode = nodes .paragraph (text = "" ) # use an empty paragraph node as parent
51- self .state .nested_parse (self . content , 0 , parNode ) # here the content of the retrieved text is parsed
54+ self .state .nested_parse (par , 0 , parNode ) # here the content of the retrieved text is parsed
5255 else : # use the text as is
53- parNode = self . content
56+ parNode = par
5457 return [parNode ]
5558
5659
0 commit comments