erest
Version:
Easy to build api server depend on @leizm/web and express.
42 lines (41 loc) • 1.3 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = typeDocs;
const utils_1 = require("./utils");
function typeString(item) {
return (0, utils_1.fieldString)([
(0, utils_1.stringOrEmpty)(item.name, true),
(0, utils_1.stringOrEmpty)(item.description),
(0, utils_1.itemTF)(item.checker),
(0, utils_1.itemTF)(item.formatter),
(0, utils_1.itemTF)(item.parser),
]);
}
function typeDocs(data) {
const defaultTypes = [];
const customTypes = [];
for (const info of Object.values(data.types)) {
if (info.isBuiltin) {
defaultTypes.push(info);
}
else {
customTypes.push(info);
}
}
defaultTypes.sort();
customTypes.sort();
const typeList = [];
const tableHead = (0, utils_1.tableHeader)(["类型", "描述", "检查", "格式化", "解析"]);
typeList.push("## 默认数据类型\n");
typeList.push(tableHead);
for (const item of defaultTypes) {
typeList.push(typeString(item));
}
typeList.push("");
typeList.push("## 自定义数据类型\n");
typeList.push(tableHead);
for (const item of customTypes) {
typeList.push(typeString(item));
}
return `${typeList.join("\n")}\n`;
}
;