| |
@@ -2002,6 +2002,8 @@
|
| |
|
| |
|
| |
class VirtualMethod(object):
|
| |
+ # cache for api documentation
|
| |
+ _apidoc = None
|
| |
# some magic to bind an XML-RPC method to an RPC server.
|
| |
# supports "nested" methods (e.g. examples.getStateName)
|
| |
# supports named arguments (if server does)
|
| |
@@ -2013,6 +2015,31 @@
|
| |
def __call__(self, *args, **opts):
|
| |
return self.__func(self.__name, args, opts)
|
| |
|
| |
+ @property
|
| |
+ def __doc__(self):
|
| |
+ # try to fetch API docs
|
| |
+ if VirtualMethod._apidoc is None:
|
| |
+ try:
|
| |
+ VirtualMethod._apidoc = dict(
|
| |
+ [(f["name"], f) for f in self.__func("_listapi", [], {})]
|
| |
+ )
|
| |
+ except:
|
| |
+ VirtualMethod._apidoc = {}
|
| |
+
|
| |
+ funcdoc = VirtualMethod._apidoc.get(self.__name)
|
| |
+ if funcdoc:
|
| |
+ # add argument description to docstring since the
|
| |
+ # call signature is not updated, yet
|
| |
+ argdesc = funcdoc["name"] + funcdoc["argdesc"] + "\n"
|
| |
+ doc = funcdoc["doc"]
|
| |
+ if doc:
|
| |
+ return argdesc + doc
|
| |
+ else:
|
| |
+ return argdesc
|
| |
+ else:
|
| |
+ return None
|
| |
+
|
| |
+
|
| |
|
| |
def grab_session_options(options):
|
| |
"""Convert optparse options to a dict that ClientSession can handle;
|
| |
This makes the api documentation available via introspection and therefore the development of scripts easier.