Skip to content

Commit

Permalink
feat(docgen): implement table rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed Feb 3, 2023
1 parent 42b8728 commit 9074328
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions docgen/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ local modules = {
--]]
}

local function concat_configuration_options(configuration_options)
local result = {}

for _, value in pairs(configuration_options) do
vim.list_extend(result, docgen.render(value))
table.insert(result, "")
end

return result
end

for _, file in ipairs(docgen.aggregate_module_files()) do
local fullpath = vim.fn.fnamemodify(file, ":p")

Expand Down Expand Up @@ -103,28 +114,40 @@ for module_name, module in pairs(modules) do
local object = docgen.to_lua_object(module.parsed, buffer, data.value, module_name)

do
log.warn(module_name, data.parents, data.name)
neorg.lib.ensure_nested(configuration_options, unpack(data.parents))
local ref = vim.tbl_get(configuration_options, unpack(data.parents)) or {}

local ref = vim.tbl_get(configuration_options, unpack(data.parents)) or configuration_options
if data.name then
ref[data.name] = docgen.render(buffer, data, comments, object)
ref[data.name] = {
self = {
buffer = buffer,
data = data,
comments = comments,
object = object,
},
}
else
table.insert(ref, docgen.render(buffer, data, comments, object))
ref._inline_elements = ref._inline_elements or {}

table.insert(ref._inline_elements, {
self = {
buffer = buffer,
data = data,
comments = comments,
object = object,
},
})
end
end

end)
end

-- log.warn(module_name, configuration_options)

-- Perform module lookups in the module's top comment markdown data.
-- This cannot be done earlier because then there would be no guarantee
-- that all the modules have been properly indexed and parsed.
for i, line in ipairs(module.top_comment_data.markdown) do
module.top_comment_data.markdown[i] = docgen.lookup_modules(modules, line)
end

-- fileio.write_to_wiki(module.top_comment_data.file, configuration_options)
-- log.warn(module_name, configuration_options)
fileio.write_to_wiki(module.top_comment_data.file, concat_configuration_options(configuration_options))
end

0 comments on commit 9074328

Please sign in to comment.