@@ -48,14 +48,17 @@ class Method(object):
4848 """
4949 def __init__ (self , name : str , func : Callable [..., JSONType ],
5050 mtype : MethodType = MethodType .RPCMETHOD ,
51- deprecated : Union [bool , List [str ]] = None ):
51+ deprecated : Union [bool , List [str ]] = None ,
52+ description : str = None ):
5253 self .name = name
5354 self .func = func
5455 self .mtype = mtype
5556 self .background = False
5657 self .deprecated = deprecated
58+ self .description = description
5759 self .before : List [str ] = []
5860 self .after : List [str ] = []
61+ self .description = description
5962
6063
6164class RpcException (Exception ):
@@ -323,7 +326,8 @@ def convert_featurebits(
323326
324327 def add_method (self , name : str , func : Callable [..., Any ],
325328 background : bool = False ,
326- deprecated : Optional [Union [bool , List [str ]]] = None ) -> None :
329+ deprecated : Optional [Union [bool , List [str ]]] = None ,
330+ description : str = None ) -> None :
327331 """Add a plugin method to the dispatch table.
328332
329333 The function will be expected at call time (see `_dispatch`)
@@ -360,7 +364,7 @@ def add_method(self, name: str, func: Callable[..., Any],
360364 )
361365
362366 # Register the function with the name
363- method = Method (name , func , MethodType .RPCMETHOD , deprecated )
367+ method = Method (name , func , MethodType .RPCMETHOD , deprecated , description )
364368 method .background = background
365369 self .methods [name ] = method
366370
@@ -493,7 +497,8 @@ def decorator(f: Callable[..., None]) -> Callable[..., None]:
493497 def method (self , method_name : str , category : Optional [str ] = None ,
494498 desc : Optional [str ] = None ,
495499 long_desc : Optional [str ] = None ,
496- deprecated : Union [bool , List [str ]] = None ) -> JsonDecoratorType :
500+ deprecated : Union [bool , List [str ]] = None ,
501+ description : str = None ) -> JsonDecoratorType :
497502 """Decorator to add a plugin method to the dispatch table.
498503
499504 Internally uses add_method.
@@ -502,7 +507,7 @@ def decorator(f: Callable[..., JSONType]) -> Callable[..., JSONType]:
502507 for attr , attr_name in [(category , "Category" ), (desc , "Description" ), (long_desc , "Long description" )]:
503508 if attr is not None :
504509 self .log ("{} is deprecated but defined in method {}; it will be ignored by Core Lightning" .format (attr_name , method_name ), level = "warn" )
505- self .add_method (method_name , f , background = False , deprecated = deprecated )
510+ self .add_method (method_name , f , background = False , deprecated = deprecated , description = description )
506511 return f
507512 return decorator
508513
@@ -936,6 +941,9 @@ def _getmanifest(self, **kwargs) -> JSONType:
936941 else :
937942 args .append ("[%s]" % arg )
938943
944+ if method .description :
945+ args .append ("\n %s" % method .description )
946+
939947 methods .append ({
940948 'name' : method .name ,
941949 'usage' : " " .join (args )
0 commit comments