Skip to content

Commit 5a468a1

Browse files
committed
Add raw descriptions
1 parent 8c4aca0 commit 5a468a1

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

script/cli/doc.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ local function packObject(source, mark)
6565
end
6666
if source.type == 'function.return' then
6767
new['desc'] = source.comment and getDesc(source.comment)
68+
new['rawdesc'] = source.comment and getDesc(source.comment, true)
6869
end
6970
if source.type == 'doc.type.table' then
7071
new['fields'] = packObject(source.fields, mark)
@@ -82,6 +83,7 @@ local function packObject(source, mark)
8283
end
8384
if source.bindDocs then
8485
new['desc'] = getDesc(source)
86+
new['rawdesc'] = getDesc(source, true)
8587
end
8688
new['view'] = new['view'] or vm.getInfer(source):view(ws.rootUri)
8789
end
@@ -115,6 +117,7 @@ local function collectTypes(global, results)
115117
name = global.name,
116118
type = 'type',
117119
desc = nil,
120+
rawdesc = nil,
118121
defines = {},
119122
fields = {},
120123
}
@@ -131,6 +134,7 @@ local function collectTypes(global, results)
131134
extends = getExtends(set),
132135
}
133136
result.desc = result.desc or getDesc(set)
137+
result.rawdesc = result.rawdesc or getDesc(set, true)
134138
::CONTINUE::
135139
end
136140
if #result.defines == 0 then
@@ -163,6 +167,7 @@ local function collectTypes(global, results)
163167
field.start = source.start
164168
field.finish = source.finish
165169
field.desc = getDesc(source)
170+
field.rawdesc = getDesc(source, true)
166171
field.extends = packObject(source.extends)
167172
return
168173
end
@@ -180,6 +185,7 @@ local function collectTypes(global, results)
180185
field.start = source.start
181186
field.finish = source.finish
182187
field.desc = getDesc(source)
188+
field.rawdesc = getDesc(source, true)
183189
field.extends = packObject(source.value)
184190
return
185191
end
@@ -199,6 +205,7 @@ local function collectTypes(global, results)
199205
field.start = source.start
200206
field.finish = source.finish
201207
field.desc = getDesc(source)
208+
field.rawdesc = getDesc(source, true)
202209
field.extends = packObject(source.value)
203210
return
204211
end
@@ -237,6 +244,7 @@ local function collectVars(global, results)
237244
extends = packObject(set.value),
238245
}
239246
result.desc = result.desc or getDesc(set)
247+
result.rawdesc = result.rawdesc or getDesc(set, true)
240248
end
241249
end
242250
if #result.defines == 0 then

script/core/hover/description.lua

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ local function tryDocFieldComment(source)
336336
end
337337
end
338338

339-
local function getFunctionComment(source)
339+
local function getFunctionComment(source, raw)
340340
local docGroup = source.bindDocs
341341
if not docGroup then
342342
return
@@ -356,14 +356,14 @@ local function getFunctionComment(source)
356356
if doc.type == 'doc.comment' then
357357
local comment = normalizeComment(doc.comment.text, uri)
358358
md:add('md', comment)
359-
elseif doc.type == 'doc.param' then
359+
elseif doc.type == 'doc.param' and not raw then
360360
if doc.comment then
361361
md:add('md', ('@*param* `%s` — %s'):format(
362362
doc.param[1],
363363
doc.comment.text
364364
))
365365
end
366-
elseif doc.type == 'doc.return' then
366+
elseif doc.type == 'doc.return' and not raw then
367367
if hasReturnComment then
368368
local name = {}
369369
for _, rtn in ipairs(doc.returns) do
@@ -401,13 +401,13 @@ local function getFunctionComment(source)
401401
end
402402

403403
---@async
404-
local function tryDocComment(source)
404+
local function tryDocComment(source, raw)
405405
local md = markdown()
406406
if source.value and source.value.type == 'function' then
407407
source = source.value
408408
end
409409
if source.type == 'function' then
410-
local comment = getFunctionComment(source)
410+
local comment = getFunctionComment(source, raw)
411411
md:add('md', comment)
412412
source = source.parent
413413
end
@@ -429,7 +429,7 @@ local function tryDocComment(source)
429429
end
430430

431431
---@async
432-
local function tryDocOverloadToComment(source)
432+
local function tryDocOverloadToComment(source, raw)
433433
if source.type ~= 'doc.type.function' then
434434
return
435435
end
@@ -438,7 +438,7 @@ local function tryDocOverloadToComment(source)
438438
or not doc.bindSource then
439439
return
440440
end
441-
local md = tryDocComment(doc.bindSource)
441+
local md = tryDocComment(doc.bindSource, raw)
442442
if md then
443443
return md
444444
end
@@ -529,7 +529,7 @@ local function tryDocEnum(source)
529529
end
530530

531531
---@async
532-
return function (source)
532+
return function (source, raw)
533533
if source.type == 'string' then
534534
return asString(source)
535535
end
@@ -539,10 +539,10 @@ return function (source)
539539
if source.type == 'field' then
540540
source = source.parent
541541
end
542-
return tryDocOverloadToComment(source)
542+
return tryDocOverloadToComment(source, raw)
543543
or tryDocFieldComment(source)
544544
or tyrDocParamComment(source)
545-
or tryDocComment(source)
545+
or tryDocComment(source, raw)
546546
or tryDocClassComment(source)
547547
or tryDocModule(source)
548548
or tryDocEnum(source)

0 commit comments

Comments
 (0)