mirror of
https://github.com/lune-org/docs.git
synced 2024-12-12 04:50:36 +00:00
Fix docs generation when there are multiple classes in a library
This commit is contained in:
parent
097297a8c0
commit
1b768a5a7f
1 changed files with 26 additions and 6 deletions
|
@ -10,16 +10,36 @@ local typedefsFile = fs.readFile("temp/moonwave.json")
|
||||||
local items: { moonwave.Item } = serde.decode("json", typedefsFile)
|
local items: { moonwave.Item } = serde.decode("json", typedefsFile)
|
||||||
|
|
||||||
-- Generate markdown for all of the libraries
|
-- Generate markdown for all of the libraries
|
||||||
local generatedFiles = {}
|
local generatedFiles = {} :: { [number]: {
|
||||||
|
displayName: string,
|
||||||
|
name: string,
|
||||||
|
content: string,
|
||||||
|
} }
|
||||||
for _, item in items do
|
for _, item in items do
|
||||||
local file = item.source.path
|
local file = item.source.path
|
||||||
local name = string.match(file, "(.+)%.luau")
|
local name = string.match(file, "(.+)%.luau")
|
||||||
assert(name ~= nil, "Failed to remove luau suffix from file name")
|
assert(name ~= nil, "Failed to remove luau suffix from file name")
|
||||||
table.insert(generatedFiles, {
|
|
||||||
displayName = item.name,
|
-- If we have an existing entry, such as when we have multiple
|
||||||
name = string.lower(name),
|
-- classes within the same library (Regex, RegexCaptures, ...)
|
||||||
content = writeMarkdown(item),
|
-- 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
|
end
|
||||||
|
|
||||||
-- Remove any old files, generate new ones
|
-- Remove any old files, generate new ones
|
||||||
|
|
Loading…
Reference in a new issue