RPCHelpMan: Add space after colons in extended description
Also, add doxygen comment to ToDescriptionString
This commit is contained in:
parent
fafd040f73
commit
fabca42c68
2 changed files with 29 additions and 9 deletions
|
@ -165,9 +165,9 @@ struct Sections {
|
||||||
if (outer_type == OuterType::NAMED_ARG) return; // Nothing more to do for non-recursive types on first recursion
|
if (outer_type == OuterType::NAMED_ARG) return; // Nothing more to do for non-recursive types on first recursion
|
||||||
auto left = indent;
|
auto left = indent;
|
||||||
if (arg.m_type_str.size() != 0 && outer_type == OuterType::OBJ) {
|
if (arg.m_type_str.size() != 0 && outer_type == OuterType::OBJ) {
|
||||||
left += "\"" + arg.m_name + "\":" + arg.m_type_str.at(0);
|
left += "\"" + arg.m_name + "\": " + arg.m_type_str.at(0);
|
||||||
} else {
|
} else {
|
||||||
left += outer_type == OuterType::OBJ ? arg.ToStringObj() : arg.ToString();
|
left += outer_type == OuterType::OBJ ? arg.ToStringObj(/* oneline */ false) : arg.ToString(/* oneline */ false);
|
||||||
}
|
}
|
||||||
left += ",";
|
left += ",";
|
||||||
PushSection({left, arg.ToDescriptionString(/* implicitly_required */ outer_type == OuterType::ARR)});
|
PushSection({left, arg.ToDescriptionString(/* implicitly_required */ outer_type == OuterType::ARR)});
|
||||||
|
@ -188,7 +188,7 @@ struct Sections {
|
||||||
}
|
}
|
||||||
case RPCArg::Type::ARR: {
|
case RPCArg::Type::ARR: {
|
||||||
auto left = indent;
|
auto left = indent;
|
||||||
left += outer_type == OuterType::OBJ ? "\"" + arg.m_name + "\":" : "";
|
left += outer_type == OuterType::OBJ ? "\"" + arg.m_name + "\": " : "";
|
||||||
left += "[";
|
left += "[";
|
||||||
const auto right = outer_type == OuterType::NAMED_ARG ? "" : arg.ToDescriptionString(/* implicitly_required */ outer_type == OuterType::ARR);
|
const auto right = outer_type == OuterType::NAMED_ARG ? "" : arg.ToDescriptionString(/* implicitly_required */ outer_type == OuterType::ARR);
|
||||||
PushSection({left, right});
|
PushSection({left, right});
|
||||||
|
@ -345,9 +345,16 @@ std::string RPCArg::ToDescriptionString(const bool implicitly_required) const
|
||||||
return ret;
|
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) {
|
switch (m_type) {
|
||||||
case Type::STR:
|
case Type::STR:
|
||||||
return res + "\"str\"";
|
return res + "\"str\"";
|
||||||
|
@ -362,7 +369,7 @@ std::string RPCArg::ToStringObj() const
|
||||||
case Type::ARR:
|
case Type::ARR:
|
||||||
res += "[";
|
res += "[";
|
||||||
for (const auto& i : m_inner) {
|
for (const auto& i : m_inner) {
|
||||||
res += i.ToString() + ",";
|
res += i.ToString(oneline) + ",";
|
||||||
}
|
}
|
||||||
return res + "...]";
|
return res + "...]";
|
||||||
case Type::OBJ:
|
case Type::OBJ:
|
||||||
|
@ -393,7 +400,7 @@ std::string RPCArg::ToString(const bool oneline) const
|
||||||
case Type::OBJ_USER_KEYS: {
|
case Type::OBJ_USER_KEYS: {
|
||||||
std::string res;
|
std::string res;
|
||||||
for (size_t i = 0; i < m_inner.size();) {
|
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 (++i < m_inner.size()) res += ",";
|
||||||
}
|
}
|
||||||
if (m_type == Type::OBJ) {
|
if (m_type == Type::OBJ) {
|
||||||
|
|
|
@ -88,8 +88,21 @@ struct RPCArg {
|
||||||
assert(type == Type::ARR || type == Type::OBJ);
|
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;
|
std::string ToDescriptionString(bool implicitly_required = false) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue