@@ -212,11 +212,11 @@ local function lookUpDocComments(source)
212212 return table.concat (lines , ' \n ' )
213213end
214214
215- local function tryDocClassComment (source )
215+ local function tryDocClassComment (source , types )
216+ types = types or {[' doc.class' ] = true }
217+
216218 for _ , def in ipairs (vm .getDefs (source )) do
217- if def .type == ' doc.class'
218- or def .type == ' doc.alias'
219- or def .type == ' doc.enum' then
219+ if types [def .type ] then
220220 local comment = getBindComment (def )
221221 if comment then
222222 return comment
@@ -238,7 +238,9 @@ local function buildEnumChunk(docType, name, uri)
238238 end
239239 local enums = {}
240240 local types = {}
241- local lines = {}
241+ local lines = {(' #### %s:' ):format (name )}
242+ local commentTypes = {[' doc.enum' ] = true , [' doc.alias' ] = true }
243+
242244 for _ , tp in ipairs (vm .getDefs (docType )) do
243245 types [# types + 1 ] = vm .getInfer (tp ):view (guide .getUri (docType ))
244246 if tp .type == ' doc.type.string'
@@ -247,20 +249,22 @@ local function buildEnumChunk(docType, name, uri)
247249 or tp .type == ' doc.type.code' then
248250 enums [# enums + 1 ] = tp
249251 end
250- local comment = tryDocClassComment (tp )
252+
253+ local comment = tryDocClassComment (tp , commentTypes )
251254 if comment then
252255 for line in util .eachLine (comment ) do
253256 lines [# lines + 1 ] = line
254257 end
255258 end
256259 end
260+
257261 if # enums == 0 then
258262 return nil
259263 end
260- if # lines > 0 and lines [ # lines ] ~= " " then
264+ if # lines > 1 then
261265 lines [# lines + 1 ] = " "
262266 end
263- lines [ # lines + 1 ] = ( ' #### %s: ' ): format ( name )
267+
264268 for _ , enum in ipairs (enums ) do
265269 local suffix = (enum .default and ' (default)' )
266270 or (enum .additional and ' (additional)' )
@@ -410,21 +414,24 @@ local function tryDocComment(source, raw)
410414 md :add (' md' , getFunctionCommentMarkdown (source , raw ))
411415 source = source .parent
412416 end
417+
413418 local comment = lookUpDocComments (source )
414419 md :add (' md' , comment )
420+
415421 if source .type == ' doc.alias' then
416422 local enums = buildEnumChunk (source , source .alias [1 ], guide .getUri (source ))
423+ or tryDocClassComment (source , {[' doc.alias' ] = true })
424+
417425 md :add (' md' , enums )
418- end
419- if source .type == ' doc.enum' then
426+ elseif source .type == ' doc.enum' then
420427 local enums = buildEnumChunk (source , source .enum [1 ], guide .getUri (source ))
428+ or tryDocClassComment (source , {[' doc.enum' ] = true })
429+
421430 md :add (' md' , enums )
422431 end
432+
423433 local result = md :string ()
424- if result == ' ' then
425- return nil
426- end
427- return result
434+ return result ~= ' ' and result or nil
428435end
429436
430437--- @async
0 commit comments