|
#!/usr/bin/env python
|
|
|
|
import inspect
|
|
|
|
from arvados.api import api_client, api_kwargs_from_config
|
|
|
|
MOD_NAME = 'arvados.api_resources'
|
|
|
|
def document_callable(decl, name, value=None, indent=None, doc=None):
|
|
if value is None:
|
|
signature = '()'
|
|
else:
|
|
signature = inspect.signature(value)
|
|
if indent is None:
|
|
indent = 0 if decl == 'class' else 1
|
|
if doc is None and value is not None:
|
|
doc = getattr(value, '__doc__', None)
|
|
prefix = ' ' * indent
|
|
if doc is None:
|
|
out_s = f"""
|
|
{prefix}{decl} {name}{signature}:
|
|
{prefix} ...
|
|
"""
|
|
else:
|
|
out_s = f"""
|
|
{prefix}{decl} {name}{signature}:
|
|
{prefix} {doc!r}
|
|
{prefix} ...
|
|
"""
|
|
print(out_s)
|
|
|
|
arv_kwargs = api_kwargs_from_config('v1')
|
|
arv_client = api_client(**arv_kwargs)
|
|
|
|
resources_to_document = {}
|
|
document_callable('class', 'ArvadosAPIClient')
|
|
for attr_name in sorted(dir(arv_client)):
|
|
attr_value = getattr(arv_client, attr_name)
|
|
if attr_name.startswith('_'):
|
|
pass
|
|
elif callable(attr_value):
|
|
if attr_value.__name__ == 'methodResource':
|
|
returned_classname = attr_name.title().replace('_', '')
|
|
resources_to_document[returned_classname] = attr_value()
|
|
doc = f"Return a `{MOD_NAME}.{returned_classname}` instance with associated API methods."
|
|
else:
|
|
doc = None
|
|
document_callable('def', attr_name, attr_value, doc=doc)
|
|
|
|
for cls_name, cls in resources_to_document.items():
|
|
document_callable('class', cls_name)
|
|
for attr_name in sorted(dir(cls)):
|
|
attr_value = getattr(cls, attr_name)
|
|
if attr_name.startswith('_'):
|
|
pass
|
|
elif callable(attr_value):
|
|
document_callable('def', attr_name, attr_value)
|