Merge #14987: RPCHelpMan: Pass through Result and Examples

faa1522e5e RPCHelpMan: Pass through Result and Examples (MarcoFalke)

Pull request description:

  Passing the rpc result and rpc examples through `RPCHelpMan` makes it clear in what order they appear in the stringified version. Future improvements could then autoformat or autogenerate them.

Tree-SHA512: b32a5c178cc80f50a7e9b93a38e2b26d5994188ecafe9e61bbc599941b44b9b0e4e4be6413d4464fac6e8e73661a191a77d34917f2e6293de19fb59519dd4487
This commit is contained in:
MarcoFalke
2019-01-29 09:55:37 -05:00
11 changed files with 1011 additions and 759 deletions

View File

@@ -231,10 +231,12 @@ UniValue help(const JSONRPCRequest& jsonRequest)
"\nList all commands, or get help for a specified command.\n",
{
{"command", RPCArg::Type::STR, /* opt */ true, /* default_val */ "all commands", "The command to get help on"},
}}
.ToString() +
"\nResult:\n"
},
RPCResult{
"\"text\" (string) The help text\n"
},
RPCExamples{""},
}.ToString()
);
std::string strCommand;
@@ -254,8 +256,11 @@ UniValue stop(const JSONRPCRequest& jsonRequest)
if (jsonRequest.fHelp || jsonRequest.params.size() > 1)
throw std::runtime_error(
RPCHelpMan{"stop",
"\nStop Bitcoin server.", {}}
.ToString());
"\nStop Bitcoin server.",
{},
RPCResults{},
RPCExamples{""},
}.ToString());
// Event loop will exit after current HTTP requests have been handled, so
// this reply will get back to the client.
StartShutdown();
@@ -270,14 +275,16 @@ static UniValue uptime(const JSONRPCRequest& jsonRequest)
if (jsonRequest.fHelp || jsonRequest.params.size() > 0)
throw std::runtime_error(
RPCHelpMan{"uptime",
"\nReturns the total uptime of the server.\n", {}}
.ToString() +
"\nResult:\n"
"\nReturns the total uptime of the server.\n",
{},
RPCResult{
"ttt (numeric) The number of seconds that the server has been running\n"
"\nExamples:\n"
+ HelpExampleCli("uptime", "")
},
RPCExamples{
HelpExampleCli("uptime", "")
+ HelpExampleRpc("uptime", "")
);
},
}.ToString());
return GetTime() - GetStartupTime();
}
@@ -287,8 +294,11 @@ static UniValue getrpcinfo(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() > 0) {
throw std::runtime_error(
RPCHelpMan{"getrpcinfo",
"\nReturns details of the RPC server.\n", {}}
.ToString()
"\nReturns details of the RPC server.\n",
{},
RPCResults{},
RPCExamples{""},
}.ToString()
);
}