From 6aa01e5b8c03782eb853f67395a8ff91d06ec09f Mon Sep 17 00:00:00 2001 From: jyelon Date: Mon, 16 May 2022 15:32:59 -0400 Subject: [PATCH] Improve the 'doc' function's readability --- luprex/core/cpp/source.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/luprex/core/cpp/source.cpp b/luprex/core/cpp/source.cpp index 2ea0f15c..9ef21c4a 100644 --- a/luprex/core/cpp/source.cpp +++ b/luprex/core/cpp/source.cpp @@ -527,14 +527,16 @@ eng::string SourceDB::function_docs(const LuaStack &LS0, LuaSlot fn) { get_reg_name(reg, classname, funcname); eng::ostringstream oss; util::StringVec docs = util::split_docstring(reg->get_docs()); - for (const eng::string &line : docs) { - oss << "-- " << line << std::endl; - } oss << "function "; if (!classname.empty()) { oss << classname << "."; } - oss << funcname << "(" << reg->get_args() << ")"; + oss << funcname << "(" << reg->get_args() << ")" << std::endl; + oss << "--" << std::endl; + for (const eng::string &line : docs) { + oss << "-- " << line << std::endl; + } + oss << "--" << std::endl; return oss.str(); } else if (LS.isfunction(fn)) { lua_Debug ar; @@ -574,9 +576,12 @@ eng::string SourceDB::function_docs(const LuaStack &LS0, LuaSlot fn) { // Output the docs. eng::ostringstream result; - for (int i = linelo; i <= linehi; i++) { + result << lines[linehi] << std::endl; + result << "--" << std::endl; + for (int i = linelo; i < linehi; i++) { result << lines[i] << std::endl; } + result << "--" << std::endl; return result.str(); } else { return "";