@@ -7,6 +7,7 @@ local util = require 'utility'
77local guide = require ' parser.guide'
88local rpath = require ' workspace.require-path'
99local furi = require ' file-uri'
10+ local wssymbol = require ' core.workspace-symbol'
1011
1112local function collectRequire (mode , literal , uri )
1213 local result , searchers
@@ -125,6 +126,52 @@ local function getBindComment(source)
125126 return table.concat (lines , ' \n ' )
126127end
127128
129+ --- @async
130+ local function packSee (see )
131+ local name = see .name [1 ]
132+ local buf = {}
133+ local target
134+ for _ , symbol in ipairs (wssymbol (name )) do
135+ if symbol .name == name then
136+ target = symbol .source
137+ break
138+ end
139+ end
140+ if target then
141+ local row , col = guide .rowColOf (target .start )
142+ buf [# buf + 1 ] = (' [%s](%s#%d#%d)' ):format (name , guide .getUri (target ), row + 1 , col )
143+ else
144+ buf [# buf + 1 ] = (' ~%s~' ):format (name )
145+ end
146+ if see .comment then
147+ buf [# buf + 1 ] = ' '
148+ buf [# buf + 1 ] = see .comment .text
149+ end
150+ return table.concat (buf )
151+ end
152+
153+ --- @async
154+ local function lookUpDocSees (lines , docGroup )
155+ local sees = {}
156+ for _ , doc in ipairs (docGroup ) do
157+ if doc .type == ' doc.see' then
158+ sees [# sees + 1 ] = doc
159+ end
160+ end
161+ if # sees == 0 then
162+ return
163+ end
164+ if # sees == 1 then
165+ lines [# lines + 1 ] = (' See: %s' ):format (packSee (sees [1 ]))
166+ return
167+ end
168+ lines [# lines + 1 ] = ' See:'
169+ for _ , see in ipairs (sees ) do
170+ lines [# lines + 1 ] = (' * %s' ):format (packSee (see ))
171+ end
172+ end
173+
174+ --- @async
128175local function lookUpDocComments (source )
129176 local docGroup = source .bindDocs
130177 if not docGroup then
@@ -158,6 +205,7 @@ local function lookUpDocComments(source)
158205 if source .comment then
159206 lines [# lines + 1 ] = normalizeComment (source .comment .text , uri )
160207 end
208+ lookUpDocSees (lines , docGroup )
161209 if not lines or # lines == 0 then
162210 return nil
163211 end
@@ -352,6 +400,7 @@ local function getFunctionComment(source)
352400 return comment
353401end
354402
403+ --- @async
355404local function tryDocComment (source )
356405 local md = markdown ()
357406 if source .value and source .value .type == ' function' then
@@ -379,6 +428,7 @@ local function tryDocComment(source)
379428 return result
380429end
381430
431+ --- @async
382432local function tryDocOverloadToComment (source )
383433 if source .type ~= ' doc.type.function' then
384434 return
@@ -457,6 +507,7 @@ local function tryDocEnum(source)
457507 return md :string ()
458508end
459509
510+ --- @async
460511return function (source )
461512 if source .type == ' string' then
462513 return asString (source )
0 commit comments