From 71721a152ed96352e8026596ee9bd77d14df945a Mon Sep 17 00:00:00 2001 From: Yann Sionneau Date: Tue, 23 Jun 2015 18:35:32 +0200 Subject: [PATCH] artiq_rpctool: list-methods also prints class docstring --- artiq/frontend/artiq_rpctool.py | 6 ++++-- artiq/protocols/pc_rpc.py | 11 +++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/artiq/frontend/artiq_rpctool.py b/artiq/frontend/artiq_rpctool.py index bdecadb89..a97c5bb70 100755 --- a/artiq/frontend/artiq_rpctool.py +++ b/artiq/frontend/artiq_rpctool.py @@ -36,8 +36,10 @@ def list_targets(target_names, id_parameters): def list_methods(remote): - methods = remote.get_rpc_method_list() - for name, (argspec, docstring) in sorted(methods.items()): + doc = remote.get_rpc_method_list() + if doc["docstring"] is not None: + print(doc["docstring"]) + for name, (argspec, docstring) in sorted(doc["methods"].items()): args = "" for arg in argspec["args"]: args += arg diff --git a/artiq/protocols/pc_rpc.py b/artiq/protocols/pc_rpc.py index da2c5ae66..918c26c17 100644 --- a/artiq/protocols/pc_rpc.py +++ b/artiq/protocols/pc_rpc.py @@ -442,15 +442,18 @@ class Server(_AsyncioServer): try: if obj["action"] == "get_rpc_method_list": members = inspect.getmembers(target, inspect.ismethod) - methods = {} + doc = { + "docstring": target.__doc__, + "methods": {} + } for name, method in members: if name.startswith("_"): continue method = getattr(target, name) argspec = inspect.getfullargspec(method) - methods[name] = (dict(argspec.__dict__), - inspect.getdoc(method)) - obj = {"status": "ok", "ret": methods} + doc["methods"][name] = (dict(argspec.__dict__), + inspect.getdoc(method)) + obj = {"status": "ok", "ret": doc} elif obj["action"] == "call": logger.debug("calling %s", _PrettyPrintCall(obj)) method = getattr(target, obj["name"])