Skip to content

Commit 71721a1

Browse files
committedJun 23, 2015
artiq_rpctool: list-methods also prints class docstring
1 parent f0dddd9 commit 71721a1

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed
 

Diff for: ‎artiq/frontend/artiq_rpctool.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ def list_targets(target_names, id_parameters):
3636

3737

3838
def list_methods(remote):
39-
methods = remote.get_rpc_method_list()
40-
for name, (argspec, docstring) in sorted(methods.items()):
39+
doc = remote.get_rpc_method_list()
40+
if doc["docstring"] is not None:
41+
print(doc["docstring"])
42+
for name, (argspec, docstring) in sorted(doc["methods"].items()):
4143
args = ""
4244
for arg in argspec["args"]:
4345
args += arg

Diff for: ‎artiq/protocols/pc_rpc.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -442,15 +442,18 @@ def _handle_connection_cr(self, reader, writer):
442442
try:
443443
if obj["action"] == "get_rpc_method_list":
444444
members = inspect.getmembers(target, inspect.ismethod)
445-
methods = {}
445+
doc = {
446+
"docstring": target.__doc__,
447+
"methods": {}
448+
}
446449
for name, method in members:
447450
if name.startswith("_"):
448451
continue
449452
method = getattr(target, name)
450453
argspec = inspect.getfullargspec(method)
451-
methods[name] = (dict(argspec.__dict__),
452-
inspect.getdoc(method))
453-
obj = {"status": "ok", "ret": methods}
454+
doc["methods"][name] = (dict(argspec.__dict__),
455+
inspect.getdoc(method))
456+
obj = {"status": "ok", "ret": doc}
454457
elif obj["action"] == "call":
455458
logger.debug("calling %s", _PrettyPrintCall(obj))
456459
method = getattr(target, obj["name"])

0 commit comments

Comments
 (0)