Skip to content
Snippets Groups Projects
Unverified Commit 2792f9a6 authored by 最萌小汐's avatar 最萌小汐 Committed by GitHub
Browse files

Merge pull request #2430 from NyakoFox/rawdesc

Add a `rawdesc` field to exported docs
parents 8c4aca0f 5a468a1a
No related branches found
No related tags found
No related merge requests found
...@@ -65,6 +65,7 @@ local function packObject(source, mark) ...@@ -65,6 +65,7 @@ local function packObject(source, mark)
end end
if source.type == 'function.return' then if source.type == 'function.return' then
new['desc'] = source.comment and getDesc(source.comment) new['desc'] = source.comment and getDesc(source.comment)
new['rawdesc'] = source.comment and getDesc(source.comment, true)
end end
if source.type == 'doc.type.table' then if source.type == 'doc.type.table' then
new['fields'] = packObject(source.fields, mark) new['fields'] = packObject(source.fields, mark)
...@@ -82,6 +83,7 @@ local function packObject(source, mark) ...@@ -82,6 +83,7 @@ local function packObject(source, mark)
end end
if source.bindDocs then if source.bindDocs then
new['desc'] = getDesc(source) new['desc'] = getDesc(source)
new['rawdesc'] = getDesc(source, true)
end end
new['view'] = new['view'] or vm.getInfer(source):view(ws.rootUri) new['view'] = new['view'] or vm.getInfer(source):view(ws.rootUri)
end end
...@@ -115,6 +117,7 @@ local function collectTypes(global, results) ...@@ -115,6 +117,7 @@ local function collectTypes(global, results)
name = global.name, name = global.name,
type = 'type', type = 'type',
desc = nil, desc = nil,
rawdesc = nil,
defines = {}, defines = {},
fields = {}, fields = {},
} }
...@@ -131,6 +134,7 @@ local function collectTypes(global, results) ...@@ -131,6 +134,7 @@ local function collectTypes(global, results)
extends = getExtends(set), extends = getExtends(set),
} }
result.desc = result.desc or getDesc(set) result.desc = result.desc or getDesc(set)
result.rawdesc = result.rawdesc or getDesc(set, true)
::CONTINUE:: ::CONTINUE::
end end
if #result.defines == 0 then if #result.defines == 0 then
...@@ -163,6 +167,7 @@ local function collectTypes(global, results) ...@@ -163,6 +167,7 @@ local function collectTypes(global, results)
field.start = source.start field.start = source.start
field.finish = source.finish field.finish = source.finish
field.desc = getDesc(source) field.desc = getDesc(source)
field.rawdesc = getDesc(source, true)
field.extends = packObject(source.extends) field.extends = packObject(source.extends)
return return
end end
...@@ -180,6 +185,7 @@ local function collectTypes(global, results) ...@@ -180,6 +185,7 @@ local function collectTypes(global, results)
field.start = source.start field.start = source.start
field.finish = source.finish field.finish = source.finish
field.desc = getDesc(source) field.desc = getDesc(source)
field.rawdesc = getDesc(source, true)
field.extends = packObject(source.value) field.extends = packObject(source.value)
return return
end end
...@@ -199,6 +205,7 @@ local function collectTypes(global, results) ...@@ -199,6 +205,7 @@ local function collectTypes(global, results)
field.start = source.start field.start = source.start
field.finish = source.finish field.finish = source.finish
field.desc = getDesc(source) field.desc = getDesc(source)
field.rawdesc = getDesc(source, true)
field.extends = packObject(source.value) field.extends = packObject(source.value)
return return
end end
...@@ -237,6 +244,7 @@ local function collectVars(global, results) ...@@ -237,6 +244,7 @@ local function collectVars(global, results)
extends = packObject(set.value), extends = packObject(set.value),
} }
result.desc = result.desc or getDesc(set) result.desc = result.desc or getDesc(set)
result.rawdesc = result.rawdesc or getDesc(set, true)
end end
end end
if #result.defines == 0 then if #result.defines == 0 then
......
...@@ -336,7 +336,7 @@ local function tryDocFieldComment(source) ...@@ -336,7 +336,7 @@ local function tryDocFieldComment(source)
end end
end end
local function getFunctionComment(source) local function getFunctionComment(source, raw)
local docGroup = source.bindDocs local docGroup = source.bindDocs
if not docGroup then if not docGroup then
return return
...@@ -356,14 +356,14 @@ local function getFunctionComment(source) ...@@ -356,14 +356,14 @@ local function getFunctionComment(source)
if doc.type == 'doc.comment' then if doc.type == 'doc.comment' then
local comment = normalizeComment(doc.comment.text, uri) local comment = normalizeComment(doc.comment.text, uri)
md:add('md', comment) md:add('md', comment)
elseif doc.type == 'doc.param' then elseif doc.type == 'doc.param' and not raw then
if doc.comment then if doc.comment then
md:add('md', ('@*param* `%s` — %s'):format( md:add('md', ('@*param* `%s` — %s'):format(
doc.param[1], doc.param[1],
doc.comment.text doc.comment.text
)) ))
end end
elseif doc.type == 'doc.return' then elseif doc.type == 'doc.return' and not raw then
if hasReturnComment then if hasReturnComment then
local name = {} local name = {}
for _, rtn in ipairs(doc.returns) do for _, rtn in ipairs(doc.returns) do
...@@ -401,13 +401,13 @@ local function getFunctionComment(source) ...@@ -401,13 +401,13 @@ local function getFunctionComment(source)
end end
---@async ---@async
local function tryDocComment(source) local function tryDocComment(source, raw)
local md = markdown() local md = markdown()
if source.value and source.value.type == 'function' then if source.value and source.value.type == 'function' then
source = source.value source = source.value
end end
if source.type == 'function' then if source.type == 'function' then
local comment = getFunctionComment(source) local comment = getFunctionComment(source, raw)
md:add('md', comment) md:add('md', comment)
source = source.parent source = source.parent
end end
...@@ -429,7 +429,7 @@ local function tryDocComment(source) ...@@ -429,7 +429,7 @@ local function tryDocComment(source)
end end
---@async ---@async
local function tryDocOverloadToComment(source) local function tryDocOverloadToComment(source, raw)
if source.type ~= 'doc.type.function' then if source.type ~= 'doc.type.function' then
return return
end end
...@@ -438,7 +438,7 @@ local function tryDocOverloadToComment(source) ...@@ -438,7 +438,7 @@ local function tryDocOverloadToComment(source)
or not doc.bindSource then or not doc.bindSource then
return return
end end
local md = tryDocComment(doc.bindSource) local md = tryDocComment(doc.bindSource, raw)
if md then if md then
return md return md
end end
...@@ -529,7 +529,7 @@ local function tryDocEnum(source) ...@@ -529,7 +529,7 @@ local function tryDocEnum(source)
end end
---@async ---@async
return function (source) return function (source, raw)
if source.type == 'string' then if source.type == 'string' then
return asString(source) return asString(source)
end end
...@@ -539,10 +539,10 @@ return function (source) ...@@ -539,10 +539,10 @@ return function (source)
if source.type == 'field' then if source.type == 'field' then
source = source.parent source = source.parent
end end
return tryDocOverloadToComment(source) return tryDocOverloadToComment(source, raw)
or tryDocFieldComment(source) or tryDocFieldComment(source)
or tyrDocParamComment(source) or tyrDocParamComment(source)
or tryDocComment(source) or tryDocComment(source, raw)
or tryDocClassComment(source) or tryDocClassComment(source)
or tryDocModule(source) or tryDocModule(source)
or tryDocEnum(source) or tryDocEnum(source)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment