From e50b20f07f44de64667143984f2ea0564db09ff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 21 Jul 2023 14:11:06 +0800 Subject: fix doc --- tools/build-doc.lua | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'tools') 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'):format(first.type)) + return ('object'):format(view(first)) elseif conf.patternProperties then local _, first = next(conf.patternProperties) assert(first) - md:add('ts', ('Object'):format(first.type)) + return ('Object'):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) -- cgit v1.2.3