@@ -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)' )
0 commit comments