Skip to content

Commit

Permalink
feat(docgen): sort entries when rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed Feb 3, 2023
1 parent 9cf679a commit b420e70
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
10 changes: 9 additions & 1 deletion docgen/docgen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,15 @@ docgen.htmlify = function(configuration_option, indent)
or "<summary>table (click to expand)</summary>",
"",
})
for name_or_index, _ in pairs(self.object) do
local unrolled = neorg.lib.unroll(self.object)

table.sort(unrolled, function(x, y)
return x[1] < y[1]
end)

for _, data in ipairs(unrolled) do
local name_or_index = data[1]

local subitem = configuration_option[name_or_index]
or (
type(name_or_index) == "number"
Expand Down
10 changes: 8 additions & 2 deletions docgen/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ 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))
local unrolled = neorg.lib.unroll(configuration_options)

table.sort(unrolled, function(x, y)
return x[1] < y[1]
end)

for _, values in pairs(unrolled) do
vim.list_extend(result, docgen.render(values[2]))
table.insert(result, "")
end

Expand Down

0 comments on commit b420e70

Please sign in to comment.