diff options
author | MarcoFalke <falke.marco@gmail.com> | 2018-12-04 13:30:06 -0500 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2018-12-04 13:47:49 -0500 |
commit | fabca42c68ee4cdff08d30e91412ccf1de6d7b41 (patch) | |
tree | aeaab7e7d2bbba758858daa52f7b91580a8c6636 /src | |
parent | fafd040f7321294d5e4335b9581a6bd46a714c37 (diff) |
RPCHelpMan: Add space after colons in extended description
Also, add doxygen comment to ToDescriptionString
Diffstat (limited to 'src')
-rw-r--r-- | src/rpc/util.cpp | 21 | ||||
-rw-r--r-- | src/rpc/util.h | 17 |
2 files changed, 29 insertions, 9 deletions
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index a1c0134146..bb1c315bc7 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -165,9 +165,9 @@ struct Sections { if (outer_type == OuterType::NAMED_ARG) return; // Nothing more to do for non-recursive types on first recursion auto left = indent; 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 { - 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)}); @@ -188,7 +188,7 @@ struct Sections { } case RPCArg::Type::ARR: { auto left = indent; - left += outer_type == OuterType::OBJ ? "\"" + arg.m_name + "\":" : ""; + left += outer_type == OuterType::OBJ ? "\"" + arg.m_name + "\": " : ""; left += "["; const auto right = outer_type == OuterType::NAMED_ARG ? "" : arg.ToDescriptionString(/* implicitly_required */ outer_type == OuterType::ARR); PushSection({left, right}); @@ -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) { diff --git a/src/rpc/util.h b/src/rpc/util.h index 11238ce9f7..1d1df2c635 100644 --- a/src/rpc/util.h +++ b/src/rpc/util.h @@ -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; }; |