diff options
author | CppCXY <812125110@qq.com> | 2024-02-22 20:29:13 +0800 |
---|---|---|
committer | CppCXY <812125110@qq.com> | 2024-02-22 20:29:13 +0800 |
commit | 9b6df71d97a70ee7179949ef9f15368cbf29dcbd (patch) | |
tree | bf7a7e62ed7c164a12bdce437c17262a5235bcec /tools | |
parent | 483fe246b6ae8c25d433aa15e43f04f0e71a74d5 (diff) | |
parent | 3e6fd3ce1f2f0528336ded939d776a29bbfaf2eb (diff) | |
download | lua-language-server-9b6df71d97a70ee7179949ef9f15368cbf29dcbd.zip |
Merge branch 'master' of github.com:CppCXY/lua-language-server
Diffstat (limited to 'tools')
-rw-r--r-- | tools/build-doc.lua | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/tools/build-doc.lua b/tools/build-doc.lua index fbf5fa6b..783a5311 100644 --- a/tools/build-doc.lua +++ b/tools/build-doc.lua @@ -53,29 +53,37 @@ local function getDesc(lang, desc) return locale[id] end -local function buildType(md, lang, conf) - md:add('md', '## type') +local function view(conf) if type(conf.type) == 'table' then - md:add('ts', ('%s | %s'):format(conf.type[1], conf.type[2])) + local subViews = {} + for i = 1, #conf.type do + subViews[i] = conf.type[i] + end + return table.concat(subViews, ' | ') elseif conf.type == 'array' then - md:add('ts', ('Array<%s>'):format(conf.items.type)) + return ('Array<%s>'):format(view(conf.items)) elseif conf.type == 'object' then if conf.properties then local _, first = next(conf.properties) assert(first) - md:add('ts', ('object<string, %s>'):format(first.type)) + return ('object<string, %s>'):format(view(first)) elseif conf.patternProperties then local _, first = next(conf.patternProperties) assert(first) - md:add('ts', ('Object<string, %s>'):format(first.type)) + return ('Object<string, %s>'):format(view(first)) else - md:add('ts', '**Unknown object type!!**') + return '**Unknown object type!!**' end else - md:add('ts', ('%s'):format(conf.type)) + return tostring(conf.type) end end +local function buildType(md, lang, conf) + md:add('md', '## type') + md:add('ts', view(conf)) +end + local function buildDesc(md, lang, conf) local desc = conf.markdownDescription or conf.description desc = getDesc(lang, desc) |