Improve the 'doc' function's readability
This commit is contained in:
@@ -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 "";
|
||||
|
||||
Reference in New Issue
Block a user