RPCHelpMan: Add space after colons in extended description

Also, add doxygen comment to ToDescriptionString
This commit is contained in:
MarcoFalke 2018-12-04 13:30:06 -05:00
parent fafd040f73
commit fabca42c68
No known key found for this signature in database
GPG key ID: CE2B75697E69A548
2 changed files with 29 additions and 9 deletions

View file

@ -167,7 +167,7 @@ struct Sections {
if (arg.m_type_str.size() != 0 && outer_type == OuterType::OBJ) {
left += "\"" + arg.m_name + "\": " + arg.m_type_str.at(0);
} else {
left += outer_type == OuterType::OBJ ? arg.ToStringObj() : arg.ToString();
left += outer_type == OuterType::OBJ ? arg.ToStringObj(/* oneline */ false) : arg.ToString(/* oneline */ false);
}
left += ",";
PushSection({left, arg.ToDescriptionString(/* implicitly_required */ outer_type == OuterType::ARR)});
@ -345,9 +345,16 @@ std::string RPCArg::ToDescriptionString(const bool implicitly_required) const
return ret;
}
std::string RPCArg::ToStringObj() const
std::string RPCArg::ToStringObj(const bool oneline) const
{
std::string res = "\"" + m_name + "\":";
std::string res;
res += "\"";
res += m_name;
if (oneline) {
res += "\":";
} else {
res += "\": ";
}
switch (m_type) {
case Type::STR:
return res + "\"str\"";
@ -362,7 +369,7 @@ std::string RPCArg::ToStringObj() const
case Type::ARR:
res += "[";
for (const auto& i : m_inner) {
res += i.ToString() + ",";
res += i.ToString(oneline) + ",";
}
return res + "...]";
case Type::OBJ:
@ -393,7 +400,7 @@ std::string RPCArg::ToString(const bool oneline) const
case Type::OBJ_USER_KEYS: {
std::string res;
for (size_t i = 0; i < m_inner.size();) {
res += m_inner[i].ToStringObj();
res += m_inner[i].ToStringObj(oneline);
if (++i < m_inner.size()) res += ",";
}
if (m_type == Type::OBJ) {

View file

@ -88,8 +88,21 @@ struct RPCArg {
assert(type == Type::ARR || type == Type::OBJ);
}
std::string ToString(bool oneline = false) const;
std::string ToStringObj() const;
/**
* Return the type string of the argument.
* Set oneline to allow it to be overrided by a custom oneline type string (m_oneline_description).
*/
std::string ToString(bool oneline) const;
/**
* Return the type string of the argument when it is in an object (dict).
* Set oneline to get the oneline representation (less whitespace)
*/
std::string ToStringObj(bool oneline) const;
/**
* Return the description string, including the argument type and whether
* the argument is required.
* implicitly_required is set for arguments in an array, which are neither optional nor required.
*/
std::string ToDescriptionString(bool implicitly_required = false) const;
};