Skip to content

Commit

Permalink
Fix docs generation when there are multiple classes in a library
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptibell committed Jun 17, 2024
1 parent 097297a commit 1b768a5
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions .lune/generate.luau
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,36 @@ local typedefsFile = fs.readFile("temp/moonwave.json")
local items: { moonwave.Item } = serde.decode("json", typedefsFile)

-- Generate markdown for all of the libraries
local generatedFiles = {}
local generatedFiles = {} :: { [number]: {
displayName: string,
name: string,
content: string,
} }
for _, item in items do
local file = item.source.path
local name = string.match(file, "(.+)%.luau")
assert(name ~= nil, "Failed to remove luau suffix from file name")
table.insert(generatedFiles, {
displayName = item.name,
name = string.lower(name),
content = writeMarkdown(item),
})

-- If we have an existing entry, such as when we have multiple
-- classes within the same library (Regex, RegexCaptures, ...)
-- we want to append to the existing entry instead of creating
local existing = nil
for _, info in generatedFiles do
if info.name == string.lower(name) then
existing = info
break
end
end

if existing then
existing.content ..= writeMarkdown(item)
else
table.insert(generatedFiles, {
displayName = item.name,
name = string.lower(name),
content = writeMarkdown(item),
})
end
end

-- Remove any old files, generate new ones
Expand Down

0 comments on commit 1b768a5

Please sign in to comment.