|
import inspect
|
|
|
|
def get_api_info(api):
|
|
try:
|
|
|
|
module_parts = api.split('.')
|
|
function_name = module_parts.pop()
|
|
module_name = '.'.join(module_parts)
|
|
|
|
|
|
module = __import__(module_name, fromlist=[function_name])
|
|
|
|
|
|
api_object = getattr(module, function_name)
|
|
|
|
|
|
signature = inspect.signature(api_object)
|
|
|
|
|
|
docstring = inspect.getdoc(api_object)
|
|
|
|
return {
|
|
'name': api,
|
|
'signature': str(signature),
|
|
'docstring': docstring
|
|
}
|
|
except ImportError:
|
|
return {'name': api, 'error': 'Module not found'}
|
|
except AttributeError:
|
|
return {'name': api, 'error': 'Function or class not found in module'}
|
|
except Exception as e:
|
|
return {'name': api, 'error': str(e)}
|
|
|