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);
|
get_reg_name(reg, classname, funcname);
|
||||||
eng::ostringstream oss;
|
eng::ostringstream oss;
|
||||||
util::StringVec docs = util::split_docstring(reg->get_docs());
|
util::StringVec docs = util::split_docstring(reg->get_docs());
|
||||||
for (const eng::string &line : docs) {
|
|
||||||
oss << "-- " << line << std::endl;
|
|
||||||
}
|
|
||||||
oss << "function ";
|
oss << "function ";
|
||||||
if (!classname.empty()) {
|
if (!classname.empty()) {
|
||||||
oss << classname << ".";
|
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();
|
return oss.str();
|
||||||
} else if (LS.isfunction(fn)) {
|
} else if (LS.isfunction(fn)) {
|
||||||
lua_Debug ar;
|
lua_Debug ar;
|
||||||
@@ -574,9 +576,12 @@ eng::string SourceDB::function_docs(const LuaStack &LS0, LuaSlot fn) {
|
|||||||
|
|
||||||
// Output the docs.
|
// Output the docs.
|
||||||
eng::ostringstream result;
|
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 << lines[i] << std::endl;
|
||||||
}
|
}
|
||||||
|
result << "--" << std::endl;
|
||||||
return result.str();
|
return result.str();
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
Reference in New Issue
Block a user