def get_docstring(node, clean=True):
 if (not isinstance(node, (AsyncFunctionDef, FunctionDef, ClassDef, Module))):
  raise TypeError(("%r can't have docstrings" % node.__class__.__name__))
 if (not (node.body and isinstance(node.body[0], Expr))):
  return
 node = node.body[0].value
 if isinstance(node, Str):
  text = node.s
 elif (isinstance(node, Constant) and isinstance(node.value, str)):
  text = node.value
 else:
  return
 if clean:
  import inspect
  text = inspect.cleandoc(text)
 return text

def get_docstring ( node , clean = True ) : if ( not isinstance ( node , ( AsyncFunctionDef , FunctionDef , ClassDef , Module ) ) ) : raise TypeError ( ( "%r can't have docstrings" % node . __class__ . __name__ ) ) if ( not ( node . body and isinstance ( node . body [ 0 ] , Expr ) ) ) : return node = node . body [ 0 ] . value if isinstance ( node , Str ) : text = node . s elif ( isinstance ( node , Constant ) and isinstance ( node . value , str ) ) : text = node . value else : return if clean : import inspect text = inspect . cleandoc ( text ) return text
return the docstring for the given node or none if no docstring can be found .