forked from M-Labs/artiq
artiq_rpctool: list-methods also prints class docstring
This commit is contained in:
parent
f0dddd9f39
commit
71721a152e
|
@ -36,8 +36,10 @@ def list_targets(target_names, id_parameters):
|
||||||
|
|
||||||
|
|
||||||
def list_methods(remote):
|
def list_methods(remote):
|
||||||
methods = remote.get_rpc_method_list()
|
doc = remote.get_rpc_method_list()
|
||||||
for name, (argspec, docstring) in sorted(methods.items()):
|
if doc["docstring"] is not None:
|
||||||
|
print(doc["docstring"])
|
||||||
|
for name, (argspec, docstring) in sorted(doc["methods"].items()):
|
||||||
args = ""
|
args = ""
|
||||||
for arg in argspec["args"]:
|
for arg in argspec["args"]:
|
||||||
args += arg
|
args += arg
|
||||||
|
|
|
@ -442,15 +442,18 @@ class Server(_AsyncioServer):
|
||||||
try:
|
try:
|
||||||
if obj["action"] == "get_rpc_method_list":
|
if obj["action"] == "get_rpc_method_list":
|
||||||
members = inspect.getmembers(target, inspect.ismethod)
|
members = inspect.getmembers(target, inspect.ismethod)
|
||||||
methods = {}
|
doc = {
|
||||||
|
"docstring": target.__doc__,
|
||||||
|
"methods": {}
|
||||||
|
}
|
||||||
for name, method in members:
|
for name, method in members:
|
||||||
if name.startswith("_"):
|
if name.startswith("_"):
|
||||||
continue
|
continue
|
||||||
method = getattr(target, name)
|
method = getattr(target, name)
|
||||||
argspec = inspect.getfullargspec(method)
|
argspec = inspect.getfullargspec(method)
|
||||||
methods[name] = (dict(argspec.__dict__),
|
doc["methods"][name] = (dict(argspec.__dict__),
|
||||||
inspect.getdoc(method))
|
inspect.getdoc(method))
|
||||||
obj = {"status": "ok", "ret": methods}
|
obj = {"status": "ok", "ret": doc}
|
||||||
elif obj["action"] == "call":
|
elif obj["action"] == "call":
|
||||||
logger.debug("calling %s", _PrettyPrintCall(obj))
|
logger.debug("calling %s", _PrettyPrintCall(obj))
|
||||||
method = getattr(target, obj["name"])
|
method = getattr(target, obj["name"])
|
||||||
|
|
Loading…
Reference in New Issue